@fluidframework/odsp-driver 2.1.0-274160 → 2.1.0-276985
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/api-report/{odsp-driver.alpha.api.md → odsp-driver.legacy.alpha.api.md} +1 -1
- package/dist/checkUrl.d.ts +1 -0
- package/dist/checkUrl.d.ts.map +1 -1
- package/dist/checkUrl.js +1 -0
- package/dist/checkUrl.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/contractsPublic.d.ts +1 -0
- package/dist/contractsPublic.d.ts.map +1 -1
- package/dist/contractsPublic.js.map +1 -1
- package/dist/createFile.d.ts +3 -3
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js +11 -9
- package/dist/createFile.js.map +1 -1
- package/dist/createNewContainerOnExistingFile.d.ts +1 -1
- package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
- package/dist/createNewContainerOnExistingFile.js +2 -2
- package/dist/createNewContainerOnExistingFile.js.map +1 -1
- package/dist/createNewUtils.d.ts +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +24 -18
- package/dist/createNewUtils.js.map +1 -1
- package/dist/createOdspCreateContainerRequest.d.ts +1 -0
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/createOdspCreateContainerRequest.js +1 -0
- package/dist/createOdspCreateContainerRequest.js.map +1 -1
- package/dist/createOdspUrl.d.ts +1 -0
- package/dist/createOdspUrl.d.ts.map +1 -1
- package/dist/createOdspUrl.js +1 -0
- package/dist/createOdspUrl.js.map +1 -1
- package/dist/epochTracker.d.ts +4 -0
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +1 -0
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +7 -9
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +23 -21
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.js +14 -8
- package/dist/getFileLink.js.map +1 -1
- package/dist/getUrlAndHeadersWithAuth.d.ts +2 -5
- package/dist/getUrlAndHeadersWithAuth.d.ts.map +1 -1
- package/dist/getUrlAndHeadersWithAuth.js +7 -28
- package/dist/getUrlAndHeadersWithAuth.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/odspCache.d.ts +4 -0
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspCache.js.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.d.ts +3 -4
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.js +4 -5
- package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +2 -2
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +9 -8
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentService.d.ts +4 -4
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +9 -9
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactory.d.ts +2 -0
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactory.js +2 -0
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +1 -0
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +7 -4
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +2 -2
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +25 -19
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts +9 -0
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +3 -1
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -0
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +1 -0
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspFluidFileLink.d.ts +4 -0
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspFluidFileLink.js +4 -0
- package/dist/odspFluidFileLink.js.map +1 -1
- package/dist/odspPublicUtils.d.ts +2 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/odspPublicUtils.js +1 -0
- package/dist/odspPublicUtils.js.map +1 -1
- package/dist/odspSnapshotParser.js +2 -2
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts +2 -3
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +8 -6
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUtils.d.ts +12 -3
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +10 -6
- package/dist/odspUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/prefetchLatestSnapshot.d.ts +2 -1
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +6 -5
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/vroom.d.ts +2 -2
- package/dist/vroom.d.ts.map +1 -1
- package/dist/vroom.js +7 -9
- package/dist/vroom.js.map +1 -1
- package/lib/checkUrl.d.ts +1 -0
- package/lib/checkUrl.d.ts.map +1 -1
- package/lib/checkUrl.js +1 -0
- package/lib/checkUrl.js.map +1 -1
- package/lib/constants.d.ts +2 -0
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +2 -0
- package/lib/constants.js.map +1 -1
- package/lib/contractsPublic.d.ts +1 -0
- package/lib/contractsPublic.d.ts.map +1 -1
- package/lib/contractsPublic.js.map +1 -1
- package/lib/createFile.d.ts +3 -3
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js +12 -10
- package/lib/createFile.js.map +1 -1
- package/lib/createNewContainerOnExistingFile.d.ts +1 -1
- package/lib/createNewContainerOnExistingFile.d.ts.map +1 -1
- package/lib/createNewContainerOnExistingFile.js +2 -2
- package/lib/createNewContainerOnExistingFile.js.map +1 -1
- package/lib/createNewUtils.d.ts +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +26 -20
- package/lib/createNewUtils.js.map +1 -1
- package/lib/createOdspCreateContainerRequest.d.ts +1 -0
- package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/lib/createOdspCreateContainerRequest.js +1 -0
- package/lib/createOdspCreateContainerRequest.js.map +1 -1
- package/lib/createOdspUrl.d.ts +1 -0
- package/lib/createOdspUrl.d.ts.map +1 -1
- package/lib/createOdspUrl.js +1 -0
- package/lib/createOdspUrl.js.map +1 -1
- package/lib/epochTracker.d.ts +4 -0
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +1 -0
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts +7 -9
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +24 -22
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.js +15 -9
- package/lib/getFileLink.js.map +1 -1
- package/lib/getUrlAndHeadersWithAuth.d.ts +2 -5
- package/lib/getUrlAndHeadersWithAuth.d.ts.map +1 -1
- package/lib/getUrlAndHeadersWithAuth.js +5 -26
- package/lib/getUrlAndHeadersWithAuth.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/odspCache.d.ts +4 -0
- package/lib/odspCache.d.ts.map +1 -1
- package/lib/odspCache.js.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.d.ts +3 -4
- package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.js +4 -5
- package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts +2 -2
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +9 -8
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentService.d.ts +4 -4
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +9 -9
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactory.d.ts +2 -0
- package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactory.js +2 -0
- package/lib/odspDocumentServiceFactory.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +1 -0
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +7 -4
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +2 -2
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +26 -20
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDriverUrlResolver.d.ts +9 -0
- package/lib/odspDriverUrlResolver.d.ts.map +1 -1
- package/lib/odspDriverUrlResolver.js +2 -1
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -0
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +1 -0
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspFluidFileLink.d.ts +4 -0
- package/lib/odspFluidFileLink.d.ts.map +1 -1
- package/lib/odspFluidFileLink.js +4 -0
- package/lib/odspFluidFileLink.js.map +1 -1
- package/lib/odspPublicUtils.d.ts +2 -0
- package/lib/odspPublicUtils.d.ts.map +1 -1
- package/lib/odspPublicUtils.js +1 -0
- package/lib/odspPublicUtils.js.map +1 -1
- package/lib/odspSnapshotParser.js +2 -2
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts +2 -3
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +9 -7
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUtils.d.ts +12 -3
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +11 -7
- package/lib/odspUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/prefetchLatestSnapshot.d.ts +2 -1
- package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
- package/lib/prefetchLatestSnapshot.js +6 -5
- package/lib/prefetchLatestSnapshot.js.map +1 -1
- package/lib/vroom.d.ts +2 -2
- package/lib/vroom.d.ts.map +1 -1
- package/lib/vroom.js +7 -9
- package/lib/vroom.js.map +1 -1
- package/package.json +13 -13
- package/src/checkUrl.ts +1 -0
- package/src/constants.ts +2 -0
- package/src/contractsPublic.ts +1 -0
- package/src/createFile.ts +15 -21
- package/src/createNewContainerOnExistingFile.ts +2 -2
- package/src/createNewUtils.ts +35 -26
- package/src/createOdspCreateContainerRequest.ts +1 -0
- package/src/createOdspUrl.ts +1 -0
- package/src/epochTracker.ts +4 -0
- package/src/fetchSnapshot.ts +36 -34
- package/src/getFileLink.ts +27 -20
- package/src/getUrlAndHeadersWithAuth.ts +6 -31
- package/src/odspCache.ts +4 -0
- package/src/odspDelayLoadedDeltaStream.ts +4 -5
- package/src/odspDeltaStorageService.ts +11 -7
- package/src/odspDocumentService.ts +8 -8
- package/src/odspDocumentServiceFactory.ts +2 -0
- package/src/odspDocumentServiceFactoryCore.ts +6 -3
- package/src/odspDocumentStorageManager.ts +36 -33
- package/src/odspDriverUrlResolver.ts +2 -1
- package/src/odspDriverUrlResolverForShareLink.ts +2 -0
- package/src/odspFluidFileLink.ts +4 -0
- package/src/odspPublicUtils.ts +2 -0
- package/src/odspSnapshotParser.ts +2 -2
- package/src/odspSummaryUploadManager.ts +11 -10
- package/src/odspUtils.ts +20 -6
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +10 -5
- package/src/vroom.ts +11 -11
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
fetchSnapshot,
|
|
52
52
|
fetchSnapshotWithRedeem,
|
|
53
53
|
} from "./fetchSnapshot.js";
|
|
54
|
-
import {
|
|
54
|
+
import { getHeadersWithAuth } from "./getUrlAndHeadersWithAuth.js";
|
|
55
55
|
import { IOdspCache, IPrefetchSnapshotContents } from "./odspCache.js";
|
|
56
56
|
import { FlushResult } from "./odspDocumentDeltaConnection.js";
|
|
57
57
|
import { OdspDocumentStorageServiceBase } from "./odspDocumentStorageServiceBase.js";
|
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
isInstanceOfISnapshot,
|
|
64
64
|
isSnapshotFetchForLoadingGroup,
|
|
65
65
|
useLegacyFlowWithoutGroupsForSnapshotFetch,
|
|
66
|
+
type TokenFetchOptionsEx,
|
|
66
67
|
} from "./odspUtils.js";
|
|
67
68
|
import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
68
69
|
|
|
@@ -98,7 +99,7 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
98
99
|
|
|
99
100
|
constructor(
|
|
100
101
|
private readonly odspResolvedUrl: IOdspResolvedUrl,
|
|
101
|
-
private readonly
|
|
102
|
+
private readonly getAuthHeader: InstrumentedStorageTokenFetcher,
|
|
102
103
|
private readonly logger: ITelemetryLoggerExt,
|
|
103
104
|
private readonly fetchFullSnapshot: boolean,
|
|
104
105
|
private readonly cache: IOdspCache,
|
|
@@ -124,12 +125,13 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
124
125
|
this.checkAttachmentPOSTUrl();
|
|
125
126
|
|
|
126
127
|
const response = await getWithRetryForTokenRefresh(async (options) => {
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
const url = `${this.attachmentPOSTUrl}/content`;
|
|
129
|
+
const method = "POST";
|
|
130
|
+
const authHeader = await this.getAuthHeader(
|
|
131
|
+
{ ...options, request: { url, method } },
|
|
132
|
+
"CreateBlob",
|
|
132
133
|
);
|
|
134
|
+
const headers = getHeadersWithAuth(authHeader);
|
|
133
135
|
headers["Content-Type"] = "application/octet-stream";
|
|
134
136
|
|
|
135
137
|
return PerformanceEvent.timedExecAsync(
|
|
@@ -146,7 +148,7 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
146
148
|
{
|
|
147
149
|
body: file,
|
|
148
150
|
headers,
|
|
149
|
-
method
|
|
151
|
+
method,
|
|
150
152
|
},
|
|
151
153
|
"createBlob",
|
|
152
154
|
),
|
|
@@ -170,13 +172,13 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
170
172
|
this.checkAttachmentGETUrl();
|
|
171
173
|
|
|
172
174
|
const blob = await getWithRetryForTokenRefresh(async (options) => {
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
|
|
175
|
+
const url = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;
|
|
176
|
+
const method = "GET";
|
|
177
|
+
const authHeader = await this.getAuthHeader(
|
|
178
|
+
{ ...options, request: { url, method } },
|
|
179
|
+
"GetBlob",
|
|
179
180
|
);
|
|
181
|
+
const headers = getHeadersWithAuth(authHeader);
|
|
180
182
|
|
|
181
183
|
return PerformanceEvent.timedExecAsync(
|
|
182
184
|
this.logger,
|
|
@@ -483,12 +485,13 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
483
485
|
}
|
|
484
486
|
|
|
485
487
|
return getWithRetryForTokenRefresh(async (options) => {
|
|
486
|
-
const
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
const url = `${this.snapshotUrl}/versions?top=${count}`;
|
|
489
|
+
const method = "GET";
|
|
490
|
+
const storageToken = await this.getAuthHeader(
|
|
491
|
+
{ ...options, request: { url, method } },
|
|
492
|
+
"GetVersions",
|
|
491
493
|
);
|
|
494
|
+
const headers = getHeadersWithAuth(storageToken);
|
|
492
495
|
|
|
493
496
|
// Fetch the latest snapshot versions for the document
|
|
494
497
|
const response = await PerformanceEvent.timedExecAsync(
|
|
@@ -604,14 +607,16 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
604
607
|
|
|
605
608
|
const snapshotDownloader = async (
|
|
606
609
|
finalOdspResolvedUrl: IOdspResolvedUrl,
|
|
607
|
-
|
|
610
|
+
tokenFetcher: InstrumentedStorageTokenFetcher,
|
|
611
|
+
tokenFetchOptions: TokenFetchOptionsEx,
|
|
608
612
|
loadingGroupId: string[] | undefined,
|
|
609
613
|
options: ISnapshotOptions | undefined,
|
|
610
614
|
controller?: AbortController,
|
|
611
615
|
): Promise<ISnapshotRequestAndResponseOptions> => {
|
|
612
616
|
return downloadSnapshot(
|
|
613
617
|
finalOdspResolvedUrl,
|
|
614
|
-
|
|
618
|
+
tokenFetcher,
|
|
619
|
+
tokenFetchOptions,
|
|
615
620
|
loadingGroupId,
|
|
616
621
|
options,
|
|
617
622
|
this.snapshotFormatFetchType,
|
|
@@ -631,7 +636,7 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
631
636
|
try {
|
|
632
637
|
const odspSnapshot = await fetchSnapshotWithRedeem(
|
|
633
638
|
this.odspResolvedUrl,
|
|
634
|
-
this.
|
|
639
|
+
this.getAuthHeader,
|
|
635
640
|
snapshotOptions,
|
|
636
641
|
!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
|
|
637
642
|
this.logger,
|
|
@@ -673,7 +678,7 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
673
678
|
};
|
|
674
679
|
const odspSnapshot = await fetchSnapshotWithRedeem(
|
|
675
680
|
this.odspResolvedUrl,
|
|
676
|
-
this.
|
|
681
|
+
this.getAuthHeader,
|
|
677
682
|
snapshotOptionsWithoutBlobs,
|
|
678
683
|
!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
|
|
679
684
|
this.logger,
|
|
@@ -767,10 +772,9 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
767
772
|
});
|
|
768
773
|
this.odspSummaryUploadManager = new module.OdspSummaryUploadManager(
|
|
769
774
|
this.odspResolvedUrl.endpoints.snapshotStorageUrl,
|
|
770
|
-
this.
|
|
775
|
+
this.getAuthHeader,
|
|
771
776
|
this.logger,
|
|
772
777
|
this.epochTracker,
|
|
773
|
-
!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
|
|
774
778
|
this.relayServiceTenantAndSessionId,
|
|
775
779
|
);
|
|
776
780
|
return this.odspSummaryUploadManager;
|
|
@@ -811,15 +815,15 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
811
815
|
scenarioName?: string,
|
|
812
816
|
): Promise<ISnapshotTree | undefined> {
|
|
813
817
|
return getWithRetryForTokenRefresh(async (options) => {
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
818
|
+
const snapshotDownloader = async (url: string): Promise<IOdspResponse<unknown>> => {
|
|
819
|
+
const authHeader = await this.getAuthHeader(
|
|
820
|
+
{ ...options, request: { url, method: "GET" } },
|
|
821
|
+
"ReadCommit",
|
|
822
|
+
);
|
|
823
|
+
const headers = getHeadersWithAuth(authHeader);
|
|
820
824
|
return this.epochTracker.fetchAndParseAsJSON(
|
|
821
825
|
url,
|
|
822
|
-
|
|
826
|
+
{ headers },
|
|
823
827
|
"snapshotTree",
|
|
824
828
|
undefined,
|
|
825
829
|
scenarioName,
|
|
@@ -827,7 +831,6 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
827
831
|
};
|
|
828
832
|
const snapshot = await fetchSnapshot(
|
|
829
833
|
this.snapshotUrl!,
|
|
830
|
-
storageToken,
|
|
831
834
|
id,
|
|
832
835
|
this.fetchFullSnapshot,
|
|
833
836
|
!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,
|
|
@@ -93,6 +93,7 @@ const isFluidPackage = (pkg: Record<string, unknown>): boolean =>
|
|
|
93
93
|
/**
|
|
94
94
|
* Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
|
|
95
95
|
* url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`
|
|
96
|
+
* @legacy
|
|
96
97
|
* @alpha
|
|
97
98
|
*/
|
|
98
99
|
export class OdspDriverUrlResolver implements IUrlResolver {
|
|
@@ -230,7 +231,7 @@ export class OdspDriverUrlResolver implements IUrlResolver {
|
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
|
|
233
|
-
function decodeOdspUrl(url: string): {
|
|
234
|
+
export function decodeOdspUrl(url: string): {
|
|
234
235
|
siteUrl: string;
|
|
235
236
|
driveId: string;
|
|
236
237
|
itemId: string;
|
|
@@ -31,6 +31,7 @@ import { createOdspLogger, getOdspResolvedUrl } from "./odspUtils.js";
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Properties passed to the code responsible for fetching share link for a file.
|
|
34
|
+
* @legacy
|
|
34
35
|
* @alpha
|
|
35
36
|
*/
|
|
36
37
|
export interface ShareLinkFetcherProps {
|
|
@@ -52,6 +53,7 @@ const isFluidPackage = (pkg: Record<string, unknown>): boolean =>
|
|
|
52
53
|
* Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
|
|
53
54
|
* url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.
|
|
54
55
|
* This resolver also handles share links and try to generate one for the use by the app.
|
|
56
|
+
* @legacy
|
|
55
57
|
* @alpha
|
|
56
58
|
*/
|
|
57
59
|
export class OdspDriverUrlResolverForShareLink implements IUrlResolver {
|
package/src/odspFluidFileLink.ts
CHANGED
|
@@ -23,6 +23,7 @@ const additionalContextParamName = "x";
|
|
|
23
23
|
* Transforms given Fluid data store locator into string that can be embedded into url
|
|
24
24
|
* @param locator - describes Fluid data store locator info to be encoded
|
|
25
25
|
* @returns string representing encoded Fluid data store locator info
|
|
26
|
+
* @legacy
|
|
26
27
|
* @alpha
|
|
27
28
|
*/
|
|
28
29
|
export function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string {
|
|
@@ -113,6 +114,7 @@ function decodeOdspFluidDataStoreLocator(
|
|
|
113
114
|
/**
|
|
114
115
|
* This parameter is provided by host in the resolve request and it contains information about the file
|
|
115
116
|
* like driveId, itemId, siteUrl, datastorePath, packageName etc.
|
|
117
|
+
* @legacy
|
|
116
118
|
* @alpha
|
|
117
119
|
*/
|
|
118
120
|
export const locatorQueryParamName = "nav";
|
|
@@ -121,6 +123,7 @@ export const locatorQueryParamName = "nav";
|
|
|
121
123
|
* Embeds Fluid data store locator data into given ODSP url
|
|
122
124
|
* @param url - file url in ODSP format (can be either canonical or share link)
|
|
123
125
|
* @param locator - object representing Fluid data store location in ODSP terms
|
|
126
|
+
* @legacy
|
|
124
127
|
* @alpha
|
|
125
128
|
*/
|
|
126
129
|
export function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator): void {
|
|
@@ -136,6 +139,7 @@ export function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocat
|
|
|
136
139
|
* @param url - ODSP url representing Fluid file link
|
|
137
140
|
* @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true
|
|
138
141
|
* @returns object representing Fluid data store location in ODSP terms
|
|
142
|
+
* @legacy
|
|
139
143
|
* @alpha
|
|
140
144
|
*/
|
|
141
145
|
export function getLocatorFromOdspUrl(
|
package/src/odspPublicUtils.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
* Creates a unique and stable id for a document stored in ODSP which doesn't expose the driveId and itemId of
|
|
14
14
|
* said document.
|
|
15
15
|
*
|
|
16
|
+
* @legacy
|
|
16
17
|
* @alpha
|
|
17
18
|
*/
|
|
18
19
|
export async function getHashedDocumentId(driveId: string, itemId: string): Promise<string> {
|
|
@@ -21,6 +22,7 @@ export async function getHashedDocumentId(driveId: string, itemId: string): Prom
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
25
|
+
* @legacy
|
|
24
26
|
* @alpha
|
|
25
27
|
* @deprecated - This is deprecated.
|
|
26
28
|
*/
|
|
@@ -38,10 +38,10 @@ function buildHierarchy(flatTree: IOdspSnapshotCommit): ISnapshotTree {
|
|
|
38
38
|
unreferenced: entry.unreferenced,
|
|
39
39
|
groupId: entry.groupId,
|
|
40
40
|
};
|
|
41
|
-
node.trees[
|
|
41
|
+
node.trees[entryPathBase] = newTree;
|
|
42
42
|
lookup[entry.path] = newTree;
|
|
43
43
|
} else if (entry.type === "blob") {
|
|
44
|
-
node.blobs[
|
|
44
|
+
node.blobs[entryPathBase] = entry.id;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
OdspSummaryTreeValue,
|
|
29
29
|
} from "./contracts.js";
|
|
30
30
|
import { EpochTracker } from "./epochTracker.js";
|
|
31
|
-
import {
|
|
31
|
+
import { getHeadersWithAuth } from "./getUrlAndHeadersWithAuth.js";
|
|
32
32
|
import { getWithRetryForTokenRefresh } from "./odspUtils.js";
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -42,10 +42,9 @@ export class OdspSummaryUploadManager {
|
|
|
42
42
|
|
|
43
43
|
constructor(
|
|
44
44
|
private readonly snapshotUrl: string,
|
|
45
|
-
private readonly
|
|
45
|
+
private readonly getAuthHeader: InstrumentedStorageTokenFetcher,
|
|
46
46
|
logger: ITelemetryLoggerExt,
|
|
47
47
|
private readonly epochTracker: EpochTracker,
|
|
48
|
-
private readonly forceAccessTokenViaAuthorizationHeader: boolean,
|
|
49
48
|
private readonly relayServiceTenantAndSessionId: () => string | undefined,
|
|
50
49
|
) {
|
|
51
50
|
this.mc = loggerToMonitoringContext(logger);
|
|
@@ -102,13 +101,14 @@ export class OdspSummaryUploadManager {
|
|
|
102
101
|
};
|
|
103
102
|
|
|
104
103
|
return getWithRetryForTokenRefresh(async (options) => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.forceAccessTokenViaAuthorizationHeader,
|
|
104
|
+
const url = `${this.snapshotUrl}/snapshot`;
|
|
105
|
+
const method = "POST";
|
|
106
|
+
const authHeader = await this.getAuthHeader(
|
|
107
|
+
{ ...options, request: { url, method } },
|
|
108
|
+
"WriteSummaryTree",
|
|
111
109
|
);
|
|
110
|
+
|
|
111
|
+
const headers = getHeadersWithAuth(authHeader);
|
|
112
112
|
headers["Content-Type"] = "application/json";
|
|
113
113
|
const relayServiceTenantAndSessionId = this.relayServiceTenantAndSessionId();
|
|
114
114
|
// This would be undefined in case of summary is uploaded in detached container with attachment
|
|
@@ -179,6 +179,7 @@ export class OdspSummaryUploadManager {
|
|
|
179
179
|
let blobs = 0;
|
|
180
180
|
const keys = Object.keys(tree.tree);
|
|
181
181
|
for (const key of keys) {
|
|
182
|
+
assert(!key.includes("/"), "id should not include slashes");
|
|
182
183
|
const summaryObject = tree.tree[key];
|
|
183
184
|
|
|
184
185
|
let id: string | undefined;
|
|
@@ -243,7 +244,7 @@ export class OdspSummaryUploadManager {
|
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
const baseEntry: IOdspSummaryTreeBaseEntry = {
|
|
246
|
-
path:
|
|
247
|
+
path: key,
|
|
247
248
|
type: getGitType(summaryObject),
|
|
248
249
|
};
|
|
249
250
|
|
package/src/odspUtils.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
InstrumentedStorageTokenFetcher,
|
|
32
32
|
InstrumentedTokenFetcher,
|
|
33
33
|
OdspErrorTypes,
|
|
34
|
+
authHeaderFromTokenResponse,
|
|
34
35
|
OdspResourceTokenFetchOptions,
|
|
35
36
|
TokenFetchOptions,
|
|
36
37
|
TokenFetcher,
|
|
@@ -55,6 +56,7 @@ import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
|
55
56
|
export const getWithRetryForTokenRefreshRepeat = "getWithRetryForTokenRefreshRepeat";
|
|
56
57
|
|
|
57
58
|
/**
|
|
59
|
+
* @legacy
|
|
58
60
|
* @alpha
|
|
59
61
|
*/
|
|
60
62
|
export interface IOdspResponse<T> {
|
|
@@ -64,7 +66,14 @@ export interface IOdspResponse<T> {
|
|
|
64
66
|
duration: number;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
/**
|
|
70
|
+
* This interface captures the portion of TokenFetchOptions required for refreshing tokens
|
|
71
|
+
* It is controlled by logic in getWithRetryForTokenRefresh to specify what is the required refresh behavior
|
|
72
|
+
*/
|
|
73
|
+
export interface TokenFetchOptionsEx {
|
|
74
|
+
refresh: boolean;
|
|
75
|
+
claims?: string;
|
|
76
|
+
tenantId?: string;
|
|
68
77
|
/**
|
|
69
78
|
* The previous error we hit in {@link getWithRetryForTokenRefresh}.
|
|
70
79
|
*/
|
|
@@ -354,7 +363,8 @@ export function toInstrumentedOdspStorageTokenFetcher(
|
|
|
354
363
|
logger,
|
|
355
364
|
resolvedUrlParts,
|
|
356
365
|
tokenFetcher,
|
|
357
|
-
true, // throwOnNullToken
|
|
366
|
+
true, // throwOnNullToken
|
|
367
|
+
false, // returnPlainToken
|
|
358
368
|
);
|
|
359
369
|
// Drop undefined from signature - we can do it safely due to throwOnNullToken == true above
|
|
360
370
|
return res as InstrumentedStorageTokenFetcher;
|
|
@@ -364,12 +374,14 @@ export function toInstrumentedOdspStorageTokenFetcher(
|
|
|
364
374
|
* Returns a function that can be used to fetch storage or websocket token.
|
|
365
375
|
* There are scenarios where websocket token is not required / present (consumer stack and ordering service token),
|
|
366
376
|
* thus it could return null. Use toInstrumentedOdspStorageTokenFetcher if you deal with storage token.
|
|
377
|
+
* @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token
|
|
367
378
|
*/
|
|
368
379
|
export function toInstrumentedOdspTokenFetcher(
|
|
369
380
|
logger: ITelemetryLoggerExt,
|
|
370
381
|
resolvedUrlParts: IOdspUrlParts,
|
|
371
382
|
tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,
|
|
372
383
|
throwOnNullToken: boolean,
|
|
384
|
+
returnPlainToken: boolean,
|
|
373
385
|
): InstrumentedTokenFetcher {
|
|
374
386
|
return async (
|
|
375
387
|
options: TokenFetchOptions,
|
|
@@ -394,7 +406,9 @@ export function toInstrumentedOdspTokenFetcher(
|
|
|
394
406
|
...resolvedUrlParts,
|
|
395
407
|
}).then(
|
|
396
408
|
(tokenResponse) => {
|
|
397
|
-
const
|
|
409
|
+
const returnVal = returnPlainToken
|
|
410
|
+
? tokenFromResponse(tokenResponse)
|
|
411
|
+
: authHeaderFromTokenResponse(tokenResponse);
|
|
398
412
|
// This event alone generates so many events that is materially impacts cost of telemetry
|
|
399
413
|
// Thus do not report end event when it comes back quickly.
|
|
400
414
|
// Note that most of the hosts do not report if result is comming from cache or not,
|
|
@@ -403,10 +417,10 @@ export function toInstrumentedOdspTokenFetcher(
|
|
|
403
417
|
if (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {
|
|
404
418
|
event.end({
|
|
405
419
|
fromCache: isTokenFromCache(tokenResponse),
|
|
406
|
-
isNull:
|
|
420
|
+
isNull: returnVal === null,
|
|
407
421
|
});
|
|
408
422
|
}
|
|
409
|
-
if (
|
|
423
|
+
if (returnVal === null && throwOnNullToken) {
|
|
410
424
|
throw new NonRetryableError(
|
|
411
425
|
// pre-0.58 error message: Token is null for ${name} call
|
|
412
426
|
`The Host-provided token fetcher returned null`,
|
|
@@ -414,7 +428,7 @@ export function toInstrumentedOdspTokenFetcher(
|
|
|
414
428
|
{ method: name, driverVersion },
|
|
415
429
|
);
|
|
416
430
|
}
|
|
417
|
-
return
|
|
431
|
+
return returnVal;
|
|
418
432
|
},
|
|
419
433
|
(error) => {
|
|
420
434
|
// There is an important but unofficial contract here where token providers can set canRetry: true
|
package/src/packageVersion.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
OdspResourceTokenFetchOptions,
|
|
16
16
|
TokenFetcher,
|
|
17
17
|
getKeyForCacheEntry,
|
|
18
|
+
type InstrumentedStorageTokenFetcher,
|
|
18
19
|
} from "@fluidframework/odsp-driver-definitions/internal";
|
|
19
20
|
import {
|
|
20
21
|
PerformanceEvent,
|
|
@@ -35,6 +36,7 @@ import {
|
|
|
35
36
|
createOdspLogger,
|
|
36
37
|
getOdspResolvedUrl,
|
|
37
38
|
toInstrumentedOdspStorageTokenFetcher,
|
|
39
|
+
type TokenFetchOptionsEx,
|
|
38
40
|
} from "./odspUtils.js";
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -45,7 +47,7 @@ import {
|
|
|
45
47
|
* @param getStorageToken - function that can provide the storage token for a given site. This is
|
|
46
48
|
* is also referred to as the "VROOM" token in SPO.
|
|
47
49
|
* @param persistedCache - Cache to store the fetched snapshot.
|
|
48
|
-
* @param forceAccessTokenViaAuthorizationHeader -
|
|
50
|
+
* @param forceAccessTokenViaAuthorizationHeader - @deprecated Not used, true value always used instead. Whether to force passing given token via authorization header.
|
|
49
51
|
* @param logger - Logger to have telemetry events.
|
|
50
52
|
* @param hostSnapshotFetchOptions - Options to fetch the snapshot if any. Otherwise default will be used.
|
|
51
53
|
* @param enableRedeemFallback - True to have the sharing link redeem fallback in case the Trees Latest/Redeem
|
|
@@ -57,6 +59,7 @@ import {
|
|
|
57
59
|
* @param odspDocumentServiceFactory - factory to access the non persistent cache and store the prefetch promise.
|
|
58
60
|
*
|
|
59
61
|
* @returns `true` if the snapshot is cached, `false` otherwise.
|
|
62
|
+
* @legacy
|
|
60
63
|
* @alpha
|
|
61
64
|
*/
|
|
62
65
|
export async function prefetchLatestSnapshot(
|
|
@@ -86,7 +89,7 @@ export async function prefetchLatestSnapshot(
|
|
|
86
89
|
driveId: odspResolvedUrl.driveId,
|
|
87
90
|
itemId: odspResolvedUrl.itemId,
|
|
88
91
|
};
|
|
89
|
-
const
|
|
92
|
+
const getAuthHeader = toInstrumentedOdspStorageTokenFetcher(
|
|
90
93
|
odspLogger,
|
|
91
94
|
resolvedUrlData,
|
|
92
95
|
getStorageToken,
|
|
@@ -94,14 +97,16 @@ export async function prefetchLatestSnapshot(
|
|
|
94
97
|
|
|
95
98
|
const snapshotDownloader = async (
|
|
96
99
|
finalOdspResolvedUrl: IOdspResolvedUrl,
|
|
97
|
-
|
|
100
|
+
storageTokenFetcher: InstrumentedStorageTokenFetcher,
|
|
101
|
+
tokenFetchOptions: TokenFetchOptionsEx,
|
|
98
102
|
loadingGroupId: string[] | undefined,
|
|
99
103
|
snapshotOptions: ISnapshotOptions | undefined,
|
|
100
104
|
controller?: AbortController,
|
|
101
105
|
): Promise<ISnapshotRequestAndResponseOptions> => {
|
|
102
106
|
return downloadSnapshot(
|
|
103
107
|
finalOdspResolvedUrl,
|
|
104
|
-
|
|
108
|
+
storageTokenFetcher,
|
|
109
|
+
tokenFetchOptions,
|
|
105
110
|
loadingGroupId,
|
|
106
111
|
snapshotOptions,
|
|
107
112
|
undefined,
|
|
@@ -135,7 +140,7 @@ export async function prefetchLatestSnapshot(
|
|
|
135
140
|
);
|
|
136
141
|
await fetchSnapshotWithRedeem(
|
|
137
142
|
odspResolvedUrl,
|
|
138
|
-
|
|
143
|
+
getAuthHeader,
|
|
139
144
|
hostSnapshotFetchOptions,
|
|
140
145
|
forceAccessTokenViaAuthorizationHeader,
|
|
141
146
|
odspLogger,
|
package/src/vroom.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface IJoinSessionBody {
|
|
|
31
31
|
* @param path - The API path that is relevant to this request
|
|
32
32
|
* @param method - The type of request, such as GET or POST
|
|
33
33
|
* @param logger - A logger to use for this request
|
|
34
|
-
* @param
|
|
34
|
+
* @param getAuthHeader - A function that is able to provide the access token for this request
|
|
35
35
|
* @param epochTracker - fetch wrapper which incorporates epoch logic around joinSession call
|
|
36
36
|
* @param requestSocketToken - flag indicating whether joinSession is expected to return access token
|
|
37
37
|
* which is used when establishing websocket connection with collab session backend service.
|
|
@@ -44,17 +44,21 @@ interface IJoinSessionBody {
|
|
|
44
44
|
export async function fetchJoinSession(
|
|
45
45
|
urlParts: IOdspUrlParts,
|
|
46
46
|
path: string,
|
|
47
|
-
method:
|
|
47
|
+
method: "GET" | "POST",
|
|
48
48
|
logger: ITelemetryLoggerExt,
|
|
49
|
-
|
|
49
|
+
getAuthHeader: InstrumentedStorageTokenFetcher,
|
|
50
50
|
epochTracker: EpochTracker,
|
|
51
51
|
requestSocketToken: boolean,
|
|
52
52
|
options: TokenFetchOptionsEx,
|
|
53
53
|
disableJoinSessionRefresh: boolean | undefined,
|
|
54
54
|
isRefreshingJoinSession: boolean,
|
|
55
|
-
guestDisplayName?: string,
|
|
56
55
|
): Promise<ISocketStorageDiscovery> {
|
|
57
|
-
const
|
|
56
|
+
const apiRoot = getApiRoot(new URL(urlParts.siteUrl));
|
|
57
|
+
const url = `${apiRoot}/drives/${urlParts.driveId}/items/${urlParts.itemId}/${path}?ump=1`;
|
|
58
|
+
const authHeader = await getAuthHeader(
|
|
59
|
+
{ ...options, request: { url, method } },
|
|
60
|
+
"JoinSession",
|
|
61
|
+
);
|
|
58
62
|
|
|
59
63
|
const tokenRefreshProps = options.refresh
|
|
60
64
|
? { hasClaims: !!options.claims, hasTenantId: !!options.tenantId }
|
|
@@ -75,10 +79,9 @@ export async function fetchJoinSession(
|
|
|
75
79
|
...tokenRefreshProps,
|
|
76
80
|
},
|
|
77
81
|
async (event) => {
|
|
78
|
-
const apiRoot = getApiRoot(new URL(urlParts.siteUrl));
|
|
79
82
|
const formBoundary = uuid();
|
|
80
83
|
let postBody = `--${formBoundary}\r\n`;
|
|
81
|
-
postBody += `Authorization:
|
|
84
|
+
postBody += `Authorization: ${authHeader}\r\n`;
|
|
82
85
|
postBody += `X-HTTP-Method-Override: POST\r\n`;
|
|
83
86
|
postBody += `Content-Type: application/json\r\n`;
|
|
84
87
|
if (!disableJoinSessionRefresh) {
|
|
@@ -90,9 +93,6 @@ export async function fetchJoinSession(
|
|
|
90
93
|
const body: IJoinSessionBody = {
|
|
91
94
|
requestSocketToken: true,
|
|
92
95
|
};
|
|
93
|
-
if (guestDisplayName !== undefined) {
|
|
94
|
-
body.guestDisplayName = guestDisplayName;
|
|
95
|
-
}
|
|
96
96
|
postBody += `\r\n${JSON.stringify(body)}\r\n`;
|
|
97
97
|
}
|
|
98
98
|
postBody += `\r\n--${formBoundary}--`;
|
|
@@ -103,7 +103,7 @@ export async function fetchJoinSession(
|
|
|
103
103
|
const response = await runWithRetry(
|
|
104
104
|
async () =>
|
|
105
105
|
epochTracker.fetchAndParseAsJSON<ISocketStorageDiscovery>(
|
|
106
|
-
|
|
106
|
+
url,
|
|
107
107
|
{ method, headers, body: postBody },
|
|
108
108
|
"joinSession",
|
|
109
109
|
true,
|