Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace ucan

Index

Type aliases

Fact

Fact: SessionKey | Record<string, string>

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: Ucan | undefined; ptc: string | undefined | null; rsc: Resource }

Type declaration

  • aud: string
  • exp: number
  • fct: Fact[]
  • iss: string
  • nbf: number
  • prf: Ucan | undefined
  • ptc: string | undefined | null
  • rsc: Resource

Variables

Const WNFS_PREFIX

WNFS_PREFIX: "wnfs" = "wnfs"

Functions

build

  • build(__namedParameters: { addSignature?: boolean; audience: string; facts?: Fact[]; issuer: string; lifetimeInSeconds?: number; potency?: string | null; proof?: Ucan; 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; facts?: Fact[]; issuer: string; lifetimeInSeconds?: number; potency?: string | null; proof?: Ucan; resource?: Resource }
      • Optional addSignature?: boolean
      • audience: string
      • Optional facts?: Fact[]
      • issuer: string
      • Optional lifetimeInSeconds?: number
      • Optional potency?: string | null
      • Optional proof?: Ucan
      • Optional resource?: Resource

    Returns Promise<Ucan>

compileDictionary

  • compileDictionary(ucans: string[]): Record<string, Ucan>
  • Given a list of UCANs, generate a dictionary. The key will be in the form of ${resourceKey}:${resourceValue}

    Parameters

    • ucans: string[]

    Returns Record<string, 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
  • Encode a UCAN.

    Parameters

    • ucan: Ucan

      The UCAN to encode

    Returns string

encodeHeader

  • Encode the header of a UCAN.

    Parameters

    Returns string

encodePayload

  • Encode the payload of a UCAN.

    Parameters

    Returns string

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