Packages > @fluidframework/routerlicious-driver > ITokenProvider

ITokenProvider Interface

Abstracts the token fetching mechanism for a hosting application. The hosting application is responsible for providing an implementation.

Signature

export interface ITokenProvider

Methods

Method Modifiers Return Type Description
documentPostCreateCallback(documentId, creationToken) optional Promise<void> A callback triggered directly after creating the document. In this callback the client has the opportunity, to verify against an authorization service, if the user who claims to create the document is the same user who created it.
fetchOrdererToken(tenantId, documentId, refresh) Promise<ITokenResponse> Fetches the orderer token from host.
fetchStorageToken(tenantId, documentId, refresh) Promise<ITokenResponse> Fetches the storage token from host.

Method Details

documentPostCreateCallback

A callback triggered directly after creating the document. In this callback the client has the opportunity, to verify against an authorization service, if the user who claims to create the document is the same user who created it.

Signature

documentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;

Remarks

Notes:

* Using the callback may have performance impact on the document creation process.

* Any exceptions thrown in the callback would fail the creation workflow.

Parameters

Parameter Type Description
documentId string Document ID.
creationToken string A special token that doesn't provide any kind of access, but it has the user's payload and document id. It can be used to validate the identity of the document creator.

Returns

Return type: Promise<void>

fetchOrdererToken

Fetches the orderer token from host.

Signature

fetchOrdererToken(tenantId: string, documentId?: string, refresh?: boolean): Promise<ITokenResponse>;

Parameters

Parameter Modifiers Type Description
tenantId string Tenant ID.
documentId optional string Optional. Document ID is only required for document-scoped requests.
refresh optional boolean

Optional flag indicating whether token fetch must bypass local cache. This likely indicates that some previous request failed authorization due to an expired token, and so a fresh token is required.

Default: false.

NOTE: This parameter will be made required in the future.

Returns

Return type: Promise<ITokenResponse >

fetchStorageToken

Fetches the storage token from host.

Signature

fetchStorageToken(tenantId: string, documentId: string, refresh?: boolean): Promise<ITokenResponse>;

Parameters

Parameter Modifiers Type Description
tenantId string Tenant ID.
documentId string Document ID.
refresh optional boolean

Optional flag indicating whether token fetch must bypass local cache. This likely indicates that some previous request failed authorization due to an expired token, and so a fresh token is required.

Default: false.

NOTE: This parameter will be made required in the future.

Returns

Return type: Promise<ITokenResponse >