@fluidframework/odsp-driver Package

Packages > @fluidframework/odsp-driver

Classes

List of classes contained in this package or namespace
Class Description
LocalPersistentCache Default local-only implementation of IPersistedCache, used if no persisted cache is provided by the host
NonPersistentCache
OdspDeltaStorageService Provides access to the underlying delta storage on the server for sharepoint driver.
OdspDocumentDeltaConnection Represents a connection to a stream of delta updates
OdspDocumentService The DocumentService manages the Socket.IO connection and manages routing requests to connected clients
OdspDocumentServiceFactory Factory for creating the sharepoint document service. Use this if you want to use the sharepoint implementation.
OdspDocumentServiceFactoryCore Factory for creating the sharepoint document service. Use this if you want to use the sharepoint implementation.This constructor should be used by environments that support dynamic imports and that wish to leverage code splitting as a means to keep bundles as small as possible.
OdspDocumentServiceFactoryWithCodeSplit
OdspDocumentStorageService
OdspDriverUrlResolver
OdspDriverUrlResolver2
PersistedCacheWithErrorHandling
PromiseCacheWithOneHourSlidingExpiry

Enumerations

List of enums contained in this package or namespace
Enumeration Description
SharingLinkHeader
SnapshotType

Functions

List of functions contained in this package or namespace
Function Description
allowlist(retriableCodes) Creates a filter that will allow retries for the allowed status codes
asyncWithCache(asyncCallback, cacheExpiryTimeMs) A utility function to execute async callback and cache result for given amount of time. If the same function is executed within cache expiry period then cached result is returned.
asyncWithRetry(asyncCallback, retryPolicy, timeoutPolicy) A utility function to execute async callback with support for retries and timeout
authorizedFetchWithRetry(props) A utility function to do authorized fetch with retry. Authorized fetch requires auth token to be included with request. This function supports long lived tokens and handles token refresh in case of authorization failure due to insufficient claims. Note that this function does not reject the returned promise if fetch fails. Clients are expected to inspect the status in the response to determine if the fetch succeeded or not.
constantBackoff(backoffTimeMs)
convertSummaryToSnapshotTreeForCreateNew(summary) Converts a summary tree to ODSP tree
createNewFluidFile(getStorageToken, newFileInfo, logger, createNewSummary, getSharingLinkToken) Creates a new Fluid file. '.fluid' is appended to the filename Returns resolved url
createOdspCache(persistedCache, nonpersistentCache, logger)
createOdspCreateContainerRequest(siteUrl, driveId, filePath, fileName)
createOdspUrl(siteUrl, driveId, itemId, path, containerPackageName) Encodes ODC/SPO information into a URL format that can be handled by the Loader
delay(timeMs) returns a promise that resolves after timeMs
denylist(nonRetriableCodes) Creates a filter that will allow retries for everything except codes on the deny list
encodeOdspFluidDataStoreLocator(locator) Transforms given Fluid data store locator into string that can be embedded into url
errorObjectFromSocketError(socketError) Returns network error based on error object from ODSP socket (IOdspSocketError)
exponentialBackoff(backoffTimeMs)
fetchAndParseHelper(requestInfo, requestInit) A utility function to fetch and parse as JSON with support for retries
fetchHelper(requestInfo, requestInit)
fetchJoinSession(driveId, itemId, siteUrl, path, method, logger, getStorageToken) Makes join session call on SPO to get information about the web socket for a document
fetchSnapshot(snapshotUrl, token, versionId, fetchFullSnapshot, logger) Fetches a snapshot from the server with a given version id.
fetchWithRetry(requestInfo, requestInit, nameForLogging, logger, retryPolicy, timeoutMs, getAdditionalProps) A utility function to do fetch with support for retries. Note that this function does not reject the returned promise if fetch fails. Clients are expected to inspect the status in the response to determine if the fetch succeeded or not.
getApiRoot(origin) Gets the correct API root for the given ODSP url, e.g. 'https://foo-my.sharepoint.com/_api/v2.1'
getGraphItemLite(getShareLinkToken, driveId, itemId, logger) This API gets only few properties representing the GraphItem - hence 'Lite'. Scope needed: files.read.all
getHashedDocumentId(driveId, itemId)
getLocatorFromOdspUrl(url) Extract ODSP Fluid data store locator object from given ODSP url
getOdspUrlParts(url) Breaks an ODSP URL into its parts, extracting the site, drive ID, and item ID. Returns undefined for invalid/malformed URLs.
getShareLink(getShareLinkToken, siteUrl, driveId, itemId, identityType, logger, scope, type) Returns share link with requested scope and type for a file with given drive and item ids. Scope needed: files.readwrite.all
getWithRetryForTokenRefresh(get) This API should be used with pretty much all network calls (fetch, webSocket connection) in order to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors simply propagate to caller
graphFetch(getShareLinkToken, graphUrl, nameForLogging, logger, requestInit, retryPolicy, timeoutMs) Issues a graph fetch request
isLocalStorageAvailable() Tests if localStorage is usable. Should we move this outside to a library?
isOdcOrigin(origin) Checks whether or not the given URL origin is an ODC origin
isOdcUrl(url) Whether or not the given URL is a valid ODC URL
isSpoUrl(url) Whether or not the given URL is a valid SPO/ODB URL
isTokenFromCache(tokenResponse) Helper method which returns flag indicating whether token response comes from local cache
linearBackoff(backoffTimeMs)
noRetry()
parseAuthErrorClaims(responseHeader) Checks if response headers contains www-authenticate header and extracts claims that should be passed to token authority when requesting new token.Header sample: www-authenticate=Bearer realm="", authorization_uri="https://login.microsoftonline.com/common/oauth2/authorize", error="insufficient_claims", claims="dummy"Note that claims value is base64 encoded inside header but this method will return unencoded value.
resolveDataStore(url) Retrieves data store path information from a storage URL. Returns undefined if the resolver does not handle this URL
resolveRequest(request)
storeLocatorInOdspUrl(url, locator) Embeds Fluid data store locator data into given ODSP url
throwOdspNetworkError(errorMessage, statusCode, response) Throws network error - an object with a bunch of network related properties
tokenFromResponse(tokenResponse) Helper method which transforms return value for StorageTokenFetcher and PushTokenFetcher to token string

Interfaces

List of interfaces contained in this package or namespace
Interface Description
AsyncWithRetryResult
AuthorizedFetchProps
AuthorizedRequestTokenPolicy
CachedResult
FetchResponse
GraphItemLite This represents a lite version of GraphItem containing only the name, webUrl and webDavUrl properties
HostStoragePolicy
HostStoragePolicyInternal Same as HostStoragePolicy, but adds options that are internal to runtime. All fields should be optional.
IBlob Blob content
ICacheEntry Cache entry. Identifies file that this entry belongs to, and type of content stored in it.
ICreateFileResponse
IDeltaStorageGetResponse Interface for delta storage response. Contains either SequencedDocumentMessages or SequencedDeltaOpMessage.
IDocumentStorageGetVersionsResponse
IDocumentStorageVersion
IFileEntry
INewFileInfo
INonPersistentCache Internal cache interface used within driver only
IOdspCache Internal cache interface used within driver only
IOdspResolvedUrl
IOdspResponse
IOdspSnapshot
IOdspSocketError Interface for error responses for the WebSocket connection
IOdspUrlParts
IPersistedCache Persistent cache. This interface can be implemented by the host to provide durable caching across sessions. If not provided at driver factory construction, factory will use in-memory cache implementation that does not survive across sessions.
ISequencedDeltaOpMessage
ISharingLinkHeader
ISnapshotBlob
ISnapshotCommit
ISnapshotOptions
ISnapshotRequest
ISnapshotResponse
ISnapshotTree
ISnapshotTreeBaseEntry
ISnapshotTreeHandleEntry
ISnapshotTreeValueEntry
ISocketStorageDiscovery Socket storage discovery api response
ITree
ITreeEntry
OdspDocumentInfo
OdspFluidDataStoreLocator
RetryPolicy Specifies how to do retries
TimeoutPolicy Specifies how to handle timeout
TokenFetchOptions Represents token fetch options
TokenResponse Represents token response

Variables

List of variables contained in this package or namespace
Variable Description
getOrigin Parse the given url and return the origin (host name)
OdcApiSiteOrigin
OdcFileSiteOrigin
snapshotExpirySummarizerOps Describes how many ops behind snapshot can be for summarizer client to still use it
startingUpdateUsageOpFrequency
updateUsageOpMultiplier

Type Aliases

List of type aliases contained in this package or namespace
Type Alias Description
BackoffFunction Determines how long to wait before retrying retriesAttempted n where the last retry done was the n-th retry, initial request not included. first retry is 0, second is 1 etc.
CacheContentType Describes what kind of content is stored in cache entry.
FetchWithRetryResponse
IdentityType
PushTokenFetcher Method signature for callback method used to fetch Push token
RetryFilter returns true when retriable operation should/can be tried again
SharingLinkTokenFetcher Method signature for callback method used to fetch Sharing link token
SnapshotTreeEntry
SnapshotTreeValue
StorageTokenFetcher Method signature for callback method used to fetch Storage token

Enumerations

SharingLinkHeader enum

Signature:

export declare enum SharingLinkHeader 

Enumeration Members

List of members in use in this enum
Member Value Description
isSharingLink "isSharingLink"

SnapshotType enum

Signature:

export declare enum SnapshotType 

Enumeration Members

List of members in use in this enum
Member Value Description
Channel "channel"
Container "container"

Functions

allowlist

Creates a filter that will allow retries for the allowed status codes

Signature:

export declare function allowlist(retriableCodes: number[]): RetryFilter<Response>;

Parameters

List of parameters
Parameter Type Description
retriableCodes number[] Cannot be null/undefined

Returns:

RetryFilter<Response>

asyncWithCache

A utility function to execute async callback and cache result for given amount of time. If the same function is executed within cache expiry period then cached result is returned.

Signature:

export declare function asyncWithCache<T>(asyncCallback: () => Promise<T | undefined>, cacheExpiryTimeMs: number): () => Promise<T | undefined>;

Parameters

List of parameters
Parameter Type Description
asyncCallback () => Promise function returning result as a promise
cacheExpiryTimeMs number time in milliseconds for cached result to be valid

Returns:

() => Promise<T | undefined>

asyncWithRetry

A utility function to execute async callback with support for retries and timeout

Signature:

export declare function asyncWithRetry<T>(asyncCallback: (retryAttempt: number) => Promise<T>, retryPolicy?: RetryPolicy<T>, timeoutPolicy?: TimeoutPolicy<T>): Promise<AsyncWithRetryResult<T>>;

Parameters

List of parameters
Parameter Type Description
asyncCallback (retryAttempt: number) => Promise function returning result as a promise
retryPolicy RetryPolicy how to do retries
timeoutPolicy TimeoutPolicy how to treat timeout

Returns:

Promise<AsyncWithRetryResult<T>>

authorizedFetchWithRetry

A utility function to do authorized fetch with retry. Authorized fetch requires auth token to be included with request. This function supports long lived tokens and handles token refresh in case of authorization failure due to insufficient claims. Note that this function does not reject the returned promise if fetch fails. Clients are expected to inspect the status in the response to determine if the fetch succeeded or not.

Signature:

export declare function authorizedFetchWithRetry(props: AuthorizedFetchProps): Promise<FetchWithRetryResponse>;

Parameters

List of parameters
Parameter Type Description
props AuthorizedFetchProps set of properties describing fetch behavior

Returns:

Promise<FetchWithRetryResponse>

promise to fetch response

constantBackoff

Signature:

export declare function constantBackoff(backoffTimeMs: number): BackoffFunction;

Parameters

List of parameters
Parameter Type Description
backoffTimeMs number

Returns:

BackoffFunction

convertSummaryToSnapshotTreeForCreateNew

Converts a summary tree to ODSP tree

Signature:

export declare function convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): ISnapshotTree;

Parameters

List of parameters
Parameter Type Description
summary ISummaryTree

Returns:

ISnapshotTree

createNewFluidFile

Creates a new Fluid file. ‘.fluid’ is appended to the filename Returns resolved url

Signature:

export declare function createNewFluidFile(getStorageToken: (options: TokenFetchOptions, name?: string) => Promise<string | null>, newFileInfo: INewFileInfo, logger: ITelemetryLogger, createNewSummary: ISummaryTree, getSharingLinkToken?: (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise<string | null>): Promise<IOdspResolvedUrl>;

Parameters

List of parameters
Parameter Type Description
getStorageToken (options: TokenFetchOptions, name?: string) => Promise
newFileInfo INewFileInfo
logger ITelemetryLogger
createNewSummary ISummaryTree
getSharingLinkToken (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise

Returns:

Promise<IOdspResolvedUrl>

createOdspCache

Signature:

export declare function createOdspCache(persistedCache: IPersistedCache, nonpersistentCache: INonPersistentCache, logger: ITelemetryLogger): IOdspCache;

Parameters

List of parameters
Parameter Type Description
persistedCache IPersistedCache
nonpersistentCache INonPersistentCache
logger ITelemetryLogger

Returns:

IOdspCache

createOdspCreateContainerRequest

Signature:

export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string): IRequest;

Parameters

List of parameters
Parameter Type Description
siteUrl string
driveId string
filePath string
fileName string

Returns:

IRequest

createOdspUrl

Encodes ODC/SPO information into a URL format that can be handled by the Loader

Signature:

export declare function createOdspUrl(siteUrl: string, driveId: string, itemId: string, path: string, containerPackageName?: string): string;

Parameters

List of parameters
Parameter Type Description
siteUrl string The site where the container is hosted
driveId string The id of the drive with the container
itemId string The id of the container
path string A path that corresponds to a request that will be handled by the container
containerPackageName string A string representing the container package name to be used for preloading scripts

Returns:

string

delay

returns a promise that resolves after timeMs

Signature:

export declare function delay(timeMs: number): Promise<void>;

Parameters

List of parameters
Parameter Type Description
timeMs number

Returns:

Promise<void>

denylist

Creates a filter that will allow retries for everything except codes on the deny list

Signature:

export declare function denylist(nonRetriableCodes: number[]): RetryFilter<Response>;

Parameters

List of parameters
Parameter Type Description
nonRetriableCodes number[] Cannot be null/undefined

Returns:

RetryFilter<Response>

encodeOdspFluidDataStoreLocator

Transforms given Fluid data store locator into string that can be embedded into url

Signature:

export declare function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string;

Parameters

List of parameters
Parameter Type Description
locator OdspFluidDataStoreLocator describes Fluid data store locator info to be encoded

Returns:

string

string representing encoded Fluid data store locator info

errorObjectFromSocketError

Returns network error based on error object from ODSP socket (IOdspSocketError)

Signature:

export declare function errorObjectFromSocketError(socketError: IOdspSocketError): import("@fluidframework/odsp-doclib-utils").OdspError;

Parameters

List of parameters
Parameter Type Description
socketError IOdspSocketError

Returns:

import("@fluidframework/odsp-doclib-utils”).OdspError

exponentialBackoff

Signature:

export declare function exponentialBackoff(backoffTimeMs: number): BackoffFunction;

Parameters

List of parameters
Parameter Type Description
backoffTimeMs number

Returns:

BackoffFunction

fetchAndParseHelper

A utility function to fetch and parse as JSON with support for retries

Signature:

export declare function fetchAndParseHelper<T>(requestInfo: RequestInfo, requestInit: RequestInit | undefined): Promise<IOdspResponse<T>>;

Parameters

List of parameters
Parameter Type Description
requestInfo RequestInfo fetch requestInfo, can be a string
requestInit RequestInit | undefined fetch requestInit

Returns:

Promise<IOdspResponse<T>>

fetchHelper

Signature:

export declare function fetchHelper(requestInfo: RequestInfo, requestInit: RequestInit | undefined): Promise<Response>;

Parameters

List of parameters
Parameter Type Description
requestInfo RequestInfo
requestInit RequestInit | undefined

Returns:

Promise<Response>

fetchJoinSession

Makes join session call on SPO to get information about the web socket for a document

Signature:

export declare function fetchJoinSession(driveId: string, itemId: string, siteUrl: string, path: string, method: string, logger: ITelemetryLogger, getStorageToken: (options: TokenFetchOptions, name?: string) => Promise<string | null>): Promise<ISocketStorageDiscovery>;

Parameters

List of parameters
Parameter Type Description
driveId string The SPO drive id that this request should be made against
itemId string The SPO item id that this request should be made against
siteUrl string The SPO site that this request should be made against
path string The API path that is relevant to this request
method string The type of request, such as GET or POST
logger ITelemetryLogger A logger to use for this request
getStorageToken (options: TokenFetchOptions, name?: string) => Promise

Returns:

Promise<ISocketStorageDiscovery>

fetchSnapshot

Fetches a snapshot from the server with a given version id.

Signature:

export declare function fetchSnapshot(snapshotUrl: string, token: string | null, versionId: string, fetchFullSnapshot: boolean, logger: ITelemetryLogger): Promise<IOdspResponse<IOdspSnapshot>>;

Parameters

List of parameters
Parameter Type Description
snapshotUrl string snapshot url from where the odsp snapshot will be fetched
token string | null token used for authorization in the request
versionId string id of specific snapshot to be fetched
fetchFullSnapshot boolean whether we want to fetch full snapshot(with blobs)
logger ITelemetryLogger

Returns:

Promise<IOdspResponse<IOdspSnapshot>>

A promise of the snapshot and the status code of the response

fetchWithRetry

A utility function to do fetch with support for retries. Note that this function does not reject the returned promise if fetch fails. Clients are expected to inspect the status in the response to determine if the fetch succeeded or not.

Signature:

export declare function fetchWithRetry(requestInfo: RequestInfo, requestInit: RequestInit | undefined, nameForLogging: string, logger?: ITelemetryLogger, retryPolicy?: RetryPolicy<Response>, timeoutMs?: number, getAdditionalProps?: (response: Response, isFinalAttempt: boolean) => Promise<ITelemetryProperties>): Promise<FetchWithRetryResponse>;

Parameters

List of parameters
Parameter Type Description
requestInfo RequestInfo fetch requestInfo, can be a string
requestInit RequestInit | undefined fetch requestInit
nameForLogging string
logger ITelemetryLogger used to log results of operation, including any error
retryPolicy RetryPolicy how to do retries
timeoutMs number time in milliseconds to treat fetch as timed out
getAdditionalProps (response: Response, isFinalAttempt: boolean) => Promise<ITelemetryProperties> optional callback used to get additional properties that get logged about the request

Returns:

Promise<FetchWithRetryResponse>

getApiRoot

Gets the correct API root for the given ODSP url, e.g. ‘https://foo-my.sharepoint.com/_api/v2.1’

Signature:

export declare function getApiRoot(origin: string): string;

Parameters

List of parameters
Parameter Type Description
origin string The URL origin

Returns:

string

getGraphItemLite

This API gets only few properties representing the GraphItem - hence ‘Lite’. Scope needed: files.read.all

Signature:

export declare function getGraphItemLite(getShareLinkToken: (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise<string | null>, driveId: string, itemId: string, logger?: ITelemetryLogger): Promise<GraphItemLite | undefined>;

Parameters

List of parameters
Parameter Type Description
getShareLinkToken (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise used to fetch access token needed to execute operation
driveId string ID for the drive that contains the file
itemId string ID of the file
logger ITelemetryLogger used to log results of operation, including any error

Returns:

Promise<GraphItemLite | undefined>

Object containing name, webUrl and webDavUrl properties. - name represents file name - webUrl represents file url, this is url that can be used for direct loading of file on web. Primarily used as canonical url for file residing in ODC - webDavUrl represents file url in WebDAV standard, this url includes file path. This is needed for APIs powering MRU and Share functionality.

getHashedDocumentId

Signature:

export declare function getHashedDocumentId(driveId: string, itemId: string): string;

Parameters

List of parameters
Parameter Type Description
driveId string
itemId string

Returns:

string

getLocatorFromOdspUrl

Extract ODSP Fluid data store locator object from given ODSP url

Signature:

export declare function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | undefined;

Parameters

List of parameters
Parameter Type Description
url URL ODSP url representing Fluid file link

Returns:

OdspFluidDataStoreLocator | undefined

object representing Fluid data store location in ODSP terms

getOdspUrlParts

Breaks an ODSP URL into its parts, extracting the site, drive ID, and item ID. Returns undefined for invalid/malformed URLs.

Signature:

export declare function getOdspUrlParts(url: URL): Promise<IOdspUrlParts | undefined>;

Parameters

List of parameters
Parameter Type Description
url URL The (raw) URL to parse

Returns:

Promise<IOdspUrlParts | undefined>

Returns share link with requested scope and type for a file with given drive and item ids. Scope needed: files.readwrite.all

Signature:

export declare function getShareLink(getShareLinkToken: (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise<string | null>, siteUrl: string, driveId: string, itemId: string, identityType: IdentityType, logger?: ITelemetryLogger, scope?: "anonymous" | "organization" | "default" | "existingAccess", type?: "view" | "edit"): Promise<string | undefined>;

Parameters

List of parameters
Parameter Type Description
getShareLinkToken (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise used to fetch access token needed to execute operation
siteUrl string url of the site that contains the file
driveId string drive where file is stored
itemId string file id
identityType IdentityType type of client account
logger ITelemetryLogger used to log results of operation, including any error
scope "anonymous" | "organization" | "default" | "existingAccess" access scope that will be granted via generated link. 'default' scope tells server to use default access which is determined based on tenant settings
type "view" | "edit" access type. This value is ignored when scope is set to either 'default' or 'existingAccess'

Returns:

Promise<string | undefined>

Promise which resolves to share link url when successful; otherwise, undefined.

getWithRetryForTokenRefresh

This API should be used with pretty much all network calls (fetch, webSocket connection) in order to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors simply propagate to caller

Signature:

export declare function getWithRetryForTokenRefresh<T>(get: (options: TokenFetchOptions) => Promise<T>): Promise<T>;

Parameters

List of parameters
Parameter Type Description
get (options: TokenFetchOptions) => Promise

Returns:

Promise<T>

graphFetch

Issues a graph fetch request

Signature:

export declare function graphFetch(getShareLinkToken: (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise<string | null>, graphUrl: string, nameForLogging: string, logger?: ITelemetryLogger, requestInit?: RequestInit, retryPolicy?: RetryPolicy<Response>, timeoutMs?: number): Promise<Response>;

Parameters

List of parameters
Parameter Type Description
getShareLinkToken (options: TokenFetchOptions, isForFileDefaultUrl: boolean) => Promise Token provider than can supply Graph tokens
graphUrl string Url to fetch. Can either be a full URL (e.g. https://graph.microsoft.com/v1.0/me/people) or a partial url (e.g. me/people)
nameForLogging string Name used for logging
logger ITelemetryLogger used to log results of operation, including any error
requestInit RequestInit Request Init to be passed to fetch
retryPolicy RetryPolicy Retry policy to be passed to fetchWithRetry
timeoutMs number Timeout value to be passed to fetchWithRetry

Returns:

Promise<Response>

isLocalStorageAvailable

Tests if localStorage is usable. Should we move this outside to a library?

Signature:

export declare function isLocalStorageAvailable(): boolean;

Returns:

boolean

isOdcOrigin

Checks whether or not the given URL origin is an ODC origin

Signature:

export declare function isOdcOrigin(origin: string): boolean;

Parameters

List of parameters
Parameter Type Description
origin string The URL origin to check

Returns:

boolean

isOdcUrl

Whether or not the given URL is a valid ODC URL

Signature:

export declare function isOdcUrl(url: string | URL): boolean;

Parameters

List of parameters
Parameter Type Description
url string | URL The URL to check

Returns:

boolean

isSpoUrl

Whether or not the given URL is a valid SPO/ODB URL

Signature:

export declare function isSpoUrl(url: string): boolean;

Parameters

List of parameters
Parameter Type Description
url string The URL to check

Returns:

boolean

isTokenFromCache

Helper method which returns flag indicating whether token response comes from local cache

Signature:

export declare function isTokenFromCache(tokenResponse: string | TokenResponse | null): boolean | undefined;

Parameters

List of parameters
Parameter Type Description
tokenResponse string | TokenResponse | null return value for StorageTokenFetcher and PushTokenFetcher methods

Returns:

boolean | undefined

Value indicating whether response came from cache. Undefined is returned when we could not determine the source of token.

linearBackoff

Signature:

export declare function linearBackoff(backoffTimeMs: number): BackoffFunction;

Parameters

List of parameters
Parameter Type Description
backoffTimeMs number

Returns:

BackoffFunction

noRetry

Signature:

export declare function noRetry(): RetryFilter<any>;

Returns:

RetryFilter<any>

parseAuthErrorClaims

Checks if response headers contains www-authenticate header and extracts claims that should be passed to token authority when requesting new token.

Header sample: www-authenticate=Bearer realm=””, authorization_uri="https://login.microsoftonline.com/common/oauth2/authorize”, error="insufficient_claims”, claims="dummy”

Note that claims value is base64 encoded inside header but this method will return unencoded value.

Signature:

export declare function parseAuthErrorClaims(responseHeader: Headers): string | undefined;

Parameters

List of parameters
Parameter Type Description
responseHeader Headers

Returns:

string | undefined

resolveDataStore

Retrieves data store path information from a storage URL. Returns undefined if the resolver does not handle this URL

Signature:

export declare function resolveDataStore(url: URL): string | undefined;

Parameters

List of parameters
Parameter Type Description
url URL

Returns:

string | undefined

resolveRequest

Signature:

export declare function resolveRequest(request: IRequest): Promise<IOdspResolvedUrl>;

Parameters

List of parameters
Parameter Type Description
request IRequest

Returns:

Promise<IOdspResolvedUrl>

storeLocatorInOdspUrl

Embeds Fluid data store locator data into given ODSP url

Signature:

export declare function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator): void;

Parameters

List of parameters
Parameter Type Description
url URL file url in ODSP format (can be either canonical or share link)
locator OdspFluidDataStoreLocator object representing Fluid data store location in ODSP terms

Returns:

void

throwOdspNetworkError

Throws network error - an object with a bunch of network related properties

Signature:

export declare function throwOdspNetworkError(errorMessage: string, statusCode: number, response?: Response): never;

Parameters

List of parameters
Parameter Type Description
errorMessage string
statusCode number
response Response

Returns:

never

tokenFromResponse

Helper method which transforms return value for StorageTokenFetcher and PushTokenFetcher to token string

Signature:

export declare function tokenFromResponse(tokenResponse: string | TokenResponse | null | undefined): string | null;

Parameters

List of parameters
Parameter Type Description
tokenResponse string | TokenResponse | null | undefined return value for StorageTokenFetcher and PushTokenFetcher methods

Returns:

string | null

Token value

Variables

getOrigin

Parse the given url and return the origin (host name)

Signature:

getOrigin: (url: string) => string

OdcApiSiteOrigin

Signature:

OdcApiSiteOrigin = "https://api.onedrive.com"

OdcFileSiteOrigin

Signature:

OdcFileSiteOrigin = "https://1drv.ms"

snapshotExpirySummarizerOps

Describes how many ops behind snapshot can be for summarizer client to still use it

Signature:

snapshotExpirySummarizerOps = 1000

startingUpdateUsageOpFrequency

Signature:

startingUpdateUsageOpFrequency = 100

updateUsageOpMultiplier

Signature:

updateUsageOpMultiplier = 1.2

Type Aliases

BackoffFunction

Determines how long to wait before retrying retriesAttempted n where the last retry done was the n-th retry, initial request not included. first retry is 0, second is 1 etc.

Signature:

export declare type BackoffFunction = (retriesAttempted: number) => number;

CacheContentType

Describes what kind of content is stored in cache entry.

Signature:

export declare type CacheContentType = "snapshot";

FetchWithRetryResponse

Signature:

export declare type FetchWithRetryResponse = AsyncWithRetryResult<FetchResponse>;

IdentityType

Signature:

export declare type IdentityType = "Consumer" | "Enterprise";

PushTokenFetcher

Method signature for callback method used to fetch Push token

Signature:

export declare type PushTokenFetcher = (refresh: boolean, claims?: string) => Promise<string | TokenResponse | null>;

RetryFilter

returns true when retriable operation should/can be tried again

Signature:

export declare type RetryFilter<T> = (result: T) => boolean;

SharingLinkTokenFetcher

Method signature for callback method used to fetch Sharing link token

Signature:

export declare type SharingLinkTokenFetcher = (forFileDefaultUrl: boolean, refresh: boolean, claims?: string) => Promise<string | TokenResponse | null>;

SnapshotTreeEntry

Signature:

export declare type SnapshotTreeEntry = ISnapshotTreeValueEntry | ISnapshotTreeHandleEntry;

SnapshotTreeValue

Signature:

export declare type SnapshotTreeValue = ISnapshotTree | ISnapshotBlob | ISnapshotCommit;

StorageTokenFetcher

Method signature for callback method used to fetch Storage token

Signature:

export declare type StorageTokenFetcher = (siteUrl: string, refresh: boolean, claims?: string) => Promise<string | TokenResponse | null>;