@fluidframework/odsp-driver 1.2.3-84921 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAItE,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAEhB,+BAA+B,EAClC,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAwB,wBAAwB,EAA8B,MAAM,aAAa,CAAC;AAGxH,OAAO,EAKH,aAAa,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,oBAAY,yBAAyB;IACjC,IAAI,IAAI;IACR,MAAM,IAAI;IACV,aAAa,IAAI;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAC/B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,OAAO,EAC1B,sCAAsC,EAAE,OAAO,EAC/C,MAAM,EAAE,gBAAgB,EACxB,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,KAAK,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAC9G,OAAO,CAAC,iBAAiB,CAAC,CAwB5B;AAED,wBAAsB,uBAAuB,CACzC,eAAe,EAAE,gBAAgB,EACjC,mBAAmB,EAAE,+BAA+B,EAC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,OAAO,CAAC,IAAI,CAAC,EACvE,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAClC,oBAAoB,CAAC,EAAE,OAAO,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAsD5B;AAiRD,MAAM,WAAW,kCAAkC;IAC/C,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;KAAE,CAAC;CAC7C;AAiDD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,QAK5D;AAWD;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAClC,eAAe,EAAE,gBAAgB,EACjC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,gBAAgB,GAAG,SAAS,EAC7C,uBAAuB,CAAC,EAAE,yBAAyB,EACnD,UAAU,CAAC,EAAE,eAAe,EAC5B,YAAY,CAAC,EAAE,YAAY,EAC3B,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,kCAAkC,CAAC,CAwC7C"}
@@ -140,8 +140,15 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
140
140
  const contentType = odspResponse.headers.get("content-type");
141
141
  odspResponse.propsToLog = Object.assign(Object.assign({}, odspResponse.propsToLog), { contentType, accept: response.requestHeaders.accept });
142
142
  let parsedSnapshotContents;
143
+ let contentTypeToRead;
144
+ if ((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf("application/ms-fluid")) !== -1) {
145
+ contentTypeToRead = "application/ms-fluid";
146
+ }
147
+ else if ((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf("application/json")) !== -1) {
148
+ contentTypeToRead = "application/json";
149
+ }
143
150
  try {
144
- switch (contentType) {
151
+ switch (contentTypeToRead) {
145
152
  case "application/json": {
146
153
  const text = await odspResponse.content.text();
147
154
  odspResponse.propsToLog.bodySize = text.length;
@@ -375,14 +382,12 @@ async function downloadSnapshot(odspResolvedUrl, storageToken, logger, snapshotO
375
382
  };
376
383
  // Decide what snapshot format to fetch as per the feature gate.
377
384
  switch (snapshotFormatFetchType) {
378
- case SnapshotFormatSupportType.JsonAndBinary:
379
- headers.accept = `application/json, application/ms-fluid; v=${compactSnapshotParser_1.currentReadVersion}`;
380
- break;
381
385
  case SnapshotFormatSupportType.Binary:
382
386
  headers.accept = `application/ms-fluid; v=${compactSnapshotParser_1.currentReadVersion}`;
383
387
  break;
384
388
  default:
385
- headers.accept = "application/json";
389
+ // By default ask both versions and let the server decide the format.
390
+ headers.accept = `application/json, application/ms-fluid; v=${compactSnapshotParser_1.currentReadVersion}`;
386
391
  }
387
392
  const odspResponse = await ((_a = epochTracker === null || epochTracker === void 0 ? void 0 : epochTracker.fetch(url, fetchOptions, "treesLatest", true, scenarioName)) !== null && _a !== void 0 ? _a : (0, odspUtils_1.fetchHelper)(url, fetchOptions));
388
393
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAElC,+DAAqF;AACrF,2EAAqE;AACrE,qEAA4F;AAC5F,qFAKiD;AAEjD,+DAAmF;AACnF,2CAAwH;AACxH,qDAAkD;AAClD,yEAAsE;AACtE,2CAMqB;AAErB,6DAAiF;AACjF,mEAA2F;AAC3F,uDAA+C;AAE/C,qDAA8C;AAE9C;;GAEG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACjC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AACrB,CAAC,EAJW,yBAAyB,GAAzB,iCAAyB,KAAzB,iCAAyB,QAIpC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,aAAa,CAC/B,WAAmB,EACnB,KAAoB,EACpB,SAAiB,EACjB,iBAA0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AC,+BAA+B,CAAC,EAAE;QAC7E,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACnC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU;SAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { isFluidError, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n fetchAndParseAsJSONHelper,\n fetchHelper,\n getWithRetryForTokenRefresh,\n getWithRetryForTokenRefreshRepeat,\n IOdspResponse,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport { currentReadVersion, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n */\nexport enum SnapshotFormatSupportType {\n Json = 0,\n Binary = 1,\n JsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n snapshotUrl: string,\n token: string | null,\n versionId: string,\n fetchFullSnapshot: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (url: string, fetchOptions: { [index: string]: any; }) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n const path = `/trees/${versionId}`;\n let queryParams: ISnapshotOptions = {};\n\n if (fetchFullSnapshot) {\n if (versionId !== \"latest\") {\n queryParams = { channels: 1, blobs: 2 };\n } else {\n queryParams = { deltas: 1, channels: 1, blobs: 2 };\n }\n }\n\n const queryString = getQueryString(queryParams);\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);\n const response = await PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"fetchSnapshot\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => snapshotDownloader(url, { headers }),\n ) as IOdspResponse<IOdspSnapshot>;\n return convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n removeEntries: () => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n return fetchLatestSnapshotCore(\n odspResolvedUrl,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n enableRedeemFallback,\n ).catch(async (error) => {\n if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n // Execute the redeem fallback\n logger.sendErrorEvent({\n eventName: \"RedeemFallback\",\n errorType: error.errorType,\n }, error);\n await redeemSharingLink(\n odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);\n const odspResolvedUrlWithoutShareLink: IOdspResolvedUrl =\n {\n ...odspResolvedUrl,\n shareLinkInfo: {\n ...odspResolvedUrl.shareLinkInfo,\n sharingLinkToRedeem: undefined,\n },\n };\n\n return fetchLatestSnapshotCore(\n odspResolvedUrlWithoutShareLink,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n );\n } else {\n throw error;\n }\n }).catch(async (error) => {\n // Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n // have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n // snapshot from cache in the future.\n if (typeof error === \"object\" && error !== null && error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n await removeEntries();\n }\n throw error;\n });\n}\n\nasync function redeemSharingLink(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n) {\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"RedeemShareLink\",\n },\n async () => getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n assert(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n 0x1ed /* \"Share link should be present\" */);\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"RedeemShareLink\");\n const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);\n const redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers.prefer = \"redeemSharingLink\";\n return fetchAndParseAsJSONHelper(url, { headers });\n }),\n );\n}\n\nasync function fetchLatestSnapshotCore(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n return getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n assert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n let controller: AbortController | undefined;\n if (snapshotOptions?.timeout !== undefined) {\n controller = new AbortController();\n setTimeout(\n () => controller!.abort(),\n snapshotOptions.timeout,\n );\n }\n const perfEvent = {\n eventName: \"TreesLatest\",\n attempts: tokenFetchOptions.refresh ? 2 : 1,\n shareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n isSummarizer: odspResolvedUrl.summarizer,\n redeemFallbackEnabled: enableRedeemFallback,\n };\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n perfEvent[`snapshotOption_${key}`] = value;\n }\n });\n }\n // This event measures only successful cases of getLatest call (no tokens, no retries).\n return PerformanceEvent.timedExecAsync(\n logger,\n perfEvent,\n async (event) => {\n const response = await snapshotDownloader(\n odspResolvedUrl,\n storageToken,\n snapshotOptions,\n controller,\n );\n const odspResponse = response.odspResponse;\n const contentType = odspResponse.headers.get(\"content-type\");\n odspResponse.propsToLog = {\n ...odspResponse.propsToLog,\n contentType,\n accept: response.requestHeaders.accept,\n };\n let parsedSnapshotContents: IOdspResponse<ISnapshotContents> | undefined;\n try {\n switch (contentType) {\n case \"application/json\": {\n const text = await odspResponse.content.text();\n odspResponse.propsToLog.bodySize = text.length;\n const content: IOdspSnapshot = JSON.parse(text);\n validateBlobsAndTrees(content);\n const snapshotContents: ISnapshotContents =\n convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n case \"application/ms-fluid\": {\n const content = await odspResponse.content.arrayBuffer();\n odspResponse.propsToLog.bodySize = content.byteLength;\n const snapshotContents: ISnapshotContents = parseCompactSnapshotResponse(\n new ReadBuffer(new Uint8Array(content)));\n if (snapshotContents.snapshotTree.trees === undefined ||\n snapshotContents.snapshotTree.blobs === undefined) {\n throw new NonRetryableError(\n \"Returned odsp snapshot is malformed. No trees or blobs!\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n default:\n throw new NonRetryableError(\n \"Unknown snapshot content type\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n } catch (error) {\n if (isFluidError(error)) {\n error.addTelemetryProperties({ driverVersion: pkgVersion, ...odspResponse.propsToLog });\n throw error;\n }\n const enhancedError = wrapError(\n error,\n (errorMessage) => new NonRetryableError(\n `Error parsing snapshot response: ${errorMessage}`,\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog }));\n throw enhancedError;\n }\n assert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n const snapshot = parsedSnapshotContents.content;\n // From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n // fetchStart: immediately before the browser starts to fetch the resource.\n // requestStart: immediately before the browser starts requesting the resource from the server\n // responseStart: immediately after the browser receives the first byte of the response from the server.\n // responseEnd: immediately after the browser receives the last byte of the resource\n // or immediately before the transport connection is closed, whichever comes first.\n // secureConnectionStart: immediately before the browser starts the handshake process to secure the\n // current connection. If a secure connection is not used, this property returns zero.\n // startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n // domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n // domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n // redirectStart: start time of the fetch which that initiates the redirect.\n // redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n let dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n let redirectTime: number | undefined; // redirectEnd - redirectStart\n let tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n let secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n let responseNetworkTime: number | undefined; // responsEnd - responseStart\n let fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n let reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n let networkTime: number | undefined; // responseEnd - startTime\n const spReqDuration = odspResponse.headers.get(\"sprequestduration\");\n\n // getEntriesByType is only available in browser performance object\n const resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n // Usually the latest fetch call is to the end of resources, so we start from the end.\n for (let i = resources1.length - 1; i > 0; i--) {\n const indResTime = resources1[i] as PerformanceResourceTiming;\n const resource_name = indResTime.name;\n const resource_initiatortype = indResTime.initiatorType;\n if ((resource_initiatortype.localeCompare(\"fetch\") === 0)\n && (resource_name.localeCompare(response.requestUrl) === 0)) {\n redirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n dnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n tcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n secureConnectionTime = (indResTime.secureConnectionStart > 0) ?\n (indResTime.connectEnd - indResTime.secureConnectionStart) : undefined;\n responseNetworkTime = (indResTime.responseStart > 0) ?\n (indResTime.responseEnd - indResTime.responseStart) : undefined;\n fetchStartToResponseEndTime = (indResTime.fetchStart > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n reqStartToResponseEndTime = (indResTime.requestStart > 0) ?\n (indResTime.responseEnd - indResTime.requestStart) : undefined;\n networkTime = (indResTime.startTime > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n if (spReqDuration !== undefined && networkTime !== undefined) {\n networkTime = networkTime - parseInt(spReqDuration, 10);\n }\n break;\n }\n }\n\n const { numTrees, numBlobs, encodedBlobsSize } =\n evalBlobsAndTrees(parsedSnapshotContents.content);\n\n // There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n // cannot cache using an HTTP response header.\n const canCache =\n odspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n const sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0 ?\n snapshot.ops[0].sequenceNumber - 1 :\n undefined;\n\n if (!Number.isInteger(sequenceNumber)\n || seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber) {\n logger.sendErrorEvent({ eventName: \"fetchSnapshotError\", sequenceNumber, seqNumberFromOps });\n snapshot.sequenceNumber = undefined;\n } else if (canCache) {\n const fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n assert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n const value: ISnapshotCachedEntry = {\n ...snapshot,\n cacheEntryTime: Date.now(),\n };\n const valueWithEpoch: IVersionedValueWithEpoch = {\n value,\n fluidEpoch,\n version: persistedCacheValueVersion,\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n putInCache(valueWithEpoch);\n }\n event.end({\n trees: numTrees,\n blobs: snapshot.blobs?.size ?? 0,\n leafNodes: numBlobs,\n encodedBlobsSize,\n sequenceNumber,\n ops: snapshot.ops?.length ?? 0,\n userOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n // Interval between the first fetch until the last byte of the last redirect.\n redirectTime,\n // Interval between start and finish of the domain name lookup for the resource.\n dnsLookupTime,\n // Interval to receive all (first to last) bytes form the server.\n responseNetworkTime,\n // Time to establish the connection to the server to retrieve the resource.\n tcpHandshakeTime,\n // Time from the end of the connection until the inital handshake process to secure the connection.\n secureConnectionTime,\n // Interval between the initial fetch until the last byte is received.\n fetchStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte.\n reqStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte but\n // excluding the Snaphot request duration indicated on the snapshot response header.\n networkTime,\n // Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n // Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n // Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n // if the permission has changed.\n sltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n ...odspResponse.propsToLog,\n });\n return snapshot;\n },\n ).catch((error) => {\n // We hit these errors in stress tests, under load\n // It's useful to try one more time in such case.\n if (typeof error === \"object\" && error !== null && (error.errorType === DriverErrorType.fetchFailure ||\n error.errorType === OdspErrorType.fetchTimeout)) {\n error[getWithRetryForTokenRefreshRepeat] = true;\n }\n throw error;\n });\n });\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n odspResponse: IOdspResponse<Response>;\n requestUrl: string;\n requestHeaders: { [index: string]: any; };\n}\n\nfunction getFormBodyAndHeaders(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n headers?: { [index: string]: string; },\n) {\n const formBoundary = uuid();\n const formParams: string[] = [];\n formParams.push(`--${formBoundary}`);\n formParams.push(`Authorization: Bearer ${storageToken}`);\n formParams.push(`X-HTTP-Method-Override: GET`);\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (headers !== undefined) {\n Object.entries(headers).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n formParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n }\n formParams.push(`_post: 1`);\n formParams.push(`\\r\\n--${formBoundary}--`);\n const postBody = formParams.join(\"\\r\\n\");\n const header: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n return { body: postBody, headers: header };\n}\n\nfunction evalBlobsAndTrees(snapshot: ISnapshotContents) {\n const numTrees = countTreesInSnapshotTree(snapshot.snapshotTree);\n const numBlobs = snapshot.blobs.size;\n let encodedBlobsSize = 0;\n for (const [_, blobContent] of snapshot.blobs) {\n encodedBlobsSize += blobContent.byteLength;\n }\n return { numTrees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n assert(snapshot.trees !== undefined,\n 0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */);\n assert(snapshot.blobs !== undefined,\n 0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n let numTrees = 0;\n for (const [_, tree] of Object.entries(snapshotTree.trees)) {\n numTrees += 1;\n numTrees += countTreesInSnapshotTree(tree);\n }\n return numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param logger - logger\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n logger: ITelemetryLogger,\n snapshotOptions: ISnapshotOptions | undefined,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n controller?: AbortController,\n epochTracker?: EpochTracker,\n scenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n const url = `${snapshotUrl}/trees/latest?ump=1`;\n // The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n // This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n // for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n const header = { prefer: \"manualredirect\" };\n const { body, headers } = getFormBodyAndHeaders(\n odspResolvedUrl, storageToken, snapshotOptions, header);\n const fetchOptions = {\n body,\n headers,\n signal: controller?.signal,\n method: \"POST\",\n };\n // Decide what snapshot format to fetch as per the feature gate.\n switch (snapshotFormatFetchType) {\n case SnapshotFormatSupportType.JsonAndBinary:\n headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n break;\n case SnapshotFormatSupportType.Binary:\n headers.accept = `application/ms-fluid; v=${currentReadVersion}`;\n break;\n default:\n headers.accept = \"application/json\";\n }\n\n const odspResponse = await (epochTracker?.fetch(url, fetchOptions, \"treesLatest\", true, scenarioName) ??\n fetchHelper(url, fetchOptions));\n\n return {\n odspResponse,\n requestHeaders: headers,\n requestUrl: url,\n };\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined\n && (typeof error === \"object\" && error !== null)\n && (error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)) {\n return true;\n }\n return false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n /**\n * Encode the url to accepted format by Sharepoint\n * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n */\n let encodedUrl = fromUtf8ToBase64(encodeURI(url));\n encodedUrl = encodedUrl\n .replace(/=+$/g, \"\")\n .replace(/\\//g, \"_\")\n .replace(/\\+/g, \"-\");\n encodedUrl = \"u!\".concat(encodedUrl);\n return encodedUrl;\n}\n"]}
1
+ {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAElC,+DAAqF;AACrF,2EAAqE;AACrE,qEAA4F;A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rE,OAAO,CAAC,MAAM,GAAG,6CAA6C,0CAAkB,EAAE,CAAC;KAC1F;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,CAAC,mCACjG,IAAA,uBAAW,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;IAEpC,OAAO;QACH,YAAY;QACZ,cAAc,EAAE,OAAO;QACvB,UAAU,EAAE,GAAG;KAClB,CAAC;AACN,CAAC;AAjDD,4CAiDC;AAED,SAAS,wBAAwB,CAAC,eAAiC,EAAE,KAAU;;IAC3E,IAAI,CAAA,MAAA,eAAe,CAAC,aAAa,0CAAE,mBAAmB,MAAK,SAAS;WAC7D,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;WAC7C,CAAC,KAAK,CAAC,SAAS,KAAK,oCAAe,CAAC,kBAAkB;eACnD,KAAK,CAAC,SAAS,KAAK,oCAAe,CAAC,+BAA+B,CAAC,EAAE;QAC7E,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACnC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU;SAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { isFluidError, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n fetchAndParseAsJSONHelper,\n fetchHelper,\n getWithRetryForTokenRefresh,\n getWithRetryForTokenRefreshRepeat,\n IOdspResponse,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport { currentReadVersion, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n */\nexport enum SnapshotFormatSupportType {\n Json = 0,\n Binary = 1,\n JsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n snapshotUrl: string,\n token: string | null,\n versionId: string,\n fetchFullSnapshot: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (url: string, fetchOptions: { [index: string]: any; }) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n const path = `/trees/${versionId}`;\n let queryParams: ISnapshotOptions = {};\n\n if (fetchFullSnapshot) {\n if (versionId !== \"latest\") {\n queryParams = { channels: 1, blobs: 2 };\n } else {\n queryParams = { deltas: 1, channels: 1, blobs: 2 };\n }\n }\n\n const queryString = getQueryString(queryParams);\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);\n const response = await PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"fetchSnapshot\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => snapshotDownloader(url, { headers }),\n ) as IOdspResponse<IOdspSnapshot>;\n return convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n removeEntries: () => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n return fetchLatestSnapshotCore(\n odspResolvedUrl,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n enableRedeemFallback,\n ).catch(async (error) => {\n if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n // Execute the redeem fallback\n logger.sendErrorEvent({\n eventName: \"RedeemFallback\",\n errorType: error.errorType,\n }, error);\n await redeemSharingLink(\n odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);\n const odspResolvedUrlWithoutShareLink: IOdspResolvedUrl =\n {\n ...odspResolvedUrl,\n shareLinkInfo: {\n ...odspResolvedUrl.shareLinkInfo,\n sharingLinkToRedeem: undefined,\n },\n };\n\n return fetchLatestSnapshotCore(\n odspResolvedUrlWithoutShareLink,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n );\n } else {\n throw error;\n }\n }).catch(async (error) => {\n // Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n // have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n // snapshot from cache in the future.\n if (typeof error === \"object\" && error !== null && error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n await removeEntries();\n }\n throw error;\n });\n}\n\nasync function redeemSharingLink(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n) {\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"RedeemShareLink\",\n },\n async () => getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n assert(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n 0x1ed /* \"Share link should be present\" */);\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"RedeemShareLink\");\n const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);\n const redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers.prefer = \"redeemSharingLink\";\n return fetchAndParseAsJSONHelper(url, { headers });\n }),\n );\n}\n\nasync function fetchLatestSnapshotCore(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n return getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n assert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n let controller: AbortController | undefined;\n if (snapshotOptions?.timeout !== undefined) {\n controller = new AbortController();\n setTimeout(\n () => controller!.abort(),\n snapshotOptions.timeout,\n );\n }\n const perfEvent = {\n eventName: \"TreesLatest\",\n attempts: tokenFetchOptions.refresh ? 2 : 1,\n shareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n isSummarizer: odspResolvedUrl.summarizer,\n redeemFallbackEnabled: enableRedeemFallback,\n };\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n perfEvent[`snapshotOption_${key}`] = value;\n }\n });\n }\n // This event measures only successful cases of getLatest call (no tokens, no retries).\n return PerformanceEvent.timedExecAsync(\n logger,\n perfEvent,\n async (event) => {\n const response = await snapshotDownloader(\n odspResolvedUrl,\n storageToken,\n snapshotOptions,\n controller,\n );\n const odspResponse = response.odspResponse;\n const contentType = odspResponse.headers.get(\"content-type\");\n odspResponse.propsToLog = {\n ...odspResponse.propsToLog,\n contentType,\n accept: response.requestHeaders.accept,\n };\n let parsedSnapshotContents: IOdspResponse<ISnapshotContents> | undefined;\n let contentTypeToRead: string | undefined;\n if (contentType?.indexOf(\"application/ms-fluid\") !== -1) {\n contentTypeToRead = \"application/ms-fluid\";\n } else if (contentType?.indexOf(\"application/json\") !== -1) {\n contentTypeToRead = \"application/json\";\n }\n\n try {\n switch (contentTypeToRead) {\n case \"application/json\": {\n const text = await odspResponse.content.text();\n odspResponse.propsToLog.bodySize = text.length;\n const content: IOdspSnapshot = JSON.parse(text);\n validateBlobsAndTrees(content);\n const snapshotContents: ISnapshotContents =\n convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n case \"application/ms-fluid\": {\n const content = await odspResponse.content.arrayBuffer();\n odspResponse.propsToLog.bodySize = content.byteLength;\n const snapshotContents: ISnapshotContents = parseCompactSnapshotResponse(\n new ReadBuffer(new Uint8Array(content)));\n if (snapshotContents.snapshotTree.trees === undefined ||\n snapshotContents.snapshotTree.blobs === undefined) {\n throw new NonRetryableError(\n \"Returned odsp snapshot is malformed. No trees or blobs!\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n default:\n throw new NonRetryableError(\n \"Unknown snapshot content type\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n } catch (error) {\n if (isFluidError(error)) {\n error.addTelemetryProperties({ driverVersion: pkgVersion, ...odspResponse.propsToLog });\n throw error;\n }\n const enhancedError = wrapError(\n error,\n (errorMessage) => new NonRetryableError(\n `Error parsing snapshot response: ${errorMessage}`,\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog }));\n throw enhancedError;\n }\n assert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n const snapshot = parsedSnapshotContents.content;\n // From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n // fetchStart: immediately before the browser starts to fetch the resource.\n // requestStart: immediately before the browser starts requesting the resource from the server\n // responseStart: immediately after the browser receives the first byte of the response from the server.\n // responseEnd: immediately after the browser receives the last byte of the resource\n // or immediately before the transport connection is closed, whichever comes first.\n // secureConnectionStart: immediately before the browser starts the handshake process to secure the\n // current connection. If a secure connection is not used, this property returns zero.\n // startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n // domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n // domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n // redirectStart: start time of the fetch which that initiates the redirect.\n // redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n let dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n let redirectTime: number | undefined; // redirectEnd - redirectStart\n let tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n let secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n let responseNetworkTime: number | undefined; // responsEnd - responseStart\n let fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n let reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n let networkTime: number | undefined; // responseEnd - startTime\n const spReqDuration = odspResponse.headers.get(\"sprequestduration\");\n\n // getEntriesByType is only available in browser performance object\n const resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n // Usually the latest fetch call is to the end of resources, so we start from the end.\n for (let i = resources1.length - 1; i > 0; i--) {\n const indResTime = resources1[i] as PerformanceResourceTiming;\n const resource_name = indResTime.name;\n const resource_initiatortype = indResTime.initiatorType;\n if ((resource_initiatortype.localeCompare(\"fetch\") === 0)\n && (resource_name.localeCompare(response.requestUrl) === 0)) {\n redirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n dnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n tcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n secureConnectionTime = (indResTime.secureConnectionStart > 0) ?\n (indResTime.connectEnd - indResTime.secureConnectionStart) : undefined;\n responseNetworkTime = (indResTime.responseStart > 0) ?\n (indResTime.responseEnd - indResTime.responseStart) : undefined;\n fetchStartToResponseEndTime = (indResTime.fetchStart > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n reqStartToResponseEndTime = (indResTime.requestStart > 0) ?\n (indResTime.responseEnd - indResTime.requestStart) : undefined;\n networkTime = (indResTime.startTime > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n if (spReqDuration !== undefined && networkTime !== undefined) {\n networkTime = networkTime - parseInt(spReqDuration, 10);\n }\n break;\n }\n }\n\n const { numTrees, numBlobs, encodedBlobsSize } =\n evalBlobsAndTrees(parsedSnapshotContents.content);\n\n // There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n // cannot cache using an HTTP response header.\n const canCache =\n odspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n const sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0 ?\n snapshot.ops[0].sequenceNumber - 1 :\n undefined;\n\n if (!Number.isInteger(sequenceNumber)\n || seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber) {\n logger.sendErrorEvent({ eventName: \"fetchSnapshotError\", sequenceNumber, seqNumberFromOps });\n snapshot.sequenceNumber = undefined;\n } else if (canCache) {\n const fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n assert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n const value: ISnapshotCachedEntry = {\n ...snapshot,\n cacheEntryTime: Date.now(),\n };\n const valueWithEpoch: IVersionedValueWithEpoch = {\n value,\n fluidEpoch,\n version: persistedCacheValueVersion,\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n putInCache(valueWithEpoch);\n }\n event.end({\n trees: numTrees,\n blobs: snapshot.blobs?.size ?? 0,\n leafNodes: numBlobs,\n encodedBlobsSize,\n sequenceNumber,\n ops: snapshot.ops?.length ?? 0,\n userOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n // Interval between the first fetch until the last byte of the last redirect.\n redirectTime,\n // Interval between start and finish of the domain name lookup for the resource.\n dnsLookupTime,\n // Interval to receive all (first to last) bytes form the server.\n responseNetworkTime,\n // Time to establish the connection to the server to retrieve the resource.\n tcpHandshakeTime,\n // Time from the end of the connection until the inital handshake process to secure the connection.\n secureConnectionTime,\n // Interval between the initial fetch until the last byte is received.\n fetchStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte.\n reqStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte but\n // excluding the Snaphot request duration indicated on the snapshot response header.\n networkTime,\n // Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n // Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n // Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n // if the permission has changed.\n sltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n ...odspResponse.propsToLog,\n });\n return snapshot;\n },\n ).catch((error) => {\n // We hit these errors in stress tests, under load\n // It's useful to try one more time in such case.\n if (typeof error === \"object\" && error !== null && (error.errorType === DriverErrorType.fetchFailure ||\n error.errorType === OdspErrorType.fetchTimeout)) {\n error[getWithRetryForTokenRefreshRepeat] = true;\n }\n throw error;\n });\n });\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n odspResponse: IOdspResponse<Response>;\n requestUrl: string;\n requestHeaders: { [index: string]: any; };\n}\n\nfunction getFormBodyAndHeaders(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n headers?: { [index: string]: string; },\n) {\n const formBoundary = uuid();\n const formParams: string[] = [];\n formParams.push(`--${formBoundary}`);\n formParams.push(`Authorization: Bearer ${storageToken}`);\n formParams.push(`X-HTTP-Method-Override: GET`);\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (headers !== undefined) {\n Object.entries(headers).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n formParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n }\n formParams.push(`_post: 1`);\n formParams.push(`\\r\\n--${formBoundary}--`);\n const postBody = formParams.join(\"\\r\\n\");\n const header: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n return { body: postBody, headers: header };\n}\n\nfunction evalBlobsAndTrees(snapshot: ISnapshotContents) {\n const numTrees = countTreesInSnapshotTree(snapshot.snapshotTree);\n const numBlobs = snapshot.blobs.size;\n let encodedBlobsSize = 0;\n for (const [_, blobContent] of snapshot.blobs) {\n encodedBlobsSize += blobContent.byteLength;\n }\n return { numTrees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n assert(snapshot.trees !== undefined,\n 0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */);\n assert(snapshot.blobs !== undefined,\n 0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n let numTrees = 0;\n for (const [_, tree] of Object.entries(snapshotTree.trees)) {\n numTrees += 1;\n numTrees += countTreesInSnapshotTree(tree);\n }\n return numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param logger - logger\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n logger: ITelemetryLogger,\n snapshotOptions: ISnapshotOptions | undefined,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n controller?: AbortController,\n epochTracker?: EpochTracker,\n scenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n const url = `${snapshotUrl}/trees/latest?ump=1`;\n // The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n // This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n // for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n const header = { prefer: \"manualredirect\" };\n const { body, headers } = getFormBodyAndHeaders(\n odspResolvedUrl, storageToken, snapshotOptions, header);\n const fetchOptions = {\n body,\n headers,\n signal: controller?.signal,\n method: \"POST\",\n };\n // Decide what snapshot format to fetch as per the feature gate.\n switch (snapshotFormatFetchType) {\n case SnapshotFormatSupportType.Binary:\n headers.accept = `application/ms-fluid; v=${currentReadVersion}`;\n break;\n default:\n // By default ask both versions and let the server decide the format.\n headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n }\n\n const odspResponse = await (epochTracker?.fetch(url, fetchOptions, \"treesLatest\", true, scenarioName) ??\n fetchHelper(url, fetchOptions));\n\n return {\n odspResponse,\n requestHeaders: headers,\n requestUrl: url,\n };\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined\n && (typeof error === \"object\" && error !== null)\n && (error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)) {\n return true;\n }\n return false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n /**\n * Encode the url to accepted format by Sharepoint\n * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n */\n let encodedUrl = fromUtf8ToBase64(encodeURI(url));\n encodedUrl = encodedUrl\n .replace(/=+$/g, \"\")\n .replace(/\\//g, \"_\")\n .replace(/\\+/g, \"-\");\n encodedUrl = \"u!\".concat(encodedUrl);\n return encodedUrl;\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/odsp-driver";
8
- export declare const pkgVersion = "1.2.3-84921";
8
+ export declare const pkgVersion = "1.2.5";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,gBAAgB,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,UAAU,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/odsp-driver";
11
- exports.pkgVersion = "1.2.3-84921";
11
+ exports.pkgVersion = "1.2.5";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"1.2.3-84921\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"1.2.5\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAItE,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAEhB,+BAA+B,EAClC,MAAM,yCAAyC,CAAC;AAGjD,OAAO,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,CAClC,eAAe,EAAE,gBAAgB,EACjC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,gBAAgB,GAAG,SAAS,EAC7C,uBAAuB,CAAC,EAAE,yBAAyB,EACnD,UAAU,CAAC,EAAE,eAAe,EAC5B,YAAY,CAAC,EAAE,YAAY,EAC3B,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,kCAAkC,CAAC,CAwC7C"}
@@ -132,8 +132,15 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
132
132
  const contentType = odspResponse.headers.get("content-type");
133
133
  odspResponse.propsToLog = Object.assign(Object.assign({}, odspResponse.propsToLog), { contentType, accept: response.requestHeaders.accept });
134
134
  let parsedSnapshotContents;
135
+ let contentTypeToRead;
136
+ if ((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf("application/ms-fluid")) !== -1) {
137
+ contentTypeToRead = "application/ms-fluid";
138
+ }
139
+ else if ((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf("application/json")) !== -1) {
140
+ contentTypeToRead = "application/json";
141
+ }
135
142
  try {
136
- switch (contentType) {
143
+ switch (contentTypeToRead) {
137
144
  case "application/json": {
138
145
  const text = await odspResponse.content.text();
139
146
  odspResponse.propsToLog.bodySize = text.length;
@@ -366,14 +373,12 @@ export async function downloadSnapshot(odspResolvedUrl, storageToken, logger, sn
366
373
  };
367
374
  // Decide what snapshot format to fetch as per the feature gate.
368
375
  switch (snapshotFormatFetchType) {
369
- case SnapshotFormatSupportType.JsonAndBinary:
370
- headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;
371
- break;
372
376
  case SnapshotFormatSupportType.Binary:
373
377
  headers.accept = `application/ms-fluid; v=${currentReadVersion}`;
374
378
  break;
375
379
  default:
376
- headers.accept = "application/json";
380
+ // By default ask both versions and let the server decide the format.
381
+ headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;
377
382
  }
378
383
  const odspResponse = await ((_a = epochTracker === null || epochTracker === void 0 ? void 0 : epochTracker.fetch(url, fetchOptions, "treesLatest", true, scenarioName)) !== null && _a !== void 0 ? _a : fetchHelper(url, fetchOptions));
379
384
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAGH,aAAa,GAEhB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAiE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACH,yBAAyB,EACzB,WAAW,EACX,2BAA2B,EAC3B,iCAAiC,GAEpC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,yCAAyC,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAN,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACjC,yEAAQ,C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S,KAAK,eAAe,CAAC,+BAA+B,CAAC,EAAE;QAC7E,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACnC;;;OAGG;IACH,IAAI,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU;SAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { isFluidError, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n fetchAndParseAsJSONHelper,\n fetchHelper,\n getWithRetryForTokenRefresh,\n getWithRetryForTokenRefreshRepeat,\n IOdspResponse,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport { currentReadVersion, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n */\nexport enum SnapshotFormatSupportType {\n Json = 0,\n Binary = 1,\n JsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n snapshotUrl: string,\n token: string | null,\n versionId: string,\n fetchFullSnapshot: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (url: string, fetchOptions: { [index: string]: any; }) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n const path = `/trees/${versionId}`;\n let queryParams: ISnapshotOptions = {};\n\n if (fetchFullSnapshot) {\n if (versionId !== \"latest\") {\n queryParams = { channels: 1, blobs: 2 };\n } else {\n queryParams = { deltas: 1, channels: 1, blobs: 2 };\n }\n }\n\n const queryString = getQueryString(queryParams);\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);\n const response = await PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"fetchSnapshot\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => snapshotDownloader(url, { headers }),\n ) as IOdspResponse<IOdspSnapshot>;\n return convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n removeEntries: () => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n return fetchLatestSnapshotCore(\n odspResolvedUrl,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n enableRedeemFallback,\n ).catch(async (error) => {\n if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n // Execute the redeem fallback\n logger.sendErrorEvent({\n eventName: \"RedeemFallback\",\n errorType: error.errorType,\n }, error);\n await redeemSharingLink(\n odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);\n const odspResolvedUrlWithoutShareLink: IOdspResolvedUrl =\n {\n ...odspResolvedUrl,\n shareLinkInfo: {\n ...odspResolvedUrl.shareLinkInfo,\n sharingLinkToRedeem: undefined,\n },\n };\n\n return fetchLatestSnapshotCore(\n odspResolvedUrlWithoutShareLink,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n );\n } else {\n throw error;\n }\n }).catch(async (error) => {\n // Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n // have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n // snapshot from cache in the future.\n if (typeof error === \"object\" && error !== null && error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n await removeEntries();\n }\n throw error;\n });\n}\n\nasync function redeemSharingLink(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n) {\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"RedeemShareLink\",\n },\n async () => getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n assert(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n 0x1ed /* \"Share link should be present\" */);\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"RedeemShareLink\");\n const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);\n const redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers.prefer = \"redeemSharingLink\";\n return fetchAndParseAsJSONHelper(url, { headers });\n }),\n );\n}\n\nasync function fetchLatestSnapshotCore(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n return getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n assert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n let controller: AbortController | undefined;\n if (snapshotOptions?.timeout !== undefined) {\n controller = new AbortController();\n setTimeout(\n () => controller!.abort(),\n snapshotOptions.timeout,\n );\n }\n const perfEvent = {\n eventName: \"TreesLatest\",\n attempts: tokenFetchOptions.refresh ? 2 : 1,\n shareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n isSummarizer: odspResolvedUrl.summarizer,\n redeemFallbackEnabled: enableRedeemFallback,\n };\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n perfEvent[`snapshotOption_${key}`] = value;\n }\n });\n }\n // This event measures only successful cases of getLatest call (no tokens, no retries).\n return PerformanceEvent.timedExecAsync(\n logger,\n perfEvent,\n async (event) => {\n const response = await snapshotDownloader(\n odspResolvedUrl,\n storageToken,\n snapshotOptions,\n controller,\n );\n const odspResponse = response.odspResponse;\n const contentType = odspResponse.headers.get(\"content-type\");\n odspResponse.propsToLog = {\n ...odspResponse.propsToLog,\n contentType,\n accept: response.requestHeaders.accept,\n };\n let parsedSnapshotContents: IOdspResponse<ISnapshotContents> | undefined;\n try {\n switch (contentType) {\n case \"application/json\": {\n const text = await odspResponse.content.text();\n odspResponse.propsToLog.bodySize = text.length;\n const content: IOdspSnapshot = JSON.parse(text);\n validateBlobsAndTrees(content);\n const snapshotContents: ISnapshotContents =\n convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n case \"application/ms-fluid\": {\n const content = await odspResponse.content.arrayBuffer();\n odspResponse.propsToLog.bodySize = content.byteLength;\n const snapshotContents: ISnapshotContents = parseCompactSnapshotResponse(\n new ReadBuffer(new Uint8Array(content)));\n if (snapshotContents.snapshotTree.trees === undefined ||\n snapshotContents.snapshotTree.blobs === undefined) {\n throw new NonRetryableError(\n \"Returned odsp snapshot is malformed. No trees or blobs!\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n default:\n throw new NonRetryableError(\n \"Unknown snapshot content type\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n } catch (error) {\n if (isFluidError(error)) {\n error.addTelemetryProperties({ driverVersion: pkgVersion, ...odspResponse.propsToLog });\n throw error;\n }\n const enhancedError = wrapError(\n error,\n (errorMessage) => new NonRetryableError(\n `Error parsing snapshot response: ${errorMessage}`,\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog }));\n throw enhancedError;\n }\n assert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n const snapshot = parsedSnapshotContents.content;\n // From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n // fetchStart: immediately before the browser starts to fetch the resource.\n // requestStart: immediately before the browser starts requesting the resource from the server\n // responseStart: immediately after the browser receives the first byte of the response from the server.\n // responseEnd: immediately after the browser receives the last byte of the resource\n // or immediately before the transport connection is closed, whichever comes first.\n // secureConnectionStart: immediately before the browser starts the handshake process to secure the\n // current connection. If a secure connection is not used, this property returns zero.\n // startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n // domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n // domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n // redirectStart: start time of the fetch which that initiates the redirect.\n // redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n let dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n let redirectTime: number | undefined; // redirectEnd - redirectStart\n let tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n let secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n let responseNetworkTime: number | undefined; // responsEnd - responseStart\n let fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n let reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n let networkTime: number | undefined; // responseEnd - startTime\n const spReqDuration = odspResponse.headers.get(\"sprequestduration\");\n\n // getEntriesByType is only available in browser performance object\n const resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n // Usually the latest fetch call is to the end of resources, so we start from the end.\n for (let i = resources1.length - 1; i > 0; i--) {\n const indResTime = resources1[i] as PerformanceResourceTiming;\n const resource_name = indResTime.name;\n const resource_initiatortype = indResTime.initiatorType;\n if ((resource_initiatortype.localeCompare(\"fetch\") === 0)\n && (resource_name.localeCompare(response.requestUrl) === 0)) {\n redirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n dnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n tcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n secureConnectionTime = (indResTime.secureConnectionStart > 0) ?\n (indResTime.connectEnd - indResTime.secureConnectionStart) : undefined;\n responseNetworkTime = (indResTime.responseStart > 0) ?\n (indResTime.responseEnd - indResTime.responseStart) : undefined;\n fetchStartToResponseEndTime = (indResTime.fetchStart > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n reqStartToResponseEndTime = (indResTime.requestStart > 0) ?\n (indResTime.responseEnd - indResTime.requestStart) : undefined;\n networkTime = (indResTime.startTime > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n if (spReqDuration !== undefined && networkTime !== undefined) {\n networkTime = networkTime - parseInt(spReqDuration, 10);\n }\n break;\n }\n }\n\n const { numTrees, numBlobs, encodedBlobsSize } =\n evalBlobsAndTrees(parsedSnapshotContents.content);\n\n // There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n // cannot cache using an HTTP response header.\n const canCache =\n odspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n const sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0 ?\n snapshot.ops[0].sequenceNumber - 1 :\n undefined;\n\n if (!Number.isInteger(sequenceNumber)\n || seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber) {\n logger.sendErrorEvent({ eventName: \"fetchSnapshotError\", sequenceNumber, seqNumberFromOps });\n snapshot.sequenceNumber = undefined;\n } else if (canCache) {\n const fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n assert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n const value: ISnapshotCachedEntry = {\n ...snapshot,\n cacheEntryTime: Date.now(),\n };\n const valueWithEpoch: IVersionedValueWithEpoch = {\n value,\n fluidEpoch,\n version: persistedCacheValueVersion,\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n putInCache(valueWithEpoch);\n }\n event.end({\n trees: numTrees,\n blobs: snapshot.blobs?.size ?? 0,\n leafNodes: numBlobs,\n encodedBlobsSize,\n sequenceNumber,\n ops: snapshot.ops?.length ?? 0,\n userOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n // Interval between the first fetch until the last byte of the last redirect.\n redirectTime,\n // Interval between start and finish of the domain name lookup for the resource.\n dnsLookupTime,\n // Interval to receive all (first to last) bytes form the server.\n responseNetworkTime,\n // Time to establish the connection to the server to retrieve the resource.\n tcpHandshakeTime,\n // Time from the end of the connection until the inital handshake process to secure the connection.\n secureConnectionTime,\n // Interval between the initial fetch until the last byte is received.\n fetchStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte.\n reqStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte but\n // excluding the Snaphot request duration indicated on the snapshot response header.\n networkTime,\n // Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n // Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n // Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n // if the permission has changed.\n sltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n ...odspResponse.propsToLog,\n });\n return snapshot;\n },\n ).catch((error) => {\n // We hit these errors in stress tests, under load\n // It's useful to try one more time in such case.\n if (typeof error === \"object\" && error !== null && (error.errorType === DriverErrorType.fetchFailure ||\n error.errorType === OdspErrorType.fetchTimeout)) {\n error[getWithRetryForTokenRefreshRepeat] = true;\n }\n throw error;\n });\n });\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n odspResponse: IOdspResponse<Response>;\n requestUrl: string;\n requestHeaders: { [index: string]: any; };\n}\n\nfunction getFormBodyAndHeaders(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n headers?: { [index: string]: string; },\n) {\n const formBoundary = uuid();\n const formParams: string[] = [];\n formParams.push(`--${formBoundary}`);\n formParams.push(`Authorization: Bearer ${storageToken}`);\n formParams.push(`X-HTTP-Method-Override: GET`);\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (headers !== undefined) {\n Object.entries(headers).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n formParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n }\n formParams.push(`_post: 1`);\n formParams.push(`\\r\\n--${formBoundary}--`);\n const postBody = formParams.join(\"\\r\\n\");\n const header: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n return { body: postBody, headers: header };\n}\n\nfunction evalBlobsAndTrees(snapshot: ISnapshotContents) {\n const numTrees = countTreesInSnapshotTree(snapshot.snapshotTree);\n const numBlobs = snapshot.blobs.size;\n let encodedBlobsSize = 0;\n for (const [_, blobContent] of snapshot.blobs) {\n encodedBlobsSize += blobContent.byteLength;\n }\n return { numTrees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n assert(snapshot.trees !== undefined,\n 0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */);\n assert(snapshot.blobs !== undefined,\n 0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n let numTrees = 0;\n for (const [_, tree] of Object.entries(snapshotTree.trees)) {\n numTrees += 1;\n numTrees += countTreesInSnapshotTree(tree);\n }\n return numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param logger - logger\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n logger: ITelemetryLogger,\n snapshotOptions: ISnapshotOptions | undefined,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n controller?: AbortController,\n epochTracker?: EpochTracker,\n scenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n const url = `${snapshotUrl}/trees/latest?ump=1`;\n // The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n // This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n // for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n const header = { prefer: \"manualredirect\" };\n const { body, headers } = getFormBodyAndHeaders(\n odspResolvedUrl, storageToken, snapshotOptions, header);\n const fetchOptions = {\n body,\n headers,\n signal: controller?.signal,\n method: \"POST\",\n };\n // Decide what snapshot format to fetch as per the feature gate.\n switch (snapshotFormatFetchType) {\n case SnapshotFormatSupportType.JsonAndBinary:\n headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n break;\n case SnapshotFormatSupportType.Binary:\n headers.accept = `application/ms-fluid; v=${currentReadVersion}`;\n break;\n default:\n headers.accept = \"application/json\";\n }\n\n const odspResponse = await (epochTracker?.fetch(url, fetchOptions, \"treesLatest\", true, scenarioName) ??\n fetchHelper(url, fetchOptions));\n\n return {\n odspResponse,\n requestHeaders: headers,\n requestUrl: url,\n };\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined\n && (typeof error === \"object\" && error !== null)\n && (error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)) {\n return true;\n }\n return false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n /**\n * Encode the url to accepted format by Sharepoint\n * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n */\n let encodedUrl = fromUtf8ToBase64(encodeURI(url));\n encodedUrl = encodedUrl\n .replace(/=+$/g, \"\")\n .replace(/\\//g, \"_\")\n .replace(/\\+/g, \"-\");\n encodedUrl = \"u!\".concat(encodedUrl);\n return encodedUrl;\n}\n"]}
1
+ {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,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E,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACnC;;;OAGG;IACH,IAAI,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU;SAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { isFluidError, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n fetchAndParseAsJSONHelper,\n fetchHelper,\n getWithRetryForTokenRefresh,\n getWithRetryForTokenRefreshRepeat,\n IOdspResponse,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport { currentReadVersion, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n */\nexport enum SnapshotFormatSupportType {\n Json = 0,\n Binary = 1,\n JsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n snapshotUrl: string,\n token: string | null,\n versionId: string,\n fetchFullSnapshot: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (url: string, fetchOptions: { [index: string]: any; }) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n const path = `/trees/${versionId}`;\n let queryParams: ISnapshotOptions = {};\n\n if (fetchFullSnapshot) {\n if (versionId !== \"latest\") {\n queryParams = { channels: 1, blobs: 2 };\n } else {\n queryParams = { deltas: 1, channels: 1, blobs: 2 };\n }\n }\n\n const queryString = getQueryString(queryParams);\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${snapshotUrl}${path}${queryString}`, token, forceAccessTokenViaAuthorizationHeader);\n const response = await PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"fetchSnapshot\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => snapshotDownloader(url, { headers }),\n ) as IOdspResponse<IOdspSnapshot>;\n return convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n removeEntries: () => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n return fetchLatestSnapshotCore(\n odspResolvedUrl,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n enableRedeemFallback,\n ).catch(async (error) => {\n if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n // Execute the redeem fallback\n logger.sendErrorEvent({\n eventName: \"RedeemFallback\",\n errorType: error.errorType,\n }, error);\n await redeemSharingLink(\n odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);\n const odspResolvedUrlWithoutShareLink: IOdspResolvedUrl =\n {\n ...odspResolvedUrl,\n shareLinkInfo: {\n ...odspResolvedUrl.shareLinkInfo,\n sharingLinkToRedeem: undefined,\n },\n };\n\n return fetchLatestSnapshotCore(\n odspResolvedUrlWithoutShareLink,\n storageTokenFetcher,\n snapshotOptions,\n logger,\n snapshotDownloader,\n putInCache,\n );\n } else {\n throw error;\n }\n }).catch(async (error) => {\n // Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n // have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n // snapshot from cache in the future.\n if (typeof error === \"object\" && error !== null && error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n await removeEntries();\n }\n throw error;\n });\n}\n\nasync function redeemSharingLink(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n) {\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: \"RedeemShareLink\",\n },\n async () => getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n assert(!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n 0x1ed /* \"Share link should be present\" */);\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"RedeemShareLink\");\n const encodedShareUrl = getEncodedShareUrl(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem);\n const redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n redeemUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers.prefer = \"redeemSharingLink\";\n return fetchAndParseAsJSONHelper(url, { headers });\n }),\n );\n}\n\nasync function fetchLatestSnapshotCore(\n odspResolvedUrl: IOdspResolvedUrl,\n storageTokenFetcher: InstrumentedStorageTokenFetcher,\n snapshotOptions: ISnapshotOptions | undefined,\n logger: ITelemetryLogger,\n snapshotDownloader: (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => Promise<ISnapshotRequestAndResponseOptions>,\n putInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n enableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n return getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n const storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n assert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n let controller: AbortController | undefined;\n if (snapshotOptions?.timeout !== undefined) {\n controller = new AbortController();\n setTimeout(\n () => controller!.abort(),\n snapshotOptions.timeout,\n );\n }\n const perfEvent = {\n eventName: \"TreesLatest\",\n attempts: tokenFetchOptions.refresh ? 2 : 1,\n shareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n isSummarizer: odspResolvedUrl.summarizer,\n redeemFallbackEnabled: enableRedeemFallback,\n };\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n perfEvent[`snapshotOption_${key}`] = value;\n }\n });\n }\n // This event measures only successful cases of getLatest call (no tokens, no retries).\n return PerformanceEvent.timedExecAsync(\n logger,\n perfEvent,\n async (event) => {\n const response = await snapshotDownloader(\n odspResolvedUrl,\n storageToken,\n snapshotOptions,\n controller,\n );\n const odspResponse = response.odspResponse;\n const contentType = odspResponse.headers.get(\"content-type\");\n odspResponse.propsToLog = {\n ...odspResponse.propsToLog,\n contentType,\n accept: response.requestHeaders.accept,\n };\n let parsedSnapshotContents: IOdspResponse<ISnapshotContents> | undefined;\n let contentTypeToRead: string | undefined;\n if (contentType?.indexOf(\"application/ms-fluid\") !== -1) {\n contentTypeToRead = \"application/ms-fluid\";\n } else if (contentType?.indexOf(\"application/json\") !== -1) {\n contentTypeToRead = \"application/json\";\n }\n\n try {\n switch (contentTypeToRead) {\n case \"application/json\": {\n const text = await odspResponse.content.text();\n odspResponse.propsToLog.bodySize = text.length;\n const content: IOdspSnapshot = JSON.parse(text);\n validateBlobsAndTrees(content);\n const snapshotContents: ISnapshotContents =\n convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n case \"application/ms-fluid\": {\n const content = await odspResponse.content.arrayBuffer();\n odspResponse.propsToLog.bodySize = content.byteLength;\n const snapshotContents: ISnapshotContents = parseCompactSnapshotResponse(\n new ReadBuffer(new Uint8Array(content)));\n if (snapshotContents.snapshotTree.trees === undefined ||\n snapshotContents.snapshotTree.blobs === undefined) {\n throw new NonRetryableError(\n \"Returned odsp snapshot is malformed. No trees or blobs!\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n parsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n break;\n }\n default:\n throw new NonRetryableError(\n \"Unknown snapshot content type\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog },\n );\n }\n } catch (error) {\n if (isFluidError(error)) {\n error.addTelemetryProperties({ driverVersion: pkgVersion, ...odspResponse.propsToLog });\n throw error;\n }\n const enhancedError = wrapError(\n error,\n (errorMessage) => new NonRetryableError(\n `Error parsing snapshot response: ${errorMessage}`,\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, ...odspResponse.propsToLog }));\n throw enhancedError;\n }\n assert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n const snapshot = parsedSnapshotContents.content;\n // From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming\n // fetchStart: immediately before the browser starts to fetch the resource.\n // requestStart: immediately before the browser starts requesting the resource from the server\n // responseStart: immediately after the browser receives the first byte of the response from the server.\n // responseEnd: immediately after the browser receives the last byte of the resource\n // or immediately before the transport connection is closed, whichever comes first.\n // secureConnectionStart: immediately before the browser starts the handshake process to secure the\n // current connection. If a secure connection is not used, this property returns zero.\n // startTime: Time when the resource fetch started. This value is equivalent to fetchStart.\n // domainLookupStart: immediately before the browser starts the domain name lookup for the resource.\n // domainLookupEnd: immediately after the browser finishes the domain name lookup for the resource.\n // redirectStart: start time of the fetch which that initiates the redirect.\n // redirectEnd: immediately after receiving the last byte of the response of the last redirect.\n let dnsLookupTime: number | undefined; // domainLookupEnd - domainLookupStart\n let redirectTime: number | undefined; // redirectEnd - redirectStart\n let tcpHandshakeTime: number | undefined; // connectEnd - connectStart\n let secureConnectionTime: number | undefined; // connectEnd - secureConnectionStart\n let responseNetworkTime: number | undefined; // responsEnd - responseStart\n let fetchStartToResponseEndTime: number | undefined; // responseEnd - fetchStart\n let reqStartToResponseEndTime: number | undefined; // responseEnd - requestStart\n let networkTime: number | undefined; // responseEnd - startTime\n const spReqDuration = odspResponse.headers.get(\"sprequestduration\");\n\n // getEntriesByType is only available in browser performance object\n const resources1 = performance.getEntriesByType?.(\"resource\") ?? [];\n // Usually the latest fetch call is to the end of resources, so we start from the end.\n for (let i = resources1.length - 1; i > 0; i--) {\n const indResTime = resources1[i] as PerformanceResourceTiming;\n const resource_name = indResTime.name;\n const resource_initiatortype = indResTime.initiatorType;\n if ((resource_initiatortype.localeCompare(\"fetch\") === 0)\n && (resource_name.localeCompare(response.requestUrl) === 0)) {\n redirectTime = indResTime.redirectEnd - indResTime.redirectStart;\n dnsLookupTime = indResTime.domainLookupEnd - indResTime.domainLookupStart;\n tcpHandshakeTime = indResTime.connectEnd - indResTime.connectStart;\n secureConnectionTime = (indResTime.secureConnectionStart > 0) ?\n (indResTime.connectEnd - indResTime.secureConnectionStart) : undefined;\n responseNetworkTime = (indResTime.responseStart > 0) ?\n (indResTime.responseEnd - indResTime.responseStart) : undefined;\n fetchStartToResponseEndTime = (indResTime.fetchStart > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n reqStartToResponseEndTime = (indResTime.requestStart > 0) ?\n (indResTime.responseEnd - indResTime.requestStart) : undefined;\n networkTime = (indResTime.startTime > 0) ?\n (indResTime.responseEnd - indResTime.fetchStart) : undefined;\n if (spReqDuration !== undefined && networkTime !== undefined) {\n networkTime = networkTime - parseInt(spReqDuration, 10);\n }\n break;\n }\n }\n\n const { numTrees, numBlobs, encodedBlobsSize } =\n evalBlobsAndTrees(parsedSnapshotContents.content);\n\n // There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n // cannot cache using an HTTP response header.\n const canCache =\n odspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n const sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0 ?\n snapshot.ops[0].sequenceNumber - 1 :\n undefined;\n\n if (!Number.isInteger(sequenceNumber)\n || seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber) {\n logger.sendErrorEvent({ eventName: \"fetchSnapshotError\", sequenceNumber, seqNumberFromOps });\n snapshot.sequenceNumber = undefined;\n } else if (canCache) {\n const fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n assert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n const value: ISnapshotCachedEntry = {\n ...snapshot,\n cacheEntryTime: Date.now(),\n };\n const valueWithEpoch: IVersionedValueWithEpoch = {\n value,\n fluidEpoch,\n version: persistedCacheValueVersion,\n };\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n putInCache(valueWithEpoch);\n }\n event.end({\n trees: numTrees,\n blobs: snapshot.blobs?.size ?? 0,\n leafNodes: numBlobs,\n encodedBlobsSize,\n sequenceNumber,\n ops: snapshot.ops?.length ?? 0,\n userOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n // Interval between the first fetch until the last byte of the last redirect.\n redirectTime,\n // Interval between start and finish of the domain name lookup for the resource.\n dnsLookupTime,\n // Interval to receive all (first to last) bytes form the server.\n responseNetworkTime,\n // Time to establish the connection to the server to retrieve the resource.\n tcpHandshakeTime,\n // Time from the end of the connection until the inital handshake process to secure the connection.\n secureConnectionTime,\n // Interval between the initial fetch until the last byte is received.\n fetchStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte.\n reqStartToResponseEndTime,\n // Interval between starting the request for the resource until receiving the last byte but\n // excluding the Snaphot request duration indicated on the snapshot response header.\n networkTime,\n // Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n // Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n // Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n // if the permission has changed.\n sltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n ...odspResponse.propsToLog,\n });\n return snapshot;\n },\n ).catch((error) => {\n // We hit these errors in stress tests, under load\n // It's useful to try one more time in such case.\n if (typeof error === \"object\" && error !== null && (error.errorType === DriverErrorType.fetchFailure ||\n error.errorType === OdspErrorType.fetchTimeout)) {\n error[getWithRetryForTokenRefreshRepeat] = true;\n }\n throw error;\n });\n });\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n odspResponse: IOdspResponse<Response>;\n requestUrl: string;\n requestHeaders: { [index: string]: any; };\n}\n\nfunction getFormBodyAndHeaders(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n headers?: { [index: string]: string; },\n) {\n const formBoundary = uuid();\n const formParams: string[] = [];\n formParams.push(`--${formBoundary}`);\n formParams.push(`Authorization: Bearer ${storageToken}`);\n formParams.push(`X-HTTP-Method-Override: GET`);\n if (snapshotOptions !== undefined) {\n Object.entries(snapshotOptions).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (headers !== undefined) {\n Object.entries(headers).forEach(([key, value]) => {\n if (value !== undefined) {\n formParams.push(`${key}: ${value}`);\n }\n });\n }\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n formParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n }\n formParams.push(`_post: 1`);\n formParams.push(`\\r\\n--${formBoundary}--`);\n const postBody = formParams.join(\"\\r\\n\");\n const header: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n return { body: postBody, headers: header };\n}\n\nfunction evalBlobsAndTrees(snapshot: ISnapshotContents) {\n const numTrees = countTreesInSnapshotTree(snapshot.snapshotTree);\n const numBlobs = snapshot.blobs.size;\n let encodedBlobsSize = 0;\n for (const [_, blobContent] of snapshot.blobs) {\n encodedBlobsSize += blobContent.byteLength;\n }\n return { numTrees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n assert(snapshot.trees !== undefined,\n 0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */);\n assert(snapshot.blobs !== undefined,\n 0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n let numTrees = 0;\n for (const [_, tree] of Object.entries(snapshotTree.trees)) {\n numTrees += 1;\n numTrees += countTreesInSnapshotTree(tree);\n }\n return numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param logger - logger\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n odspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n logger: ITelemetryLogger,\n snapshotOptions: ISnapshotOptions | undefined,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n controller?: AbortController,\n epochTracker?: EpochTracker,\n scenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n // back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n const sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n if (sharingLinkToRedeem) {\n odspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n }\n\n const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n const url = `${snapshotUrl}/trees/latest?ump=1`;\n // The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n // Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n // This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n // for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n const header = { prefer: \"manualredirect\" };\n const { body, headers } = getFormBodyAndHeaders(\n odspResolvedUrl, storageToken, snapshotOptions, header);\n const fetchOptions = {\n body,\n headers,\n signal: controller?.signal,\n method: \"POST\",\n };\n // Decide what snapshot format to fetch as per the feature gate.\n switch (snapshotFormatFetchType) {\n case SnapshotFormatSupportType.Binary:\n headers.accept = `application/ms-fluid; v=${currentReadVersion}`;\n break;\n default:\n // By default ask both versions and let the server decide the format.\n headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n }\n\n const odspResponse = await (epochTracker?.fetch(url, fetchOptions, \"treesLatest\", true, scenarioName) ??\n fetchHelper(url, fetchOptions));\n\n return {\n odspResponse,\n requestHeaders: headers,\n requestUrl: url,\n };\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined\n && (typeof error === \"object\" && error !== null)\n && (error.errorType === DriverErrorType.authorizationError\n || error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)) {\n return true;\n }\n return false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n /**\n * Encode the url to accepted format by Sharepoint\n * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n */\n let encodedUrl = fromUtf8ToBase64(encodeURI(url));\n encodedUrl = encodedUrl\n .replace(/=+$/g, \"\")\n .replace(/\\//g, \"_\")\n .replace(/\\+/g, \"-\");\n encodedUrl = \"u!\".concat(encodedUrl);\n return encodedUrl;\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/odsp-driver";
8
- export declare const pkgVersion = "1.2.3-84921";
8
+ export declare const pkgVersion = "1.2.5";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,gBAAgB,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,UAAU,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/odsp-driver";
8
- export const pkgVersion = "1.2.3-84921";
8
+ export const pkgVersion = "1.2.5";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"1.2.3-84921\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"1.2.5\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/odsp-driver",
3
- "version": "1.2.3-84921",
3
+ "version": "1.2.5",
4
4
  "description": "Socket storage implementation for SPO and ODC",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -62,16 +62,16 @@
62
62
  "dependencies": {
63
63
  "@fluidframework/common-definitions": "^0.20.1",
64
64
  "@fluidframework/common-utils": "^0.32.1",
65
- "@fluidframework/core-interfaces": "1.2.3-84921",
66
- "@fluidframework/driver-base": "1.2.3-84921",
67
- "@fluidframework/driver-definitions": "1.2.3-84921",
68
- "@fluidframework/driver-utils": "1.2.3-84921",
65
+ "@fluidframework/core-interfaces": "^1.2.5",
66
+ "@fluidframework/driver-base": "^1.2.5",
67
+ "@fluidframework/driver-definitions": "^1.2.5",
68
+ "@fluidframework/driver-utils": "^1.2.5",
69
69
  "@fluidframework/gitresources": "^0.1036.5000",
70
- "@fluidframework/odsp-doclib-utils": "1.2.3-84921",
71
- "@fluidframework/odsp-driver-definitions": "1.2.3-84921",
70
+ "@fluidframework/odsp-doclib-utils": "^1.2.5",
71
+ "@fluidframework/odsp-driver-definitions": "^1.2.5",
72
72
  "@fluidframework/protocol-base": "^0.1036.5000",
73
73
  "@fluidframework/protocol-definitions": "^0.1028.2000",
74
- "@fluidframework/telemetry-utils": "1.2.3-84921",
74
+ "@fluidframework/telemetry-utils": "^1.2.5",
75
75
  "abort-controller": "^3.0.0",
76
76
  "node-fetch": "^2.6.1",
77
77
  "socket.io-client": "^4.4.1",
@@ -81,7 +81,7 @@
81
81
  "@fluidframework/build-common": "^0.24.0",
82
82
  "@fluidframework/build-tools": "^0.2.74327",
83
83
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
84
- "@fluidframework/mocha-test-setup": "1.2.3-84921",
84
+ "@fluidframework/mocha-test-setup": "^1.2.5",
85
85
  "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@1.2.1",
86
86
  "@microsoft/api-extractor": "^7.22.2",
87
87
  "@rushstack/eslint-config": "^2.5.1",
@@ -242,8 +242,15 @@ async function fetchLatestSnapshotCore(
242
242
  accept: response.requestHeaders.accept,
243
243
  };
244
244
  let parsedSnapshotContents: IOdspResponse<ISnapshotContents> | undefined;
245
+ let contentTypeToRead: string | undefined;
246
+ if (contentType?.indexOf("application/ms-fluid") !== -1) {
247
+ contentTypeToRead = "application/ms-fluid";
248
+ } else if (contentType?.indexOf("application/json") !== -1) {
249
+ contentTypeToRead = "application/json";
250
+ }
251
+
245
252
  try {
246
- switch (contentType) {
253
+ switch (contentTypeToRead) {
247
254
  case "application/json": {
248
255
  const text = await odspResponse.content.text();
249
256
  odspResponse.propsToLog.bodySize = text.length;
@@ -535,14 +542,12 @@ export async function downloadSnapshot(
535
542
  };
536
543
  // Decide what snapshot format to fetch as per the feature gate.
537
544
  switch (snapshotFormatFetchType) {
538
- case SnapshotFormatSupportType.JsonAndBinary:
539
- headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;
540
- break;
541
545
  case SnapshotFormatSupportType.Binary:
542
546
  headers.accept = `application/ms-fluid; v=${currentReadVersion}`;
543
547
  break;
544
548
  default:
545
- headers.accept = "application/json";
549
+ // By default ask both versions and let the server decide the format.
550
+ headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;
546
551
  }
547
552
 
548
553
  const odspResponse = await (epochTracker?.fetch(url, fetchOptions, "treesLatest", true, scenarioName) ??
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/odsp-driver";
9
- export const pkgVersion = "1.2.3-84921";
9
+ export const pkgVersion = "1.2.5";