@fluidframework/routerlicious-driver 2.0.0-internal.2.0.4 → 2.0.0-internal.2.1.1
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/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +17 -3
- 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 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -15
- 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.map +1 -1
- package/dist/restWrapper.js +20 -9
- package/dist/restWrapper.js.map +1 -1
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +17 -3
- 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 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -5
- 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.map +1 -1
- package/lib/restWrapper.js +20 -9
- package/lib/restWrapper.js.map +1 -1
- package/package.json +12 -14
- package/src/documentService.ts +35 -12
- package/src/documentServiceFactory.ts +53 -19
- package/src/index.ts +4 -4
- package/src/packageVersion.ts +1 -1
- package/src/restWrapper.ts +34 -15
|
@@ -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
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Tokens
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export { DefaultTokenProvider } from "./defaultTokenProvider";
|
|
8
|
+
export { ITokenProvider, ITokenResponse, ITokenService } from "./tokens";
|
|
9
9
|
|
|
10
10
|
// Factory
|
|
11
|
-
export
|
|
11
|
+
export { DocumentPostCreateError, RouterliciousDocumentServiceFactory } from "./documentServiceFactory";
|
|
12
12
|
|
|
13
13
|
// Configuration
|
|
14
|
-
export
|
|
14
|
+
export { IRouterliciousDriverPolicies } from "./policies";
|
package/src/packageVersion.ts
CHANGED
package/src/restWrapper.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
RestLessClient,
|
|
12
12
|
RestWrapper,
|
|
13
13
|
} from "@fluidframework/server-services-client";
|
|
14
|
+
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
14
15
|
import fetch from "cross-fetch";
|
|
15
16
|
import type { AxiosRequestConfig, AxiosRequestHeaders } from "axios";
|
|
16
17
|
import safeStringify from "json-stringify-safe";
|
|
@@ -145,17 +146,26 @@ export class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {
|
|
|
145
146
|
token: `${fromUtf8ToBase64(tenantId)}`,
|
|
146
147
|
};
|
|
147
148
|
const getAuthorizationHeader: AuthorizationHeaderGetter = async (refreshToken?: boolean): Promise<string> => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
return PerformanceEvent.timedExecAsync(
|
|
150
|
+
logger,
|
|
151
|
+
{
|
|
152
|
+
eventName: "FetchStorageToken",
|
|
153
|
+
docId: documentId,
|
|
154
|
+
},
|
|
155
|
+
async () => {
|
|
156
|
+
// Craft credentials using tenant id and token
|
|
157
|
+
const storageToken = await tokenProvider.fetchStorageToken(
|
|
158
|
+
tenantId,
|
|
159
|
+
documentId,
|
|
160
|
+
refreshToken
|
|
161
|
+
);
|
|
162
|
+
const credentials = {
|
|
163
|
+
password: storageToken.jwt,
|
|
164
|
+
user: tenantId,
|
|
165
|
+
};
|
|
166
|
+
return getAuthorizationTokenFromCredentials(credentials);
|
|
167
|
+
}
|
|
153
168
|
);
|
|
154
|
-
const credentials = {
|
|
155
|
-
password: storageToken.jwt,
|
|
156
|
-
user: tenantId,
|
|
157
|
-
};
|
|
158
|
-
return getAuthorizationTokenFromCredentials(credentials);
|
|
159
169
|
};
|
|
160
170
|
|
|
161
171
|
const restWrapper = new RouterliciousStorageRestWrapper(
|
|
@@ -194,12 +204,21 @@ export class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {
|
|
|
194
204
|
baseurl?: string,
|
|
195
205
|
): Promise<RouterliciousOrdererRestWrapper> {
|
|
196
206
|
const getAuthorizationHeader: AuthorizationHeaderGetter = async (refreshToken?: boolean): Promise<string> => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
207
|
+
return PerformanceEvent.timedExecAsync(
|
|
208
|
+
logger,
|
|
209
|
+
{
|
|
210
|
+
eventName: "FetchOrdererToken",
|
|
211
|
+
docId: documentId,
|
|
212
|
+
},
|
|
213
|
+
async () => {
|
|
214
|
+
const ordererToken = await tokenProvider.fetchOrdererToken(
|
|
215
|
+
tenantId,
|
|
216
|
+
documentId,
|
|
217
|
+
refreshToken,
|
|
218
|
+
);
|
|
219
|
+
return `Basic ${ordererToken.jwt}`;
|
|
220
|
+
}
|
|
201
221
|
);
|
|
202
|
-
return `Basic ${ordererToken.jwt}`;
|
|
203
222
|
};
|
|
204
223
|
|
|
205
224
|
const restWrapper = new RouterliciousOrdererRestWrapper(
|