Class: DIDSession
did-session.DIDSession
DID Session
import { DIDSession } from 'did-session'
Constructors
constructor
• new DIDSession(params
)
Parameters
Name | Type |
---|---|
params | SessionParams |
Accessors
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
did
• get
did(): DID
Get DID instance, if authorized
Returns
DID
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
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
authorize
▸ Static
authorize(authMethod
, authOpts?
): Promise
<DIDSession
>
Request authorization for session
Parameters
Name | Type |
---|---|
authMethod | AuthMethod |
authOpts | AuthOpts |
Returns
Promise
<DIDSession
>
fromSession
▸ Static
fromSession(session
): Promise
<DIDSession
>
Initialize a session from a serialized session string
Parameters
Name | Type |
---|---|
session | string |
Returns
Promise
<DIDSession
>
initDID
▸ Static
initDID(didKey
, cacao
): Promise
<DID
>
Parameters
Name | Type |
---|---|
didKey | DID |
cacao | Cacao |
Returns
Promise
<DID
>