@fluidframework/odsp-driver 2.10.0 → 2.12.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/api-report/odsp-driver.legacy.alpha.api.md +5 -2
  3. package/dist/contracts.d.ts +6 -0
  4. package/dist/contracts.d.ts.map +1 -1
  5. package/dist/contracts.js.map +1 -1
  6. package/dist/createFile/createFile.d.ts +8 -4
  7. package/dist/createFile/createFile.d.ts.map +1 -1
  8. package/dist/createFile/createFile.js +51 -6
  9. package/dist/createFile/createFile.js.map +1 -1
  10. package/dist/createFile/createNewModule.d.ts +1 -1
  11. package/dist/createFile/createNewModule.d.ts.map +1 -1
  12. package/dist/createFile/createNewModule.js +2 -1
  13. package/dist/createFile/createNewModule.js.map +1 -1
  14. package/dist/createFile/createNewUtils.d.ts.map +1 -1
  15. package/dist/createFile/createNewUtils.js +3 -1
  16. package/dist/createFile/createNewUtils.js.map +1 -1
  17. package/dist/createOdspCreateContainerRequest.d.ts +4 -1
  18. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  19. package/dist/createOdspCreateContainerRequest.js +4 -2
  20. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  21. package/dist/epochTracker.d.ts +1 -1
  22. package/dist/epochTracker.d.ts.map +1 -1
  23. package/dist/epochTracker.js.map +1 -1
  24. package/dist/fetchSnapshot.d.ts.map +1 -1
  25. package/dist/fetchSnapshot.js +5 -0
  26. package/dist/fetchSnapshot.js.map +1 -1
  27. package/dist/legacy.d.ts +1 -0
  28. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  29. package/dist/odspDocumentDeltaConnection.js +4 -0
  30. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  31. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  32. package/dist/odspDocumentStorageManager.js +13 -0
  33. package/dist/odspDocumentStorageManager.js.map +1 -1
  34. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  35. package/dist/odspDriverUrlResolverForShareLink.js +7 -35
  36. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  37. package/dist/odspUrlHelper.d.ts +6 -0
  38. package/dist/odspUrlHelper.d.ts.map +1 -1
  39. package/dist/odspUrlHelper.js +18 -1
  40. package/dist/odspUrlHelper.js.map +1 -1
  41. package/dist/odspUtils.d.ts +22 -2
  42. package/dist/odspUtils.d.ts.map +1 -1
  43. package/dist/odspUtils.js +61 -2
  44. package/dist/odspUtils.js.map +1 -1
  45. package/dist/packageVersion.d.ts +1 -1
  46. package/dist/packageVersion.js +1 -1
  47. package/dist/packageVersion.js.map +1 -1
  48. package/lib/contracts.d.ts +6 -0
  49. package/lib/contracts.d.ts.map +1 -1
  50. package/lib/contracts.js.map +1 -1
  51. package/lib/createFile/createFile.d.ts +8 -4
  52. package/lib/createFile/createFile.d.ts.map +1 -1
  53. package/lib/createFile/createFile.js +51 -7
  54. package/lib/createFile/createFile.js.map +1 -1
  55. package/lib/createFile/createNewModule.d.ts +1 -1
  56. package/lib/createFile/createNewModule.d.ts.map +1 -1
  57. package/lib/createFile/createNewModule.js +1 -1
  58. package/lib/createFile/createNewModule.js.map +1 -1
  59. package/lib/createFile/createNewUtils.d.ts.map +1 -1
  60. package/lib/createFile/createNewUtils.js +3 -1
  61. package/lib/createFile/createNewUtils.js.map +1 -1
  62. package/lib/createOdspCreateContainerRequest.d.ts +4 -1
  63. package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
  64. package/lib/createOdspCreateContainerRequest.js +6 -4
  65. package/lib/createOdspCreateContainerRequest.js.map +1 -1
  66. package/lib/epochTracker.d.ts +1 -1
  67. package/lib/epochTracker.d.ts.map +1 -1
  68. package/lib/epochTracker.js.map +1 -1
  69. package/lib/fetchSnapshot.d.ts.map +1 -1
  70. package/lib/fetchSnapshot.js +5 -0
  71. package/lib/fetchSnapshot.js.map +1 -1
  72. package/lib/legacy.d.ts +1 -0
  73. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  74. package/lib/odspDocumentDeltaConnection.js +4 -0
  75. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  76. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  77. package/lib/odspDocumentStorageManager.js +13 -0
  78. package/lib/odspDocumentStorageManager.js.map +1 -1
  79. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  80. package/lib/odspDriverUrlResolverForShareLink.js +8 -36
  81. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  82. package/lib/odspUrlHelper.d.ts +6 -0
  83. package/lib/odspUrlHelper.d.ts.map +1 -1
  84. package/lib/odspUrlHelper.js +16 -0
  85. package/lib/odspUrlHelper.js.map +1 -1
  86. package/lib/odspUtils.d.ts +22 -2
  87. package/lib/odspUtils.d.ts.map +1 -1
  88. package/lib/odspUtils.js +58 -1
  89. package/lib/odspUtils.js.map +1 -1
  90. package/lib/packageVersion.d.ts +1 -1
  91. package/lib/packageVersion.js +1 -1
  92. package/lib/packageVersion.js.map +1 -1
  93. package/package.json +14 -14
  94. package/src/contracts.ts +7 -0
  95. package/src/createFile/createFile.ts +100 -7
  96. package/src/createFile/createNewModule.ts +1 -1
  97. package/src/createFile/createNewUtils.ts +3 -1
  98. package/src/createOdspCreateContainerRequest.ts +9 -3
  99. package/src/epochTracker.ts +2 -1
  100. package/src/fetchSnapshot.ts +5 -0
  101. package/src/odspDocumentDeltaConnection.ts +4 -0
  102. package/src/odspDocumentStorageManager.ts +28 -0
  103. package/src/odspDriverUrlResolverForShareLink.ts +21 -38
  104. package/src/odspUrlHelper.ts +18 -0
  105. package/src/odspUtils.ts +75 -2
  106. package/src/packageVersion.ts +1 -1
@@ -12,8 +12,6 @@ const getFileLink_js_1 = require("./getFileLink.js");
12
12
  const odspDriverUrlResolver_js_1 = require("./odspDriverUrlResolver.js");
13
13
  const odspFluidFileLink_js_1 = require("./odspFluidFileLink.js");
14
14
  const odspUtils_js_1 = require("./odspUtils.js");
15
- // back-compat: GitHub #9653
16
- const isFluidPackage = (pkg) => typeof pkg === "object" && typeof pkg?.name === "string" && typeof pkg?.fluid === "object";
17
15
  /**
18
16
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
19
17
  * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.
@@ -90,6 +88,8 @@ class OdspDriverUrlResolverForShareLink {
90
88
  // If the locator throws some error, then try to resolve the request as it is.
91
89
  }
92
90
  const odspResolvedUrl = await new odspDriverUrlResolver_js_1.OdspDriverUrlResolver().resolve(requestToBeResolved);
91
+ odspResolvedUrl.context = await this.getContext?.(odspResolvedUrl, odspResolvedUrl.dataStorePath ?? "");
92
+ odspResolvedUrl.appName = this.appName;
93
93
  if (isSharingLinkToRedeem) {
94
94
  // We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId
95
95
  // when redeeming the share link during the redeem fallback for trees latest call becomes greater than
@@ -160,42 +160,14 @@ class OdspDriverUrlResolverForShareLink {
160
160
  * @returns The provided base URL appended with odsp-specific locator information
161
161
  */
162
162
  async appendLocatorParams(baseUrl, resolvedUrl, dataStorePath, packageInfoSource) {
163
- const url = new URL(baseUrl);
164
163
  const odspResolvedUrl = (0, odspUtils_js_1.getOdspResolvedUrl)(resolvedUrl);
165
164
  // If the user has passed an empty dataStorePath, then extract it from the resolved url.
166
165
  const actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? "");
167
- let containerPackageName;
168
- if (packageInfoSource && "name" in packageInfoSource) {
169
- containerPackageName = packageInfoSource.name;
170
- // packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails
171
- // TODO: use a stronger type
172
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
173
- }
174
- else if (isFluidPackage(packageInfoSource?.package)) {
175
- // TODO: use a stronger type
176
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
177
- containerPackageName = packageInfoSource?.package.name;
178
- }
179
- else {
180
- // TODO: use a stronger type
181
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
182
- containerPackageName = packageInfoSource?.package;
183
- }
184
- // TODO: use a stronger type
185
- containerPackageName =
186
- containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;
187
- const context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);
188
- (0, odspFluidFileLink_js_1.storeLocatorInOdspUrl)(url, {
189
- siteUrl: odspResolvedUrl.siteUrl,
190
- driveId: odspResolvedUrl.driveId,
191
- itemId: odspResolvedUrl.itemId,
192
- dataStorePath: actualDataStorePath,
193
- appName: this.appName,
194
- containerPackageName,
195
- fileVersion: odspResolvedUrl.fileVersion,
196
- context,
197
- });
198
- return url.href;
166
+ odspResolvedUrl.context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);
167
+ const containerPackageName = (0, odspUtils_js_1.getContainerPackageName)(packageInfoSource) ??
168
+ odspResolvedUrl.codeHint?.containerPackageName;
169
+ odspResolvedUrl.appName = this.appName;
170
+ return (0, odspUtils_js_1.appendNavParam)(baseUrl, odspResolvedUrl, actualDataStorePath, containerPackageName);
199
171
  }
200
172
  /**
201
173
  * Crafts a supported document/driver URL
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAAmE;AAcnE,6DAAoF;AACpF,yDAAmD;AACnD,qDAA+C;AAC/C,yEAAmE;AACnE,iEAIgC;AAChC,iDAAsE;AAkBtE,4BAA4B;AAC5B,MAAM,cAAc,GAAG,CAAC,GAA4B,EAAW,EAAE,CAChE,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,EAAE,IAAI,KAAK,QAAQ,IAAI,OAAO,GAA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AAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACjB,CAAC;CACD;AA9OD,8EA8OC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tIdentityType,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getFileLink } from \"./getFileLink.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport {\n\tgetLocatorFromOdspUrl,\n\tlocatorQueryParamName,\n\tstoreLocatorInOdspUrl,\n} from \"./odspFluidFileLink.js\";\nimport { createOdspLogger, getOdspResolvedUrl } from \"./odspUtils.js\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n * @legacy\n * @alpha\n */\nexport interface ShareLinkFetcherProps {\n\t/**\n\t * Callback method that is used to fetch access token necessary to call API that produces share link\n\t */\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n\t/**\n\t * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n\t */\n\tidentityType: IdentityType;\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 * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n * @legacy\n * @alpha\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly sharingLinkCache = new PromiseCache<string, string>();\n\tprivate readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n\t/**\n\t * Creates url resolver instance\n\t * @param shareLinkFetcherProps - properties used when fetching share link.\n\t * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n\t * getAbsoluteUrl() method requires share link.\n\t * @param logger - logger object that is used as telemetry sink\n\t * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n\t * This hint is used by link handling logic which determines which app to redirect to when user\n\t * navigates directly to the link.\n\t * @param getContext - callback function which is used to get context for given resolved url. If context\n\t * is returned then it will be embedded into url returned by getAbsoluteUrl() method.\n\t */\n\tpublic constructor(\n\t\tshareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tprivate readonly appName?: string,\n\t\tprivate readonly getContext?: (\n\t\t\tresolvedUrl: IOdspResolvedUrl,\n\t\t\tdataStorePath: string,\n\t\t) => Promise<string | undefined>,\n\t) {\n\t\tthis.logger = createOdspLogger(logger);\n\t\tif (shareLinkFetcherProps) {\n\t\t\tthis.shareLinkFetcherProps = {\n\t\t\t\t...shareLinkFetcherProps,\n\t\t\t\ttokenFetcher: shareLinkFetcherProps.tokenFetcher,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Takes an already generated data store url (from requestUrl) and appends a path to the\n\t * existing data store information.\n\t */\n\tpublic appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n\t\tconst fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n\t\tif (!fluidInfo) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parsingUrl = new URL(\n\t\t\tfluidInfo.dataStorePath,\n\t\t\t`${requestUrl.protocol}//${requestUrl.hostname}`,\n\t\t);\n\t\t// Determine if the caller is passing a query parameter or path since processing will be different.\n\t\tif (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n\t\t\tconst queryParams = new URLSearchParams(pathToAppend);\n\t\t\tfor (const [key, value] of queryParams.entries()) {\n\t\t\t\tparsingUrl.searchParams.append(key, value);\n\t\t\t}\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n\t\t} else {\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${\n\t\t\t\tparsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n\t\t\t}${pathToAppend}/${parsingUrl.search}`;\n\t\t}\n\t\tstoreLocatorInOdspUrl(requestUrl, fluidInfo);\n\n\t\treturn requestUrl.href;\n\t}\n\n\tprivate getKey(resolvedUrl: IOdspResolvedUrl): string {\n\t\treturn `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n\t}\n\n\t/**\n\t * Resolves request URL into driver details\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tconst requestToBeResolved = { headers: request.headers, url: request.url };\n\t\tconst isSharingLinkToRedeem =\n\t\t\trequestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n\t\ttry {\n\t\t\tconst url = new URL(request.url);\n\n\t\t\tconst odspFluidInfo = getLocatorFromOdspUrl(url);\n\t\t\tif (odspFluidInfo) {\n\t\t\t\trequestToBeResolved.url = createOdspUrl(odspFluidInfo);\n\t\t\t}\n\t\t} catch {\n\t\t\t// If the locator throws some error, then try to resolve the request as it is.\n\t\t}\n\n\t\tconst odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n\t\tif (isSharingLinkToRedeem) {\n\t\t\t// We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n\t\t\t// when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n\t\t\t// the eligible length.\n\t\t\todspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo ?? {}, {\n\t\t\t\tsharingLinkToRedeem: this.removeNavParam(request.url),\n\t\t\t});\n\t\t}\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\t// Kick start the sharing link request if we don't have it already as a performance optimization.\n\t\t\t// For detached create new, we don't have an item id yet and therefore cannot generate a share link\n\t\t\tthis.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n\t\t}\n\t\treturn odspResolvedUrl;\n\t}\n\n\tprivate removeNavParam(link: string): string {\n\t\tconst url = new URL(link);\n\t\tconst params = new URLSearchParams(url.search);\n\t\tparams.delete(locatorQueryParamName);\n\t\turl.search = params.toString();\n\t\treturn url.href;\n\t}\n\n\tprivate async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n\t\tif (this.shareLinkFetcherProps === undefined) {\n\t\t\tthrow new Error(\"Failed to get share link because share link fetcher props are missing\");\n\t\t}\n\n\t\tif (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to get share link because necessary information is missing \" +\n\t\t\t\t\t\"(e.g. siteUrl, driveId or itemId)\",\n\t\t\t);\n\t\t}\n\n\t\tconst key = this.getKey(resolvedUrl);\n\t\tconst cachedLinkPromise = this.sharingLinkCache.get(key);\n\t\tif (cachedLinkPromise) {\n\t\t\treturn cachedLinkPromise;\n\t\t}\n\t\tconst newLinkPromise = getFileLink(\n\t\t\tthis.shareLinkFetcherProps.tokenFetcher,\n\t\t\tresolvedUrl,\n\t\t\tthis.logger,\n\t\t).catch((error) => {\n\t\t\t// This should imply that error is a non-retriable error.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n\t\t\tthis.sharingLinkCache.remove(key);\n\t\t\tthrow error;\n\t\t});\n\t\tthis.sharingLinkCache.add(key, async () => newLinkPromise);\n\t\treturn newLinkPromise;\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n\t * and it will throw in case share link fetcher props were not specified when instance was created.\n\t * @param resolvedUrl - The driver resolved URL\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tconst shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n\n\t\treturn this.appendLocatorParams(shareLink, resolvedUrl, dataStorePath, packageInfoSource);\n\t}\n\n\t/**\n\t * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n\t * 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\t * to load the file later.\n\t * @param baseUrl - The input URL on which the locator params will be appended.\n\t * @param resolvedUrl - odsp-driver's resolvedURL object.\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @returns The provided base URL appended with odsp-specific locator information\n\t */\n\tpublic async appendLocatorParams(\n\t\tbaseUrl: string,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst url = new URL(baseUrl);\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\t\tlet containerPackageName: string | undefined;\n\t\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\t\tcontainerPackageName = packageInfoSource.name;\n\t\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t\t// TODO: use a stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\t// TODO: use a stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\t// TODO: use a stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\t// TODO: use a stronger type\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\tconst context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);\n\n\t\tstoreLocatorInOdspUrl(url, {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\tdataStorePath: actualDataStorePath,\n\t\t\tappName: this.appName,\n\t\t\tcontainerPackageName,\n\t\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\t\tcontext,\n\t\t});\n\n\t\treturn url.href;\n\t}\n\n\t/**\n\t * Crafts a supported document/driver URL\n\t */\n\tpublic static createDocumentUrl(\n\t\tbaseUrl: string,\n\t\tdriverInfo: OdspFluidDataStoreLocator,\n\t): string {\n\t\tconst url = new URL(baseUrl);\n\n\t\tstoreLocatorInOdspUrl(url, driverInfo);\n\n\t\treturn url.href;\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["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E,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC3F,CAAC;IAED;;;;;;;;;;OAUG;IACI,KAAK,CAAC,mBAAmB,CAC/B,OAAe,EACf,WAAyB,EACzB,aAAqB,EACrB,iBAAyC;QAEzC,MAAM,eAAe,GAAG,IAAA,iCAAkB,EAAC,WAAW,CAAC,CAAC;QAExD,wFAAwF;QACxF,MAAM,mBAAmB,GAAG,aAAa,IAAI,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;QAEnF,eAAe,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;QAExF,MAAM,oBAAoB,GACzB,IAAA,sCAAuB,EAAC,iBAAiB,CAAC;YAC1C,eAAe,CAAC,QAAQ,EAAE,oBAAoB,CAAC;QAEhD,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAEvC,OAAO,IAAA,6BAAc,EAAC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;IAC5F,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB,CAC9B,OAAe,EACf,UAAqC;QAErC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAE7B,IAAA,4CAAqB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACjB,CAAC;CACD;AA5ND,8EA4NC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tIdentityType,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getFileLink } from \"./getFileLink.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport {\n\tgetLocatorFromOdspUrl,\n\tlocatorQueryParamName,\n\tstoreLocatorInOdspUrl,\n} from \"./odspFluidFileLink.js\";\nimport {\n\tappendNavParam,\n\tcreateOdspLogger,\n\tgetOdspResolvedUrl,\n\tgetContainerPackageName,\n} from \"./odspUtils.js\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n * @legacy\n * @alpha\n */\nexport interface ShareLinkFetcherProps {\n\t/**\n\t * Callback method that is used to fetch access token necessary to call API that produces share link\n\t */\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n\t/**\n\t * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n\t */\n\tidentityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n * @legacy\n * @alpha\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly sharingLinkCache = new PromiseCache<string, string>();\n\tprivate readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n\t/**\n\t * Creates url resolver instance\n\t * @param shareLinkFetcherProps - properties used when fetching share link.\n\t * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n\t * getAbsoluteUrl() method requires share link.\n\t * @param logger - logger object that is used as telemetry sink\n\t * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n\t * This hint is used by link handling logic which determines which app to redirect to when user\n\t * navigates directly to the link.\n\t * @param getContext - callback function which is used to get context for given resolved url. If context\n\t * is returned then it will be embedded into url returned by getAbsoluteUrl() method.\n\t */\n\tpublic constructor(\n\t\tshareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tprivate readonly appName?: string,\n\t\tprivate readonly getContext?: (\n\t\t\tresolvedUrl: IOdspResolvedUrl,\n\t\t\tdataStorePath: string,\n\t\t) => Promise<string | undefined>,\n\t) {\n\t\tthis.logger = createOdspLogger(logger);\n\t\tif (shareLinkFetcherProps) {\n\t\t\tthis.shareLinkFetcherProps = {\n\t\t\t\t...shareLinkFetcherProps,\n\t\t\t\ttokenFetcher: shareLinkFetcherProps.tokenFetcher,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Takes an already generated data store url (from requestUrl) and appends a path to the\n\t * existing data store information.\n\t */\n\tpublic appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n\t\tconst fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n\t\tif (!fluidInfo) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parsingUrl = new URL(\n\t\t\tfluidInfo.dataStorePath,\n\t\t\t`${requestUrl.protocol}//${requestUrl.hostname}`,\n\t\t);\n\t\t// Determine if the caller is passing a query parameter or path since processing will be different.\n\t\tif (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n\t\t\tconst queryParams = new URLSearchParams(pathToAppend);\n\t\t\tfor (const [key, value] of queryParams.entries()) {\n\t\t\t\tparsingUrl.searchParams.append(key, value);\n\t\t\t}\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n\t\t} else {\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${\n\t\t\t\tparsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n\t\t\t}${pathToAppend}/${parsingUrl.search}`;\n\t\t}\n\t\tstoreLocatorInOdspUrl(requestUrl, fluidInfo);\n\n\t\treturn requestUrl.href;\n\t}\n\n\tprivate getKey(resolvedUrl: IOdspResolvedUrl): string {\n\t\treturn `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n\t}\n\n\t/**\n\t * Resolves request URL into driver details\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tconst requestToBeResolved = { headers: request.headers, url: request.url };\n\t\tconst isSharingLinkToRedeem =\n\t\t\trequestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n\t\ttry {\n\t\t\tconst url = new URL(request.url);\n\n\t\t\tconst odspFluidInfo = getLocatorFromOdspUrl(url);\n\t\t\tif (odspFluidInfo) {\n\t\t\t\trequestToBeResolved.url = createOdspUrl(odspFluidInfo);\n\t\t\t}\n\t\t} catch {\n\t\t\t// If the locator throws some error, then try to resolve the request as it is.\n\t\t}\n\n\t\tconst odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n\t\todspResolvedUrl.context = await this.getContext?.(\n\t\t\todspResolvedUrl,\n\t\t\todspResolvedUrl.dataStorePath ?? \"\",\n\t\t);\n\n\t\todspResolvedUrl.appName = this.appName;\n\n\t\tif (isSharingLinkToRedeem) {\n\t\t\t// We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n\t\t\t// when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n\t\t\t// the eligible length.\n\t\t\todspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo ?? {}, {\n\t\t\t\tsharingLinkToRedeem: this.removeNavParam(request.url),\n\t\t\t});\n\t\t}\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\t// Kick start the sharing link request if we don't have it already as a performance optimization.\n\t\t\t// For detached create new, we don't have an item id yet and therefore cannot generate a share link\n\t\t\tthis.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n\t\t}\n\t\treturn odspResolvedUrl;\n\t}\n\n\tprivate removeNavParam(link: string): string {\n\t\tconst url = new URL(link);\n\t\tconst params = new URLSearchParams(url.search);\n\t\tparams.delete(locatorQueryParamName);\n\t\turl.search = params.toString();\n\t\treturn url.href;\n\t}\n\n\tprivate async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n\t\tif (this.shareLinkFetcherProps === undefined) {\n\t\t\tthrow new Error(\"Failed to get share link because share link fetcher props are missing\");\n\t\t}\n\n\t\tif (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to get share link because necessary information is missing \" +\n\t\t\t\t\t\"(e.g. siteUrl, driveId or itemId)\",\n\t\t\t);\n\t\t}\n\n\t\tconst key = this.getKey(resolvedUrl);\n\t\tconst cachedLinkPromise = this.sharingLinkCache.get(key);\n\t\tif (cachedLinkPromise) {\n\t\t\treturn cachedLinkPromise;\n\t\t}\n\t\tconst newLinkPromise = getFileLink(\n\t\t\tthis.shareLinkFetcherProps.tokenFetcher,\n\t\t\tresolvedUrl,\n\t\t\tthis.logger,\n\t\t).catch((error) => {\n\t\t\t// This should imply that error is a non-retriable error.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n\t\t\tthis.sharingLinkCache.remove(key);\n\t\t\tthrow error;\n\t\t});\n\t\tthis.sharingLinkCache.add(key, async () => newLinkPromise);\n\t\treturn newLinkPromise;\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n\t * and it will throw in case share link fetcher props were not specified when instance was created.\n\t * @param resolvedUrl - The driver resolved URL\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tconst shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n\n\t\treturn this.appendLocatorParams(shareLink, resolvedUrl, dataStorePath, packageInfoSource);\n\t}\n\n\t/**\n\t * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n\t * 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\t * to load the file later.\n\t * @param baseUrl - The input URL on which the locator params will be appended.\n\t * @param resolvedUrl - odsp-driver's resolvedURL object.\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @returns The provided base URL appended with odsp-specific locator information\n\t */\n\tpublic async appendLocatorParams(\n\t\tbaseUrl: string,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\t\todspResolvedUrl.context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);\n\n\t\tconst containerPackageName: string | undefined =\n\t\t\tgetContainerPackageName(packageInfoSource) ??\n\t\t\todspResolvedUrl.codeHint?.containerPackageName;\n\n\t\todspResolvedUrl.appName = this.appName;\n\n\t\treturn appendNavParam(baseUrl, odspResolvedUrl, actualDataStorePath, containerPackageName);\n\t}\n\n\t/**\n\t * Crafts a supported document/driver URL\n\t */\n\tpublic static createDocumentUrl(\n\t\tbaseUrl: string,\n\t\tdriverInfo: OdspFluidDataStoreLocator,\n\t): string {\n\t\tconst url = new URL(baseUrl);\n\n\t\tstoreLocatorInOdspUrl(url, driverInfo);\n\n\t\treturn url.href;\n\t}\n}\n"]}
@@ -34,4 +34,10 @@ export declare function isOdcUrl(url: URL): boolean;
34
34
  * @internal
35
35
  */
36
36
  export declare function getOdspUrlParts(url: URL): Promise<IOdspUrlParts | undefined>;
37
+ /**
38
+ * Inspect the ODSP siteUrl to guess if this document is in SPDF or MSIT, to aid livesite investigations
39
+ * @param urlOnSite - The URL of the site or a resource on the site
40
+ * @returns undefined if the URL doesn't match known SPDF/MSIT patterns, "SPDF" if it's SPDF, "MSIT" if it's MSIT
41
+ */
42
+ export declare function checkForKnownServerFarmType(urlOnSite: string): "SPDF" | "MSIT" | undefined;
37
43
  //# sourceMappingURL=odspUrlHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspUrlHelper.d.ts","sourceRoot":"","sources":["../src/odspUrlHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AAIjF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAW9C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAO3C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAM1C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAe1C;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA6ClF"}
1
+ {"version":3,"file":"odspUrlHelper.d.ts","sourceRoot":"","sources":["../src/odspUrlHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AAIjF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAW9C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAO3C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAM1C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAe1C;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA6ClF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAW1F"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getOdspUrlParts = exports.isOdcUrl = exports.isSpoUrl = exports.getApiRoot = exports.hasOdcOrigin = void 0;
7
+ exports.checkForKnownServerFarmType = exports.getOdspUrlParts = exports.isOdcUrl = exports.isSpoUrl = exports.getApiRoot = exports.hasOdcOrigin = void 0;
8
8
  // Centralized store for all ODC/SPO logic
9
9
  /**
10
10
  * Checks whether or not the given URL has an ODC origin
@@ -111,4 +111,21 @@ async function getOdspUrlParts(url) {
111
111
  }
112
112
  }
113
113
  exports.getOdspUrlParts = getOdspUrlParts;
114
+ /**
115
+ * Inspect the ODSP siteUrl to guess if this document is in SPDF or MSIT, to aid livesite investigations
116
+ * @param urlOnSite - The URL of the site or a resource on the site
117
+ * @returns undefined if the URL doesn't match known SPDF/MSIT patterns, "SPDF" if it's SPDF, "MSIT" if it's MSIT
118
+ */
119
+ function checkForKnownServerFarmType(urlOnSite) {
120
+ const domain = new URL(urlOnSite).hostname.toLowerCase();
121
+ if (domain.endsWith(".sharepoint-df.com")) {
122
+ return "SPDF";
123
+ }
124
+ else if (domain === "microsoft.sharepoint.com" ||
125
+ domain === "microsoft-my.sharepoint.com") {
126
+ return "MSIT";
127
+ }
128
+ return undefined;
129
+ }
130
+ exports.checkForKnownServerFarmType = checkForKnownServerFarmType;
114
131
  //# sourceMappingURL=odspUrlHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspUrlHelper.js","sourceRoot":"","sources":["../src/odspUrlHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0CAA0C;AAE1C;;;;GAIG;AACH,SAAgB,YAAY,CAAC,GAAQ;IACpC,OAAO;IACN,kDAAkD;IAClD,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;QACnC,8BAA8B;QAC9B,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACvC,WAAW;QACX,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QAC3C,iBAAiB;QACjB,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CACvC,CAAC;AACH,CAAC;AAXD,oCAWC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAQ;IAClC,IAAI,MAAM,GAAG,OAAO,CAAC;IACrB,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,GAAG,EAAE,CAAC;IACb,CAAC;IAED,OAAO,GAAG,GAAG,CAAC,MAAM,IAAI,MAAM,MAAM,CAAC;AACtC,CAAC;AAPD,gCAOC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,GAAQ;IAChC,2FAA2F;IAC3F,MAAM,SAAS,GAAG,4BAA4B,CAAC;IAC/C,MAAM,SAAS,GAAG,6CAA6C,CAAC;IAEhE,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7F,CAAC;AAND,4BAMC;AAED;;;;GAIG;AACH,SAA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G,GAAG,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrE,CAAC;SAAM,CAAC;QACP,gBAAgB,GAAG,wDAAwD,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE3F,IAAI,gBAAgB,KAAK,IAAI,EAAE,CAAC;YAC/B,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAEnC,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrE,CAAC;AACF,CAAC;AA7CD,0CA6CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions/internal\";\n\n// Centralized store for all ODC/SPO logic\n\n/**\n * Checks whether or not the given URL has an ODC origin\n * @param url - The URL to check\n * @internal\n */\nexport function hasOdcOrigin(url: URL): boolean {\n\treturn (\n\t\t// Primary API endpoint and several test endpoints\n\t\turl.origin.endsWith(\"onedrive.com\") ||\n\t\t// *storage.live.com hostnames\n\t\turl.origin.endsWith(\"storage.live.com\") ||\n\t\t// live-int\n\t\turl.origin.endsWith(\"storage.live-int.com\") ||\n\t\t// Test endpoints\n\t\turl.origin.endsWith(\"onedrive-tst.com\")\n\t);\n}\n\n/**\n * Gets the correct API root for the given ODSP url, e.g. 'https://foo-my.sharepoint.com/_api/v2.1'\n * @param url - The URL\n * @internal\n */\nexport function getApiRoot(url: URL): string {\n\tlet prefix = \"_api/\";\n\tif (hasOdcOrigin(url)) {\n\t\tprefix = \"\";\n\t}\n\n\treturn `${url.origin}/${prefix}v2.1`;\n}\n\n/**\n * Whether or not the given URL is a valid SPO/ODB URL\n * @param url - The URL to check\n * @internal\n */\nexport function isSpoUrl(url: URL): boolean {\n\t// Format: foo.sharepoint.com/_api/v2.1./drives/bar/items/baz and foo.sharepoint-df.com/...\n\tconst hostRegex = /\\.sharepoint(?:-df)?\\.com$/;\n\tconst pathRegex = /^\\/_api\\/v2\\.1\\/drives\\/[^/]+\\/items\\/[^/]+/;\n\n\treturn hostRegex.test(url.host.toLowerCase()) && pathRegex.test(url.pathname.toLowerCase());\n}\n\n/**\n * Whether or not the given URL is a valid ODC URL\n * @param url - The URL to check\n * @internal\n */\nexport function isOdcUrl(url: URL): boolean {\n\tif (!hasOdcOrigin(url)) {\n\t\treturn false;\n\t}\n\n\tconst path = url.pathname.toLowerCase();\n\n\t// Splitting the regexes so we don't have regex soup\n\t// Format: /v2.1/drive/items/ABC123!123 and /v2.1/drives/ABC123/items/ABC123!123\n\tconst odcRegex = /^\\/v2\\.1\\/(?:drive|drives\\/[^/]+)\\/items\\/[\\dA-Za-z]+!\\d+/;\n\n\t// Format: /v2.1/drives('ABC123')/items('ABC123!123')\n\tconst odcODataRegex = /^\\/v2\\.1\\/drives\\('[^/]+'\\)\\/items\\('[\\dA-Za-z]+!\\d+'\\)/;\n\n\treturn odcRegex.test(path) || odcODataRegex.test(path);\n}\n\n/**\n * Breaks an ODSP URL into its parts, extracting the site, drive ID, and item ID.\n * Returns undefined for invalid/malformed URLs.\n * @param url - The (raw) URL to parse\n * @internal\n */\nexport async function getOdspUrlParts(url: URL): Promise<IOdspUrlParts | undefined> {\n\tconst pathname = url.pathname;\n\n\t// Joinsession like URL\n\t// Pick a regex based on the hostname\n\t// TODO This will only support ODC using api.onedrive.com, update to handle the future (share links etc)\n\tlet joinSessionMatch: RegExpExecArray | null;\n\tif (hasOdcOrigin(url)) {\n\t\t// Capture groups:\n\t\t// 0: match\n\t\t// 1: origin\n\t\t// 2: optional `drives` capture (the `/drives/<DRIVEID>` API format vs `/drive`)\n\t\t// 3: optional captured drive ID\n\t\t// 4: Item ID\n\t\t// 5: Drive ID portion of Item ID\n\t\tjoinSessionMatch =\n\t\t\t/(.*)\\/v2\\.1\\/drive(s\\/([\\dA-Za-z]+))?\\/items\\/(([\\dA-Za-z]+)!\\d+)/.exec(pathname);\n\n\t\tif (joinSessionMatch === null) {\n\t\t\t// Try again but with the OData format ( `/drives('ABC123')/items('ABC123!456')` )\n\t\t\tjoinSessionMatch =\n\t\t\t\t/(.*)\\/v2\\.1\\/drives\\('([\\dA-Za-z]+)'\\)\\/items\\('(([\\dA-Za-z]+)!\\d+)'\\)/.exec(\n\t\t\t\t\tpathname,\n\t\t\t\t);\n\n\t\t\tif (joinSessionMatch === null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst driveId = joinSessionMatch[3] || joinSessionMatch[5];\n\t\tconst itemId = joinSessionMatch[4];\n\n\t\treturn { siteUrl: `${url.origin}${url.pathname}`, driveId, itemId };\n\t} else {\n\t\tjoinSessionMatch = /(.*)\\/_api\\/v2\\.1\\/drives\\/([^/]*)\\/items\\/([^/]*)(.*)/.exec(pathname);\n\n\t\tif (joinSessionMatch === null) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst driveId = joinSessionMatch[2];\n\t\tconst itemId = joinSessionMatch[3];\n\n\t\treturn { siteUrl: `${url.origin}${url.pathname}`, driveId, itemId };\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspUrlHelper.js","sourceRoot":"","sources":["../src/odspUrlHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0CAA0C;AAE1C;;;;GAIG;AACH,SAAgB,YAAY,CAAC,GAAQ;IACpC,OAAO;IACN,kDAAkD;IAClD,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;QACnC,8BAA8B;QAC9B,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACvC,WAAW;QACX,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QAC3C,iBAAiB;QACjB,G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,CAAC,SAAiB;IAC5D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACzD,IAAI,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC3C,OAAO,MAAM,CAAC;IACf,CAAC;SAAM,IACN,MAAM,KAAK,0BAA0B;QACrC,MAAM,KAAK,6BAA6B,EACvC,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAXD,kEAWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions/internal\";\n\n// Centralized store for all ODC/SPO logic\n\n/**\n * Checks whether or not the given URL has an ODC origin\n * @param url - The URL to check\n * @internal\n */\nexport function hasOdcOrigin(url: URL): boolean {\n\treturn (\n\t\t// Primary API endpoint and several test endpoints\n\t\turl.origin.endsWith(\"onedrive.com\") ||\n\t\t// *storage.live.com hostnames\n\t\turl.origin.endsWith(\"storage.live.com\") ||\n\t\t// live-int\n\t\turl.origin.endsWith(\"storage.live-int.com\") ||\n\t\t// Test endpoints\n\t\turl.origin.endsWith(\"onedrive-tst.com\")\n\t);\n}\n\n/**\n * Gets the correct API root for the given ODSP url, e.g. 'https://foo-my.sharepoint.com/_api/v2.1'\n * @param url - The URL\n * @internal\n */\nexport function getApiRoot(url: URL): string {\n\tlet prefix = \"_api/\";\n\tif (hasOdcOrigin(url)) {\n\t\tprefix = \"\";\n\t}\n\n\treturn `${url.origin}/${prefix}v2.1`;\n}\n\n/**\n * Whether or not the given URL is a valid SPO/ODB URL\n * @param url - The URL to check\n * @internal\n */\nexport function isSpoUrl(url: URL): boolean {\n\t// Format: foo.sharepoint.com/_api/v2.1./drives/bar/items/baz and foo.sharepoint-df.com/...\n\tconst hostRegex = /\\.sharepoint(?:-df)?\\.com$/;\n\tconst pathRegex = /^\\/_api\\/v2\\.1\\/drives\\/[^/]+\\/items\\/[^/]+/;\n\n\treturn hostRegex.test(url.host.toLowerCase()) && pathRegex.test(url.pathname.toLowerCase());\n}\n\n/**\n * Whether or not the given URL is a valid ODC URL\n * @param url - The URL to check\n * @internal\n */\nexport function isOdcUrl(url: URL): boolean {\n\tif (!hasOdcOrigin(url)) {\n\t\treturn false;\n\t}\n\n\tconst path = url.pathname.toLowerCase();\n\n\t// Splitting the regexes so we don't have regex soup\n\t// Format: /v2.1/drive/items/ABC123!123 and /v2.1/drives/ABC123/items/ABC123!123\n\tconst odcRegex = /^\\/v2\\.1\\/(?:drive|drives\\/[^/]+)\\/items\\/[\\dA-Za-z]+!\\d+/;\n\n\t// Format: /v2.1/drives('ABC123')/items('ABC123!123')\n\tconst odcODataRegex = /^\\/v2\\.1\\/drives\\('[^/]+'\\)\\/items\\('[\\dA-Za-z]+!\\d+'\\)/;\n\n\treturn odcRegex.test(path) || odcODataRegex.test(path);\n}\n\n/**\n * Breaks an ODSP URL into its parts, extracting the site, drive ID, and item ID.\n * Returns undefined for invalid/malformed URLs.\n * @param url - The (raw) URL to parse\n * @internal\n */\nexport async function getOdspUrlParts(url: URL): Promise<IOdspUrlParts | undefined> {\n\tconst pathname = url.pathname;\n\n\t// Joinsession like URL\n\t// Pick a regex based on the hostname\n\t// TODO This will only support ODC using api.onedrive.com, update to handle the future (share links etc)\n\tlet joinSessionMatch: RegExpExecArray | null;\n\tif (hasOdcOrigin(url)) {\n\t\t// Capture groups:\n\t\t// 0: match\n\t\t// 1: origin\n\t\t// 2: optional `drives` capture (the `/drives/<DRIVEID>` API format vs `/drive`)\n\t\t// 3: optional captured drive ID\n\t\t// 4: Item ID\n\t\t// 5: Drive ID portion of Item ID\n\t\tjoinSessionMatch =\n\t\t\t/(.*)\\/v2\\.1\\/drive(s\\/([\\dA-Za-z]+))?\\/items\\/(([\\dA-Za-z]+)!\\d+)/.exec(pathname);\n\n\t\tif (joinSessionMatch === null) {\n\t\t\t// Try again but with the OData format ( `/drives('ABC123')/items('ABC123!456')` )\n\t\t\tjoinSessionMatch =\n\t\t\t\t/(.*)\\/v2\\.1\\/drives\\('([\\dA-Za-z]+)'\\)\\/items\\('(([\\dA-Za-z]+)!\\d+)'\\)/.exec(\n\t\t\t\t\tpathname,\n\t\t\t\t);\n\n\t\t\tif (joinSessionMatch === null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tconst driveId = joinSessionMatch[3] || joinSessionMatch[5];\n\t\tconst itemId = joinSessionMatch[4];\n\n\t\treturn { siteUrl: `${url.origin}${url.pathname}`, driveId, itemId };\n\t} else {\n\t\tjoinSessionMatch = /(.*)\\/_api\\/v2\\.1\\/drives\\/([^/]*)\\/items\\/([^/]*)(.*)/.exec(pathname);\n\n\t\tif (joinSessionMatch === null) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst driveId = joinSessionMatch[2];\n\t\tconst itemId = joinSessionMatch[3];\n\n\t\treturn { siteUrl: `${url.origin}${url.pathname}`, driveId, itemId };\n\t}\n}\n\n/**\n * Inspect the ODSP siteUrl to guess if this document is in SPDF or MSIT, to aid livesite investigations\n * @param urlOnSite - The URL of the site or a resource on the site\n * @returns undefined if the URL doesn't match known SPDF/MSIT patterns, \"SPDF\" if it's SPDF, \"MSIT\" if it's MSIT\n */\nexport function checkForKnownServerFarmType(urlOnSite: string): \"SPDF\" | \"MSIT\" | undefined {\n\tconst domain = new URL(urlOnSite).hostname.toLowerCase();\n\tif (domain.endsWith(\".sharepoint-df.com\")) {\n\t\treturn \"SPDF\";\n\t} else if (\n\t\tdomain === \"microsoft.sharepoint.com\" ||\n\t\tdomain === \"microsoft-my.sharepoint.com\"\n\t) {\n\t\treturn \"MSIT\";\n\t}\n\treturn undefined;\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ITelemetryBaseLogger, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
6
- import { IResolvedUrl, ISnapshot } from "@fluidframework/driver-definitions/internal";
6
+ import { IResolvedUrl, ISnapshot, IContainerPackageInfo } from "@fluidframework/driver-definitions/internal";
7
7
  import { ICacheEntry, IOdspResolvedUrl, IOdspUrlParts, ISharingLinkKind, InstrumentedStorageTokenFetcher, InstrumentedTokenFetcher, OdspResourceTokenFetchOptions, TokenFetcher } from "@fluidframework/odsp-driver-definitions/internal";
8
8
  import { type IConfigProvider, ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
9
9
  import { ISnapshotContents } from "./odspPublicUtils.js";
@@ -75,7 +75,8 @@ export declare function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspReso
75
75
  /**
76
76
  * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}
77
77
  * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.
78
- * @internal
78
+ * @legacy
79
+ * @alpha
79
80
  */
80
81
  export declare function isOdspResolvedUrl(resolvedUrl: IResolvedUrl): resolvedUrl is IOdspResolvedUrl;
81
82
  export declare const createOdspLogger: (logger?: ITelemetryBaseLogger) => ITelemetryLoggerExt;
@@ -116,4 +117,23 @@ export declare function isInstanceOfISnapshot(obj: ISnapshotContents | ISnapshot
116
117
  */
117
118
  export declare function isSnapshotFetchForLoadingGroup(loadingGroupIds: string[] | undefined): boolean;
118
119
  export declare function useLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds: string[] | undefined): boolean;
120
+ /**
121
+ * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application
122
+ * 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
123
+ * to load the file later.
124
+ * @param baseUrl - The input URL on which the locator params will be appended.
125
+ * @param resolvedUrl - odsp-driver's resolvedURL object.
126
+ * @param dataStorePath - The relative data store path URL.
127
+ * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath
128
+ * will be extracted from the resolved url if present.
129
+ * @param containerPackageName - Name of the package to be included in the URL.
130
+ * @returns The provided base URL appended with odsp-specific locator information
131
+ */
132
+ export declare function appendNavParam(baseUrl: string, odspResolvedUrl: IOdspResolvedUrl, dataStorePath: string, containerPackageName?: string): string;
133
+ /**
134
+ * Returns the package name of the container package information.
135
+ * @param packageInfoSource - Information of the package connected to the URL
136
+ * @returns The package name of the container package
137
+ */
138
+ export declare function getContainerPackageName(packageInfoSource: IContainerPackageInfo | undefined): string | undefined;
119
139
  //# sourceMappingURL=odspUtils.d.ts.map
@@ -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,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AActF,OAAO,EACN,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,+BAA+B,EAC/B,wBAAwB,EAGxB,6BAA6B,EAE7B,YAAY,EAKZ,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,KAAK,eAAe,EAEpB,mBAAmB,EAKnB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,eAAO,MAAM,iCAAiC,sCAAsC,CAAC;AAErF;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,UAAU,EAAE,wBAAwB,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG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AElB;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC7C,eAAe,EAAE,MAAM,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
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.useLegacyFlowWithoutGroupsForSnapshotFetch = exports.isSnapshotFetchForLoadingGroup = exports.isInstanceOfISnapshot = exports.getJoinSessionCacheKey = exports.measureP = exports.measure = exports.buildOdspShareLinkReqParams = exports.maxUmpPostBodySize = exports.snapshotWithLoadingGroupIdSupported = exports.createCacheSnapshotKey = exports.toInstrumentedOdspTokenFetcher = exports.toInstrumentedOdspStorageTokenFetcher = exports.createOdspLogger = exports.isOdspResolvedUrl = exports.getOdspResolvedUrl = exports.isNewFileInfo = exports.fetchAndParseAsJSONHelper = exports.fetchArray = exports.fetchHelper = exports.getWithRetryForTokenRefresh = exports.getWithRetryForTokenRefreshRepeat = void 0;
7
+ exports.getContainerPackageName = exports.appendNavParam = exports.useLegacyFlowWithoutGroupsForSnapshotFetch = exports.isSnapshotFetchForLoadingGroup = exports.isInstanceOfISnapshot = exports.getJoinSessionCacheKey = exports.measureP = exports.measure = exports.buildOdspShareLinkReqParams = exports.maxUmpPostBodySize = exports.snapshotWithLoadingGroupIdSupported = exports.createCacheSnapshotKey = exports.toInstrumentedOdspTokenFetcher = exports.toInstrumentedOdspStorageTokenFetcher = exports.createOdspLogger = exports.isOdspResolvedUrl = exports.getOdspResolvedUrl = exports.isNewFileInfo = exports.fetchAndParseAsJSONHelper = exports.fetchArray = exports.fetchHelper = exports.getWithRetryForTokenRefresh = exports.getWithRetryForTokenRefreshRepeat = void 0;
8
8
  const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  const internal_1 = require("@fluidframework/core-utils/internal");
10
10
  const internal_2 = require("@fluidframework/driver-utils/internal");
@@ -12,6 +12,7 @@ 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
14
  const fetch_js_1 = require("./fetch.js");
15
+ const odspFluidFileLink_js_1 = require("./odspFluidFileLink.js");
15
16
  const packageVersion_js_1 = require("./packageVersion.js");
16
17
  exports.getWithRetryForTokenRefreshRepeat = "getWithRetryForTokenRefreshRepeat";
17
18
  function headersToMap(headers) {
@@ -192,7 +193,8 @@ exports.getOdspResolvedUrl = getOdspResolvedUrl;
192
193
  /**
193
194
  * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}
194
195
  * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.
195
- * @internal
196
+ * @legacy
197
+ * @alpha
196
198
  */
197
199
  function isOdspResolvedUrl(resolvedUrl) {
198
200
  return "odspResolvedUrl" in resolvedUrl && resolvedUrl.odspResolvedUrl === true;
@@ -354,4 +356,61 @@ function useLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds) {
354
356
  return loadingGroupIds === undefined;
355
357
  }
356
358
  exports.useLegacyFlowWithoutGroupsForSnapshotFetch = useLegacyFlowWithoutGroupsForSnapshotFetch;
359
+ // back-compat: GitHub #9653
360
+ const isFluidPackage = (pkg) => typeof pkg === "object" && typeof pkg?.name === "string" && typeof pkg?.fluid === "object";
361
+ /**
362
+ * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application
363
+ * 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
364
+ * to load the file later.
365
+ * @param baseUrl - The input URL on which the locator params will be appended.
366
+ * @param resolvedUrl - odsp-driver's resolvedURL object.
367
+ * @param dataStorePath - The relative data store path URL.
368
+ * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath
369
+ * will be extracted from the resolved url if present.
370
+ * @param containerPackageName - Name of the package to be included in the URL.
371
+ * @returns The provided base URL appended with odsp-specific locator information
372
+ */
373
+ function appendNavParam(baseUrl, odspResolvedUrl, dataStorePath, containerPackageName) {
374
+ const url = new URL(baseUrl);
375
+ // If the user has passed an empty dataStorePath, then extract it from the resolved url.
376
+ const actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? "");
377
+ (0, odspFluidFileLink_js_1.storeLocatorInOdspUrl)(url, {
378
+ siteUrl: odspResolvedUrl.siteUrl,
379
+ driveId: odspResolvedUrl.driveId,
380
+ itemId: odspResolvedUrl.itemId,
381
+ dataStorePath: actualDataStorePath,
382
+ appName: odspResolvedUrl.appName,
383
+ containerPackageName,
384
+ fileVersion: odspResolvedUrl.fileVersion,
385
+ context: odspResolvedUrl.context,
386
+ });
387
+ return url.href;
388
+ }
389
+ exports.appendNavParam = appendNavParam;
390
+ /**
391
+ * Returns the package name of the container package information.
392
+ * @param packageInfoSource - Information of the package connected to the URL
393
+ * @returns The package name of the container package
394
+ */
395
+ function getContainerPackageName(packageInfoSource) {
396
+ let containerPackageName;
397
+ if (packageInfoSource && "name" in packageInfoSource) {
398
+ containerPackageName = packageInfoSource.name;
399
+ // packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails
400
+ // TODO: use a stronger type
401
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
402
+ }
403
+ else if (isFluidPackage(packageInfoSource?.package)) {
404
+ // TODO: use a stronger type
405
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
406
+ containerPackageName = packageInfoSource?.package.name;
407
+ }
408
+ else {
409
+ // TODO: use a stronger type
410
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
411
+ containerPackageName = packageInfoSource?.package;
412
+ }
413
+ return containerPackageName;
414
+ }
415
+ exports.getContainerPackageName = getContainerPackageName;
357
416
  //# sourceMappingURL=odspUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAK3D,kEAA6D;AAE7D,oEAO+C;AAC/C,yEAIoD;AACpD,+EAgB0D;AAC1D,uEAQkD;AAElD,yCAAmC;AAGnC,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,KAA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C;IAChC,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,0BAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IACvC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACvB,CAAC;AALD,4BAKC;AAED,SAAgB,sBAAsB,CAAC,eAAiC;IACvE,OAAO,GAAG,eAAe,CAAC,gBAAgB,cAAc,CAAC;AAC1D,CAAC;AAFD,wDAEC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB;AACpC,gDAAgD;AAChD,GAA8C;IAE9C,OAAO,GAAG,KAAK,SAAS,IAAI,iBAAiB,IAAI,GAAG,IAAI,GAAG,CAAC,eAAe,KAAK,CAAC,CAAC;AACnF,CAAC;AALD,sDAKC;AAED;;;GAGG;AACH,SAAgB,8BAA8B,CAC7C,eAAqC;IAErC,OAAO,eAAe,KAAK,SAAS,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AACpE,CAAC;AAJD,wEAIC;AAED;;;GAGG;AACH,SAAgB,0CAA0C,CACzD,eAAqC;IAErC,OAAO,eAAe,KAAK,SAAS,CAAC;AACtC,CAAC;AAJD,gGAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IResolvedUrl, ISnapshot } 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\";\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 = performance.now();\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: performance.now() - 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 * @internal\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 = performance.now();\n\tconst result = callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performance.now();\n\tconst result = await callback();\n\tconst time = performance.now() - 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"]}
1
+ {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAK3D,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,OA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7B,wFAAwF;IACxF,MAAM,mBAAmB,GAAG,aAAa,IAAI,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAEnF,IAAA,4CAAqB,EAAC,GAAG,EAAE;QAC1B,OAAO,EAAE,eAAe,CAAC,OAAO;QAChC,OAAO,EAAE,eAAe,CAAC,OAAO;QAChC,MAAM,EAAE,eAAe,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 { performance } 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 = performance.now();\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: performance.now() - 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 = performance.now();\n\tconst result = callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performance.now();\n\tconst result = await callback();\n\tconst time = performance.now() - 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"]}
@@ -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.10.0";
8
+ export declare const pkgVersion = "2.12.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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.10.0";
11
+ exports.pkgVersion = "2.12.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.10.0\";\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,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.12.0\";\n"]}
@@ -144,6 +144,12 @@ export interface ICreateFileResponse {
144
144
  "sharing"?: any;
145
145
  "sharingLink"?: string;
146
146
  "sharingLinkErrorReason"?: string;
147
+ "name": string;
148
+ }
149
+ export interface IRenameFileResponse {
150
+ "@odata.context": string;
151
+ "id": string;
152
+ "name": string;
147
153
  }
148
154
  export interface IVersionedValueWithEpoch {
149
155
  value: any;
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAGrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,yBAAyB,EAAE,GAAG,wBAAwB,EAAE,CAAC;CAChE;AAED,MAAM,WAAW,wBAAwB;IACxC,EAAE,EAAE,yBAAyB,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mCAAmC;IACnD,KAAK,EAAE,uBAAuB,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,MAAM,CAAC;CACX;AAED;;;;GAIG;AAEH,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc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