## Index

### Namespaces

- dictionary

### Type aliases

- Fact
- Potency
- Resource
- SessionKey
- Ucan
- UcanHeader
- UcanPayload

### Functions

- build
- decode
- encode
- encodeHeader
- encodePayload
- isExpired
- isValid
- rootIssuer
- sign

## Type aliases

### Fact

Fact: SessionKey | Record<string, string>

- Defined in ucan/types.ts:5

### Potency

Potency: string | Record<string, unknown> | undefined | null

- Defined in ucan/types.ts:10

### Resource

Resource: "*" | Record<string, string>

- Defined in ucan/types.ts:7

### SessionKey

SessionKey: { sessionKey: string }

- Defined in ucan/types.ts:1

#### Type declaration

- ##### sessionKey: string

### Ucan

Ucan: { header: UcanHeader; payload: UcanPayload; signature: string | null }

- Defined in ucan/types.ts:29

#### Type declaration

- ##### header: UcanHeader

- ##### payload: UcanPayload

- ##### signature: string | null

### UcanHeader

UcanHeader: { alg: string; typ: string; uav: string }

- Defined in ucan/types.ts:12

#### Type declaration

- ##### alg: string

- ##### typ: string

- ##### uav: string

### UcanPayload

UcanPayload: { aud: string; exp: number; fct: Fact[]; iss: string; nbf: number; prf: string | null; ptc: Potency; rsc: Resource }

- Defined in ucan/types.ts:18

#### Type declaration

- ##### aud: string

- ##### exp: number

- ##### fct: Fact[]

- ##### iss: string

- ##### nbf: number

- ##### prf: string | null

- ##### ptc: Potency

- ##### rsc: Resource

## Functions

### build

- build(__namedParameters: { addSignature?: boolean; audience: string; expiration?: number; facts?: Fact[]; issuer?: string; lifetimeInSeconds?: number; potency?: Potency; proof?: string; resource?: Resource }): Promise<Ucan>

- - Defined in ucan/token.ts:29

  Create a UCAN, User Controlled Authorization Networks, JWT. This JWT can be used for authorization.

  ### Header

  `alg`, Algorithm, the type of signature. `typ`, Type, the type of this data structure, JWT. `uav`, UCAN version.

  ### Payload

  `aud`, Audience, the ID of who it's intended for. `exp`, Expiry, unix timestamp of when the jwt is no longer valid. `iss`, Issuer, the ID of who sent this. `nbf`, Not Before, unix timestamp of when the jwt becomes valid. `prf`, Proof, an optional nested token with equal or greater privileges. `ptc`, Potency, which rights come with the token. `rsc`, Resource, the involved resource.

  #### Parameters

  - ##### __namedParameters: { addSignature?: boolean; audience: string; expiration?: number; facts?: Fact[]; issuer?: string; lifetimeInSeconds?: number; potency?: Potency; proof?: string; resource?: Resource }

    - ##### Optional addSignature?: boolean

    - ##### audience: string

    - ##### Optional expiration?: number

    - ##### Optional facts?: Fact[]

    - ##### Optional issuer?: string

    - ##### Optional lifetimeInSeconds?: number

    - ##### Optional potency?: Potency

    - ##### Optional proof?: string

    - ##### Optional resource?: Resource

  #### Returns Promise<Ucan>

### decode

- decode(ucan: string): Ucan

- - Defined in ucan/token.ts:99

  Try to decode a UCAN. Will throw if it fails.

  #### Parameters

  - ##### ucan: string

    The encoded UCAN to decode

  #### Returns Ucan

### encode

- encode(ucan: Ucan): string

- - Defined in ucan/token.ts:116

  Encode a UCAN.

  #### Parameters

  - ##### ucan: Ucan

    The UCAN to encode

  #### Returns string

### encodeHeader

- encodeHeader(header: UcanHeader): string

- - Defined in ucan/token.ts:130

  Encode the header of a UCAN.

  #### Parameters

  - ##### header: UcanHeader

    The UcanHeader to encode

  #### Returns string

### encodePayload

- encodePayload(payload: UcanPayload): string

- - Defined in ucan/token.ts:139

  Encode the payload of a UCAN.

  #### Parameters

  - ##### payload: UcanPayload

    The UcanPayload to encode

  #### Returns string

### isExpired

- isExpired(ucan: Ucan): boolean

- - Defined in ucan/token.ts:150

  Check if a UCAN is expired.

  #### Parameters

  - ##### ucan: Ucan

    The UCAN to validate

  #### Returns boolean

### isValid

- isValid(ucan: Ucan): Promise<boolean>

- - Defined in ucan/token.ts:160

  Check if a UCAN is valid.

  #### Parameters

  - ##### ucan: Ucan

    The decoded UCAN

  #### Returns Promise<boolean>

### rootIssuer

- rootIssuer(ucan: string, level?: number): string

- - Defined in ucan/token.ts:191

  Given a UCAN, lookup the root issuer.

  Throws when given an improperly formatted UCAN. This could be a nested UCAN (ie. proof).

  #### Parameters

  - ##### ucan: string

    A UCAN.

  - ##### level: number = 0

  #### Returns string

  The root issuer.

### sign

- sign(header: UcanHeader, payload: UcanPayload): Promise<string>

- - Defined in ucan/token.ts:200

  Generate UCAN signature.

  #### Parameters

  - ##### header: UcanHeader

  - ##### payload: UcanPayload

  #### Returns Promise<string>

Generated using TypeDoc