@inrupt/solid-client / acp/policy

Module: acp/policy

Type aliases

AccessModes

Ƭ AccessModes: Object

The different Access Modes that a Policy can allow or deny for a Resource.

since 1.6.0

Type declaration

Name

Type

append

boolean

read

boolean

write

boolean


Policy

Ƭ Policy: ThingPersisted

A Policy can be applied to Resources to grant or deny AccessModes to users who match the Policy’s Rules.

since 1.6.0


ResourcePolicy

Ƭ ResourcePolicy: ThingPersisted

A Resource Policy is like a regular Policy, but rather than being re-used for different Resources, it is used for a single Resource and is stored in that Resource’s Access Control Resource.

since 1.6.0

Functions

createPolicy

createPolicy(url): Policy

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Initialise a new, empty Policy.

since 1.6.0

Parameters

Name

Type

Description

url

Url | UrlString

URL that identifies this Policy.

Returns

Policy


createResourcePolicyFor

createResourcePolicyFor(resourceWithAcr, name): ResourcePolicy

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Initialise a new, empty ResourcePolicy for the given Resource.

since 1.6.0

Parameters

Name

Type

Description

resourceWithAcr

WithAccessibleAcr

The Resource to which the Policy is to apply.

name

string

The name that identifies this Policy.


getAllowModes

Const getAllowModes<P>(policy): AccessModes

See getAllowModesV1. Will be updated to point to getAllowModesV2 when pod.inrupt.com is transitioned to the updated vocabulary.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

policy

P

Returns

AccessModes


getAllowModesV1

getAllowModesV1<P>(policy): AccessModes

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy, return which AccessModes it allows.

since 1.6.0

deprecated The Access Control Policies proposal will be updated to use a different vocabulary for allow- and deny-modes. To be compatible with servers that implement that, use getAllowModesV2.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy for which you want to know the Access Modes it allows.

Returns

AccessModes


getAllowModesV2

getAllowModesV2<P>(policy): AccessModes

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy, return which AccessModes it allows.

since Not released yet.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy for which you want to know the Access Modes it allows.

Returns

AccessModes


getDenyModes

Const getDenyModes<P>(policy): AccessModes

See getDenyModesV1. Will be updated to point to getDenyModesV2 when pod.inrupt.com is transitioned to the updated vocabulary.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

policy

P

Returns

AccessModes


getDenyModesV1

getDenyModesV1<P>(policy): AccessModes

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy, return which AccessModes it disallows.

since 1.6.0

deprecated The Access Control Policies proposal will be updated to use a different vocabulary for allow- and deny-modes. To be compatible with servers that implement that, use getDenyModesV2.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy on which you want to know the Access Modes it disallows.

Returns

AccessModes


getDenyModesV2

getDenyModesV2<P>(policy): AccessModes

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy, return which AccessModes it disallows.

since Not released yet.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy on which you want to know the Access Modes it disallows.

Returns

AccessModes


getPolicy

getPolicy(policyResource, url): Policy | null

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Get the Policy with the given URL from an SolidDataset.

since 1.6.0

Parameters

Name

Type

Description

policyResource

SolidDataset

The Resource that contains the given Policy.

url

Url | UrlString

URL that identifies this Policy.

Returns

Policy | null

The requested Policy, if it exists, or null if it does not.


getPolicyAll

getPolicyAll(policyResource): Policy[]

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Get all Policy’s in a given SolidDataset.

since 1.6.0

Parameters

Name

Type

Description

policyResource

SolidDataset

The Resource that contains Access Policies.

Returns

Policy[]


getResourceAcrPolicy

getResourceAcrPolicy(resourceWithAcr, name): ResourcePolicy | null

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Get the ResourcePolicy with the given name that applies to a Resource’s Access Control Resource from that Access Control Resource.

since 1.6.0

Parameters

Name

Type

Description

resourceWithAcr

WithAccessibleAcr

The Resource whose ACR contains the given Policy.

name

string

The name that identifies this Policy.

Returns

ResourcePolicy | null

The requested Policy, if it exists and applies to the Resource’s ACR, or null if it does not.


getResourceAcrPolicyAll

getResourceAcrPolicyAll(resourceWithAcr): ResourcePolicy[]

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Get all ResourcePolicy’s that apply to a given Resource’s Access Control Resource from that Access Control Resource.

since 1.6.0

Parameters

Name

Type

Description

resourceWithAcr

WithAccessibleAcr

The Resource whose Access Control Resource contains Access Policies.

Returns

ResourcePolicy[]


getResourcePolicy

getResourcePolicy(resourceWithAcr, name): ResourcePolicy | null

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Get the ResourcePolicy with the given name that applies to a Resource from its Access Control Resource.

since 1.6.0

Parameters

Name

Type

Description

resourceWithAcr

WithAccessibleAcr

The Resource whose ACR contains the given Policy.

name

string

The name that identifies this Policy.

Returns

ResourcePolicy | null

The requested Policy, if it exists and applies to the given Resource, or null if it does not.


getResourcePolicyAll

getResourcePolicyAll(resourceWithAcr): ResourcePolicy[]

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Get all ResourcePolicy’s that apply to a Resource in its Access Control Resource.

since 1.6.0

Parameters

Name

Type

Description

resourceWithAcr

WithAccessibleAcr

The Resource whose Access Control Resource contains Access Policies applying to it.

Returns

ResourcePolicy[]


policyAsMarkdown

policyAsMarkdown(policy): string

Gets a human-readable representation of the given Policy to aid debugging.

Note that changes to the exact format of the return value are not considered a breaking change; it is intended to aid in debugging, not as a serialisation method that can be reliably parsed.

since 1.6.0

Parameters

Name

Type

Description

policy

Policy | ResourcePolicy

The Policy to get a human-readable representation of.

Returns

string


removePolicy

removePolicy<Dataset>(policyResource, policy): Dataset

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Remove the given Policy from the given SolidDataset.

since 1.6.0

Type parameters

Name

Type

Dataset

extends Readonly<Object>

Parameters

Name

Type

Description

policyResource

Dataset

The Resource that contains Access Policies.

policy

Url | UrlString | Policy

The Policy to remove from the resource.

Returns

Dataset


removeResourceAcrPolicy

removeResourceAcrPolicy<ResourceExt>(resourceWithAcr, policy): ResourceExt

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Remove the given ResourcePolicy that applies to a given Resource’s Access Control Resource from that Access Control Resource.

since 1.6.0

Type parameters

Name

Type

ResourceExt

extends WithAccessibleAcr

Parameters

Name

Type

Description

resourceWithAcr

ResourceExt

The Resource whose Access Control Resource contains Access Policies.

policy

string | Url | UrlString | ResourcePolicy

The ACR Policy to remove from the Resource’s Access Control Resource.

Returns

ResourceExt


removeResourcePolicy

removeResourcePolicy<ResourceExt>(resourceWithAcr, policy): ResourceExt

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Remove the given ResourcePolicy from the given Resource’s Access Control Resource.

since 1.6.0

Type parameters

Name

Type

ResourceExt

extends WithAccessibleAcr

Parameters

Name

Type

Description

resourceWithAcr

ResourceExt

The Resource whose Access Control Resource contains Access Policies.

policy

string | Url | UrlString | ResourcePolicy

The Policy to remove from the Resource’s Access Control Resource.

Returns

ResourceExt


setAllowModes

Const setAllowModes<P>(policy, modes): P

See setAllowModesV1. Will be updated to point to setAllowModesV2 when pod.inrupt.com is transitioned to the updated vocabulary.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

policy

P

modes

AccessModes

Returns

P


setAllowModesV1

setAllowModesV1<P>(policy, modes): P

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy and a set of AccessModes, return a new Policy based on the given Policy, but with the given Access Modes allowed on it.

since 1.6.0

deprecated The Access Control Policies proposal will be updated to use a different vocabulary for allow- and deny-modes. To be compatible with servers that implement that, use setAllowModesV2.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy on which to set the modes to allow.

modes

AccessModes

Modes to allow for this Policy.

Returns

P


setAllowModesV2

setAllowModesV2<P>(policy, modes): P

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy and a set of AccessModes, return a new Policy based on the given Policy, but with the given Access Modes allowed on it.

since Not released yet.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy on which to set the modes to allow.

modes

AccessModes

Modes to allow for this Policy.

Returns

P


setDenyModes

Const setDenyModes<P>(policy, modes): P

See setDenyModesV1. Will be updated to point to setDenyModesV2 when pod.inrupt.com is transitioned to the updated vocabulary.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

policy

P

modes

AccessModes

Returns

P


setDenyModesV1

setDenyModesV1<P>(policy, modes): P

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy and a set of AccessModes, return a new Policy based on the given Policy, but with the given Access Modes disallowed on it.

since 1.6.0

deprecated The Access Control Policies proposal will be updated to use a different vocabulary for allow- and deny-modes. To be compatible with servers that implement that, use setDenyModesV2.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy on which to set the modes to disallow.

modes

AccessModes

Modes to disallow for this Policy.

Returns

P


setDenyModesV2

setDenyModesV2<P>(policy, modes): P

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Given a Policy and a set of AccessModes, return a new Policy based on the given Policy, but with the given Access Modes disallowed on it.

since Not released yet.

Type parameters

Name

Type

P

extends ThingPersisted

Parameters

Name

Type

Description

policy

P

The Policy on which to set the modes to disallow.

modes

AccessModes

Modes to disallow for this Policy.

Returns

P


setPolicy

setPolicy<Dataset>(policyResource, policy): Dataset

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Insert the given Policy into the given SolidDataset, replacing previous instances of that Policy.

since 1.6.0

Type parameters

Name

Type

Dataset

extends Readonly<Object>

Parameters

Name

Type

Description

policyResource

Dataset

The Resource that contains Access Policies.

policy

Policy

The Policy to insert into the Resource.

Returns

Dataset

A new dataset equal to the given resource, but with the given Policy.


setResourceAcrPolicy

setResourceAcrPolicy<ResourceExt>(resourceWithAcr, policy): ResourceExt

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Insert the given ResourcePolicy into the given Resource’s Acccess Control Resource, replacing previous instances of that Policy, to apply to the Access Control Resource itself.

since 1.6.0

Type parameters

Name

Type

ResourceExt

extends WithAccessibleAcr

Parameters

Name

Type

Description

resourceWithAcr

ResourceExt

The Resource whose Access Control Resource contains Access Policies.

policy

ResourcePolicy

The Policy to insert into the Resource’s Access Control Resource.

Returns

ResourceExt

A new Resource equal to the given Resource, but with the given Policy in its Access Control Resource, applying to that Access Control Resource.


setResourcePolicy

setResourcePolicy<ResourceExt>(resourceWithAcr, policy): ResourceExt

Note

There is no Access Control Policies specification yet. As such, this function is still experimental and subject to change, even in a non-major release.

Insert the given ResourcePolicy into the given Resource’s Acccess Control Resource, replacing previous instances of that Policy.

since 1.6.0

Type parameters

Name

Type

ResourceExt

extends WithAccessibleAcr

Parameters

Name

Type

Description

resourceWithAcr

ResourceExt

The Resource whose Access Control Resource contains Access Policies.

policy

ResourcePolicy

The Policy to insert into the Resource’s Access Control Resource.

Returns

ResourceExt

A new Resource equal to the given Resource, but with the given Policy in its Access Control Resource.