@inrupt/solid-client / acp/policy

Module: acp/policy

Table of contents

Type aliases

Functions

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

Defined in: src/acp/policy.ts:70


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

Defined in: src/acp/policy.ts:60


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

Defined in: src/acp/policy.ts:65

Functions

createPolicy

createPolicy(url: Url | UrlString): 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

Defined in: src/acp/policy.ts:93


createResourcePolicyFor

createResourcePolicyFor(resourceWithAcr: WithAccessibleAcr, name: string): 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.

Returns: ResourcePolicy

Defined in: src/acp/policy.ts:292


getAllowModes

getAllowModes<P>(policy: P): 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

Type parameters:

Name

Type

P

ThingPersisted

Parameters:

Name

Type

Description

policy

P

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

Returns: AccessModes

Defined in: src/acp/policy.ts:220


getDenyModes

getDenyModes<P>(policy: P): 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

Type parameters:

Name

Type

P

ThingPersisted

Parameters:

Name

Type

Description

policy

P

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

Returns: AccessModes

Defined in: src/acp/policy.ts:270


getPolicy

getPolicy(policyResource: SolidDataset, url: Url | UrlString): 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.

Defined in: src/acp/policy.ts:113


getPolicyAll

getPolicyAll(policyResource: SolidDataset): 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[]

Defined in: src/acp/policy.ts:135


getResourceAcrPolicy

getResourceAcrPolicy(resourceWithAcr: WithAccessibleAcr, name: string): 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.

Defined in: src/acp/policy.ts:351


getResourceAcrPolicyAll

getResourceAcrPolicyAll(resourceWithAcr: WithAccessibleAcr): 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[]

Defined in: src/acp/policy.ts:405


getResourcePolicy

getResourcePolicy(resourceWithAcr: WithAccessibleAcr, name: string): 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.

Defined in: src/acp/policy.ts:318


getResourcePolicyAll

getResourcePolicyAll(resourceWithAcr: WithAccessibleAcr): 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[]

Defined in: src/acp/policy.ts:382


policyAsMarkdown

policyAsMarkdown(policy: Policy | ResourcePolicy): 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

Defined in: src/acp/policy.ts:586


removePolicy

removePolicy<Dataset>(policyResource: Dataset, policy: Url | UrlString | 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

DatasetCore<Quad, Quad, Dataset>

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

Defined in: src/acp/policy.ts:154


removeResourceAcrPolicy

removeResourceAcrPolicy<ResourceExt>(resourceWithAcr: ResourceExt, policy: string | Url | UrlString | ResourcePolicy): 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

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

Defined in: src/acp/policy.ts:484


removeResourcePolicy

removeResourcePolicy<ResourceExt>(resourceWithAcr: ResourceExt, policy: string | Url | UrlString | ResourcePolicy): 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

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

Defined in: src/acp/policy.ts:429


setAllowModes

setAllowModes<P>(policy: P, modes: AccessModes): 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

Type parameters:

Name

Type

P

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

Defined in: src/acp/policy.ts:192


setDenyModes

setDenyModes<P>(policy: P, modes: AccessModes): 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

Type parameters:

Name

Type

P

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

Defined in: src/acp/policy.ts:242


setPolicy

setPolicy<Dataset>(policyResource: Dataset, policy: 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

DatasetCore<Quad, Quad, Dataset>

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.

Defined in: src/acp/policy.ts:173


setResourceAcrPolicy

setResourceAcrPolicy<ResourceExt>(resourceWithAcr: ResourceExt, policy: ResourcePolicy): 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

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.

Defined in: src/acp/policy.ts:566


setResourcePolicy

setResourcePolicy<ResourceExt>(resourceWithAcr: ResourceExt, policy: ResourcePolicy): 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

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.

Defined in: src/acp/policy.ts:541