@fluidframework/odsp-driver 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.203917

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 (259) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/api-extractor.json +1 -1
  3. package/api-report/odsp-driver.api.md +306 -0
  4. package/dist/ReadBufferUtils.js +3 -3
  5. package/dist/ReadBufferUtils.js.map +1 -1
  6. package/dist/checkUrl.d.ts +1 -0
  7. package/dist/checkUrl.d.ts.map +1 -1
  8. package/dist/checkUrl.js +1 -0
  9. package/dist/checkUrl.js.map +1 -1
  10. package/dist/compactSnapshotParser.d.ts +2 -0
  11. package/dist/compactSnapshotParser.d.ts.map +1 -1
  12. package/dist/compactSnapshotParser.js +1 -0
  13. package/dist/compactSnapshotParser.js.map +1 -1
  14. package/dist/constants.d.ts +6 -0
  15. package/dist/constants.d.ts.map +1 -1
  16. package/dist/constants.js +6 -0
  17. package/dist/constants.js.map +1 -1
  18. package/dist/contracts.d.ts +3 -3
  19. package/dist/contracts.d.ts.map +1 -1
  20. package/dist/contractsPublic.d.ts +15 -0
  21. package/dist/contractsPublic.d.ts.map +1 -1
  22. package/dist/contractsPublic.js +8 -2
  23. package/dist/contractsPublic.js.map +1 -1
  24. package/dist/createOdspCreateContainerRequest.d.ts +1 -0
  25. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  26. package/dist/createOdspCreateContainerRequest.js +1 -0
  27. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  28. package/dist/createOdspUrl.d.ts +1 -0
  29. package/dist/createOdspUrl.d.ts.map +1 -1
  30. package/dist/createOdspUrl.js +1 -0
  31. package/dist/createOdspUrl.js.map +1 -1
  32. package/dist/epochTracker.d.ts +12 -2
  33. package/dist/epochTracker.d.ts.map +1 -1
  34. package/dist/epochTracker.js +1 -0
  35. package/dist/epochTracker.js.map +1 -1
  36. package/dist/fetch.d.ts +1 -1
  37. package/dist/fetch.d.ts.map +1 -1
  38. package/dist/fetchSnapshot.d.ts +1 -0
  39. package/dist/fetchSnapshot.d.ts.map +1 -1
  40. package/dist/fetchSnapshot.js +15 -11
  41. package/dist/fetchSnapshot.js.map +1 -1
  42. package/dist/index.d.ts +5 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +3 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/odsp-driver-alpha.d.ts +558 -0
  47. package/dist/odsp-driver-beta.d.ts +558 -0
  48. package/dist/odsp-driver-public.d.ts +558 -0
  49. package/dist/odsp-driver-untrimmed.d.ts +558 -0
  50. package/dist/odspCache.d.ts +6 -0
  51. package/dist/odspCache.d.ts.map +1 -1
  52. package/dist/odspCache.js.map +1 -1
  53. package/dist/odspDocumentDeltaConnection.d.ts +1 -1
  54. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  55. package/dist/odspDocumentDeltaConnection.js +78 -69
  56. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  57. package/dist/odspDocumentService.js +23 -19
  58. package/dist/odspDocumentService.js.map +1 -1
  59. package/dist/odspDocumentServiceFactory.d.ts +4 -0
  60. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  61. package/dist/odspDocumentServiceFactory.js +4 -0
  62. package/dist/odspDocumentServiceFactory.js.map +1 -1
  63. package/dist/odspDocumentServiceFactoryCore.d.ts +1 -0
  64. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  65. package/dist/odspDocumentServiceFactoryCore.js +32 -27
  66. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  67. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
  68. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  69. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
  70. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  71. package/dist/odspDocumentStorageManager.js +5 -1
  72. package/dist/odspDocumentStorageManager.js.map +1 -1
  73. package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
  74. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  75. package/dist/odspDocumentStorageServiceBase.js +1 -14
  76. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  77. package/dist/odspDriverUrlResolver.d.ts +1 -0
  78. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  79. package/dist/odspDriverUrlResolver.js +2 -0
  80. package/dist/odspDriverUrlResolver.js.map +1 -1
  81. package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -0
  82. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  83. package/dist/odspDriverUrlResolverForShareLink.js +1 -0
  84. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  85. package/dist/odspFluidFileLink.d.ts +10 -1
  86. package/dist/odspFluidFileLink.d.ts.map +1 -1
  87. package/dist/odspFluidFileLink.js +14 -6
  88. package/dist/odspFluidFileLink.js.map +1 -1
  89. package/dist/odspPublicUtils.d.ts +6 -0
  90. package/dist/odspPublicUtils.d.ts.map +1 -1
  91. package/dist/odspPublicUtils.js +3 -0
  92. package/dist/odspPublicUtils.js.map +1 -1
  93. package/dist/odspSummaryUploadManager.js +5 -1
  94. package/dist/odspSummaryUploadManager.js.map +1 -1
  95. package/dist/odspUrlHelper.d.ts +5 -0
  96. package/dist/odspUrlHelper.d.ts.map +1 -1
  97. package/dist/odspUrlHelper.js +5 -0
  98. package/dist/odspUrlHelper.js.map +1 -1
  99. package/dist/odspUtils.d.ts +4 -1
  100. package/dist/odspUtils.d.ts.map +1 -1
  101. package/dist/odspUtils.js +1 -0
  102. package/dist/odspUtils.js.map +1 -1
  103. package/dist/opsCaching.d.ts +1 -1
  104. package/dist/opsCaching.d.ts.map +1 -1
  105. package/dist/opsCaching.js +13 -1
  106. package/dist/opsCaching.js.map +1 -1
  107. package/dist/packageVersion.d.ts +1 -1
  108. package/dist/packageVersion.js +1 -1
  109. package/dist/packageVersion.js.map +1 -1
  110. package/dist/prefetchLatestSnapshot.d.ts +2 -0
  111. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  112. package/dist/prefetchLatestSnapshot.js +2 -0
  113. package/dist/prefetchLatestSnapshot.js.map +1 -1
  114. package/dist/socketModule.d.ts +7 -0
  115. package/dist/socketModule.d.ts.map +1 -0
  116. package/dist/socketModule.js +10 -0
  117. package/dist/socketModule.js.map +1 -0
  118. package/dist/tsdoc-metadata.json +1 -1
  119. package/dist/zipItDataRepresentationUtils.d.ts +2 -2
  120. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  121. package/dist/zipItDataRepresentationUtils.js +6 -6
  122. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  123. package/lib/ReadBufferUtils.js +3 -3
  124. package/lib/ReadBufferUtils.js.map +1 -1
  125. package/lib/checkUrl.d.ts +1 -0
  126. package/lib/checkUrl.d.ts.map +1 -1
  127. package/lib/checkUrl.js +1 -0
  128. package/lib/checkUrl.js.map +1 -1
  129. package/lib/compactSnapshotParser.d.ts +2 -0
  130. package/lib/compactSnapshotParser.d.ts.map +1 -1
  131. package/lib/compactSnapshotParser.js +1 -0
  132. package/lib/compactSnapshotParser.js.map +1 -1
  133. package/lib/constants.d.ts +6 -0
  134. package/lib/constants.d.ts.map +1 -1
  135. package/lib/constants.js +6 -0
  136. package/lib/constants.js.map +1 -1
  137. package/lib/contracts.d.ts +3 -3
  138. package/lib/contracts.d.ts.map +1 -1
  139. package/lib/contractsPublic.d.ts +15 -0
  140. package/lib/contractsPublic.d.ts.map +1 -1
  141. package/lib/contractsPublic.js +6 -0
  142. package/lib/contractsPublic.js.map +1 -1
  143. package/lib/createOdspCreateContainerRequest.d.ts +1 -0
  144. package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
  145. package/lib/createOdspCreateContainerRequest.js +1 -0
  146. package/lib/createOdspCreateContainerRequest.js.map +1 -1
  147. package/lib/createOdspUrl.d.ts +1 -0
  148. package/lib/createOdspUrl.d.ts.map +1 -1
  149. package/lib/createOdspUrl.js +1 -0
  150. package/lib/createOdspUrl.js.map +1 -1
  151. package/lib/epochTracker.d.ts +12 -2
  152. package/lib/epochTracker.d.ts.map +1 -1
  153. package/lib/epochTracker.js +1 -0
  154. package/lib/epochTracker.js.map +1 -1
  155. package/lib/fetch.d.ts +1 -1
  156. package/lib/fetch.d.ts.map +1 -1
  157. package/lib/fetchSnapshot.d.ts +1 -0
  158. package/lib/fetchSnapshot.d.ts.map +1 -1
  159. package/lib/fetchSnapshot.js +14 -10
  160. package/lib/fetchSnapshot.js.map +1 -1
  161. package/lib/index.d.ts +5 -1
  162. package/lib/index.d.ts.map +1 -1
  163. package/lib/index.js +1 -0
  164. package/lib/index.js.map +1 -1
  165. package/lib/odspCache.d.ts +6 -0
  166. package/lib/odspCache.d.ts.map +1 -1
  167. package/lib/odspCache.js.map +1 -1
  168. package/lib/odspDocumentDeltaConnection.d.ts +1 -1
  169. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  170. package/lib/odspDocumentDeltaConnection.js +77 -68
  171. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  172. package/lib/odspDocumentService.js +18 -18
  173. package/lib/odspDocumentService.js.map +1 -1
  174. package/lib/odspDocumentServiceFactory.d.ts +4 -0
  175. package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
  176. package/lib/odspDocumentServiceFactory.js +4 -0
  177. package/lib/odspDocumentServiceFactory.js.map +1 -1
  178. package/lib/odspDocumentServiceFactoryCore.d.ts +1 -0
  179. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  180. package/lib/odspDocumentServiceFactoryCore.js +27 -26
  181. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  182. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
  183. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  184. package/lib/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
  185. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  186. package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
  187. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  188. package/lib/odspDocumentStorageServiceBase.js +1 -14
  189. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  190. package/lib/odspDriverUrlResolver.d.ts +1 -0
  191. package/lib/odspDriverUrlResolver.d.ts.map +1 -1
  192. package/lib/odspDriverUrlResolver.js +2 -0
  193. package/lib/odspDriverUrlResolver.js.map +1 -1
  194. package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -0
  195. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  196. package/lib/odspDriverUrlResolverForShareLink.js +1 -0
  197. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  198. package/lib/odspFluidFileLink.d.ts +10 -1
  199. package/lib/odspFluidFileLink.d.ts.map +1 -1
  200. package/lib/odspFluidFileLink.js +14 -6
  201. package/lib/odspFluidFileLink.js.map +1 -1
  202. package/lib/odspPublicUtils.d.ts +6 -0
  203. package/lib/odspPublicUtils.d.ts.map +1 -1
  204. package/lib/odspPublicUtils.js +3 -0
  205. package/lib/odspPublicUtils.js.map +1 -1
  206. package/lib/odspUrlHelper.d.ts +5 -0
  207. package/lib/odspUrlHelper.d.ts.map +1 -1
  208. package/lib/odspUrlHelper.js +5 -0
  209. package/lib/odspUrlHelper.js.map +1 -1
  210. package/lib/odspUtils.d.ts +4 -1
  211. package/lib/odspUtils.d.ts.map +1 -1
  212. package/lib/odspUtils.js +1 -0
  213. package/lib/odspUtils.js.map +1 -1
  214. package/lib/opsCaching.d.ts +1 -1
  215. package/lib/opsCaching.d.ts.map +1 -1
  216. package/lib/opsCaching.js +13 -1
  217. package/lib/opsCaching.js.map +1 -1
  218. package/lib/packageVersion.d.ts +1 -1
  219. package/lib/packageVersion.js +1 -1
  220. package/lib/packageVersion.js.map +1 -1
  221. package/lib/prefetchLatestSnapshot.d.ts +2 -0
  222. package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
  223. package/lib/prefetchLatestSnapshot.js +2 -0
  224. package/lib/prefetchLatestSnapshot.js.map +1 -1
  225. package/lib/socketModule.d.ts +7 -0
  226. package/lib/socketModule.d.ts.map +1 -0
  227. package/lib/socketModule.js +7 -0
  228. package/lib/socketModule.js.map +1 -0
  229. package/lib/zipItDataRepresentationUtils.d.ts +2 -2
  230. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  231. package/lib/zipItDataRepresentationUtils.js +3 -3
  232. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  233. package/package.json +24 -26
  234. package/src/checkUrl.ts +1 -0
  235. package/src/compactSnapshotParser.ts +2 -0
  236. package/src/constants.ts +7 -0
  237. package/src/contractsPublic.ts +15 -1
  238. package/src/createOdspCreateContainerRequest.ts +1 -0
  239. package/src/createOdspUrl.ts +1 -0
  240. package/src/epochTracker.ts +10 -0
  241. package/src/fetchSnapshot.ts +16 -15
  242. package/src/index.ts +10 -1
  243. package/src/odspCache.ts +6 -0
  244. package/src/odspDocumentDeltaConnection.ts +56 -32
  245. package/src/odspDocumentServiceFactory.ts +4 -0
  246. package/src/odspDocumentServiceFactoryCore.ts +1 -0
  247. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +2 -1
  248. package/src/odspDocumentStorageServiceBase.ts +1 -15
  249. package/src/odspDriverUrlResolver.ts +2 -0
  250. package/src/odspDriverUrlResolverForShareLink.ts +2 -0
  251. package/src/odspFluidFileLink.ts +21 -5
  252. package/src/odspPublicUtils.ts +6 -0
  253. package/src/odspUrlHelper.ts +5 -0
  254. package/src/odspUtils.ts +4 -0
  255. package/src/opsCaching.ts +15 -1
  256. package/src/packageVersion.ts +1 -1
  257. package/src/prefetchLatestSnapshot.ts +2 -0
  258. package/src/socketModule.ts +8 -0
  259. package/src/zipItDataRepresentationUtils.ts +5 -1
@@ -6,8 +6,9 @@ import { IDocumentServiceFactory } from "@fluidframework/driver-definitions";
6
6
  import { OdspResourceTokenFetchOptions, TokenFetcher, IPersistedCache, HostStoragePolicy } from "@fluidframework/odsp-driver-definitions";
7
7
  import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore";
8
8
  /**
9
- * @deprecated - This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the
9
+ * @deprecated This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the
10
10
  * other dynamically imported module.
11
+ * @public
11
12
  */
12
13
  export declare class OdspDocumentServiceFactoryWithCodeSplit extends OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
13
14
  constructor(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy);
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentServiceFactoryWithCodeSplit.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryWithCodeSplit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACN,6BAA6B,EAC7B,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;GAGG;AACH,qBAAa,uCACZ,SAAQ,8BACR,YAAW,uBAAuB;gBAGjC,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,iBAAiB,EAAE,YAAY,CAAC,6BAA6B,CAAC,GAAG,SAAS,EAC1E,cAAc,CAAC,EAAE,eAAe,EAChC,UAAU,CAAC,EAAE,iBAAiB;CAI/B"}
1
+ {"version":3,"file":"odspDocumentServiceFactoryWithCodeSplit.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryWithCodeSplit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACN,6BAA6B,EAC7B,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;;GAIG;AACH,qBAAa,uCACZ,SAAQ,8BACR,YAAW,uBAAuB;gBAGjC,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,iBAAiB,EAAE,YAAY,CAAC,6BAA6B,CAAC,GAAG,SAAS,EAC1E,cAAc,CAAC,EAAE,eAAe,EAChC,UAAU,CAAC,EAAE,iBAAiB;CAI/B"}
@@ -4,8 +4,9 @@
4
4
  */
5
5
  import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore";
6
6
  /**
7
- * @deprecated - This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the
7
+ * @deprecated This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the
8
8
  * other dynamically imported module.
9
+ * @public
9
10
  */
10
11
  export class OdspDocumentServiceFactoryWithCodeSplit extends OdspDocumentServiceFactoryCore {
11
12
  constructor(getStorageToken, getWebsocketToken, persistedCache, hostPolicy) {
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentServiceFactoryWithCodeSplit.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryWithCodeSplit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;GAGG;AACH,MAAM,OAAO,uCACZ,SAAQ,8BAA8B;IAGtC,YACC,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport {\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tIPersistedCache,\n\tHostStoragePolicy,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\n\n/**\n * @deprecated - This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the\n * other dynamically imported module.\n */\nexport class OdspDocumentServiceFactoryWithCodeSplit\n\textends OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory\n{\n\tconstructor(\n\t\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tpersistedCache?: IPersistedCache,\n\t\thostPolicy?: HostStoragePolicy,\n\t) {\n\t\tsuper(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDocumentServiceFactoryWithCodeSplit.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryWithCodeSplit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;;GAIG;AACH,MAAM,OAAO,uCACZ,SAAQ,8BAA8B;IAGtC,YACC,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport {\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tIPersistedCache,\n\tHostStoragePolicy,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\n\n/**\n * @deprecated This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the\n * other dynamically imported module.\n * @public\n */\nexport class OdspDocumentServiceFactoryWithCodeSplit\n\textends OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory\n{\n\tconstructor(\n\t\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tpersistedCache?: IPersistedCache,\n\t\thostPolicy?: HostStoragePolicy,\n\t) {\n\t\tsuper(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);\n\t}\n}\n"]}
@@ -36,7 +36,7 @@ export declare abstract class OdspDocumentStorageServiceBase implements IDocumen
36
36
  set ops(ops: api.ISequencedDocumentMessage[] | undefined);
37
37
  get ops(): api.ISequencedDocumentMessage[] | undefined;
38
38
  get snapshotSequenceNumber(): number | undefined;
39
- get repositoryUrl(): string;
39
+ readonly repositoryUrl = "";
40
40
  abstract createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
41
41
  private readBlobCore;
42
42
  protected abstract fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer>;
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentStorageServiceBase.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageServiceBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EAGf,WAAW,EACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,cAAM,SAAS;IAEd,OAAO,CAAC,gBAAgB,CAA4C;IAIpE,OAAO,CAAC,mBAAmB,CAAkB;IAE7C,OAAO,CAAC,QAAQ,CAAC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AG,SAAS;CAqBrB"}
@@ -99,6 +99,7 @@ export class OdspDocumentStorageServiceBase {
99
99
  this.commitCache = new Map();
100
100
  this.attributesBlobHandles = new Set();
101
101
  this.blobCache = new BlobCache();
102
+ this.repositoryUrl = "";
102
103
  // We circumvent the restrictions on the policy only when using this TestOverride setting,
103
104
  // which also applies to the code that reads from the cache in epochTracker.ts
104
105
  // This may result in files created for testing being unusable in production sessions,
@@ -109,17 +110,6 @@ export class OdspDocumentStorageServiceBase {
109
110
  this.policies = {
110
111
  // By default, ODSP tells the container not to prefetch/cache.
111
112
  caching: LoaderCachingPolicy.NoCaching,
112
- // ODSP storage works better if it has less number of blobs / edges
113
- // Runtime creating many small blobs results in sub-optimal perf.
114
- // 2K seems like the sweat spot:
115
- // The smaller the number, less blobs we aggregate. Most storages are very likely to have notion
116
- // of minimal "cluster" size, so having small blobs is wasteful
117
- // At the same time increasing the limit ensure that more blobs with user content are aggregated,
118
- // reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob
119
- // are not reused across data stores, or even within data store, resulting in duplication of content)
120
- // Note that duplication of content should not have significant impact for bytes over wire as
121
- // compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.
122
- minBlobSize: 2048,
123
113
  maximumCacheDurationMs: maximumCacheDurationMsInEffect,
124
114
  };
125
115
  }
@@ -133,9 +123,6 @@ export class OdspDocumentStorageServiceBase {
133
123
  get snapshotSequenceNumber() {
134
124
  return this._snapshotSequenceNumber;
135
125
  }
136
- get repositoryUrl() {
137
- return "";
138
- }
139
126
  async readBlobCore(blobId) {
140
127
  const { blobContent, evicted } = this.blobCache.getBlob(blobId);
141
128
  return blobContent ?? this.fetchBlobFromStorage(blobId, evicted);
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentStorageServiceBase.js","sourceRoot":"","sources":["../src/odspDocumentStorageServiceBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD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,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;YACxE,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;SACnC;QAED,IAAI,KAAK,EAAE;YACV,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,IAAI,QAAQ,EAAE;YACb,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;SACf;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n\tLoaderCachingPolicy,\n\tFiveDaysMs,\n\tFetchSource,\n} from \"@fluidframework/driver-definitions\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IConfigProvider } from \"@fluidframework/telemetry-utils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\n\nconst maximumCacheDurationMs: FiveDaysMs = 432000000; // 5 * 24 * 60 * 60 * 1000 = 5 days in ms\n\nclass BlobCache {\n\t// Save the timeout so we can cancel and reschedule it as needed\n\tprivate blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n\t// If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n\t// This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n\t// too many calls to setTimeout/clearTimeout.\n\tprivate deferBlobCacheClear: boolean = false;\n\n\tprivate readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n\t// Tracks all blob IDs evicted from cache\n\tprivate readonly blobsEvicted: Set<string> = new Set();\n\n\t// Initial time-out to purge data from cache\n\t// If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n\t// requests to storage, which brings down perf and may trip protection limits causing 429s\n\tprivate blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n\t// SPO does not keep old snapshots around for long, so we are running chances of not\n\t// being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n\t// even if blob read by runtime, it could be read again in the future)\n\t// So for now, purging is disabled.\n\tprivate readonly purgeEnabled = false;\n\n\tpublic get value() {\n\t\treturn this._blobCache;\n\t}\n\n\tpublic addBlobs(blobs: Map<string, ArrayBuffer>) {\n\t\tblobs.forEach((value, blobId) => {\n\t\t\tthis._blobCache.set(blobId, value);\n\t\t});\n\t\t// Reset the timer on cache set\n\t\tthis.scheduleClearBlobsCache();\n\t}\n\n\t/**\n\t * Schedule a timer for clearing the blob cache or defer the current one.\n\t */\n\tprivate scheduleClearBlobsCache() {\n\t\tif (this.blobCacheTimeout !== undefined) {\n\t\t\t// If we already have an outstanding timer, just signal that we should defer the clear\n\t\t\tthis.deferBlobCacheClear = true;\n\t\t} else if (this.purgeEnabled) {\n\t\t\t// If we don't have an outstanding timer, set a timer\n\t\t\t// When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n\t\t\tconst clearCacheOrDefer = () => {\n\t\t\t\tthis.blobCacheTimeout = undefined;\n\t\t\t\tif (this.deferBlobCacheClear) {\n\t\t\t\t\tthis.deferBlobCacheClear = false;\n\t\t\t\t\tthis.scheduleClearBlobsCache();\n\t\t\t\t} else {\n\t\t\t\t\t// NOTE: Slightly better algorithm here would be to purge either only big blobs,\n\t\t\t\t\t// or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n\t\t\t\t\t// Purging is optimizing memory footprint. But count controls potential number of storage requests\n\t\t\t\t\t// We want to optimize both - memory footprint and number of future requests to storage.\n\t\t\t\t\t// Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n\t\t\t\t\t// control when blobs will be used.\n\t\t\t\t\tthis._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));\n\t\t\t\t\tthis._blobCache.clear();\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n\t\t\t// any future storage reads that get into the cache should be cleared from cache rather quickly -\n\t\t\t// there is not much value in keeping them longer\n\t\t\tthis.blobCacheTimeoutDuration = 10 * 1000;\n\t\t}\n\t}\n\n\tpublic getBlob(blobId: string) {\n\t\t// Reset the timer on attempted cache read\n\t\tthis.scheduleClearBlobsCache();\n\t\tconst blobContent = this._blobCache.get(blobId);\n\t\tconst evicted = this.blobsEvicted.has(blobId);\n\t\treturn { blobContent, evicted };\n\t}\n\n\tpublic setBlob(blobId: string, blob: ArrayBuffer) {\n\t\t// This API is called as result of cache miss and reading blob from storage.\n\t\t// Runtime never reads same blob twice.\n\t\t// The only reason we may get read request for same blob is blob de-duping in summaries.\n\t\t// Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n\t\t// Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n\t\t// blobs are de-duped.\n\t\tconst size = blob.byteLength;\n\t\tif (size < 256 * 1024) {\n\t\t\t// Reset the timer on cache set\n\t\t\tthis.scheduleClearBlobsCache();\n\t\t\treturn this._blobCache.set(blobId, blob);\n\t\t} else {\n\t\t\t// we evicted it here by not caching.\n\t\t\tthis.blobsEvicted.add(blobId);\n\t\t}\n\t}\n}\n\nexport abstract class OdspDocumentStorageServiceBase implements IDocumentStorageService {\n\treadonly policies: IDocumentStorageServicePolicies;\n\n\tconstructor(config: IConfigProvider) {\n\t\t// We circumvent the restrictions on the policy only when using this TestOverride setting,\n\t\t// which also applies to the code that reads from the cache in epochTracker.ts\n\t\t// This may result in files created for testing being unusable in production sessions,\n\t\t// due to the GC code guarding against this policy changing over the lifetime of a file.\n\t\tconst maximumCacheDurationMsInEffect = (\n\t\t\tconfig.getBoolean(\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\")\n\t\t\t\t? 0\n\t\t\t\t: maximumCacheDurationMs\n\t\t) as FiveDaysMs;\n\n\t\tthis.policies = {\n\t\t\t// By default, ODSP tells the container not to prefetch/cache.\n\t\t\tcaching: LoaderCachingPolicy.NoCaching,\n\n\t\t\t// ODSP storage works better if it has less number of blobs / edges\n\t\t\t// Runtime creating many small blobs results in sub-optimal perf.\n\t\t\t// 2K seems like the sweat spot:\n\t\t\t// The smaller the number, less blobs we aggregate. Most storages are very likely to have notion\n\t\t\t// of minimal \"cluster\" size, so having small blobs is wasteful\n\t\t\t// At the same time increasing the limit ensure that more blobs with user content are aggregated,\n\t\t\t// reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob\n\t\t\t// are not reused across data stores, or even within data store, resulting in duplication of content)\n\t\t\t// Note that duplication of content should not have significant impact for bytes over wire as\n\t\t\t// compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.\n\t\t\tminBlobSize: 2048,\n\t\t\tmaximumCacheDurationMs: maximumCacheDurationMsInEffect,\n\t\t};\n\t}\n\tprotected readonly commitCache: Map<string, api.ISnapshotTree> = new Map();\n\n\tprivate readonly attributesBlobHandles: Set<string> = new Set();\n\n\tprivate _ops: api.ISequencedDocumentMessage[] | undefined;\n\n\tprivate _snapshotSequenceNumber: number | undefined;\n\n\tprotected readonly blobCache = new BlobCache();\n\n\tpublic set ops(ops: api.ISequencedDocumentMessage[] | undefined) {\n\t\tassert(this._ops === undefined, 0x0a5 /* \"Trying to set ops when they are already set!\" */);\n\t\tthis._ops = ops;\n\t}\n\n\tpublic get ops(): api.ISequencedDocumentMessage[] | undefined {\n\t\treturn this._ops;\n\t}\n\n\tpublic get snapshotSequenceNumber() {\n\t\treturn this._snapshotSequenceNumber;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tpublic abstract createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;\n\n\tprivate async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n\t\tconst { blobContent, evicted } = this.blobCache.getBlob(blobId);\n\t\treturn blobContent ?? this.fetchBlobFromStorage(blobId, evicted);\n\t}\n\n\tprotected abstract fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer>;\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.readBlobCore(blobId);\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: api.IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<api.ISnapshotTree | null> {\n\t\tlet id: string;\n\t\tif (!version?.id) {\n\t\t\tconst versions = await this.getVersions(null, 1, scenarioName);\n\t\t\tif (!versions || versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tid = versions[0].id;\n\t\t} else {\n\t\t\tid = version.id;\n\t\t}\n\n\t\tconst snapshotTree = await this.readTree(id, scenarioName);\n\t\tif (!snapshotTree) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (snapshotTree.blobs) {\n\t\t\tconst attributesBlob = snapshotTree.blobs.attributes;\n\t\t\tif (attributesBlob) {\n\t\t\t\tthis.attributesBlobHandles.add(attributesBlob);\n\t\t\t}\n\t\t}\n\n\t\t// When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n\t\t// So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n\t\tconst appTree = snapshotTree.trees[\".app\"];\n\t\tconst protocolTree = snapshotTree.trees[\".protocol\"];\n\n\t\treturn this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\n\t}\n\n\tpublic abstract getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<api.IVersion[]>;\n\n\tpublic abstract uploadSummaryWithContext(\n\t\tsummary: api.ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string>;\n\n\tpublic async downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree> {\n\t\tthrow new Error(\"Not implemented yet\");\n\t}\n\n\tprotected setRootTree(id: string, tree: api.ISnapshotTree) {\n\t\tthis.commitCache.set(id, tree);\n\t}\n\n\tprotected initBlobsCache(blobs: Map<string, ArrayBuffer>) {\n\t\tthis.blobCache.addBlobs(blobs);\n\t}\n\n\tprivate async readTree(id: string, scenarioName?: string): Promise<api.ISnapshotTree | null> {\n\t\tlet tree = this.commitCache.get(id);\n\t\tif (!tree) {\n\t\t\ttree = await this.fetchTreeFromSnapshot(id, scenarioName);\n\t\t}\n\n\t\treturn tree ?? null;\n\t}\n\n\tprotected abstract fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<api.ISnapshotTree | undefined>;\n\n\tprivate combineProtocolAndAppSnapshotTree(\n\t\thierarchicalAppTree: api.ISnapshotTree,\n\t\thierarchicalProtocolTree: api.ISnapshotTree,\n\t) {\n\t\tconst summarySnapshotTree: api.ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\t...hierarchicalAppTree.blobs,\n\t\t\t},\n\t\t\ttrees: {\n\t\t\t\t...hierarchicalAppTree.trees,\n\t\t\t\t// the app tree could have a .protocol\n\t\t\t\t// in that case we want to server protocol to override it\n\t\t\t\t\".protocol\": hierarchicalProtocolTree,\n\t\t\t},\n\t\t};\n\n\t\treturn summarySnapshotTree;\n\t}\n\n\tprotected initializeFromSnapshot(\n\t\todspSnapshotCacheValue: ISnapshotContents,\n\t\tcacheOps: boolean = true,\n\t): string | undefined {\n\t\tthis._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n\t\tconst { snapshotTree, blobs, ops } = odspSnapshotCacheValue;\n\n\t\t// id should be undefined in case of just ops in snapshot.\n\t\tlet id: string | undefined;\n\t\tif (snapshotTree) {\n\t\t\tid = snapshotTree.id;\n\t\t\tassert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n\t\t\tthis.setRootTree(id, snapshotTree);\n\t\t}\n\n\t\tif (blobs) {\n\t\t\tthis.initBlobsCache(blobs);\n\t\t}\n\n\t\tif (cacheOps) {\n\t\t\tthis.ops = ops;\n\t\t}\n\t\treturn id;\n\t}\n}\n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KAAK,CAAC,uCAAuC,CAAC,CAAC;YACxE,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;SACnC;QAED,IAAI,KAAK,EAAE;YACV,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,IAAI,QAAQ,EAAE;YACb,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;SACf;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n\tLoaderCachingPolicy,\n\tFiveDaysMs,\n\tFetchSource,\n} from \"@fluidframework/driver-definitions\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IConfigProvider } from \"@fluidframework/telemetry-utils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\n\nconst maximumCacheDurationMs: FiveDaysMs = 432000000; // 5 * 24 * 60 * 60 * 1000 = 5 days in ms\n\nclass BlobCache {\n\t// Save the timeout so we can cancel and reschedule it as needed\n\tprivate blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n\t// If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n\t// This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n\t// too many calls to setTimeout/clearTimeout.\n\tprivate deferBlobCacheClear: boolean = false;\n\n\tprivate readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n\t// Tracks all blob IDs evicted from cache\n\tprivate readonly blobsEvicted: Set<string> = new Set();\n\n\t// Initial time-out to purge data from cache\n\t// If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n\t// requests to storage, which brings down perf and may trip protection limits causing 429s\n\tprivate blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n\t// SPO does not keep old snapshots around for long, so we are running chances of not\n\t// being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n\t// even if blob read by runtime, it could be read again in the future)\n\t// So for now, purging is disabled.\n\tprivate readonly purgeEnabled = false;\n\n\tpublic get value() {\n\t\treturn this._blobCache;\n\t}\n\n\tpublic addBlobs(blobs: Map<string, ArrayBuffer>) {\n\t\tblobs.forEach((value, blobId) => {\n\t\t\tthis._blobCache.set(blobId, value);\n\t\t});\n\t\t// Reset the timer on cache set\n\t\tthis.scheduleClearBlobsCache();\n\t}\n\n\t/**\n\t * Schedule a timer for clearing the blob cache or defer the current one.\n\t */\n\tprivate scheduleClearBlobsCache() {\n\t\tif (this.blobCacheTimeout !== undefined) {\n\t\t\t// If we already have an outstanding timer, just signal that we should defer the clear\n\t\t\tthis.deferBlobCacheClear = true;\n\t\t} else if (this.purgeEnabled) {\n\t\t\t// If we don't have an outstanding timer, set a timer\n\t\t\t// When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n\t\t\tconst clearCacheOrDefer = () => {\n\t\t\t\tthis.blobCacheTimeout = undefined;\n\t\t\t\tif (this.deferBlobCacheClear) {\n\t\t\t\t\tthis.deferBlobCacheClear = false;\n\t\t\t\t\tthis.scheduleClearBlobsCache();\n\t\t\t\t} else {\n\t\t\t\t\t// NOTE: Slightly better algorithm here would be to purge either only big blobs,\n\t\t\t\t\t// or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n\t\t\t\t\t// Purging is optimizing memory footprint. But count controls potential number of storage requests\n\t\t\t\t\t// We want to optimize both - memory footprint and number of future requests to storage.\n\t\t\t\t\t// Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n\t\t\t\t\t// control when blobs will be used.\n\t\t\t\t\tthis._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));\n\t\t\t\t\tthis._blobCache.clear();\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n\t\t\t// any future storage reads that get into the cache should be cleared from cache rather quickly -\n\t\t\t// there is not much value in keeping them longer\n\t\t\tthis.blobCacheTimeoutDuration = 10 * 1000;\n\t\t}\n\t}\n\n\tpublic getBlob(blobId: string) {\n\t\t// Reset the timer on attempted cache read\n\t\tthis.scheduleClearBlobsCache();\n\t\tconst blobContent = this._blobCache.get(blobId);\n\t\tconst evicted = this.blobsEvicted.has(blobId);\n\t\treturn { blobContent, evicted };\n\t}\n\n\tpublic setBlob(blobId: string, blob: ArrayBuffer) {\n\t\t// This API is called as result of cache miss and reading blob from storage.\n\t\t// Runtime never reads same blob twice.\n\t\t// The only reason we may get read request for same blob is blob de-duping in summaries.\n\t\t// Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n\t\t// Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n\t\t// blobs are de-duped.\n\t\tconst size = blob.byteLength;\n\t\tif (size < 256 * 1024) {\n\t\t\t// Reset the timer on cache set\n\t\t\tthis.scheduleClearBlobsCache();\n\t\t\treturn this._blobCache.set(blobId, blob);\n\t\t} else {\n\t\t\t// we evicted it here by not caching.\n\t\t\tthis.blobsEvicted.add(blobId);\n\t\t}\n\t}\n}\n\nexport abstract class OdspDocumentStorageServiceBase implements IDocumentStorageService {\n\treadonly policies: IDocumentStorageServicePolicies;\n\n\tconstructor(config: IConfigProvider) {\n\t\t// We circumvent the restrictions on the policy only when using this TestOverride setting,\n\t\t// which also applies to the code that reads from the cache in epochTracker.ts\n\t\t// This may result in files created for testing being unusable in production sessions,\n\t\t// due to the GC code guarding against this policy changing over the lifetime of a file.\n\t\tconst maximumCacheDurationMsInEffect = (\n\t\t\tconfig.getBoolean(\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\")\n\t\t\t\t? 0\n\t\t\t\t: maximumCacheDurationMs\n\t\t) as FiveDaysMs;\n\n\t\tthis.policies = {\n\t\t\t// By default, ODSP tells the container not to prefetch/cache.\n\t\t\tcaching: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumCacheDurationMsInEffect,\n\t\t};\n\t}\n\tprotected readonly commitCache: Map<string, api.ISnapshotTree> = new Map();\n\n\tprivate readonly attributesBlobHandles: Set<string> = new Set();\n\n\tprivate _ops: api.ISequencedDocumentMessage[] | undefined;\n\n\tprivate _snapshotSequenceNumber: number | undefined;\n\n\tprotected readonly blobCache = new BlobCache();\n\n\tpublic set ops(ops: api.ISequencedDocumentMessage[] | undefined) {\n\t\tassert(this._ops === undefined, 0x0a5 /* \"Trying to set ops when they are already set!\" */);\n\t\tthis._ops = ops;\n\t}\n\n\tpublic get ops(): api.ISequencedDocumentMessage[] | undefined {\n\t\treturn this._ops;\n\t}\n\n\tpublic get snapshotSequenceNumber() {\n\t\treturn this._snapshotSequenceNumber;\n\t}\n\n\tpublic readonly repositoryUrl = \"\";\n\n\tpublic abstract createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;\n\n\tprivate async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n\t\tconst { blobContent, evicted } = this.blobCache.getBlob(blobId);\n\t\treturn blobContent ?? this.fetchBlobFromStorage(blobId, evicted);\n\t}\n\n\tprotected abstract fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer>;\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.readBlobCore(blobId);\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: api.IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<api.ISnapshotTree | null> {\n\t\tlet id: string;\n\t\tif (!version?.id) {\n\t\t\tconst versions = await this.getVersions(null, 1, scenarioName);\n\t\t\tif (!versions || versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tid = versions[0].id;\n\t\t} else {\n\t\t\tid = version.id;\n\t\t}\n\n\t\tconst snapshotTree = await this.readTree(id, scenarioName);\n\t\tif (!snapshotTree) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (snapshotTree.blobs) {\n\t\t\tconst attributesBlob = snapshotTree.blobs.attributes;\n\t\t\tif (attributesBlob) {\n\t\t\t\tthis.attributesBlobHandles.add(attributesBlob);\n\t\t\t}\n\t\t}\n\n\t\t// When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n\t\t// So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n\t\tconst appTree = snapshotTree.trees[\".app\"];\n\t\tconst protocolTree = snapshotTree.trees[\".protocol\"];\n\n\t\treturn this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\n\t}\n\n\tpublic abstract getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<api.IVersion[]>;\n\n\tpublic abstract uploadSummaryWithContext(\n\t\tsummary: api.ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string>;\n\n\tpublic async downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree> {\n\t\tthrow new Error(\"Not implemented yet\");\n\t}\n\n\tprotected setRootTree(id: string, tree: api.ISnapshotTree) {\n\t\tthis.commitCache.set(id, tree);\n\t}\n\n\tprotected initBlobsCache(blobs: Map<string, ArrayBuffer>) {\n\t\tthis.blobCache.addBlobs(blobs);\n\t}\n\n\tprivate async readTree(id: string, scenarioName?: string): Promise<api.ISnapshotTree | null> {\n\t\tlet tree = this.commitCache.get(id);\n\t\tif (!tree) {\n\t\t\ttree = await this.fetchTreeFromSnapshot(id, scenarioName);\n\t\t}\n\n\t\treturn tree ?? null;\n\t}\n\n\tprotected abstract fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<api.ISnapshotTree | undefined>;\n\n\tprivate combineProtocolAndAppSnapshotTree(\n\t\thierarchicalAppTree: api.ISnapshotTree,\n\t\thierarchicalProtocolTree: api.ISnapshotTree,\n\t) {\n\t\tconst summarySnapshotTree: api.ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\t...hierarchicalAppTree.blobs,\n\t\t\t},\n\t\t\ttrees: {\n\t\t\t\t...hierarchicalAppTree.trees,\n\t\t\t\t// the app tree could have a .protocol\n\t\t\t\t// in that case we want to server protocol to override it\n\t\t\t\t\".protocol\": hierarchicalProtocolTree,\n\t\t\t},\n\t\t};\n\n\t\treturn summarySnapshotTree;\n\t}\n\n\tprotected initializeFromSnapshot(\n\t\todspSnapshotCacheValue: ISnapshotContents,\n\t\tcacheOps: boolean = true,\n\t): string | undefined {\n\t\tthis._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n\t\tconst { snapshotTree, blobs, ops } = odspSnapshotCacheValue;\n\n\t\t// id should be undefined in case of just ops in snapshot.\n\t\tlet id: string | undefined;\n\t\tif (snapshotTree) {\n\t\t\tid = snapshotTree.id;\n\t\t\tassert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n\t\t\tthis.setRootTree(id, snapshotTree);\n\t\t}\n\n\t\tif (blobs) {\n\t\t\tthis.initBlobsCache(blobs);\n\t\t}\n\n\t\tif (cacheOps) {\n\t\t\tthis.ops = ops;\n\t\t}\n\t\treturn id;\n\t}\n}\n"]}
@@ -4,6 +4,7 @@ import { IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
4
4
  /**
5
5
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
6
6
  * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`
7
+ * @public
7
8
  */
8
9
  export declare class OdspDriverUrlResolver implements IUrlResolver {
9
10
  constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolver.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAGN,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,gBAAgB,EAGhB,MAAM,yCAAyC,CAAC;AA8DjD;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,YAAY;;IAG5C,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA8FlE;;;;;;;OAOG;IACU,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,CAAC;CAmClB"}
1
+ {"version":3,"file":"odspDriverUrlResolver.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAGN,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,gBAAgB,EAGhB,MAAM,yCAAyC,CAAC;AA8DjD;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,YAAY;;IAG5C,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA+FlE;;;;;;;OAOG;IACU,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,CAAC;CAmClB"}
@@ -46,6 +46,7 @@ function removeBeginningSlash(str) {
46
46
  /**
47
47
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
48
48
  * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`
49
+ * @public
49
50
  */
50
51
  export class OdspDriverUrlResolver {
51
52
  constructor() { }
@@ -58,6 +59,7 @@ export class OdspDriverUrlResolver {
58
59
  const filePath = searchParams.get("path");
59
60
  const packageName = searchParams.get("containerPackageName");
60
61
  const createLinkType = searchParams.get("createLinkType");
62
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive
61
63
  if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {
62
64
  throw new NonRetryableError("Proper new file params should be there!!", DriverErrorType.genericError, { driverVersion: pkgVersion });
63
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EACN,eAAe,EACf,YAAY,GAIZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEN,cAAc,GAEd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,SAAS,UAAU,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,WAAoB;IACzF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,YAAY,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,OAAO,UAAU,MAAM,IAAI,OAAO,EAAE,CAAC;AACjF,CAAC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,WAAoB;IAC7F,MAAM,OAAO,GAAG,UA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kB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tDriverErrorType,\n\tDriverHeader,\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tShareLinkTypes,\n\tShareLinkInfoType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { getHashedDocumentId } from \"./odspPublicUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction getUrlBase(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n\tconst siteOrigin = new URL(siteUrl).origin;\n\tconst version = fileVersion ? `versions/${fileVersion}/` : \"\";\n\treturn `${getApiRoot(siteOrigin)}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n\tif (str.startsWith(\"/\")) {\n\t\treturn str.substr(1);\n\t}\n\n\treturn str;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n\tconstructor() {}\n\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [siteURL, queryString] = request.url.split(\"?\");\n\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst fileName = request.headers[DriverHeader.createNew].fileName;\n\t\t\tconst driveID = searchParams.get(\"driveId\");\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tconst packageName = searchParams.get(\"containerPackageName\");\n\t\t\tconst createLinkType = searchParams.get(\"createLinkType\");\n\t\t\tif (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Proper new file params should be there!!\",\n\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\t\t\tif (createLinkType && createLinkType in ShareLinkTypes) {\n\t\t\t\tshareLinkInfo = {\n\t\t\t\t\tcreateLink: {\n\t\t\t\t\t\ttype: ShareLinkTypes[createLinkType],\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tid: \"odspCreateNew\",\n\t\t\t\turl: `fluid-odsp://${siteURL}?${queryString}&version=null`,\n\t\t\t\tsiteUrl: siteURL,\n\t\t\t\thashedDocumentId: \"\",\n\t\t\t\tdriveId: driveID,\n\t\t\t\titemId: \"\",\n\t\t\t\tfileName,\n\t\t\t\tsummarizer: false,\n\t\t\t\tcodeHint: {\n\t\t\t\t\tcontainerPackageName: packageName ?? undefined,\n\t\t\t\t},\n\t\t\t\tfileVersion: undefined,\n\t\t\t\tshareLinkInfo,\n\t\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\t};\n\t\t}\n\t\tconst { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } = decodeOdspUrl(\n\t\t\trequest.url,\n\t\t);\n\t\tconst hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t\tassert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n\t\tconst documentUrl = `fluid-odsp://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(\n\t\t\tpath,\n\t\t)}`;\n\n\t\tconst summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\t\treturn {\n\t\t\ttype: \"fluid\",\n\t\t\todspResolvedUrl: true,\n\t\t\tendpoints: {\n\t\t\t\tsnapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentPOSTStorageUrl: getAttachmentPOSTUrl(\n\t\t\t\t\tsiteUrl,\n\t\t\t\t\tdriveId,\n\t\t\t\t\titemId,\n\t\t\t\t\tfileVersion,\n\t\t\t\t),\n\t\t\t\tattachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tdeltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t},\n\t\t\tid: hashedDocumentId,\n\t\t\ttokens: {},\n\t\t\turl: documentUrl,\n\t\t\thashedDocumentId,\n\t\t\tsiteUrl,\n\t\t\tdriveId,\n\t\t\titemId,\n\t\t\tdataStorePath: path,\n\t\t\tfileName: \"\",\n\t\t\tsummarizer,\n\t\t\tcodeHint: {\n\t\t\t\tcontainerPackageName,\n\t\t\t},\n\t\t\tfileVersion,\n\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t};\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL.\n\t * @param resolvedUrl - The driver resolved URL.\n\t * @param relativeUrl - 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\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tlet dataStorePath = relativeUrl;\n\t\tif (relativeUrl === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\t\tdataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\t\tif (dataStorePath.startsWith(\"/\")) {\n\t\t\tdataStorePath = dataStorePath.substr(1);\n\t\t}\n\n\t\t// back-compat: GitHub #9653\n\t\tconst isFluidPackage = (pkg: any) =>\n\t\t\ttypeof pkg === \"object\" &&\n\t\t\ttypeof pkg?.name === \"string\" &&\n\t\t\ttypeof pkg?.fluid === \"object\";\n\t\tlet containerPackageName;\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} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\treturn createOdspUrl({\n\t\t\t...odspResolvedUrl,\n\t\t\tcontainerPackageName,\n\t\t\tdataStorePath,\n\t\t});\n\t}\n}\n\nfunction decodeOdspUrl(url: string): {\n\tsiteUrl: string;\n\tdriveId: string;\n\titemId: string;\n\tpath: string;\n\tcontainerPackageName?: string;\n\tfileVersion?: string;\n} {\n\tconst [siteUrl, queryString] = url.split(\"?\");\n\n\tconst searchParams = new URLSearchParams(queryString);\n\n\tconst driveId = searchParams.get(\"driveId\");\n\tconst itemId = searchParams.get(\"itemId\");\n\tconst path = searchParams.get(\"path\");\n\tconst containerPackageName = searchParams.get(\"containerPackageName\");\n\tconst fileVersion = searchParams.get(\"fileVersion\");\n\n\tif (driveId === null) {\n\t\tthrow new Error(\"ODSP URL did not contain a drive id\");\n\t}\n\n\tif (itemId === null) {\n\t\tthrow new Error(\"ODSP Url did not contain an item id\");\n\t}\n\n\tif (path === null) {\n\t\tthrow new Error(\"ODSP Url did not contain a path\");\n\t}\n\n\treturn {\n\t\tsiteUrl,\n\t\tdriveId: decodeURIComponent(driveId),\n\t\titemId: decodeURIComponent(itemId),\n\t\tpath: decodeURIComponent(path),\n\t\tcontainerPackageName: containerPackageName\n\t\t\t? decodeURIComponent(containerPackageName)\n\t\t\t: undefined,\n\t\tfileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n\t};\n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,CAAC,GAAW;IAQjC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9C,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;IAEtD,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,oBAAoB,GAAG,YAAY,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAEpD,IAAI,OAAO,KAAK,IAAI,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACvD;IAED,IAAI,MAAM,KAAK,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACvD;IAED,IAAI,IAAI,KAAK,IAAI,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KACnD;IAED,OAAO;QACN,OAAO;QACP,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAClC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAC9B,oBAAoB,EAAE,oBAAoB;YACzC,CAAC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC;YAC1C,CAAC,CAAC,SAAS;QACZ,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tDriverErrorType,\n\tDriverHeader,\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tShareLinkTypes,\n\tShareLinkInfoType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { getHashedDocumentId } from \"./odspPublicUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction getUrlBase(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n\tconst siteOrigin = new URL(siteUrl).origin;\n\tconst version = fileVersion ? `versions/${fileVersion}/` : \"\";\n\treturn `${getApiRoot(siteOrigin)}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n) {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n\tif (str.startsWith(\"/\")) {\n\t\treturn str.substr(1);\n\t}\n\n\treturn str;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n * @public\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n\tconstructor() {}\n\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [siteURL, queryString] = request.url.split(\"?\");\n\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst fileName = request.headers[DriverHeader.createNew].fileName;\n\t\t\tconst driveID = searchParams.get(\"driveId\");\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tconst packageName = searchParams.get(\"containerPackageName\");\n\t\t\tconst createLinkType = searchParams.get(\"createLinkType\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive\n\t\t\tif (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Proper new file params should be there!!\",\n\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet shareLinkInfo: ShareLinkInfoType | undefined;\n\t\t\tif (createLinkType && createLinkType in ShareLinkTypes) {\n\t\t\t\tshareLinkInfo = {\n\t\t\t\t\tcreateLink: {\n\t\t\t\t\t\ttype: ShareLinkTypes[createLinkType],\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tid: \"odspCreateNew\",\n\t\t\t\turl: `fluid-odsp://${siteURL}?${queryString}&version=null`,\n\t\t\t\tsiteUrl: siteURL,\n\t\t\t\thashedDocumentId: \"\",\n\t\t\t\tdriveId: driveID,\n\t\t\t\titemId: \"\",\n\t\t\t\tfileName,\n\t\t\t\tsummarizer: false,\n\t\t\t\tcodeHint: {\n\t\t\t\t\tcontainerPackageName: packageName ?? undefined,\n\t\t\t\t},\n\t\t\t\tfileVersion: undefined,\n\t\t\t\tshareLinkInfo,\n\t\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\t};\n\t\t}\n\t\tconst { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } = decodeOdspUrl(\n\t\t\trequest.url,\n\t\t);\n\t\tconst hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t\tassert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n\t\tconst documentUrl = `fluid-odsp://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(\n\t\t\tpath,\n\t\t)}`;\n\n\t\tconst summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\t\treturn {\n\t\t\ttype: \"fluid\",\n\t\t\todspResolvedUrl: true,\n\t\t\tendpoints: {\n\t\t\t\tsnapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentPOSTStorageUrl: getAttachmentPOSTUrl(\n\t\t\t\t\tsiteUrl,\n\t\t\t\t\tdriveId,\n\t\t\t\t\titemId,\n\t\t\t\t\tfileVersion,\n\t\t\t\t),\n\t\t\t\tattachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tdeltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t},\n\t\t\tid: hashedDocumentId,\n\t\t\ttokens: {},\n\t\t\turl: documentUrl,\n\t\t\thashedDocumentId,\n\t\t\tsiteUrl,\n\t\t\tdriveId,\n\t\t\titemId,\n\t\t\tdataStorePath: path,\n\t\t\tfileName: \"\",\n\t\t\tsummarizer,\n\t\t\tcodeHint: {\n\t\t\t\tcontainerPackageName,\n\t\t\t},\n\t\t\tfileVersion,\n\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t};\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL.\n\t * @param resolvedUrl - The driver resolved URL.\n\t * @param relativeUrl - 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\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tlet dataStorePath = relativeUrl;\n\t\tif (relativeUrl === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\t\tdataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\t\tif (dataStorePath.startsWith(\"/\")) {\n\t\t\tdataStorePath = dataStorePath.substr(1);\n\t\t}\n\n\t\t// back-compat: GitHub #9653\n\t\tconst isFluidPackage = (pkg: any) =>\n\t\t\ttypeof pkg === \"object\" &&\n\t\t\ttypeof pkg?.name === \"string\" &&\n\t\t\ttypeof pkg?.fluid === \"object\";\n\t\tlet containerPackageName;\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} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\treturn createOdspUrl({\n\t\t\t...odspResolvedUrl,\n\t\t\tcontainerPackageName,\n\t\t\tdataStorePath,\n\t\t});\n\t}\n}\n\nfunction decodeOdspUrl(url: string): {\n\tsiteUrl: string;\n\tdriveId: string;\n\titemId: string;\n\tpath: string;\n\tcontainerPackageName?: string;\n\tfileVersion?: string;\n} {\n\tconst [siteUrl, queryString] = url.split(\"?\");\n\n\tconst searchParams = new URLSearchParams(queryString);\n\n\tconst driveId = searchParams.get(\"driveId\");\n\tconst itemId = searchParams.get(\"itemId\");\n\tconst path = searchParams.get(\"path\");\n\tconst containerPackageName = searchParams.get(\"containerPackageName\");\n\tconst fileVersion = searchParams.get(\"fileVersion\");\n\n\tif (driveId === null) {\n\t\tthrow new Error(\"ODSP URL did not contain a drive id\");\n\t}\n\n\tif (itemId === null) {\n\t\tthrow new Error(\"ODSP Url did not contain an item id\");\n\t}\n\n\tif (path === null) {\n\t\tthrow new Error(\"ODSP Url did not contain a path\");\n\t}\n\n\treturn {\n\t\tsiteUrl,\n\t\tdriveId: decodeURIComponent(driveId),\n\t\titemId: decodeURIComponent(itemId),\n\t\tpath: decodeURIComponent(path),\n\t\tcontainerPackageName: containerPackageName\n\t\t\t? decodeURIComponent(containerPackageName)\n\t\t\t: undefined,\n\t\tfileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n\t};\n}\n"]}
@@ -4,6 +4,7 @@ import { IOdspResolvedUrl, IdentityType, OdspResourceTokenFetchOptions, TokenFet
4
4
  import { OdspFluidDataStoreLocator } from "./contractsPublic";
5
5
  /**
6
6
  * Properties passed to the code responsible for fetching share link for a file.
7
+ * @public
7
8
  */
8
9
  export interface ShareLinkFetcherProps {
9
10
  /**
@@ -19,6 +20,7 @@ export interface ShareLinkFetcherProps {
19
20
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
20
21
  * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.
21
22
  * This resolver also handles share links and try to generate one for the use by the app.
23
+ * @public
22
24
  */
23
25
  export declare class OdspDriverUrlResolverForShareLink implements IUrlResolver {
24
26
  private readonly appName?;
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolverForShareLink.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,YAAY,EACZ,MAAM,yCAAyC,CAAC;AAOjD,OAAO,EAAE,yBAAyB,EAAqB,MAAM,mBAAmB,CAAC;AAMjF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC1D;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;CAC3B;AAED;;;;GAIG;AACH,qBAAa,iCAAkC,YAAW,YAAY;IAoBpE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IApB7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAsC;IACvE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoC;IAE1E;;;;;;;;;;;OAWG;gBA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OAEG;IACH,YAAY,EAAE,YAAY,CAAC;CAC3B;AAED;;;;;GAKG;AACH,qBAAa,iCAAkC,YAAW,YAAY;IAoBpE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IApB7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAsC;IACvE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoC;IAE1E;;;;;;;;;;;OAWG;gBAEF,qBAAqB,CAAC,EAAE,qBAAqB,GAAG,SAAS,EACzD,MAAM,CAAC,EAAE,oBAAoB,EACZ,OAAO,CAAC,oBAAQ,EAChB,UAAU,CAAC,iBACd,gBAAgB,iBACd,MAAM,KACjB,QAAQ,MAAM,GAAG,SAAS,CAAC,aAAA;IAWjC;;;OAGG;IACI,mBAAmB,CAAC,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IA4BrF,OAAO,CAAC,MAAM;IAId;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiClE,OAAO,CAAC,cAAc;YAQR,mBAAmB;IAiCjC;;;;;;;;OAQG;IACU,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,aAAa,EAAE,MAAM,EACrB,iBAAiB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,CAAC;IA6ClB;;OAEG;WACW,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB;IAQtF;;;OAGG;WACW,cAAc,CAAC,OAAO,EAAE,yBAAyB;CAG/D"}
@@ -13,6 +13,7 @@ import { getFileLink } from "./getFileLink";
13
13
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
14
14
  * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.
15
15
  * This resolver also handles share links and try to generate one for the use by the app.
16
+ * @public
16
17
  */
17
18
  export class OdspDriverUrlResolverForShareLink {
18
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAc1D,OAAO,EACN,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA6B,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C;;;;GAIG;AACH,MAAM,OAAO,iCAAiC;IAK7C;;;;;;;;;;;OAWG;IACH,YACC,qBAAyD,EACzD,MAA6B,EACZ,OAAgB,EAChB,UAGe;QAJf,YAAO,GAAP,OAAO,CAAS;QAChB,eAAU,GAAV,UAAU,CAGK;QAtBhB,qBAAgB,GAAG,IAAI,YAAY,EAAkB,CAAC;QAwBtE,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,qBAAqB,EAAE;YAC1B,IAAI,CAAC,qBAAqB,GAAG;gBAC5B,GAAG,qBAAqB;gBACxB,YAAY,EAAE,qBAAqB,CAAC,YAAY;aAChD,CAAC;SACF;IACF,CAAC;IAED;;;OAGG;IACI,mBAAmB,CAAC,UAAe,EAAE,YAAoB;QAC/D,MAAM,SAAS,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAEpD,IAAI,CAAC,SAAS,EAAE;YACf,OAAO,SAAS,CAAC;SACjB;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,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB,CAAC,OAAe,EAAE,UAAqC;QACrF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAE7B,qBAAqB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC9D,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { PromiseCache } from \"@fluidframework/core-utils\";\nimport { ITelemetryBaseLogger, IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIOdspResolvedUrl,\n\tIdentityType,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tgetLocatorFromOdspUrl,\n\tstoreLocatorInOdspUrl,\n\tencodeOdspFluidDataStoreLocator,\n\tlocatorQueryParamName,\n} from \"./odspFluidFileLink\";\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { getOdspResolvedUrl, createOdspLogger } from \"./odspUtils\";\nimport { getFileLink } from \"./getFileLink\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\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 */\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\tqueryParams.forEach((value: string, key: string) => {\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(\n\t\t\t\t\"Failed to get share link because share link fetcher props are missing\",\n\t\t\t);\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\t\tconst shareLinkUrl = new URL(shareLink);\n\n\t\tlet actualDataStorePath = dataStorePath;\n\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\tif (dataStorePath === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\tactualDataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\n\t\t// back-compat: GitHub #9653\n\t\tconst isFluidPackage = (pkg: any) =>\n\t\t\ttypeof pkg === \"object\" &&\n\t\t\ttypeof pkg?.name === \"string\" &&\n\t\t\ttypeof pkg?.fluid === \"object\";\n\t\tlet containerPackageName;\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} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\tconst context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);\n\n\t\tstoreLocatorInOdspUrl(shareLinkUrl, {\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 shareLinkUrl.href;\n\t}\n\n\t/**\n\t * Crafts a supported document/driver URL\n\t */\n\tpublic static createDocumentUrl(baseUrl: string, driverInfo: OdspFluidDataStoreLocator) {\n\t\tconst url = new URL(baseUrl);\n\n\t\tstoreLocatorInOdspUrl(url, driverInfo);\n\n\t\treturn url.href;\n\t}\n\n\t/**\n\t * Crafts a supported data store nav param\n\t * @deprecated encodeOdspFluidDataStoreLocator should be used instead\n\t */\n\tpublic static createNavParam(locator: OdspFluidDataStoreLocator) {\n\t\treturn encodeOdspFluidDataStoreLocator(locator);\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAc1D,OAAO,EACN,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA6B,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EA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CAAC,IAAI,CAAC;YAC9C,wGAAwG;SACxG;aAAM,IAAI,cAAc,CAAE,iBAAyB,EAAE,OAAO,CAAC,EAAE;YAC/D,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC;SAChE;aAAM;YACN,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC;SAC3D;QACD,oBAAoB;YACnB,oBAAoB,IAAI,eAAe,CAAC,QAAQ,EAAE,oBAAoB,CAAC;QAExE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;QAE9E,qBAAqB,CAAC,YAAY,EAAE;YACnC,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,aAAa,EAAE,mBAAmB;YAClC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,oBAAoB;YACpB,WAAW,EAAE,eAAe,CAAC,WAAW;YACxC,OAAO;SACP,CAAC,CAAC;QAEH,OAAO,YAAY,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB,CAAC,OAAe,EAAE,UAAqC;QACrF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAE7B,qBAAqB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC9D,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { PromiseCache } from \"@fluidframework/core-utils\";\nimport { ITelemetryBaseLogger, IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIOdspResolvedUrl,\n\tIdentityType,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n\tgetLocatorFromOdspUrl,\n\tstoreLocatorInOdspUrl,\n\tencodeOdspFluidDataStoreLocator,\n\tlocatorQueryParamName,\n} from \"./odspFluidFileLink\";\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { getOdspResolvedUrl, createOdspLogger } from \"./odspUtils\";\nimport { getFileLink } from \"./getFileLink\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n * @public\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 * @public\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\tqueryParams.forEach((value: string, key: string) => {\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(\n\t\t\t\t\"Failed to get share link because share link fetcher props are missing\",\n\t\t\t);\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\t\tconst shareLinkUrl = new URL(shareLink);\n\n\t\tlet actualDataStorePath = dataStorePath;\n\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\tif (dataStorePath === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\tactualDataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\n\t\t// back-compat: GitHub #9653\n\t\tconst isFluidPackage = (pkg: any) =>\n\t\t\ttypeof pkg === \"object\" &&\n\t\t\ttypeof pkg?.name === \"string\" &&\n\t\t\ttypeof pkg?.fluid === \"object\";\n\t\tlet containerPackageName;\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} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\tconst context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);\n\n\t\tstoreLocatorInOdspUrl(shareLinkUrl, {\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 shareLinkUrl.href;\n\t}\n\n\t/**\n\t * Crafts a supported document/driver URL\n\t */\n\tpublic static createDocumentUrl(baseUrl: string, driverInfo: OdspFluidDataStoreLocator) {\n\t\tconst url = new URL(baseUrl);\n\n\t\tstoreLocatorInOdspUrl(url, driverInfo);\n\n\t\treturn url.href;\n\t}\n\n\t/**\n\t * Crafts a supported data store nav param\n\t * @deprecated encodeOdspFluidDataStoreLocator should be used instead\n\t */\n\tpublic static createNavParam(locator: OdspFluidDataStoreLocator) {\n\t\treturn encodeOdspFluidDataStoreLocator(locator);\n\t}\n}\n"]}
@@ -7,20 +7,29 @@ import { OdspFluidDataStoreLocator } from "./contractsPublic";
7
7
  * Transforms given Fluid data store locator into string that can be embedded into url
8
8
  * @param locator - describes Fluid data store locator info to be encoded
9
9
  * @returns string representing encoded Fluid data store locator info
10
+ * @public
10
11
  */
11
12
  export declare function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string;
13
+ /**
14
+ * This parameter is provided by host in the resolve request and it contains information about the file
15
+ * like driveId, itemId, siteUrl, datastorePath, packageName etc.
16
+ * @public
17
+ */
12
18
  export declare const locatorQueryParamName = "nav";
13
19
  /**
14
20
  * Embeds Fluid data store locator data into given ODSP url
15
21
  * @param url - file url in ODSP format (can be either canonical or share link)
16
22
  * @param locator - object representing Fluid data store location in ODSP terms
23
+ * @public
17
24
  */
18
25
  export declare function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator): void;
19
26
  /**
20
27
  * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like
21
28
  * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.
22
29
  * @param url - ODSP url representing Fluid file link
30
+ * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true
23
31
  * @returns object representing Fluid data store location in ODSP terms
32
+ * @public
24
33
  */
25
- export declare function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | undefined;
34
+ export declare function getLocatorFromOdspUrl(url: URL, requireFluidSignature?: boolean): OdspFluidDataStoreLocator | undefined;
26
35
  //# sourceMappingURL=odspFluidFileLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspFluidFileLink.d.ts","sourceRoot":"","sources":["../src/odspFluidFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAc9D;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CA0B1F;AA2DD,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,yBAAyB,QAKjF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,yBAAyB,GAAG,SAAS,CAarF"}
1
+ {"version":3,"file":"odspFluidFileLink.d.ts","sourceRoot":"","sources":["../src/odspFluidFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAc9D;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CA0B1F;AA2DD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,yBAAyB,QAKjF;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,GAAG,EACR,qBAAqB,GAAE,OAAc,GACnC,yBAAyB,GAAG,SAAS,CAiBvC"}
@@ -18,6 +18,7 @@ const additionalContextParamName = "x";
18
18
  * Transforms given Fluid data store locator into string that can be embedded into url
19
19
  * @param locator - describes Fluid data store locator info to be encoded
20
20
  * @returns string representing encoded Fluid data store locator info
21
+ * @public
21
22
  */
22
23
  export function encodeOdspFluidDataStoreLocator(locator) {
23
24
  const siteUrl = new URL(locator.siteUrl);
@@ -45,12 +46,13 @@ export function encodeOdspFluidDataStoreLocator(locator) {
45
46
  * @param encodedLocatorValue - encoded Fluid data store locator value which was produced by
46
47
  * {@link encodeOdspFluidDataStoreLocator} function
47
48
  * @param siteOriginUrl - site origin that will be appended to encoded relative path to form absolute file url
49
+ * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true
48
50
  * @returns object representing Fluid data store location in ODSP terms
49
51
  */
50
- function decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl) {
52
+ function decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl, requireFluidSignature = true) {
51
53
  const locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));
52
54
  const signatureValue = locatorInfo.get(fluidSignatureParamName);
53
- if (signatureValue !== "1") {
55
+ if (requireFluidSignature && signatureValue !== "1") {
54
56
  return undefined;
55
57
  }
56
58
  const sitePath = locatorInfo.get(sitePathParamName);
@@ -87,13 +89,17 @@ function decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl) {
87
89
  context,
88
90
  };
89
91
  }
90
- // This parameter is provided by host in the resolve request and it contains information about the file
91
- // like driveId, itemId, siteUrl, datastorePath, packageName etc.
92
+ /**
93
+ * This parameter is provided by host in the resolve request and it contains information about the file
94
+ * like driveId, itemId, siteUrl, datastorePath, packageName etc.
95
+ * @public
96
+ */
92
97
  export const locatorQueryParamName = "nav";
93
98
  /**
94
99
  * Embeds Fluid data store locator data into given ODSP url
95
100
  * @param url - file url in ODSP format (can be either canonical or share link)
96
101
  * @param locator - object representing Fluid data store location in ODSP terms
102
+ * @public
97
103
  */
98
104
  export function storeLocatorInOdspUrl(url, locator) {
99
105
  const encodedLocatorValue = encodeOdspFluidDataStoreLocator(locator);
@@ -105,9 +111,11 @@ export function storeLocatorInOdspUrl(url, locator) {
105
111
  * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like
106
112
  * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.
107
113
  * @param url - ODSP url representing Fluid file link
114
+ * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true
108
115
  * @returns object representing Fluid data store location in ODSP terms
116
+ * @public
109
117
  */
110
- export function getLocatorFromOdspUrl(url) {
118
+ export function getLocatorFromOdspUrl(url, requireFluidSignature = true) {
111
119
  // NOTE: No need to apply decodeURIComponent when accessing query params via URLSearchParams class.
112
120
  const encodedLocatorValue = url.searchParams.get(locatorQueryParamName);
113
121
  if (!encodedLocatorValue) {
@@ -116,6 +124,6 @@ export function getLocatorFromOdspUrl(url) {
116
124
  // IMPORTANT: ODC deviates from ODSP in that its file link origin is different from vroom api origin.
117
125
  // The following code passes vroom api origin as site origin instead of file origin.
118
126
  const siteOriginUrl = url.origin.toLowerCase() === OdcFileSiteOrigin ? OdcApiSiteOrigin : url.origin;
119
- return decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl);
127
+ return decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl, requireFluidSignature);
120
128
  }
121
129
  //# sourceMappingURL=odspFluidFileLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspFluidFileLink.js","sourceRoot":"","sources":["../src/odspFluidFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,0BAA0B,GAAG,GAAG,CAAC;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AAO;QACP,MAAM;QACN,aAAa;QACb,OAAO;QACP,oBAAoB;QACpB,WAAW;QACX,OAAO;KACP,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ,EAAE,OAAkC;IACjF,MAAM,mBAAmB,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACrE,0GAA0G;IAC1G,qCAAqC;IACrC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ;IAC7C,mGAAmG;IACnG,MAAM,mBAAmB,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACxE,IAAI,CAAC,mBAAmB,EAAE;QACzB,OAAO,SAAS,CAAC;KACjB;IAED,qGAAqG;IACrG,oFAAoF;IACpF,MAAM,aAAa,GAClB,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IAEhF,OAAO,+BAA+B,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8, fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { OdspFluidDataStoreLocator } from \"./contractsPublic\";\nimport { OdcFileSiteOrigin, OdcApiSiteOrigin } from \"./constants\";\n\nconst fluidSignature = \"1\";\nconst fluidSignatureParamName = \"fluid\";\nconst sitePathParamName = \"s\";\nconst driveIdParamName = \"d\";\nconst itemIdParamName = \"f\";\nconst dataStorePathParamName = \"c\";\nconst appNameParamName = \"a\";\nconst containerPackageNameParamName = \"p\";\nconst fileVersionParamName = \"v\";\nconst additionalContextParamName = \"x\";\n\n/**\n * Transforms given Fluid data store locator into string that can be embedded into url\n * @param locator - describes Fluid data store locator info to be encoded\n * @returns string representing encoded Fluid data store locator info\n */\nexport function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string {\n\tconst siteUrl = new URL(locator.siteUrl);\n\tconst sitePath = encodeURIComponent(siteUrl.pathname);\n\tconst driveId = encodeURIComponent(locator.driveId);\n\tconst itemId = encodeURIComponent(locator.itemId);\n\tconst dataStorePath = encodeURIComponent(locator.dataStorePath);\n\n\tlet locatorSerialized = `${sitePathParamName}=${sitePath}&${driveIdParamName}=${driveId}&${itemIdParamName}=${itemId}&${dataStorePathParamName}=${dataStorePath}&${fluidSignatureParamName}=${fluidSignature}`;\n\tif (locator.appName) {\n\t\tlocatorSerialized += `&${appNameParamName}=${encodeURIComponent(locator.appName)}`;\n\t}\n\tif (locator.containerPackageName) {\n\t\tlocatorSerialized += `&${containerPackageNameParamName}=${encodeURIComponent(\n\t\t\tlocator.containerPackageName,\n\t\t)}`;\n\t}\n\tif (locator.fileVersion) {\n\t\tlocatorSerialized += `&${fileVersionParamName}=${encodeURIComponent(locator.fileVersion)}`;\n\t}\n\tif (locator.context) {\n\t\tlocatorSerialized += `&${additionalContextParamName}=${encodeURIComponent(\n\t\t\tlocator.context,\n\t\t)}`;\n\t}\n\n\treturn fromUtf8ToBase64(locatorSerialized);\n}\n\n/**\n * Decodes given encoded value representing Fluid data store locator extracted from ODSP Fluid file link\n * @param encodedLocatorValue - encoded Fluid data store locator value which was produced by\n * {@link encodeOdspFluidDataStoreLocator} function\n * @param siteOriginUrl - site origin that will be appended to encoded relative path to form absolute file url\n * @returns object representing Fluid data store location in ODSP terms\n */\nfunction decodeOdspFluidDataStoreLocator(\n\tencodedLocatorValue: string,\n\tsiteOriginUrl: string,\n): OdspFluidDataStoreLocator | undefined {\n\tconst locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));\n\n\tconst signatureValue = locatorInfo.get(fluidSignatureParamName);\n\tif (signatureValue !== \"1\") {\n\t\treturn undefined;\n\t}\n\n\tconst sitePath = locatorInfo.get(sitePathParamName);\n\tconst driveId = locatorInfo.get(driveIdParamName);\n\tconst itemId = locatorInfo.get(itemIdParamName);\n\tconst dataStorePath = locatorInfo.get(dataStorePathParamName);\n\tconst appName = locatorInfo.get(appNameParamName) ?? undefined;\n\tconst containerPackageName = locatorInfo.get(containerPackageNameParamName) ?? undefined;\n\tconst fileVersion = locatorInfo.get(fileVersionParamName) ?? undefined;\n\tconst context = locatorInfo.get(additionalContextParamName) ?? undefined;\n\t// \"\" is a valid value for dataStorePath so simply check for absence of the param;\n\t// file storage locator params must be present and non-empty\n\tif (!sitePath || !driveId || !itemId || dataStorePath === null) {\n\t\treturn undefined;\n\t}\n\n\tlet siteUrl: URL | undefined;\n\ttry {\n\t\tsiteUrl = new URL(sitePath, siteOriginUrl);\n\t} catch {\n\t\t// Ignore failure to parse url as input might be malformed\n\t}\n\n\tif (!siteUrl) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tsiteUrl: siteUrl.href,\n\t\tdriveId,\n\t\titemId,\n\t\tdataStorePath,\n\t\tappName,\n\t\tcontainerPackageName,\n\t\tfileVersion,\n\t\tcontext,\n\t};\n}\n\n// This parameter is provided by host in the resolve request and it contains information about the file\n// like driveId, itemId, siteUrl, datastorePath, packageName etc.\nexport const locatorQueryParamName = \"nav\";\n\n/**\n * Embeds Fluid data store locator data into given ODSP url\n * @param url - file url in ODSP format (can be either canonical or share link)\n * @param locator - object representing Fluid data store location in ODSP terms\n */\nexport function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator) {\n\tconst encodedLocatorValue = encodeOdspFluidDataStoreLocator(locator);\n\t// IMPORTANT: Do not apply encodeURIComponent to encodedLocatorValue, param value is automatically encoded\n\t// when set via URLSearchParams class\n\turl.searchParams.set(locatorQueryParamName, encodedLocatorValue);\n}\n\n/**\n * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like\n * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.\n * @param url - ODSP url representing Fluid file link\n * @returns object representing Fluid data store location in ODSP terms\n */\nexport function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | undefined {\n\t// NOTE: No need to apply decodeURIComponent when accessing query params via URLSearchParams class.\n\tconst encodedLocatorValue = url.searchParams.get(locatorQueryParamName);\n\tif (!encodedLocatorValue) {\n\t\treturn undefined;\n\t}\n\n\t// IMPORTANT: ODC deviates from ODSP in that its file link origin is different from vroom api origin.\n\t// The following code passes vroom api origin as site origin instead of file origin.\n\tconst siteOriginUrl =\n\t\turl.origin.toLowerCase() === OdcFileSiteOrigin ? OdcApiSiteOrigin : url.origin;\n\n\treturn decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl);\n}\n"]}
1
+ {"version":3,"file":"odspFluidFileLink.js","sourceRoot":"","sources":["../src/odspFluidFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,UAAU,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OAAO;QACP,MAAM;QACN,aAAa;QACb,OAAO;QACP,oBAAoB;QACpB,WAAW;QACX,OAAO;KACP,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAQ,EAAE,OAAkC;IACjF,MAAM,mBAAmB,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACrE,0GAA0G;IAC1G,qCAAqC;IACrC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACpC,GAAQ,EACR,wBAAiC,IAAI;IAErC,mGAAmG;IACnG,MAAM,mBAAmB,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACxE,IAAI,CAAC,mBAAmB,EAAE;QACzB,OAAO,SAAS,CAAC;KACjB;IAED,qGAAqG;IACrG,oFAAoF;IACpF,MAAM,aAAa,GAClB,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IAEhF,OAAO,+BAA+B,CACrC,mBAAmB,EACnB,aAAa,EACb,qBAAqB,CACrB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromBase64ToUtf8, fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { OdspFluidDataStoreLocator } from \"./contractsPublic\";\nimport { OdcFileSiteOrigin, OdcApiSiteOrigin } from \"./constants\";\n\nconst fluidSignature = \"1\";\nconst fluidSignatureParamName = \"fluid\";\nconst sitePathParamName = \"s\";\nconst driveIdParamName = \"d\";\nconst itemIdParamName = \"f\";\nconst dataStorePathParamName = \"c\";\nconst appNameParamName = \"a\";\nconst containerPackageNameParamName = \"p\";\nconst fileVersionParamName = \"v\";\nconst additionalContextParamName = \"x\";\n\n/**\n * Transforms given Fluid data store locator into string that can be embedded into url\n * @param locator - describes Fluid data store locator info to be encoded\n * @returns string representing encoded Fluid data store locator info\n * @public\n */\nexport function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string {\n\tconst siteUrl = new URL(locator.siteUrl);\n\tconst sitePath = encodeURIComponent(siteUrl.pathname);\n\tconst driveId = encodeURIComponent(locator.driveId);\n\tconst itemId = encodeURIComponent(locator.itemId);\n\tconst dataStorePath = encodeURIComponent(locator.dataStorePath);\n\n\tlet locatorSerialized = `${sitePathParamName}=${sitePath}&${driveIdParamName}=${driveId}&${itemIdParamName}=${itemId}&${dataStorePathParamName}=${dataStorePath}&${fluidSignatureParamName}=${fluidSignature}`;\n\tif (locator.appName) {\n\t\tlocatorSerialized += `&${appNameParamName}=${encodeURIComponent(locator.appName)}`;\n\t}\n\tif (locator.containerPackageName) {\n\t\tlocatorSerialized += `&${containerPackageNameParamName}=${encodeURIComponent(\n\t\t\tlocator.containerPackageName,\n\t\t)}`;\n\t}\n\tif (locator.fileVersion) {\n\t\tlocatorSerialized += `&${fileVersionParamName}=${encodeURIComponent(locator.fileVersion)}`;\n\t}\n\tif (locator.context) {\n\t\tlocatorSerialized += `&${additionalContextParamName}=${encodeURIComponent(\n\t\t\tlocator.context,\n\t\t)}`;\n\t}\n\n\treturn fromUtf8ToBase64(locatorSerialized);\n}\n\n/**\n * Decodes given encoded value representing Fluid data store locator extracted from ODSP Fluid file link\n * @param encodedLocatorValue - encoded Fluid data store locator value which was produced by\n * {@link encodeOdspFluidDataStoreLocator} function\n * @param siteOriginUrl - site origin that will be appended to encoded relative path to form absolute file url\n * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true\n * @returns object representing Fluid data store location in ODSP terms\n */\nfunction decodeOdspFluidDataStoreLocator(\n\tencodedLocatorValue: string,\n\tsiteOriginUrl: string,\n\trequireFluidSignature: boolean = true,\n): OdspFluidDataStoreLocator | undefined {\n\tconst locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));\n\n\tconst signatureValue = locatorInfo.get(fluidSignatureParamName);\n\tif (requireFluidSignature && signatureValue !== \"1\") {\n\t\treturn undefined;\n\t}\n\n\tconst sitePath = locatorInfo.get(sitePathParamName);\n\tconst driveId = locatorInfo.get(driveIdParamName);\n\tconst itemId = locatorInfo.get(itemIdParamName);\n\tconst dataStorePath = locatorInfo.get(dataStorePathParamName);\n\tconst appName = locatorInfo.get(appNameParamName) ?? undefined;\n\tconst containerPackageName = locatorInfo.get(containerPackageNameParamName) ?? undefined;\n\tconst fileVersion = locatorInfo.get(fileVersionParamName) ?? undefined;\n\tconst context = locatorInfo.get(additionalContextParamName) ?? undefined;\n\t// \"\" is a valid value for dataStorePath so simply check for absence of the param;\n\t// file storage locator params must be present and non-empty\n\tif (!sitePath || !driveId || !itemId || dataStorePath === null) {\n\t\treturn undefined;\n\t}\n\n\tlet siteUrl: URL | undefined;\n\ttry {\n\t\tsiteUrl = new URL(sitePath, siteOriginUrl);\n\t} catch {\n\t\t// Ignore failure to parse url as input might be malformed\n\t}\n\n\tif (!siteUrl) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tsiteUrl: siteUrl.href,\n\t\tdriveId,\n\t\titemId,\n\t\tdataStorePath,\n\t\tappName,\n\t\tcontainerPackageName,\n\t\tfileVersion,\n\t\tcontext,\n\t};\n}\n\n/**\n * This parameter is provided by host in the resolve request and it contains information about the file\n * like driveId, itemId, siteUrl, datastorePath, packageName etc.\n * @public\n */\nexport const locatorQueryParamName = \"nav\";\n\n/**\n * Embeds Fluid data store locator data into given ODSP url\n * @param url - file url in ODSP format (can be either canonical or share link)\n * @param locator - object representing Fluid data store location in ODSP terms\n * @public\n */\nexport function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator) {\n\tconst encodedLocatorValue = encodeOdspFluidDataStoreLocator(locator);\n\t// IMPORTANT: Do not apply encodeURIComponent to encodedLocatorValue, param value is automatically encoded\n\t// when set via URLSearchParams class\n\turl.searchParams.set(locatorQueryParamName, encodedLocatorValue);\n}\n\n/**\n * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like\n * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.\n * @param url - ODSP url representing Fluid file link\n * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true\n * @returns object representing Fluid data store location in ODSP terms\n * @public\n */\nexport function getLocatorFromOdspUrl(\n\turl: URL,\n\trequireFluidSignature: boolean = true,\n): OdspFluidDataStoreLocator | undefined {\n\t// NOTE: No need to apply decodeURIComponent when accessing query params via URLSearchParams class.\n\tconst encodedLocatorValue = url.searchParams.get(locatorQueryParamName);\n\tif (!encodedLocatorValue) {\n\t\treturn undefined;\n\t}\n\n\t// IMPORTANT: ODC deviates from ODSP in that its file link origin is different from vroom api origin.\n\t// The following code passes vroom api origin as site origin instead of file origin.\n\tconst siteOriginUrl =\n\t\turl.origin.toLowerCase() === OdcFileSiteOrigin ? OdcApiSiteOrigin : url.origin;\n\n\treturn decodeOdspFluidDataStoreLocator(\n\t\tencodedLocatorValue,\n\t\tsiteOriginUrl,\n\t\trequireFluidSignature,\n\t);\n}\n"]}
@@ -3,7 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
6
+ /**
7
+ * @public
8
+ */
6
9
  export declare function getHashedDocumentId(driveId: string, itemId: string): Promise<string>;
10
+ /**
11
+ * @public
12
+ */
7
13
  export interface ISnapshotContents {
8
14
  snapshotTree: ISnapshotTree;
9
15
  blobs: Map<string, ArrayBuffer>;
@@ -1 +1 @@
1
- {"version":3,"file":"odspPublicUtils.d.ts","sourceRoot":"","sources":["../src/odspPublicUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAEhG,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG1F;AAED,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,aAAa,CAAC;IAC5B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChC,GAAG,EAAE,yBAAyB,EAAE,CAAC;IAEjC;;OAEG;IACH,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC"}
1
+ {"version":3,"file":"odspPublicUtils.d.ts","sourceRoot":"","sources":["../src/odspPublicUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAEhG;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG1F;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,aAAa,CAAC;IAC5B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChC,GAAG,EAAE,yBAAyB,EAAE,CAAC;IAEjC;;OAEG;IACH,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC"}