Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace ucan

Index

Type aliases

Fact

Fact: SessionKey | Record<string, string>

Potency

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

Resource

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

SessionKey

SessionKey: { sessionKey: string }

Type declaration

  • sessionKey: string

Ucan

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

Type declaration

UcanHeader

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

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 }

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>
  • 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
  • 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

encodeHeader

encodePayload

isExpired

  • isExpired(ucan: Ucan): boolean
  • Check if a UCAN is expired.

    Parameters

    • ucan: Ucan

      The UCAN to validate

    Returns boolean

isValid

  • isValid(ucan: Ucan): Promise<boolean>
  • Check if a UCAN is valid.

    Parameters

    • ucan: Ucan

      The decoded UCAN

    Returns Promise<boolean>

rootIssuer

  • rootIssuer(ucan: string, level?: number): string
  • 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

Generated using TypeDoc