@fluidframework/routerlicious-driver 2.0.0-dev.1.4.6.106135 → 2.0.0-dev.2.3.0.115467
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/.eslintrc.js +1 -1
- package/dist/deltaStorageService.d.ts +2 -1
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/deltaStorageService.js +17 -6
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentDeltaConnection.d.ts +1 -2
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +27 -5
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +39 -16
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -18
- package/dist/index.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/restWrapper.d.ts +3 -3
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +24 -9
- package/dist/restWrapper.js.map +1 -1
- package/dist/urlUtils.d.ts.map +1 -1
- package/dist/urlUtils.js +20 -24
- package/dist/urlUtils.js.map +1 -1
- package/lib/deltaStorageService.d.ts +2 -1
- package/lib/deltaStorageService.d.ts.map +1 -1
- package/lib/deltaStorageService.js +17 -6
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentDeltaConnection.d.ts +1 -2
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +27 -5
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +40 -17
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/index.d.ts +4 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -8
- package/lib/index.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/restWrapper.d.ts +3 -3
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +24 -9
- package/lib/restWrapper.js.map +1 -1
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js +20 -24
- package/lib/urlUtils.js.map +1 -1
- package/package.json +26 -25
- package/prettier.config.cjs +8 -0
- package/src/deltaStorageService.ts +17 -8
- package/src/documentDeltaConnection.ts +1 -2
- package/src/documentService.ts +45 -13
- package/src/documentServiceFactory.ts +53 -19
- package/src/index.ts +9 -8
- package/src/packageVersion.ts +1 -1
- package/src/restWrapper.ts +42 -19
- package/src/urlUtils.ts +20 -24
|
@@ -11,9 +11,8 @@ import {
|
|
|
11
11
|
} from "@fluidframework/driver-definitions";
|
|
12
12
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
13
13
|
import { readAndParse, requestOps, emptyMessageStream } from "@fluidframework/driver-utils";
|
|
14
|
-
import { TelemetryNullLogger } from "@fluidframework/common-utils";
|
|
15
14
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
16
|
-
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
15
|
+
import { PerformanceEvent, TelemetryNullLogger } from "@fluidframework/telemetry-utils";
|
|
17
16
|
import { RestWrapper } from "@fluidframework/server-services-client";
|
|
18
17
|
import { DocumentStorageService } from "./documentStorageService";
|
|
19
18
|
|
|
@@ -27,7 +26,8 @@ export class DocumentDeltaStorageService implements IDocumentDeltaStorageService
|
|
|
27
26
|
private readonly tenantId: string,
|
|
28
27
|
private readonly id: string,
|
|
29
28
|
private readonly deltaStorageService: IDeltaStorageService,
|
|
30
|
-
private readonly documentStorageService: DocumentStorageService
|
|
29
|
+
private readonly documentStorageService: DocumentStorageService,
|
|
30
|
+
private readonly logger: ITelemetryLogger) {
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
private logtailSha: string | undefined = this.documentStorageService.logTailSha;
|
|
@@ -62,11 +62,20 @@ export class DocumentDeltaStorageService implements IDocumentDeltaStorageService
|
|
|
62
62
|
|
|
63
63
|
this.logtailSha = undefined;
|
|
64
64
|
if (opsFromLogTail.length > 0) {
|
|
65
|
-
|
|
66
|
-
op
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
try {
|
|
66
|
+
const messages = opsFromLogTail.filter((op, i) => {
|
|
67
|
+
// throw if the sequence numbers in logtail are not contiguous
|
|
68
|
+
if (i > 0 && op.sequenceNumber !== opsFromLogTail[i - 1].sequenceNumber + 1) {
|
|
69
|
+
throw new Error("Log tail ops are not contiguous");
|
|
70
|
+
}
|
|
71
|
+
return op.sequenceNumber >= from;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (messages.length > 0 && messages[0].sequenceNumber === from) {
|
|
75
|
+
return { messages, partialResult: true };
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
this.logger.sendErrorEvent({ eventName: "LogTailReadError" }, error);
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
81
|
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base";
|
|
8
|
-
import { IDocumentDeltaConnection } from "@fluidframework/driver-definitions";
|
|
9
|
-
import { IAnyDriverError } from "@fluidframework/driver-utils";
|
|
8
|
+
import { IAnyDriverError, IDocumentDeltaConnection } from "@fluidframework/driver-definitions";
|
|
10
9
|
import { IClient, IConnect } from "@fluidframework/protocol-definitions";
|
|
11
10
|
import type { io as SocketIOClientStatic } from "socket.io-client";
|
|
12
11
|
import { errorObjectFromSocketError, IR11sSocketError } from "./errorUtils";
|
package/src/documentService.ts
CHANGED
|
@@ -33,6 +33,7 @@ const RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute
|
|
|
33
33
|
* The DocumentService manages the Socket.IO connection and manages routing requests to connected
|
|
34
34
|
* clients.
|
|
35
35
|
*/
|
|
36
|
+
// eslint-disable-next-line import/namespace
|
|
36
37
|
export class DocumentService implements api.IDocumentService {
|
|
37
38
|
private lastDiscoveredAt: number = Date.now();
|
|
38
39
|
private discoverP: Promise<void> | undefined;
|
|
@@ -175,6 +176,7 @@ export class DocumentService implements api.IDocumentService {
|
|
|
175
176
|
this.documentId,
|
|
176
177
|
deltaStorageService,
|
|
177
178
|
this.documentStorageService,
|
|
179
|
+
this.logger,
|
|
178
180
|
);
|
|
179
181
|
}
|
|
180
182
|
|
|
@@ -188,20 +190,42 @@ export class DocumentService implements api.IDocumentService {
|
|
|
188
190
|
if (this.shouldUpdateDiscoveredSessionInfo()) {
|
|
189
191
|
await this.refreshDiscovery();
|
|
190
192
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.
|
|
194
|
-
|
|
193
|
+
|
|
194
|
+
const ordererToken = await PerformanceEvent.timedExecAsync(
|
|
195
|
+
this.logger,
|
|
196
|
+
{
|
|
197
|
+
eventName: "GetDeltaStreamToken",
|
|
198
|
+
docId: this.documentId,
|
|
199
|
+
details: JSON.stringify({
|
|
200
|
+
refreshToken,
|
|
201
|
+
}),
|
|
202
|
+
},
|
|
203
|
+
async () => {
|
|
204
|
+
return this.tokenProvider.fetchOrdererToken(
|
|
205
|
+
this.tenantId,
|
|
206
|
+
this.documentId,
|
|
207
|
+
refreshToken,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
195
210
|
);
|
|
196
211
|
|
|
197
|
-
return
|
|
198
|
-
this.tenantId,
|
|
199
|
-
this.documentId,
|
|
200
|
-
ordererToken.jwt,
|
|
201
|
-
io,
|
|
202
|
-
client,
|
|
203
|
-
this.deltaStreamUrl,
|
|
212
|
+
return PerformanceEvent.timedExecAsync(
|
|
204
213
|
this.logger,
|
|
214
|
+
{
|
|
215
|
+
eventName: "ConnectToDeltaStream",
|
|
216
|
+
docId: this.documentId,
|
|
217
|
+
},
|
|
218
|
+
async () => {
|
|
219
|
+
return R11sDocumentDeltaConnection.create(
|
|
220
|
+
this.tenantId,
|
|
221
|
+
this.documentId,
|
|
222
|
+
ordererToken.jwt,
|
|
223
|
+
io,
|
|
224
|
+
client,
|
|
225
|
+
this.deltaStreamUrl,
|
|
226
|
+
this.logger,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
205
229
|
);
|
|
206
230
|
};
|
|
207
231
|
|
|
@@ -228,7 +252,7 @@ export class DocumentService implements api.IDocumentService {
|
|
|
228
252
|
this.discoverP = PerformanceEvent.timedExecAsync(
|
|
229
253
|
this.logger,
|
|
230
254
|
{
|
|
231
|
-
eventName: "
|
|
255
|
+
eventName: "RefreshDiscovery",
|
|
232
256
|
},
|
|
233
257
|
async () => this.refreshDiscoveryCore(),
|
|
234
258
|
);
|
|
@@ -243,7 +267,6 @@ export class DocumentService implements api.IDocumentService {
|
|
|
243
267
|
this.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;
|
|
244
268
|
this.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;
|
|
245
269
|
this.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || this.ordererUrl;
|
|
246
|
-
this.lastDiscoveredAt = Date.now();
|
|
247
270
|
}
|
|
248
271
|
|
|
249
272
|
/**
|
|
@@ -259,6 +282,15 @@ export class DocumentService implements api.IDocumentService {
|
|
|
259
282
|
// Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,
|
|
260
283
|
// re-discover if enough time has passed since last discovery.
|
|
261
284
|
const pastLastDiscoveryTimeThreshold = (now - this.lastDiscoveredAt) > RediscoverAfterTimeSinceDiscoveryMs;
|
|
285
|
+
if (pastLastDiscoveryTimeThreshold) {
|
|
286
|
+
// Reset discover promise and refresh discovery.
|
|
287
|
+
this.lastDiscoveredAt = Date.now();
|
|
288
|
+
this.discoverP = undefined;
|
|
289
|
+
this.refreshDiscovery().catch(() => {
|
|
290
|
+
// Undo discovery time set on failure, so that next check refreshes.
|
|
291
|
+
this.lastDiscoveredAt = 0;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
262
294
|
return pastLastDiscoveryTimeThreshold;
|
|
263
295
|
}
|
|
264
296
|
}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getQuorumValuesFromProtocolSummary,
|
|
19
19
|
RateLimiter,
|
|
20
20
|
} from "@fluidframework/driver-utils";
|
|
21
|
-
import { ChildLogger } from "@fluidframework/telemetry-utils";
|
|
21
|
+
import { ChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
22
22
|
import { ISession } from "@fluidframework/server-services-client";
|
|
23
23
|
import { DocumentService } from "./documentService";
|
|
24
24
|
import { IRouterliciousDriverPolicies } from "./policies";
|
|
@@ -108,16 +108,34 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
108
108
|
resolvedUrl.endpoints.ordererUrl,
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
`/documents/${tenantId}`,
|
|
111
|
+
const res = await PerformanceEvent.timedExecAsync(
|
|
112
|
+
logger2,
|
|
114
113
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
eventName: "CreateNew",
|
|
115
|
+
details: JSON.stringify({
|
|
116
|
+
enableDiscovery: this.driverPolicies.enableDiscovery,
|
|
117
|
+
sequenceNumber: documentAttributes.sequenceNumber,
|
|
118
|
+
}),
|
|
120
119
|
},
|
|
120
|
+
async (event) => {
|
|
121
|
+
// @TODO: Remove returned "string" type when removing back-compat code
|
|
122
|
+
const postRes = await ordererRestWrapper.post<
|
|
123
|
+
{ id: string; token?: string; session?: ISession; } | string
|
|
124
|
+
>(`/documents/${tenantId}`, {
|
|
125
|
+
summary: convertSummaryToCreateNewSummary(appSummary),
|
|
126
|
+
sequenceNumber: documentAttributes.sequenceNumber,
|
|
127
|
+
values: quorumValues,
|
|
128
|
+
enableDiscovery: this.driverPolicies.enableDiscovery,
|
|
129
|
+
generateToken:
|
|
130
|
+
this.tokenProvider.documentPostCreateCallback !==
|
|
131
|
+
undefined,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
event.end({
|
|
135
|
+
docId: typeof postRes === "string" ? postRes : postRes.id,
|
|
136
|
+
});
|
|
137
|
+
return postRes;
|
|
138
|
+
}
|
|
121
139
|
);
|
|
122
140
|
|
|
123
141
|
// For supporting backward compatibility, when the request has generateToken === true, it will return
|
|
@@ -138,12 +156,20 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
138
156
|
|
|
139
157
|
// @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined
|
|
140
158
|
// is sufficient to determine if the token will be undefined or not.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
159
|
+
try {
|
|
160
|
+
await PerformanceEvent.timedExecAsync(
|
|
161
|
+
logger2,
|
|
162
|
+
{
|
|
163
|
+
eventName: "DocPostCreateCallback",
|
|
164
|
+
docId: documentId,
|
|
165
|
+
},
|
|
166
|
+
async () => {
|
|
167
|
+
if (token && this.tokenProvider.documentPostCreateCallback !== undefined) {
|
|
168
|
+
return this.tokenProvider.documentPostCreateCallback(documentId, token);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
} catch (error: any) {
|
|
172
|
+
throw new DocumentPostCreateError(error);
|
|
147
173
|
}
|
|
148
174
|
|
|
149
175
|
parsedUrl.set("pathname", replaceDocumentIdInPath(parsedUrl.pathname, documentId));
|
|
@@ -206,10 +232,18 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
206
232
|
this.driverPolicies.enableRestLess,
|
|
207
233
|
resolvedUrl.endpoints.ordererUrl,
|
|
208
234
|
);
|
|
209
|
-
|
|
210
|
-
const discoveredSession = await
|
|
211
|
-
|
|
212
|
-
|
|
235
|
+
|
|
236
|
+
const discoveredSession = await PerformanceEvent.timedExecAsync(
|
|
237
|
+
logger2,
|
|
238
|
+
{
|
|
239
|
+
eventName: "DiscoverSession",
|
|
240
|
+
docId: documentId,
|
|
241
|
+
},
|
|
242
|
+
async () => {
|
|
243
|
+
// The service responds with the current document session associated with the container.
|
|
244
|
+
return ordererRestWrapper.get<ISession>(
|
|
245
|
+
`/documents/${tenantId}/session/${documentId}`);
|
|
246
|
+
});
|
|
213
247
|
return getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);
|
|
214
248
|
};
|
|
215
249
|
const fluidResolvedUrl: IFluidResolvedUrl = session !== undefined
|
package/src/index.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
// Tokens
|
|
7
|
+
export { DefaultTokenProvider } from "./defaultTokenProvider";
|
|
8
|
+
export { ITokenProvider, ITokenResponse, ITokenService } from "./tokens";
|
|
9
|
+
|
|
10
|
+
// Factory
|
|
11
|
+
export { DocumentPostCreateError, RouterliciousDocumentServiceFactory } from "./documentServiceFactory";
|
|
12
|
+
|
|
13
|
+
// Configuration
|
|
14
|
+
export { IRouterliciousDriverPolicies } from "./policies";
|
package/src/packageVersion.ts
CHANGED
package/src/restWrapper.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
// Just using the type from a node.js module does not introduce a runtime dependency.
|
|
7
|
+
// eslint-disable-next-line import/no-nodejs-modules
|
|
8
|
+
import type { ParsedUrlQueryInput } from "querystring";
|
|
9
|
+
|
|
6
10
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
11
|
import { fromUtf8ToBase64 } from "@fluidframework/common-utils";
|
|
8
12
|
import { RateLimiter } from "@fluidframework/driver-utils";
|
|
@@ -11,6 +15,7 @@ import {
|
|
|
11
15
|
RestLessClient,
|
|
12
16
|
RestWrapper,
|
|
13
17
|
} from "@fluidframework/server-services-client";
|
|
18
|
+
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
14
19
|
import fetch from "cross-fetch";
|
|
15
20
|
import type { AxiosRequestConfig, AxiosRequestHeaders } from "axios";
|
|
16
21
|
import safeStringify from "json-stringify-safe";
|
|
@@ -45,7 +50,7 @@ export class RouterliciousRestWrapper extends RestWrapper {
|
|
|
45
50
|
private readonly getAuthorizationHeader: AuthorizationHeaderGetter,
|
|
46
51
|
private readonly useRestLess: boolean,
|
|
47
52
|
baseurl?: string,
|
|
48
|
-
defaultQueryString:
|
|
53
|
+
defaultQueryString: ParsedUrlQueryInput = {},
|
|
49
54
|
) {
|
|
50
55
|
super(baseurl, defaultQueryString);
|
|
51
56
|
}
|
|
@@ -127,7 +132,7 @@ export class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {
|
|
|
127
132
|
getAuthorizationHeader: AuthorizationHeaderGetter,
|
|
128
133
|
useRestLess: boolean,
|
|
129
134
|
baseurl?: string,
|
|
130
|
-
defaultQueryString:
|
|
135
|
+
defaultQueryString: ParsedUrlQueryInput = {},
|
|
131
136
|
) {
|
|
132
137
|
super(logger, rateLimiter, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString);
|
|
133
138
|
}
|
|
@@ -145,17 +150,26 @@ export class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {
|
|
|
145
150
|
token: `${fromUtf8ToBase64(tenantId)}`,
|
|
146
151
|
};
|
|
147
152
|
const getAuthorizationHeader: AuthorizationHeaderGetter = async (refreshToken?: boolean): Promise<string> => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
return PerformanceEvent.timedExecAsync(
|
|
154
|
+
logger,
|
|
155
|
+
{
|
|
156
|
+
eventName: "FetchStorageToken",
|
|
157
|
+
docId: documentId,
|
|
158
|
+
},
|
|
159
|
+
async () => {
|
|
160
|
+
// Craft credentials using tenant id and token
|
|
161
|
+
const storageToken = await tokenProvider.fetchStorageToken(
|
|
162
|
+
tenantId,
|
|
163
|
+
documentId,
|
|
164
|
+
refreshToken
|
|
165
|
+
);
|
|
166
|
+
const credentials = {
|
|
167
|
+
password: storageToken.jwt,
|
|
168
|
+
user: tenantId,
|
|
169
|
+
};
|
|
170
|
+
return getAuthorizationTokenFromCredentials(credentials);
|
|
171
|
+
}
|
|
153
172
|
);
|
|
154
|
-
const credentials = {
|
|
155
|
-
password: storageToken.jwt,
|
|
156
|
-
user: tenantId,
|
|
157
|
-
};
|
|
158
|
-
return getAuthorizationTokenFromCredentials(credentials);
|
|
159
173
|
};
|
|
160
174
|
|
|
161
175
|
const restWrapper = new RouterliciousStorageRestWrapper(
|
|
@@ -179,7 +193,7 @@ export class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {
|
|
|
179
193
|
getAuthorizationHeader: AuthorizationHeaderGetter,
|
|
180
194
|
useRestLess: boolean,
|
|
181
195
|
baseurl?: string,
|
|
182
|
-
defaultQueryString:
|
|
196
|
+
defaultQueryString: ParsedUrlQueryInput = {},
|
|
183
197
|
) {
|
|
184
198
|
super(logger, rateLimiter, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString);
|
|
185
199
|
}
|
|
@@ -194,12 +208,21 @@ export class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {
|
|
|
194
208
|
baseurl?: string,
|
|
195
209
|
): Promise<RouterliciousOrdererRestWrapper> {
|
|
196
210
|
const getAuthorizationHeader: AuthorizationHeaderGetter = async (refreshToken?: boolean): Promise<string> => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
211
|
+
return PerformanceEvent.timedExecAsync(
|
|
212
|
+
logger,
|
|
213
|
+
{
|
|
214
|
+
eventName: "FetchOrdererToken",
|
|
215
|
+
docId: documentId,
|
|
216
|
+
},
|
|
217
|
+
async () => {
|
|
218
|
+
const ordererToken = await tokenProvider.fetchOrdererToken(
|
|
219
|
+
tenantId,
|
|
220
|
+
documentId,
|
|
221
|
+
refreshToken,
|
|
222
|
+
);
|
|
223
|
+
return `Basic ${ordererToken.jwt}`;
|
|
224
|
+
}
|
|
201
225
|
);
|
|
202
|
-
return `Basic ${ordererToken.jwt}`;
|
|
203
226
|
};
|
|
204
227
|
|
|
205
228
|
const restWrapper = new RouterliciousOrdererRestWrapper(
|
package/src/urlUtils.ts
CHANGED
|
@@ -21,30 +21,26 @@ export const replaceDocumentIdInPath = (urlPath: string, documentId: string): st
|
|
|
21
21
|
urlPath.split("/").slice(0, -1).concat([documentId]).join("/");
|
|
22
22
|
|
|
23
23
|
export const getDiscoveredFluidResolvedUrl = (resolvedUrl: IFluidResolvedUrl, session: ISession): IFluidResolvedUrl => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
deltaStorageUrl.set("host", discoveredOrdererUrl.host);
|
|
24
|
+
const discoveredOrdererUrl = new URLParse(session.ordererUrl);
|
|
25
|
+
const deltaStorageUrl = new URLParse(resolvedUrl.endpoints.deltaStorageUrl);
|
|
26
|
+
deltaStorageUrl.set("host", discoveredOrdererUrl.host);
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const discoveredStorageUrl = new URLParse(session.historianUrl);
|
|
29
|
+
const storageUrl = new URLParse(resolvedUrl.endpoints.storageUrl);
|
|
30
|
+
storageUrl.set("host", discoveredStorageUrl.host);
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} else {
|
|
48
|
-
return resolvedUrl;
|
|
49
|
-
}
|
|
32
|
+
const parsedUrl = parseFluidUrl(resolvedUrl.url);
|
|
33
|
+
const discoveredResolvedUrl: IFluidResolvedUrl = {
|
|
34
|
+
endpoints: {
|
|
35
|
+
deltaStorageUrl: deltaStorageUrl.toString(),
|
|
36
|
+
ordererUrl: session.ordererUrl,
|
|
37
|
+
deltaStreamUrl: session.deltaStreamUrl,
|
|
38
|
+
storageUrl: storageUrl.toString(),
|
|
39
|
+
},
|
|
40
|
+
id: resolvedUrl.id,
|
|
41
|
+
tokens: resolvedUrl.tokens,
|
|
42
|
+
type: resolvedUrl.type,
|
|
43
|
+
url: new URLParse(`fluid://${discoveredOrdererUrl.host}${parsedUrl.pathname}`).toString(),
|
|
44
|
+
};
|
|
45
|
+
return discoveredResolvedUrl;
|
|
50
46
|
};
|