Class SubscriptionToken

Constructors

Properties

expiresAt: Date

Expiration of token

issuedAt: Date

Time token was issued

issuer: string

Issuer of token (MyScribae)

provider: Provider

Provider instance

scriptsClaims: {
    scripts: ScriptClaim[];
}

Claims associated with this token

Type declaration

subject: string

User identififier for your application

Methods

  • To make it easier to check a user's level of access.

    Parameters

    • target: {
          scriptGroupId?: string;
          scriptId: string | string[];
      }

      Matches specific script groups and/or scripts.

      • Optional scriptGroupId?: string
      • scriptId: string | string[]

    Returns boolean

    Example: Checking a user has access to a script


    const token = new SubscriptionToken(provider, payload);

    const isAllowed = token.matches({
    script_id:'my-script-id',
    script_group_id:'my-script-group-id'
    });

    if (!isAllowed) {
    // User does not have access to this script
    // return 403
    }

    // User has access to this script

Generated using TypeDoc