@fluidframework/odsp-driver 2.21.0 → 2.22.0
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.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -0
- package/dist/fetch.d.ts +5 -1
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +5 -9
- package/dist/fetch.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +8 -5
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.d.ts +1 -1
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/getFileLink.js +3 -3
- package/dist/getFileLink.js.map +1 -1
- package/dist/mockify.d.ts +60 -0
- package/dist/mockify.d.ts.map +1 -0
- package/dist/mockify.js +61 -0
- package/dist/mockify.js.map +1 -0
- package/dist/odspUtils.d.ts +3 -0
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +3 -3
- package/dist/odspUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/socketModule.d.ts +2 -1
- package/dist/socketModule.d.ts.map +1 -1
- package/dist/socketModule.js +2 -3
- package/dist/socketModule.js.map +1 -1
- package/dist/vroom.d.ts +1 -1
- package/dist/vroom.d.ts.map +1 -1
- package/dist/vroom.js +3 -3
- package/dist/vroom.js.map +1 -1
- package/lib/fetch.d.ts +5 -1
- package/lib/fetch.d.ts.map +1 -1
- package/lib/fetch.js +5 -5
- package/lib/fetch.js.map +1 -1
- package/lib/fetchSnapshot.d.ts +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +8 -4
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.d.ts +1 -1
- package/lib/getFileLink.d.ts.map +1 -1
- package/lib/getFileLink.js +3 -2
- package/lib/getFileLink.js.map +1 -1
- package/lib/mockify.d.ts +60 -0
- package/lib/mockify.d.ts.map +1 -0
- package/lib/mockify.js +57 -0
- package/lib/mockify.js.map +1 -0
- package/lib/odspUtils.d.ts +3 -0
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +2 -2
- package/lib/odspUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/socketModule.d.ts +2 -1
- package/lib/socketModule.d.ts.map +1 -1
- package/lib/socketModule.js +2 -3
- package/lib/socketModule.js.map +1 -1
- package/lib/vroom.d.ts +1 -1
- package/lib/vroom.d.ts.map +1 -1
- package/lib/vroom.js +3 -2
- package/lib/vroom.js.map +1 -1
- package/package.json +15 -17
- package/src/fetch.ts +5 -11
- package/src/fetchSnapshot.ts +79 -73
- package/src/getFileLink.ts +56 -53
- package/src/mockify.ts +67 -0
- package/src/odspUtils.ts +3 -3
- package/src/packageVersion.ts +1 -1
- package/src/socketModule.ts +3 -3
- package/src/vroom.ts +92 -89
package/dist/mockify.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.mockify = exports.mockifyMockKey = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* A special key used to store the original function in a {@link Mockable | mockable} function.
|
|
10
|
+
* @remarks Use {@link mockify | `mockify.key`} as a convenient way to access this key.
|
|
11
|
+
*/
|
|
12
|
+
exports.mockifyMockKey = Symbol("`mockify` mock function key");
|
|
13
|
+
/**
|
|
14
|
+
* Decorates a function to allow it to be mocked.
|
|
15
|
+
* @param fn - The function that will become mockable.
|
|
16
|
+
* @returns A function with a {@link mockifyMockKey | special property } that can be overwritten to mock the original function.
|
|
17
|
+
* By default, this property is set to the original function.
|
|
18
|
+
* If overwritten with a new function, the new function will be called instead of the original.
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const original = () => console.log("original");
|
|
22
|
+
* const mockable = mockify(original);
|
|
23
|
+
* mockable(); // logs "original"
|
|
24
|
+
* mockable[mockify.key] = () => console.log("mocked");
|
|
25
|
+
* mockable(); // logs "mocked"
|
|
26
|
+
* mockable[mockify.key] = original;
|
|
27
|
+
* mockable(); // logs "original"
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* This pattern is useful for mocking top-level exported functions in a module.
|
|
31
|
+
* For example,
|
|
32
|
+
* ```typescript
|
|
33
|
+
* export function fn() { /* ... * / }
|
|
34
|
+
* ```
|
|
35
|
+
* becomes
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { mockify } from "./mockify.js";
|
|
38
|
+
* export const fn = mockify(() => { /* ... * / });
|
|
39
|
+
* ```
|
|
40
|
+
* and can now be mocked by another module that imports it.
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import * as sinon from "sinon";
|
|
43
|
+
* import { mockify } from "./mockify.js";
|
|
44
|
+
* import { fn } from "./module.js";
|
|
45
|
+
* sinon.stub(fn, mockify.key).callsFake(() => {
|
|
46
|
+
* // ... mock function implementation ...
|
|
47
|
+
* });
|
|
48
|
+
* // ...
|
|
49
|
+
* sinon.restore();
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
function mockify(fn) {
|
|
53
|
+
const mockable = (...args) => {
|
|
54
|
+
return mockable[exports.mockifyMockKey](...args);
|
|
55
|
+
};
|
|
56
|
+
mockable[exports.mockifyMockKey] = fn;
|
|
57
|
+
return mockable;
|
|
58
|
+
}
|
|
59
|
+
exports.mockify = mockify;
|
|
60
|
+
mockify.key = exports.mockifyMockKey;
|
|
61
|
+
//# sourceMappingURL=mockify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockify.js","sourceRoot":"","sources":["../src/mockify.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAUpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAgB,OAAO,CAAwC,EAAK;IACnE,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmB,EAAiB,EAAE;QAC1D,OAAO,QAAQ,CAAC,sBAAc,CAAC,CAAC,GAAG,IAAI,CAAkB,CAAC;IAC3D,CAAC,CAAC;IACF,QAAQ,CAAC,sBAAc,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO,QAAQ,CAAC;AACjB,CAAC;AAND,0BAMC;AAED,OAAO,CAAC,GAAG,GAAG,sBAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * A special key used to store the original function in a {@link Mockable | mockable} function.\n * @remarks Use {@link mockify | `mockify.key`} as a convenient way to access this key.\n */\nexport const mockifyMockKey = Symbol(\"`mockify` mock function key\");\n\n/**\n * A function that can be mocked after being decorated by {@link mockify | mockify()}.\n */\nexport interface Mockable<T extends (...args: any[]) => unknown> {\n\t(...args: Parameters<T>): ReturnType<T>;\n\t[mockifyMockKey]: T;\n}\n\n/**\n * Decorates a function to allow it to be mocked.\n * @param fn - The function that will become mockable.\n * @returns A function with a {@link mockifyMockKey | special property } that can be overwritten to mock the original function.\n * By default, this property is set to the original function.\n * If overwritten with a new function, the new function will be called instead of the original.\n * @example\n * ```typescript\n * const original = () => console.log(\"original\");\n * const mockable = mockify(original);\n * mockable(); // logs \"original\"\n * mockable[mockify.key] = () => console.log(\"mocked\");\n * mockable(); // logs \"mocked\"\n * mockable[mockify.key] = original;\n * mockable(); // logs \"original\"\n * ```\n *\n * This pattern is useful for mocking top-level exported functions in a module.\n * For example,\n * ```typescript\n * export function fn() { /* ... * / }\n * ```\n * becomes\n * ```typescript\n * import { mockify } from \"./mockify.js\";\n * export const fn = mockify(() => { /* ... * / });\n * ```\n * and can now be mocked by another module that imports it.\n * ```typescript\n * import * as sinon from \"sinon\";\n * import { mockify } from \"./mockify.js\";\n * import { fn } from \"./module.js\";\n * sinon.stub(fn, mockify.key).callsFake(() => {\n * // ... mock function implementation ...\n * });\n * // ...\n * sinon.restore();\n * ```\n */\nexport function mockify<T extends (...args: any[]) => unknown>(fn: T): Mockable<T> {\n\tconst mockable = (...args: Parameters<T>): ReturnType<T> => {\n\t\treturn mockable[mockifyMockKey](...args) as ReturnType<T>;\n\t};\n\tmockable[mockifyMockKey] = fn;\n\treturn mockable;\n}\n\nmockify.key = mockifyMockKey;\n"]}
|
package/dist/odspUtils.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ export interface TokenFetchOptionsEx {
|
|
|
39
39
|
*/
|
|
40
40
|
export declare function getWithRetryForTokenRefresh<T>(get: (options: TokenFetchOptionsEx) => Promise<T>): Promise<T>;
|
|
41
41
|
export declare function fetchHelper(requestInfo: RequestInfo, requestInit: RequestInit | undefined): Promise<IOdspResponse<Response>>;
|
|
42
|
+
export declare namespace fetchHelper {
|
|
43
|
+
var fetch: typeof globalThis.fetch;
|
|
44
|
+
}
|
|
42
45
|
/**
|
|
43
46
|
* A utility function to fetch and parse as JSON with support for retries
|
|
44
47
|
* @param requestInfo - fetch requestInfo, can be a string
|
package/dist/odspUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspUtils.d.ts","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,YAAY,EACZ,SAAS,EACT,qBAAqB,EACrB,MAAM,6CAA6C,CAAC;AAcrD,OAAO,EACN,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EA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M,EAAE,GAAG,SAAS,GACnC,OAAO,CAET;AAMD,wBAAgB,0CAA0C,CACzD,eAAe,EAAE,MAAM,EAAE,GAAG,SAAS,GACnC,OAAO,CAET;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,gBAAgB,EACjC,aAAa,EAAE,MAAM,EACrB,oBAAoB,CAAC,EAAE,MAAM,GAC3B,MAAM,CAkBR;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,iBAAiB,EAAE,qBAAqB,GAAG,SAAS,GAClD,MAAM,GAAG,SAAS,CAiBpB"}
|
package/dist/odspUtils.js
CHANGED
|
@@ -11,7 +11,6 @@ const internal_2 = require("@fluidframework/driver-utils/internal");
|
|
|
11
11
|
const internal_3 = require("@fluidframework/odsp-doclib-utils/internal");
|
|
12
12
|
const internal_4 = require("@fluidframework/odsp-driver-definitions/internal");
|
|
13
13
|
const internal_5 = require("@fluidframework/telemetry-utils/internal");
|
|
14
|
-
const fetch_js_1 = require("./fetch.js");
|
|
15
14
|
const odspFluidFileLink_js_1 = require("./odspFluidFileLink.js");
|
|
16
15
|
const packageVersion_js_1 = require("./packageVersion.js");
|
|
17
16
|
exports.getWithRetryForTokenRefreshRepeat = "getWithRetryForTokenRefreshRepeat";
|
|
@@ -56,8 +55,7 @@ async function getWithRetryForTokenRefresh(get) {
|
|
|
56
55
|
exports.getWithRetryForTokenRefresh = getWithRetryForTokenRefresh;
|
|
57
56
|
async function fetchHelper(requestInfo, requestInit) {
|
|
58
57
|
const start = (0, client_utils_1.performanceNow)();
|
|
59
|
-
|
|
60
|
-
return (0, fetch_js_1.fetch)(requestInfo, requestInit).then(async (fetchResponse) => {
|
|
58
|
+
return fetch(requestInfo, requestInit).then(async (fetchResponse) => {
|
|
61
59
|
const response = fetchResponse;
|
|
62
60
|
// Let's assume we can retry.
|
|
63
61
|
if (!response) {
|
|
@@ -122,6 +120,8 @@ async function fetchHelper(requestInfo, requestInit) {
|
|
|
122
120
|
});
|
|
123
121
|
}
|
|
124
122
|
exports.fetchHelper = fetchHelper;
|
|
123
|
+
// This allows `fetch` to be mocked (e.g. with sinon `stub()`)
|
|
124
|
+
fetchHelper.fetch = fetch;
|
|
125
125
|
/**
|
|
126
126
|
* A utility function to fetch and parse as JSON with support for retries
|
|
127
127
|
* @param requestInfo - fetch requestInfo, can be a string
|
package/dist/odspUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAK9D,kEAA6D;AAM7D,oEAO+C;AAC/C,yEAIoD;AACpD,+EAgB0D;AAC1D,uEAQkD;AAElD,yCAAmC;AACnC,iEAA+D;AAG/D,2DAAkE;AAErD,QAAA,iCAAiC,GAAG,mCAAmC,CAAC;AA2BrF,SAAS,YAAY,CAAC,OAAgB;IACrC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9C,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B,CAChD,GAAiD;IAEjD,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACpD,MAAM,OAAO,GAAwB,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;QAC7E,QAAS,KAAkC,CAAC,SAAS,EAAE,CAAC;YACvD,kEAAkE;YAClE,KAAK,yBAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC;gBACxC,MAAM,SAAS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e,CAAC,MAAM;QAC9B,aAAa,EAAE,mBAAmB;QAClC,OAAO,EAAE,eAAe,CAAC,OAAO;QAChC,oBAAoB;QACpB,WAAW,EAAE,eAAe,CAAC,WAAW;QACxC,OAAO,EAAE,eAAe,CAAC,OAAO;KAChC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC,IAAI,CAAC;AACjB,CAAC;AAvBD,wCAuBC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CACtC,iBAAoD;IAEpD,IAAI,oBAAwC,CAAC;IAC7C,IAAI,iBAAiB,IAAI,MAAM,IAAI,iBAAiB,EAAE,CAAC;QACtD,oBAAoB,GAAG,iBAAiB,CAAC,IAAI,CAAC;QAC9C,wGAAwG;QACxG,4BAA4B;QAC5B,iJAAiJ;IAClJ,CAAC;SAAM,IAAI,cAAc,CAAE,iBAAyB,EAAE,OAAO,CAAC,EAAE,CAAC;QAChE,4BAA4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC;IACjE,CAAC;SAAM,CAAC;QACP,4BAA4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC;IAC5D,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC;AAnBD,0DAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIResolvedUrl,\n\tISnapshot,\n\tIContainerPackageInfo,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AuthorizationError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tisOnline,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tgetSPOAndGraphRequestIdsFromResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tICacheEntry,\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tISharingLinkKind,\n\tInstrumentedStorageTokenFetcher,\n\tInstrumentedTokenFetcher,\n\tOdspErrorTypes,\n\tauthHeaderFromTokenResponse,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetchOptions,\n\tTokenFetcher,\n\tisTokenFromCache,\n\tsnapshotKey,\n\ttokenFromResponse,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype IConfigProvider,\n\ttype IFluidErrorBase,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { fetch } from \"./fetch.js\";\nimport { storeLocatorInOdspUrl } from \"./odspFluidFileLink.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISnapshotContents } from \"./odspPublicUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IOdspResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\tduration: number;\n}\n\n/**\n * This interface captures the portion of TokenFetchOptions required for refreshing tokens\n * It is controlled by logic in getWithRetryForTokenRefresh to specify what is the required refresh behavior\n */\nexport interface TokenFetchOptionsEx {\n\trefresh: boolean;\n\tclaims?: string;\n\ttenantId?: string;\n\t/**\n\t * The previous error we hit in {@link getWithRetryForTokenRefresh}.\n\t */\n\tpreviousError?: unknown;\n}\n\nfunction headersToMap(headers: Headers): Map<string, string> {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(\n\tget: (options: TokenFetchOptionsEx) => Promise<T>,\n): Promise<T> {\n\treturn get({ refresh: false }).catch(async (error) => {\n\t\tconst options: TokenFetchOptionsEx = { refresh: true, previousError: error };\n\t\tswitch ((error as Partial<IFluidErrorBase>).errorType) {\n\t\t\t// If the error is 401 or 403 refresh the token and try once more.\n\t\t\tcase OdspErrorTypes.authorizationError: {\n\t\t\t\tconst authError = error as AuthorizationError;\n\t\t\t\treturn get({ ...options, claims: authError.claims, tenantId: authError.tenantId });\n\t\t\t}\n\n\t\t\tcase OdspErrorTypes.incorrectServerResponse: // some error on the wire, retry once\n\t\t\tcase OdspErrorTypes.fetchTokenError: {\n\t\t\t\t// If the token was null, then retry once.\n\t\t\t\treturn get(options);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\t// Caller may determine that it wants one retry\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-explicit-any\n\t\t\t\tif ((error as any)[getWithRetryForTokenRefreshRepeat] === true) {\n\t\t\t\t\treturn get(options);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t});\n}\n\nexport async function fetchHelper(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n\tconst start = performanceNow();\n\n\t// Node-fetch and dom have conflicting typing, force them to work by casting for now\n\treturn fetch(requestInfo, requestInit).then(\n\t\tasync (fetchResponse) => {\n\t\t\tconst response = fetchResponse as unknown as Response;\n\t\t\t// Let's assume we can retry.\n\t\t\tif (!response) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t// pre-0.58 error message: No response from fetch call\n\t\t\t\t\t\"No response from ODSP fetch call\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!response.ok || response.status < 200 || response.status >= 300) {\n\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t// pre-0.58 error message prefix: odspFetchError\n\t\t\t\t\t`ODSP fetch error [${response.status}]`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tresponse,\n\t\t\t\t\tawait response.text(),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: response,\n\t\t\t\theaders,\n\t\t\t\tpropsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n\t\t\t\tduration: performanceNow() - start,\n\t\t\t};\n\t\t},\n\t\t(error) => {\n\t\t\tconst online = isOnline();\n\n\t\t\t// The error message may not be suitable to log for privacy reasons, so tag it as such\n\t\t\tconst taggedErrorMessage = {\n\t\t\t\tvalue: `${error}`, // This uses toString for objects, which often results in `${error.name}: ${error.message}`\n\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t};\n\t\t\t// After redacting URLs we believe the error message is safe to log\n\t\t\tconst urlRegex = /((http|https):\\/\\/(\\S*))/i;\n\t\t\tconst redactedErrorText = taggedErrorMessage.value.replace(urlRegex, \"REDACTED_URL\");\n\n\t\t\t// This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\tif (error.name === \"AbortError\") {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (AbortError)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// TCP/IP timeout\n\t\t\tif (redactedErrorText.includes(\"ETIMEDOUT\")) {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (ETIMEDOUT)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (online === OnlineStatus.Offline) {\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Offline\n\t\t\t\t\t`ODSP fetch failure (Offline): ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.offlineError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// It is perhaps still possible that this is due to being offline, the error does not reveal enough\n\t\t\t\t// information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Fetch error\n\t\t\t\t\t`ODSP fetch failure: ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.fetchFailure,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet arrayBuffer: ArrayBuffer;\n\ttry {\n\t\tarrayBuffer = await content.arrayBuffer();\n\t} catch {\n\t\t// Parsing can fail and message could contain full request URI, including\n\t\t// tokens, etc. So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\tundefined, // response text\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = arrayBuffer.byteLength;\n\treturn {\n\t\theaders,\n\t\tcontent: arrayBuffer,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = await content.text();\n\t} catch {\n\t\t// JSON.parse() can fail and message would container full request URI, including\n\t\t// tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n\t\t// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n\t\t// succeeds on retry.\n\t\t// So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t// pre-0.58 error message: errorWhileParsingFetchResponse\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\ttext,\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = text.length;\n\tconst res = {\n\t\theaders,\n\t\tcontent: JSON.parse(text) as T,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n\treturn res;\n}\n\nexport interface IFileInfoBase {\n\ttype: \"New\" | \"Existing\";\n\tsiteUrl: string;\n\tdriveId: string;\n}\n\nexport interface INewFileInfo extends IFileInfoBase {\n\ttype: \"New\";\n\tfilename: string;\n\tfilePath: string;\n\t/**\n\t * application can request creation of a share link along with the creation of a new file\n\t * by passing in an optional param to specify the kind of sharing link\n\t */\n\tcreateLinkType?: ISharingLinkKind;\n}\n\nexport interface IExistingFileInfo extends IFileInfoBase {\n\ttype: \"Existing\";\n\titemId: string;\n}\n\nexport function isNewFileInfo(\n\tfileInfo: INewFileInfo | IExistingFileInfo,\n): fileInfo is INewFileInfo {\n\treturn fileInfo.type === undefined || fileInfo.type === \"New\";\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n\tassert(\n\t\t(resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true,\n\t\t0x1de /* \"Not an ODSP resolved url\" */,\n\t);\n\treturn resolvedUrl as IOdspResolvedUrl;\n}\n\n/**\n * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}\n * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.\n * @legacy\n * @alpha\n */\nexport function isOdspResolvedUrl(resolvedUrl: IResolvedUrl): resolvedUrl is IOdspResolvedUrl {\n\treturn \"odspResolvedUrl\" in resolvedUrl && resolvedUrl.odspResolvedUrl === true;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger): ITelemetryLoggerExt =>\n\tcreateChildLogger({\n\t\tlogger,\n\t\tnamespace: \"OdspDriver\",\n\t\tproperties: {\n\t\t\tall: {\n\t\t\t\tdriverVersion,\n\t\t\t},\n\t\t},\n\t});\n\n/**\n * Returns a function that can be used to fetch storage token.\n * Storage token can not be empty - if original delegate (tokenFetcher argument) returns null result, exception will be thrown\n */\nexport function toInstrumentedOdspStorageTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n): InstrumentedStorageTokenFetcher {\n\tconst res = toInstrumentedOdspTokenFetcher(\n\t\tlogger,\n\t\tresolvedUrlParts,\n\t\ttokenFetcher,\n\t\ttrue, // throwOnNullToken\n\t\tfalse, // returnPlainToken\n\t);\n\t// Drop undefined from signature - we can do it safely due to throwOnNullToken == true above\n\treturn res as InstrumentedStorageTokenFetcher;\n}\n\n/**\n * Returns a function that can be used to fetch storage or websocket token.\n * There are scenarios where websocket token is not required / present (consumer stack and ordering service token),\n * thus it could return null. Use toInstrumentedOdspStorageTokenFetcher if you deal with storage token.\n * @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token\n */\nexport function toInstrumentedOdspTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tthrowOnNullToken: boolean,\n\treturnPlainToken: boolean,\n): InstrumentedTokenFetcher {\n\treturn async (\n\t\toptions: TokenFetchOptions,\n\t\tname: string,\n\t\talwaysRecordTokenFetchTelemetry: boolean = false,\n\t) => {\n\t\t// Telemetry note: if options.refresh is true, there is a potential perf issue:\n\t\t// Host should optimize and provide non-expired tokens on all critical paths.\n\t\t// Exceptions: race conditions around expiration, revoked tokens, host that does not care\n\t\t// (fluid-fetcher)\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: `${name}_GetToken`,\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\thasClaims: !!options.claims,\n\t\t\t\thasTenantId: !!options.tenantId,\n\t\t\t},\n\t\t\tasync (event) =>\n\t\t\t\ttokenFetcher({\n\t\t\t\t\t...options,\n\t\t\t\t\t...resolvedUrlParts,\n\t\t\t\t}).then(\n\t\t\t\t\t(tokenResponse) => {\n\t\t\t\t\t\tconst returnVal = returnPlainToken\n\t\t\t\t\t\t\t? tokenFromResponse(tokenResponse)\n\t\t\t\t\t\t\t: authHeaderFromTokenResponse(tokenResponse);\n\t\t\t\t\t\t// This event alone generates so many events that is materially impacts cost of telemetry\n\t\t\t\t\t\t// Thus do not report end event when it comes back quickly.\n\t\t\t\t\t\t// Note that most of the hosts do not report if result is comming from cache or not,\n\t\t\t\t\t\t// so we can't rely on that here. But always record if specified explicitly for cases such as\n\t\t\t\t\t\t// calling trees/latest during load.\n\t\t\t\t\t\tif (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n\t\t\t\t\t\t\tevent.end({\n\t\t\t\t\t\t\t\tfromCache: isTokenFromCache(tokenResponse),\n\t\t\t\t\t\t\t\tisNull: returnVal === null,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (returnVal === null && throwOnNullToken) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t// pre-0.58 error message: Token is null for ${name} call\n\t\t\t\t\t\t\t\t`The Host-provided token fetcher returned null`,\n\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t{ method: name, driverVersion },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnVal;\n\t\t\t\t\t},\n\t\t\t\t\t(error) => {\n\t\t\t\t\t\t// There is an important but unofficial contract here where token providers can set canRetry: true\n\t\t\t\t\t\t// to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\tconst rawCanRetry = error?.canRetry;\n\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\ttypeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n\t\t\t\t\t\t\t\t\t{ method: name, errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t{ cancel: \"generic\" },\n\t\t);\n\t};\n}\n\nexport function createCacheSnapshotKey(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tsnapshotWithLoadingGroupId: boolean | undefined,\n): ICacheEntry {\n\tconst cacheEntry: ICacheEntry = {\n\t\ttype: snapshotWithLoadingGroupId ? snapshotWithLoadingGroupIdKey : snapshotKey,\n\t\tkey: odspResolvedUrl.fileVersion ?? \"\",\n\t\tfile: {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t},\n\t};\n\treturn cacheEntry;\n}\n\nexport function snapshotWithLoadingGroupIdSupported(\n\tconfig: IConfigProvider,\n): boolean | undefined {\n\treturn config.getBoolean(\"Fluid.Container.UseLoadingGroupIdForSnapshotFetch2\");\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n\n/**\n * Build request parameters to request for the creation of a sharing link along with the creation of the file\n * through the /snapshot api call.\n * @param shareLinkType - Kind of sharing link requested\n * @returns A string of request parameters that can be concatenated with the base URI\n */\nexport function buildOdspShareLinkReqParams(\n\tshareLinkType: ISharingLinkKind | undefined,\n): string | undefined {\n\tif (!shareLinkType) {\n\t\treturn;\n\t}\n\tconst scope = shareLinkType.scope;\n\tlet shareLinkRequestParams = `createLinkScope=${scope}`;\n\tconst role = shareLinkType.role;\n\tshareLinkRequestParams = role\n\t\t? `${shareLinkRequestParams}&createLinkRole=${role}`\n\t\t: shareLinkRequestParams;\n\treturn shareLinkRequestParams;\n}\n\nexport function measure<T>(callback: () => T): [T, number] {\n\tconst start = performanceNow();\n\tconst result = callback();\n\tconst time = performanceNow() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performanceNow();\n\tconst result = await callback();\n\tconst time = performanceNow() - start;\n\treturn [result, time];\n}\n\nexport function getJoinSessionCacheKey(odspResolvedUrl: IOdspResolvedUrl): string {\n\treturn `${odspResolvedUrl.hashedDocumentId}/joinsession`;\n}\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\t// eslint-disable-next-line import/no-deprecated\n\tobj: ISnapshotContents | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n\n/**\n * This tells whether request if for a specific loading group or not. The snapshot which\n * we fetch on initial load, fetches all ungrouped content.\n */\nexport function isSnapshotFetchForLoadingGroup(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds !== undefined && loadingGroupIds.length > 0;\n}\n\n/*\n * This tells whether we are using legacy flow for fetching snapshot where we don't use\n * groupId query param in the trees latest network call.\n */\nexport function useLegacyFlowWithoutGroupsForSnapshotFetch(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds === undefined;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n * has a base URL (for example a sharing link) of the Fluid file, but does not have the locator information that would be used by Fluid\n * to load the file later.\n * @param baseUrl - The input URL on which the locator params will be appended.\n * @param resolvedUrl - odsp-driver's resolvedURL object.\n * @param dataStorePath - The relative data store path URL.\n * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n * will be extracted from the resolved url if present.\n * @param containerPackageName - Name of the package to be included in the URL.\n * @returns The provided base URL appended with odsp-specific locator information\n */\nexport function appendNavParam(\n\tbaseUrl: string,\n\todspResolvedUrl: IOdspResolvedUrl,\n\tdataStorePath: string,\n\tcontainerPackageName?: string,\n): string {\n\tconst url = new URL(baseUrl);\n\n\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\tstoreLocatorInOdspUrl(url, {\n\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t\tdataStorePath: actualDataStorePath,\n\t\tappName: odspResolvedUrl.appName,\n\t\tcontainerPackageName,\n\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\tcontext: odspResolvedUrl.context,\n\t});\n\n\treturn url.href;\n}\n\n/**\n * Returns the package name of the container package information.\n * @param packageInfoSource - Information of the package connected to the URL\n * @returns The package name of the container package\n */\nexport function getContainerPackageName(\n\tpackageInfoSource: IContainerPackageInfo | undefined,\n): string | undefined {\n\tlet containerPackageName: string | undefined;\n\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\tcontainerPackageName = packageInfoSource.name;\n\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t} else {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t}\n\treturn containerPackageName;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH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AE,CAAC;QACtD,oBAAoB,GAAG,iBAAiB,CAAC,IAAI,CAAC;QAC9C,wGAAwG;QACxG,4BAA4B;QAC5B,iJAAiJ;IAClJ,CAAC;SAAM,IAAI,cAAc,CAAE,iBAAyB,EAAE,OAAO,CAAC,EAAE,CAAC;QAChE,4BAA4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC;IACjE,CAAC;SAAM,CAAC;QACP,4BAA4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC;IAC5D,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC;AAnBD,0DAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIResolvedUrl,\n\tISnapshot,\n\tIContainerPackageInfo,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AuthorizationError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tisOnline,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tgetSPOAndGraphRequestIdsFromResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tICacheEntry,\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tISharingLinkKind,\n\tInstrumentedStorageTokenFetcher,\n\tInstrumentedTokenFetcher,\n\tOdspErrorTypes,\n\tauthHeaderFromTokenResponse,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetchOptions,\n\tTokenFetcher,\n\tisTokenFromCache,\n\tsnapshotKey,\n\ttokenFromResponse,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype IConfigProvider,\n\ttype IFluidErrorBase,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { storeLocatorInOdspUrl } from \"./odspFluidFileLink.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISnapshotContents } from \"./odspPublicUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IOdspResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\tduration: number;\n}\n\n/**\n * This interface captures the portion of TokenFetchOptions required for refreshing tokens\n * It is controlled by logic in getWithRetryForTokenRefresh to specify what is the required refresh behavior\n */\nexport interface TokenFetchOptionsEx {\n\trefresh: boolean;\n\tclaims?: string;\n\ttenantId?: string;\n\t/**\n\t * The previous error we hit in {@link getWithRetryForTokenRefresh}.\n\t */\n\tpreviousError?: unknown;\n}\n\nfunction headersToMap(headers: Headers): Map<string, string> {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(\n\tget: (options: TokenFetchOptionsEx) => Promise<T>,\n): Promise<T> {\n\treturn get({ refresh: false }).catch(async (error) => {\n\t\tconst options: TokenFetchOptionsEx = { refresh: true, previousError: error };\n\t\tswitch ((error as Partial<IFluidErrorBase>).errorType) {\n\t\t\t// If the error is 401 or 403 refresh the token and try once more.\n\t\t\tcase OdspErrorTypes.authorizationError: {\n\t\t\t\tconst authError = error as AuthorizationError;\n\t\t\t\treturn get({ ...options, claims: authError.claims, tenantId: authError.tenantId });\n\t\t\t}\n\n\t\t\tcase OdspErrorTypes.incorrectServerResponse: // some error on the wire, retry once\n\t\t\tcase OdspErrorTypes.fetchTokenError: {\n\t\t\t\t// If the token was null, then retry once.\n\t\t\t\treturn get(options);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\t// Caller may determine that it wants one retry\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-explicit-any\n\t\t\t\tif ((error as any)[getWithRetryForTokenRefreshRepeat] === true) {\n\t\t\t\t\treturn get(options);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t});\n}\n\nexport async function fetchHelper(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n\tconst start = performanceNow();\n\n\treturn fetch(requestInfo, requestInit).then(\n\t\tasync (fetchResponse) => {\n\t\t\tconst response = fetchResponse;\n\t\t\t// Let's assume we can retry.\n\t\t\tif (!response) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t// pre-0.58 error message: No response from fetch call\n\t\t\t\t\t\"No response from ODSP fetch call\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!response.ok || response.status < 200 || response.status >= 300) {\n\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t// pre-0.58 error message prefix: odspFetchError\n\t\t\t\t\t`ODSP fetch error [${response.status}]`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tresponse,\n\t\t\t\t\tawait response.text(),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: response,\n\t\t\t\theaders,\n\t\t\t\tpropsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n\t\t\t\tduration: performanceNow() - start,\n\t\t\t};\n\t\t},\n\t\t(error) => {\n\t\t\tconst online = isOnline();\n\n\t\t\t// The error message may not be suitable to log for privacy reasons, so tag it as such\n\t\t\tconst taggedErrorMessage = {\n\t\t\t\tvalue: `${error}`, // This uses toString for objects, which often results in `${error.name}: ${error.message}`\n\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t};\n\t\t\t// After redacting URLs we believe the error message is safe to log\n\t\t\tconst urlRegex = /((http|https):\\/\\/(\\S*))/i;\n\t\t\tconst redactedErrorText = taggedErrorMessage.value.replace(urlRegex, \"REDACTED_URL\");\n\n\t\t\t// This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\tif (error.name === \"AbortError\") {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (AbortError)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// TCP/IP timeout\n\t\t\tif (redactedErrorText.includes(\"ETIMEDOUT\")) {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (ETIMEDOUT)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (online === OnlineStatus.Offline) {\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Offline\n\t\t\t\t\t`ODSP fetch failure (Offline): ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.offlineError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// It is perhaps still possible that this is due to being offline, the error does not reveal enough\n\t\t\t\t// information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Fetch error\n\t\t\t\t\t`ODSP fetch failure: ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.fetchFailure,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\n}\n// This allows `fetch` to be mocked (e.g. with sinon `stub()`)\nfetchHelper.fetch = fetch;\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet arrayBuffer: ArrayBuffer;\n\ttry {\n\t\tarrayBuffer = await content.arrayBuffer();\n\t} catch {\n\t\t// Parsing can fail and message could contain full request URI, including\n\t\t// tokens, etc. So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\tundefined, // response text\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = arrayBuffer.byteLength;\n\treturn {\n\t\theaders,\n\t\tcontent: arrayBuffer,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = await content.text();\n\t} catch {\n\t\t// JSON.parse() can fail and message would container full request URI, including\n\t\t// tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n\t\t// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n\t\t// succeeds on retry.\n\t\t// So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t// pre-0.58 error message: errorWhileParsingFetchResponse\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\ttext,\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = text.length;\n\tconst res = {\n\t\theaders,\n\t\tcontent: JSON.parse(text) as T,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n\treturn res;\n}\n\nexport interface IFileInfoBase {\n\ttype: \"New\" | \"Existing\";\n\tsiteUrl: string;\n\tdriveId: string;\n}\n\nexport interface INewFileInfo extends IFileInfoBase {\n\ttype: \"New\";\n\tfilename: string;\n\tfilePath: string;\n\t/**\n\t * application can request creation of a share link along with the creation of a new file\n\t * by passing in an optional param to specify the kind of sharing link\n\t */\n\tcreateLinkType?: ISharingLinkKind;\n}\n\nexport interface IExistingFileInfo extends IFileInfoBase {\n\ttype: \"Existing\";\n\titemId: string;\n}\n\nexport function isNewFileInfo(\n\tfileInfo: INewFileInfo | IExistingFileInfo,\n): fileInfo is INewFileInfo {\n\treturn fileInfo.type === undefined || fileInfo.type === \"New\";\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n\tassert(\n\t\t(resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true,\n\t\t0x1de /* \"Not an ODSP resolved url\" */,\n\t);\n\treturn resolvedUrl as IOdspResolvedUrl;\n}\n\n/**\n * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}\n * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.\n * @legacy\n * @alpha\n */\nexport function isOdspResolvedUrl(resolvedUrl: IResolvedUrl): resolvedUrl is IOdspResolvedUrl {\n\treturn \"odspResolvedUrl\" in resolvedUrl && resolvedUrl.odspResolvedUrl === true;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger): ITelemetryLoggerExt =>\n\tcreateChildLogger({\n\t\tlogger,\n\t\tnamespace: \"OdspDriver\",\n\t\tproperties: {\n\t\t\tall: {\n\t\t\t\tdriverVersion,\n\t\t\t},\n\t\t},\n\t});\n\n/**\n * Returns a function that can be used to fetch storage token.\n * Storage token can not be empty - if original delegate (tokenFetcher argument) returns null result, exception will be thrown\n */\nexport function toInstrumentedOdspStorageTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n): InstrumentedStorageTokenFetcher {\n\tconst res = toInstrumentedOdspTokenFetcher(\n\t\tlogger,\n\t\tresolvedUrlParts,\n\t\ttokenFetcher,\n\t\ttrue, // throwOnNullToken\n\t\tfalse, // returnPlainToken\n\t);\n\t// Drop undefined from signature - we can do it safely due to throwOnNullToken == true above\n\treturn res as InstrumentedStorageTokenFetcher;\n}\n\n/**\n * Returns a function that can be used to fetch storage or websocket token.\n * There are scenarios where websocket token is not required / present (consumer stack and ordering service token),\n * thus it could return null. Use toInstrumentedOdspStorageTokenFetcher if you deal with storage token.\n * @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token\n */\nexport function toInstrumentedOdspTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tthrowOnNullToken: boolean,\n\treturnPlainToken: boolean,\n): InstrumentedTokenFetcher {\n\treturn async (\n\t\toptions: TokenFetchOptions,\n\t\tname: string,\n\t\talwaysRecordTokenFetchTelemetry: boolean = false,\n\t) => {\n\t\t// Telemetry note: if options.refresh is true, there is a potential perf issue:\n\t\t// Host should optimize and provide non-expired tokens on all critical paths.\n\t\t// Exceptions: race conditions around expiration, revoked tokens, host that does not care\n\t\t// (fluid-fetcher)\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: `${name}_GetToken`,\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\thasClaims: !!options.claims,\n\t\t\t\thasTenantId: !!options.tenantId,\n\t\t\t},\n\t\t\tasync (event) =>\n\t\t\t\ttokenFetcher({\n\t\t\t\t\t...options,\n\t\t\t\t\t...resolvedUrlParts,\n\t\t\t\t}).then(\n\t\t\t\t\t(tokenResponse) => {\n\t\t\t\t\t\tconst returnVal = returnPlainToken\n\t\t\t\t\t\t\t? tokenFromResponse(tokenResponse)\n\t\t\t\t\t\t\t: authHeaderFromTokenResponse(tokenResponse);\n\t\t\t\t\t\t// This event alone generates so many events that is materially impacts cost of telemetry\n\t\t\t\t\t\t// Thus do not report end event when it comes back quickly.\n\t\t\t\t\t\t// Note that most of the hosts do not report if result is comming from cache or not,\n\t\t\t\t\t\t// so we can't rely on that here. But always record if specified explicitly for cases such as\n\t\t\t\t\t\t// calling trees/latest during load.\n\t\t\t\t\t\tif (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n\t\t\t\t\t\t\tevent.end({\n\t\t\t\t\t\t\t\tfromCache: isTokenFromCache(tokenResponse),\n\t\t\t\t\t\t\t\tisNull: returnVal === null,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (returnVal === null && throwOnNullToken) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t// pre-0.58 error message: Token is null for ${name} call\n\t\t\t\t\t\t\t\t`The Host-provided token fetcher returned null`,\n\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t{ method: name, driverVersion },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnVal;\n\t\t\t\t\t},\n\t\t\t\t\t(error) => {\n\t\t\t\t\t\t// There is an important but unofficial contract here where token providers can set canRetry: true\n\t\t\t\t\t\t// to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\tconst rawCanRetry = error?.canRetry;\n\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\ttypeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n\t\t\t\t\t\t\t\t\t{ method: name, errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t{ cancel: \"generic\" },\n\t\t);\n\t};\n}\n\nexport function createCacheSnapshotKey(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tsnapshotWithLoadingGroupId: boolean | undefined,\n): ICacheEntry {\n\tconst cacheEntry: ICacheEntry = {\n\t\ttype: snapshotWithLoadingGroupId ? snapshotWithLoadingGroupIdKey : snapshotKey,\n\t\tkey: odspResolvedUrl.fileVersion ?? \"\",\n\t\tfile: {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t},\n\t};\n\treturn cacheEntry;\n}\n\nexport function snapshotWithLoadingGroupIdSupported(\n\tconfig: IConfigProvider,\n): boolean | undefined {\n\treturn config.getBoolean(\"Fluid.Container.UseLoadingGroupIdForSnapshotFetch2\");\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n\n/**\n * Build request parameters to request for the creation of a sharing link along with the creation of the file\n * through the /snapshot api call.\n * @param shareLinkType - Kind of sharing link requested\n * @returns A string of request parameters that can be concatenated with the base URI\n */\nexport function buildOdspShareLinkReqParams(\n\tshareLinkType: ISharingLinkKind | undefined,\n): string | undefined {\n\tif (!shareLinkType) {\n\t\treturn;\n\t}\n\tconst scope = shareLinkType.scope;\n\tlet shareLinkRequestParams = `createLinkScope=${scope}`;\n\tconst role = shareLinkType.role;\n\tshareLinkRequestParams = role\n\t\t? `${shareLinkRequestParams}&createLinkRole=${role}`\n\t\t: shareLinkRequestParams;\n\treturn shareLinkRequestParams;\n}\n\nexport function measure<T>(callback: () => T): [T, number] {\n\tconst start = performanceNow();\n\tconst result = callback();\n\tconst time = performanceNow() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performanceNow();\n\tconst result = await callback();\n\tconst time = performanceNow() - start;\n\treturn [result, time];\n}\n\nexport function getJoinSessionCacheKey(odspResolvedUrl: IOdspResolvedUrl): string {\n\treturn `${odspResolvedUrl.hashedDocumentId}/joinsession`;\n}\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\t// eslint-disable-next-line import/no-deprecated\n\tobj: ISnapshotContents | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n\n/**\n * This tells whether request if for a specific loading group or not. The snapshot which\n * we fetch on initial load, fetches all ungrouped content.\n */\nexport function isSnapshotFetchForLoadingGroup(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds !== undefined && loadingGroupIds.length > 0;\n}\n\n/*\n * This tells whether we are using legacy flow for fetching snapshot where we don't use\n * groupId query param in the trees latest network call.\n */\nexport function useLegacyFlowWithoutGroupsForSnapshotFetch(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds === undefined;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n * has a base URL (for example a sharing link) of the Fluid file, but does not have the locator information that would be used by Fluid\n * to load the file later.\n * @param baseUrl - The input URL on which the locator params will be appended.\n * @param resolvedUrl - odsp-driver's resolvedURL object.\n * @param dataStorePath - The relative data store path URL.\n * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n * will be extracted from the resolved url if present.\n * @param containerPackageName - Name of the package to be included in the URL.\n * @returns The provided base URL appended with odsp-specific locator information\n */\nexport function appendNavParam(\n\tbaseUrl: string,\n\todspResolvedUrl: IOdspResolvedUrl,\n\tdataStorePath: string,\n\tcontainerPackageName?: string,\n): string {\n\tconst url = new URL(baseUrl);\n\n\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\tstoreLocatorInOdspUrl(url, {\n\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t\tdataStorePath: actualDataStorePath,\n\t\tappName: odspResolvedUrl.appName,\n\t\tcontainerPackageName,\n\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\tcontext: odspResolvedUrl.context,\n\t});\n\n\treturn url.href;\n}\n\n/**\n * Returns the package name of the container package information.\n * @param packageInfoSource - Information of the package connected to the URL\n * @returns The package name of the container package\n */\nexport function getContainerPackageName(\n\tpackageInfoSource: IContainerPackageInfo | undefined,\n): string | undefined {\n\tlet containerPackageName: string | undefined;\n\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\tcontainerPackageName = packageInfoSource.name;\n\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t} else {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t}\n\treturn containerPackageName;\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -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 = "2.
|
|
8
|
+
export declare const pkgVersion = "2.22.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -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 = "2.
|
|
11
|
+
exports.pkgVersion = "2.22.0";
|
|
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,QAAQ,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 = \"2.
|
|
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,QAAQ,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 = \"2.22.0\";\n"]}
|
package/dist/socketModule.d.ts
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { io } from "socket.io-client";
|
|
6
|
-
|
|
6
|
+
import { type Mockable } from "./mockify.js";
|
|
7
|
+
export declare const SocketIOClientStatic: Mockable<typeof io>;
|
|
7
8
|
//# sourceMappingURL=socketModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketModule.d.ts","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"socketModule.d.ts","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtD,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAe,CAAC"}
|
package/dist/socketModule.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.SocketIOClientStatic = void 0;
|
|
8
8
|
const socket_io_client_1 = require("socket.io-client");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.SocketIOClientStatic = socket_io_client_1.io;
|
|
9
|
+
const mockify_js_1 = require("./mockify.js");
|
|
10
|
+
exports.SocketIOClientStatic = (0, mockify_js_1.mockify)(socket_io_client_1.io);
|
|
12
11
|
//# sourceMappingURL=socketModule.js.map
|
package/dist/socketModule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketModule.js","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAsC;AAEtC,
|
|
1
|
+
{"version":3,"file":"socketModule.js","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAsC;AAEtC,6CAAsD;AAEzC,QAAA,oBAAoB,GAAwB,IAAA,oBAAO,EAAC,qBAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { io } from \"socket.io-client\";\n\nimport { mockify, type Mockable } from \"./mockify.js\";\n\nexport const SocketIOClientStatic: Mockable<typeof io> = mockify(io);\n"]}
|
package/dist/vroom.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ import { TokenFetchOptionsEx } from "./odspUtils.js";
|
|
|
23
23
|
* This is optional and used only when collab session is being joined by client acting in app-only mode (i.e. without user context).
|
|
24
24
|
* If not specified client display name is extracted from the access token that is used to join session.
|
|
25
25
|
*/
|
|
26
|
-
export declare
|
|
26
|
+
export declare const fetchJoinSession: import("./mockify.js").Mockable<(urlParts: IOdspUrlParts, path: string, method: "GET" | "POST", logger: ITelemetryLoggerExt, getAuthHeader: InstrumentedStorageTokenFetcher, epochTracker: EpochTracker, requestSocketToken: boolean, options: TokenFetchOptionsEx, disableJoinSessionRefresh: boolean | undefined, isRefreshingJoinSession: boolean, displayName: string | undefined) => Promise<ISocketStorageDiscovery>>;
|
|
27
27
|
//# sourceMappingURL=vroom.d.ts.map
|
package/dist/vroom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vroom.d.ts","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,+BAA+B,EAC/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"vroom.d.ts","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,+BAA+B,EAC/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAQrD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,6CAEjB,aAAa,QACjB,MAAM,UACJ,KAAK,GAAG,MAAM,UACd,mBAAmB,iBACZ,+BAA+B,gBAChC,YAAY,sBACN,OAAO,WAClB,mBAAmB,6BACD,OAAO,GAAG,SAAS,2BACrB,OAAO,eACnB,MAAM,GAAG,SAAS,KAC7B,QAAQ,uBAAuB,CAAC,CAqFnC,CAAC"}
|
package/dist/vroom.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.fetchJoinSession = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/telemetry-utils/internal");
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
|
+
const mockify_js_1 = require("./mockify.js");
|
|
10
11
|
const odspUrlHelper_js_1 = require("./odspUrlHelper.js");
|
|
11
12
|
const retryUtils_js_1 = require("./retryUtils.js");
|
|
12
13
|
/**
|
|
@@ -26,7 +27,7 @@ const retryUtils_js_1 = require("./retryUtils.js");
|
|
|
26
27
|
* This is optional and used only when collab session is being joined by client acting in app-only mode (i.e. without user context).
|
|
27
28
|
* If not specified client display name is extracted from the access token that is used to join session.
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
|
+
exports.fetchJoinSession = (0, mockify_js_1.mockify)(async (urlParts, path, method, logger, getAuthHeader, epochTracker, requestSocketToken, options, disableJoinSessionRefresh, isRefreshingJoinSession, displayName) => {
|
|
30
31
|
const apiRoot = (0, odspUrlHelper_js_1.getApiRoot)(new URL(urlParts.siteUrl));
|
|
31
32
|
const url = `${apiRoot}/drives/${urlParts.driveId}/items/${urlParts.itemId}/${path}?ump=1`;
|
|
32
33
|
const authHeader = await getAuthHeader({ ...options, request: { url, method } }, "JoinSession");
|
|
@@ -85,6 +86,5 @@ async function fetchJoinSession(urlParts, path, method, logger, getAuthHeader, e
|
|
|
85
86
|
}
|
|
86
87
|
return response.content;
|
|
87
88
|
});
|
|
88
|
-
}
|
|
89
|
-
exports.fetchJoinSession = fetchJoinSession;
|
|
89
|
+
});
|
|
90
90
|
//# sourceMappingURL=vroom.js.map
|
package/dist/vroom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vroom.js","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,uEAGkD;AAClD,+BAAkC;AAGlC,yDAAgD;AAEhD,mDAA+C;AAO/C;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"vroom.js","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,uEAGkD;AAClD,+BAAkC;AAGlC,6CAAuC;AACvC,yDAAgD;AAEhD,mDAA+C;AAO/C;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAO,EACtC,KAAK,EACJ,QAAuB,EACvB,IAAY,EACZ,MAAsB,EACtB,MAA2B,EAC3B,aAA8C,EAC9C,YAA0B,EAC1B,kBAA2B,EAC3B,OAA4B,EAC5B,yBAA8C,EAC9C,uBAAgC,EAChC,WAA+B,EACI,EAAE;IACrC,MAAM,OAAO,GAAG,IAAA,6BAAU,EAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,GAAG,OAAO,WAAW,QAAQ,CAAC,OAAO,UAAU,QAAQ,CAAC,MAAM,IAAI,IAAI,QAAQ,CAAC;IAC3F,MAAM,UAAU,GAAG,MAAM,aAAa,CACrC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EACxC,aAAa,CACb,CAAC;IAEF,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO;QACxC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE;QAClE,CAAC,CAAC,EAAE,CAAC;IACN,MAAM,OAAO,GAA6B;QACzC,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,kBAA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AAC,mBAAmB,CAC/B,GAAG,EACH,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EACnC,aAAa,EACb,IAAI,CACJ,EACF,aAAa,EACb,MAAM,CACN,CAAC;QAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC;QACxD,kEAAkE;QAClE,MAAM,iBAAiB,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAElD,8BAA8B;QAC9B,KAAK,CAAC,GAAG,CAAC;YACT,GAAG,QAAQ,CAAC,UAAU;YACtB,2CAA2C;YAC3C,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;YACnC,iBAAiB;YACjB,6BAA6B,EAAE,QAAQ,CAAC,OAAO,CAAC,6BAA6B;SAC7E,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,OAAO,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACpE,QAAQ,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC;QAC9D,CAAC;QAED,OAAO,QAAQ,CAAC,OAAO,CAAC;IACzB,CAAC,CACD,CAAC;AACH,CAAC,CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tIOdspUrlParts,\n\tISocketStorageDiscovery,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { mockify } from \"./mockify.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { TokenFetchOptionsEx } from \"./odspUtils.js\";\nimport { runWithRetry } from \"./retryUtils.js\";\n\ninterface IJoinSessionBody {\n\trequestSocketToken?: boolean;\n\tdisplayName?: string;\n}\n\n/**\n * Makes join session call on SPO to get information about the web socket for a document\n * @param urlParts - The SPO drive id, itemId, siteUrl that this request should be made against\n * @param path - The API path that is relevant to this request\n * @param method - The type of request, such as GET or POST\n * @param logger - A logger to use for this request\n * @param getAuthHeader - A function that is able to provide the access token for this request\n * @param epochTracker - fetch wrapper which incorporates epoch logic around joinSession call\n * @param requestSocketToken - flag indicating whether joinSession is expected to return access token\n * which is used when establishing websocket connection with collab session backend service.\n * @param options - Options to fetch the token.\n * @param disableJoinSessionRefresh - Whether the caller wants to disable refreshing join session periodically.\n * @param isRefreshingJoinSession - whether call is to refresh the session before expiry.\n * @param displayName - display name used to identify client joining a session.\n * This is optional and used only when collab session is being joined by client acting in app-only mode (i.e. without user context).\n * If not specified client display name is extracted from the access token that is used to join session.\n */\nexport const fetchJoinSession = mockify(\n\tasync (\n\t\turlParts: IOdspUrlParts,\n\t\tpath: string,\n\t\tmethod: \"GET\" | \"POST\",\n\t\tlogger: ITelemetryLoggerExt,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tepochTracker: EpochTracker,\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tdisableJoinSessionRefresh: boolean | undefined,\n\t\tisRefreshingJoinSession: boolean,\n\t\tdisplayName: string | undefined,\n\t): Promise<ISocketStorageDiscovery> => {\n\t\tconst apiRoot = getApiRoot(new URL(urlParts.siteUrl));\n\t\tconst url = `${apiRoot}/drives/${urlParts.driveId}/items/${urlParts.itemId}/${path}?ump=1`;\n\t\tconst authHeader = await getAuthHeader(\n\t\t\t{ ...options, request: { url, method } },\n\t\t\t\"JoinSession\",\n\t\t);\n\n\t\tconst tokenRefreshProps = options.refresh\n\t\t\t? { hasClaims: !!options.claims, hasTenantId: !!options.tenantId }\n\t\t\t: {};\n\t\tconst details: ITelemetryBaseProperties = {\n\t\t\trefreshedToken: options.refresh,\n\t\t\trequestSocketToken,\n\t\t\t...tokenRefreshProps,\n\t\t\trefreshingSession: isRefreshingJoinSession,\n\t\t};\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"JoinSession\",\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\tdetails: JSON.stringify(details),\n\t\t\t\t...tokenRefreshProps,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tlet postBody = `--${formBoundary}\\r\\n`;\n\t\t\t\tpostBody += `Authorization: ${authHeader}\\r\\n`;\n\t\t\t\tpostBody += `X-HTTP-Method-Override: POST\\r\\n`;\n\t\t\t\tpostBody += `Content-Type: application/json\\r\\n`;\n\t\t\t\tif (!disableJoinSessionRefresh) {\n\t\t\t\t\tpostBody += `prefer: FluidRemoveCheckAccess\\r\\n`;\n\t\t\t\t}\n\t\t\t\tpostBody += `_post: 1\\r\\n`;\n\n\t\t\t\tlet requestBody: IJoinSessionBody | undefined;\n\t\t\t\tif (requestSocketToken) {\n\t\t\t\t\trequestBody = { ...requestBody, requestSocketToken: true };\n\t\t\t\t}\n\t\t\t\tif (displayName) {\n\t\t\t\t\trequestBody = { ...requestBody, displayName };\n\t\t\t\t}\n\t\t\t\tif (requestBody) {\n\t\t\t\t\tpostBody += `\\r\\n${JSON.stringify(requestBody)}\\r\\n`;\n\t\t\t\t}\n\t\t\t\tpostBody += `\\r\\n--${formBoundary}--`;\n\t\t\t\tconst headers: { [index: string]: string } = {\n\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t};\n\n\t\t\t\tconst response = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<ISocketStorageDiscovery>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{ method, headers, body: postBody },\n\t\t\t\t\t\t\t\"joinSession\",\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t),\n\t\t\t\t\t\"joinSession\",\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tconst socketUrl = response.content.deltaStreamSocketUrl;\n\t\t\t\t// expecting socketUrl to be something like https://{hostName}/...\n\t\t\t\tconst webSocketHostName = socketUrl.split(\"/\")[2];\n\n\t\t\t\t// TODO SPO-specific telemetry\n\t\t\t\tevent.end({\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t// pushV2 websocket urls will contain pushf\n\t\t\t\t\tpushv2: socketUrl.includes(\"pushf\"),\n\t\t\t\t\twebSocketHostName,\n\t\t\t\t\trefreshSessionDurationSeconds: response.content.refreshSessionDurationSeconds,\n\t\t\t\t});\n\n\t\t\t\tif (response.content.runtimeTenantId && !response.content.tenantId) {\n\t\t\t\t\tresponse.content.tenantId = response.content.runtimeTenantId;\n\t\t\t\t}\n\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\t},\n);\n"]}
|
package/lib/fetch.d.ts
CHANGED
|
@@ -2,5 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated - Do not use. This is a temporary workaround to allow Pages
|
|
7
|
+
* webpack replacement to continue functioning without error.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fetch: typeof globalThis.fetch;
|
|
6
10
|
//# sourceMappingURL=fetch.d.ts.map
|
package/lib/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,KAAK,yBAAmB,CAAC"}
|
package/lib/fetch.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const fetch =
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated - Do not use. This is a temporary workaround to allow Pages
|
|
7
|
+
* webpack replacement to continue functioning without error.
|
|
8
|
+
*/
|
|
9
|
+
export const fetch = globalThis.fetch;
|
|
10
10
|
//# sourceMappingURL=fetch.js.map
|
package/lib/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @deprecated - Do not use. This is a temporary workaround to allow Pages\n * webpack replacement to continue functioning without error.\n */\nexport const fetch = globalThis.fetch;\n"]}
|
package/lib/fetchSnapshot.d.ts
CHANGED
|
@@ -59,6 +59,6 @@ export declare function validateBlobsAndTrees(snapshot: IOdspSnapshot): void;
|
|
|
59
59
|
* @param epochTracker - epoch tracker used to add/validate epoch in the network call.
|
|
60
60
|
* @returns fetched snapshot.
|
|
61
61
|
*/
|
|
62
|
-
export declare
|
|
62
|
+
export declare const downloadSnapshot: import("./mockify.js").Mockable<(odspResolvedUrl: IOdspResolvedUrl, getAuthHeader: InstrumentedStorageTokenFetcher, tokenFetchOptions: TokenFetchOptionsEx, loadingGroupIds: string[] | undefined, snapshotOptions: ISnapshotOptions | undefined, snapshotFormatFetchType?: SnapshotFormatSupportType, controller?: AbortController, epochTracker?: EpochTracker, scenarioName?: string) => Promise<ISnapshotRequestAndResponseOptions>>;
|
|
63
63
|
export {};
|
|
64
64
|
//# sourceMappingURL=fetchSnapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAUvF,OAAO,EAEN,gBAAgB,EAChB,gBAAgB,EAChB,+BAA+B,EAE/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAKnB,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EACN,aAAa,EAEb,wBAAwB,EAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAUvF,OAAO,EAEN,gBAAgB,EAChB,gBAAgB,EAChB,+BAA+B,EAE/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAKnB,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EACN,aAAa,EAEb,wBAAwB,EAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMjD,OAAO,EACN,aAAa,EASb,KAAK,mBAAmB,EACxB,MAAM,gBAAgB,CAAC;AAGxB;;;;GAIG;AACH,oBAAY,yBAAyB;IACpC,IAAI,IAAI;IACR,MAAM,IAAI;IACV,aAAa,IAAI;CACjB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;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAY3F;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CASnE;AAiBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,oDAEV,gBAAgB,iBAClB,+BAA+B,qBAC3B,mBAAmB,mBACrB,MAAM,EAAE,GAAG,SAAS,mBACpB,gBAAgB,GAAG,SAAS,4BACnB,yBAAyB,eACtC,eAAe,iBACb,YAAY,iBACZ,MAAM,KACnB,QAAQ,kCAAkC,CAAC,CA0E9C,CAAC"}
|
package/lib/fetchSnapshot.js
CHANGED
|
@@ -14,6 +14,7 @@ import { currentReadVersion, parseCompactSnapshotResponse, } from "./compactSnap
|
|
|
14
14
|
import { persistedCacheValueVersion, } from "./contracts.js";
|
|
15
15
|
import { getQueryString } from "./getQueryString.js";
|
|
16
16
|
import { getHeadersWithAuth } from "./getUrlAndHeadersWithAuth.js";
|
|
17
|
+
import { mockify } from "./mockify.js";
|
|
17
18
|
import { convertOdspSnapshotToSnapshotTreeAndBlobs } from "./odspSnapshotParser.js";
|
|
18
19
|
import { checkForKnownServerFarmType } from "./odspUrlHelper.js";
|
|
19
20
|
import { fetchAndParseAsJSONHelper, fetchHelper, getWithRetryForTokenRefresh, getWithRetryForTokenRefreshRepeat, isSnapshotFetchForLoadingGroup, measure, measureP, useLegacyFlowWithoutGroupsForSnapshotFetch, } from "./odspUtils.js";
|
|
@@ -445,13 +446,16 @@ function getTreeStatsCore(snapshotTree, stats) {
|
|
|
445
446
|
* @param epochTracker - epoch tracker used to add/validate epoch in the network call.
|
|
446
447
|
* @returns fetched snapshot.
|
|
447
448
|
*/
|
|
448
|
-
export
|
|
449
|
+
export const downloadSnapshot = mockify(async (odspResolvedUrl, getAuthHeader, tokenFetchOptions, loadingGroupIds, snapshotOptions, snapshotFormatFetchType, controller, epochTracker, scenarioName) => {
|
|
449
450
|
// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51
|
|
450
451
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
451
452
|
const sharingLinkToRedeem = odspResolvedUrl.sharingLinkToRedeem;
|
|
452
453
|
if (sharingLinkToRedeem) {
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
odspResolvedUrl.shareLinkInfo = {
|
|
455
|
+
...odspResolvedUrl.shareLinkInfo,
|
|
456
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
457
|
+
sharingLinkToRedeem,
|
|
458
|
+
};
|
|
455
459
|
}
|
|
456
460
|
const snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;
|
|
457
461
|
const queryParams = { ump: 1 };
|
|
@@ -500,7 +504,7 @@ export async function downloadSnapshot(odspResolvedUrl, getAuthHeader, tokenFetc
|
|
|
500
504
|
requestHeaders: headers,
|
|
501
505
|
requestUrl: url,
|
|
502
506
|
};
|
|
503
|
-
}
|
|
507
|
+
});
|
|
504
508
|
function isRedeemSharingLinkError(odspResolvedUrl, error) {
|
|
505
509
|
if (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&
|
|
506
510
|
typeof error === "object" &&
|