Skip to content

Class: DIDSession

did-session.DIDSession

DID Session

import { DIDSession } from '@glazed/did-session'

Constructors

constructor

new DIDSession(params)

Parameters

Name Type
params SessionParams

Accessors

authProvider

get authProvider(): EthereumAuthProvider

Get authProvider

Returns

EthereumAuthProvider


authorizations

get authorizations(): string[]

Get the list of resources a session is authorized for

Returns

string[]


cacao

get cacao(): Cacao

Get the session CACAO

Returns

Cacao


expireInSecs

get expireInSecs(): number

Number of seconds until a session expires

Returns

number


hasSession

get hasSession(): boolean

Returns

boolean


id

get id(): string

DID string associated to the session instance. session.id == session.getDID().parent

Returns

string


isExpired

get isExpired(): boolean

Determine if a session is expired or not

Returns

boolean

Methods

authorize

authorize(capabilityOpts?): Promise<DID>

Request authorization for session

Parameters

Name Type
capabilityOpts CapabilityOpts

Returns

Promise<DID>


getDID

getDID(): DID

Get DID instance, if authorized

Returns

DID


initDID

initDID(didKey, cacao): Promise<DID>

Parameters

Name Type
didKey DID
cacao Cacao

Returns

Promise<DID>


isAuthorized

isAuthorized(resources?): boolean

Determine if session is available and optionally if authorized for given resources

Parameters

Name Type
resources? string[]

Returns

boolean


serialize

serialize(): string

Serialize session into string, can store and initalize the same session again while valid

Returns

string


fromSession

Static fromSession(session, authProvider): Promise<DIDSession>

Initialize a session from a serialized session string

Parameters

Name Type
session string
authProvider EthereumAuthProvider

Returns

Promise<DIDSession>