@fluidframework/tinylicious-driver 2.0.0-internal.6.4.0 → 2.0.0-internal.7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/api-extractor.json +1 -1
- package/api-report/tinylicious-driver.api.md +44 -0
- package/dist/insecureTinyliciousTokenProvider.d.ts +2 -0
- package/dist/insecureTinyliciousTokenProvider.d.ts.map +1 -1
- package/dist/insecureTinyliciousTokenProvider.js +6 -2
- package/dist/insecureTinyliciousTokenProvider.js.map +1 -1
- package/dist/insecureTinyliciousUrlResolver.d.ts +12 -1
- package/dist/insecureTinyliciousUrlResolver.d.ts.map +1 -1
- package/dist/insecureTinyliciousUrlResolver.js +11 -0
- package/dist/insecureTinyliciousUrlResolver.js.map +1 -1
- package/dist/tinylicious-driver-alpha.d.ts +76 -0
- package/dist/tinylicious-driver-beta.d.ts +76 -0
- package/dist/tinylicious-driver-public.d.ts +76 -0
- package/dist/tinylicious-driver.d.ts +76 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/insecureTinyliciousTokenProvider.d.ts +2 -0
- package/lib/insecureTinyliciousTokenProvider.d.ts.map +1 -1
- package/lib/insecureTinyliciousTokenProvider.js +6 -2
- package/lib/insecureTinyliciousTokenProvider.js.map +1 -1
- package/lib/insecureTinyliciousUrlResolver.d.ts +12 -1
- package/lib/insecureTinyliciousUrlResolver.d.ts.map +1 -1
- package/lib/insecureTinyliciousUrlResolver.js +11 -0
- package/lib/insecureTinyliciousUrlResolver.js.map +1 -1
- package/package.json +19 -20
- package/src/insecureTinyliciousTokenProvider.ts +7 -2
- package/src/insecureTinyliciousUrlResolver.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @fluidframework/tinylicious-driver
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.7.1.0
|
|
4
|
+
|
|
5
|
+
Dependency updates only.
|
|
6
|
+
|
|
7
|
+
## 2.0.0-internal.7.0.0
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- Dependencies on @fluidframework/protocol-definitions package updated to 3.0.0 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
12
|
+
|
|
13
|
+
This included the following changes from the protocol-definitions release:
|
|
14
|
+
|
|
15
|
+
- Updating signal interfaces for some planned improvements. The intention is split the interface between signals
|
|
16
|
+
submitted by clients to the server and the resulting signals sent from the server to clients.
|
|
17
|
+
- A new optional type member is available on the ISignalMessage interface and a new ISentSignalMessage interface has
|
|
18
|
+
been added, which will be the typing for signals sent from the client to the server. Both extend a new
|
|
19
|
+
ISignalMessageBase interface that contains common members.
|
|
20
|
+
- The @fluidframework/common-definitions package dependency has been updated to version 1.0.0.
|
|
21
|
+
|
|
22
|
+
- Server upgrade: dependencies on Fluid server packages updated to 2.0.1 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
23
|
+
|
|
24
|
+
Dependencies on the following Fluid server package have been updated to version 2.0.1:
|
|
25
|
+
|
|
26
|
+
- @fluidframework/gitresources: 2.0.1
|
|
27
|
+
- @fluidframework/server-kafka-orderer: 2.0.1
|
|
28
|
+
- @fluidframework/server-lambdas: 2.0.1
|
|
29
|
+
- @fluidframework/server-lambdas-driver: 2.0.1
|
|
30
|
+
- @fluidframework/server-local-server: 2.0.1
|
|
31
|
+
- @fluidframework/server-memory-orderer: 2.0.1
|
|
32
|
+
- @fluidframework/protocol-base: 2.0.1
|
|
33
|
+
- @fluidframework/server-routerlicious: 2.0.1
|
|
34
|
+
- @fluidframework/server-routerlicious-base: 2.0.1
|
|
35
|
+
- @fluidframework/server-services: 2.0.1
|
|
36
|
+
- @fluidframework/server-services-client: 2.0.1
|
|
37
|
+
- @fluidframework/server-services-core: 2.0.1
|
|
38
|
+
- @fluidframework/server-services-ordering-kafkanode: 2.0.1
|
|
39
|
+
- @fluidframework/server-services-ordering-rdkafka: 2.0.1
|
|
40
|
+
- @fluidframework/server-services-ordering-zookeeper: 2.0.1
|
|
41
|
+
- @fluidframework/server-services-shared: 2.0.1
|
|
42
|
+
- @fluidframework/server-services-telemetry: 2.0.1
|
|
43
|
+
- @fluidframework/server-services-utils: 2.0.1
|
|
44
|
+
- @fluidframework/server-test-utils: 2.0.1
|
|
45
|
+
- tinylicious: 2.0.1
|
|
46
|
+
|
|
47
|
+
- Minimum TypeScript version now 5.1.6 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
48
|
+
|
|
49
|
+
The minimum supported TypeScript version for Fluid 2.0 clients is now 5.1.6.
|
|
50
|
+
|
|
3
51
|
## 2.0.0-internal.6.4.0
|
|
4
52
|
|
|
5
53
|
Dependency updates only.
|
package/api-extractor.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
## API Report File for "@fluidframework/tinylicious-driver"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { IRequest } from '@fluidframework/core-interfaces';
|
|
8
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
9
|
+
import { ITokenProvider } from '@fluidframework/routerlicious-driver';
|
|
10
|
+
import { ITokenResponse } from '@fluidframework/routerlicious-driver';
|
|
11
|
+
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
12
|
+
import { ScopeType } from '@fluidframework/protocol-definitions';
|
|
13
|
+
|
|
14
|
+
// @public
|
|
15
|
+
export const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
|
|
16
|
+
|
|
17
|
+
// @public
|
|
18
|
+
export const defaultTinyliciousEndpoint = "http://localhost";
|
|
19
|
+
|
|
20
|
+
// @public
|
|
21
|
+
export const defaultTinyliciousPort = 7070;
|
|
22
|
+
|
|
23
|
+
// @public
|
|
24
|
+
export class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
25
|
+
constructor(
|
|
26
|
+
scopes?: ScopeType[] | undefined);
|
|
27
|
+
// (undocumented)
|
|
28
|
+
fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse>;
|
|
29
|
+
// (undocumented)
|
|
30
|
+
fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// @public
|
|
34
|
+
export class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
35
|
+
constructor(port?: number, endpoint?: string);
|
|
36
|
+
// (undocumented)
|
|
37
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
38
|
+
// (undocumented)
|
|
39
|
+
resolve(request: IRequest): Promise<IResolvedUrl>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// (No @packageDocumentation comment for this package)
|
|
43
|
+
|
|
44
|
+
```
|
|
@@ -7,6 +7,8 @@ import { ITokenProvider, ITokenResponse } from "@fluidframework/routerlicious-dr
|
|
|
7
7
|
/**
|
|
8
8
|
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
9
9
|
* to get up and running.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
10
12
|
*/
|
|
11
13
|
export declare class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
12
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousTokenProvider.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousTokenProvider.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAItF;;;;;GAKG;AACH,qBAAa,gCAAiC,YAAW,cAAc;IAErE;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;;IARxB;;;;;;;OAOG;IACc,MAAM,CAAC,yBAAa;IAGzB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAOjF,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO7F,OAAO,CAAC,cAAc;CAkCtB"}
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.InsecureTinyliciousTokenProvider = void 0;
|
|
8
8
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
9
|
-
const server_services_client_1 = require("@fluidframework/server-services-client");
|
|
10
9
|
const jsrsasign_1 = require("jsrsasign");
|
|
11
10
|
const uuid_1 = require("uuid");
|
|
12
11
|
/**
|
|
13
12
|
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
14
13
|
* to get up and running.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
15
16
|
*/
|
|
16
17
|
class InsecureTinyliciousTokenProvider {
|
|
17
18
|
constructor(
|
|
@@ -39,9 +40,12 @@ class InsecureTinyliciousTokenProvider {
|
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
getSignedToken(tenantId, documentId, lifetime = 60 * 60, ver = "1.0") {
|
|
43
|
+
const userId = (0, uuid_1.v4)();
|
|
44
|
+
const match = userId.match(/^([\da-f]{8})-([\da-f]{4})/);
|
|
45
|
+
const userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.
|
|
42
46
|
// Current time in seconds
|
|
43
47
|
const now = Math.round(Date.now() / 1000);
|
|
44
|
-
const user = { id:
|
|
48
|
+
const user = { id: userId, name: userName };
|
|
45
49
|
const claims = {
|
|
46
50
|
documentId: documentId ?? "",
|
|
47
51
|
scopes: this.scopes ?? [protocol_definitions_1.ScopeType.DocRead, protocol_definitions_1.ScopeType.DocWrite, protocol_definitions_1.ScopeType.SummaryWrite],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousTokenProvider.js","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAA+E;AAE/E,
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousTokenProvider.js","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAA+E;AAE/E,yCAA8C;AAC9C,+BAAkC;AAElC;;;;;GAKG;AACH,MAAa,gCAAgC;IAC5C;IACC;;;;;;;OAOG;IACc,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IACnC,CAAC;IAEG,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,UAAmB;QACnE,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC;SAC9C,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,UAAkB;QAClE,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC;SAC9C,CAAC;IACH,CAAC;IAEO,cAAc,CACrB,QAAgB,EAChB,UAA8B,EAC9B,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;QAEnB,MAAM,MAAM,GAAG,IAAA,SAAI,GAAE,CAAC;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,uEAAuE;QAE5H,0BAA0B;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAE5C,MAAM,MAAM,GAAiB;YAC5B,UAAU,EAAE,UAAU,IAAI,EAAE;YAC5B,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,gCAAS,CAAC,OAAO,EAAE,gCAAS,CAAC,QAAQ,EAAE,gCAAS,CAAC,YAAY,CAAC;YACtF,QAAQ;YACR,IAAI;YACJ,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,GAAG,GAAG,QAAQ;YACnB,GAAG;SACH,CAAC;QAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAClC,OAAO,gBAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;QAC5B,2BAA2B;QAC3B,2CAA2C;QAC3C,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;IACH,CAAC;CACD;AA7DD,4EA6DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ScopeType, ITokenClaims } from \"@fluidframework/protocol-definitions\";\nimport { ITokenProvider, ITokenResponse } from \"@fluidframework/routerlicious-driver\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * As the name implies this is not secure and should not be used in production. It simply makes the example easier\n * to get up and running.\n *\n * @public\n */\nexport class InsecureTinyliciousTokenProvider implements ITokenProvider {\n\tconstructor(\n\t\t/**\n\t\t * Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider\n\t\t * will use the default scopes which are document read, write and summarizer write.\n\t\t *\n\t\t * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}\n\t\t *\n\t\t * @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]\n\t\t */\n\t\tprivate readonly scopes?: ScopeType[],\n\t) {}\n\n\tpublic async fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.getSignedToken(tenantId, documentId),\n\t\t};\n\t}\n\n\tpublic async fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.getSignedToken(tenantId, documentId),\n\t\t};\n\t}\n\n\tprivate getSignedToken(\n\t\ttenantId: string,\n\t\tdocumentId: string | undefined,\n\t\tlifetime: number = 60 * 60,\n\t\tver: string = \"1.0\",\n\t): string {\n\t\tconst userId = uuid();\n\t\tconst match = userId.match(/^([\\da-f]{8})-([\\da-f]{4})/);\n\t\tconst userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.\n\n\t\t// Current time in seconds\n\t\tconst now = Math.round(Date.now() / 1000);\n\t\tconst user = { id: userId, name: userName };\n\n\t\tconst claims: ITokenClaims = {\n\t\t\tdocumentId: documentId ?? \"\",\n\t\t\tscopes: this.scopes ?? [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite],\n\t\t\ttenantId,\n\t\t\tuser,\n\t\t\tiat: now,\n\t\t\texp: now + lifetime,\n\t\t\tver,\n\t\t};\n\n\t\tconst utf8Key = { utf8: \"12345\" };\n\t\treturn jsrsasign.jws.JWS.sign(\n\t\t\t// External API uses `null`\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tnull,\n\t\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\t\tclaims,\n\t\t\tutf8Key,\n\t\t);\n\t}\n}\n"]}
|
|
@@ -6,10 +6,14 @@ import { IRequest } from "@fluidframework/core-interfaces";
|
|
|
6
6
|
import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
9
11
|
*/
|
|
10
12
|
export declare const defaultTinyliciousPort = 7070;
|
|
11
13
|
/**
|
|
12
14
|
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
13
17
|
*/
|
|
14
18
|
export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
15
19
|
/**
|
|
@@ -17,6 +21,8 @@ export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
|
17
21
|
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
18
22
|
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
19
23
|
* documentId/containerRelativePathing
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
20
26
|
*/
|
|
21
27
|
export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
22
28
|
private readonly fluidProtocolEndpoint;
|
|
@@ -25,5 +31,10 @@ export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
|
25
31
|
resolve(request: IRequest): Promise<IResolvedUrl>;
|
|
26
32
|
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
|
|
29
40
|
//# sourceMappingURL=insecureTinyliciousUrlResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAgB,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE9F
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAgB,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE9F;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;;;GAOG;AACH,qBAAa,8BAA+B,YAAW,YAAY;IAClE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;gBAC1B,IAAI,SAAyB,EAAE,QAAQ,SAA6B;IAK1E,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAuCjD,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAY5F;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,gBAAiB,MAAM,KAAG,QAKtE,CAAC"}
|
|
@@ -8,10 +8,14 @@ exports.createTinyliciousCreateNewRequest = exports.InsecureTinyliciousUrlResolv
|
|
|
8
8
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
9
9
|
/**
|
|
10
10
|
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
11
13
|
*/
|
|
12
14
|
exports.defaultTinyliciousPort = 7070;
|
|
13
15
|
/**
|
|
14
16
|
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
15
19
|
*/
|
|
16
20
|
exports.defaultTinyliciousEndpoint = "http://localhost";
|
|
17
21
|
/**
|
|
@@ -19,6 +23,8 @@ exports.defaultTinyliciousEndpoint = "http://localhost";
|
|
|
19
23
|
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
20
24
|
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
21
25
|
* documentId/containerRelativePathing
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
22
28
|
*/
|
|
23
29
|
class InsecureTinyliciousUrlResolver {
|
|
24
30
|
constructor(port = exports.defaultTinyliciousPort, endpoint = exports.defaultTinyliciousEndpoint) {
|
|
@@ -73,6 +79,11 @@ class InsecureTinyliciousUrlResolver {
|
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
exports.InsecureTinyliciousUrlResolver = InsecureTinyliciousUrlResolver;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
76
87
|
const createTinyliciousCreateNewRequest = (documentId) => ({
|
|
77
88
|
url: documentId ?? "",
|
|
78
89
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousUrlResolver.js","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAA8F;AAE9F
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousUrlResolver.js","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAA8F;AAE9F;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;GAIG;AACU,QAAA,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAa,8BAA8B;IAG1C,YAAmB,IAAI,GAAG,8BAAsB,EAAE,QAAQ,GAAG,kCAA0B;QACtF,IAAI,CAAC,mBAAmB,GAAG,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC;QACjD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC5F,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,mBAAmB,GAAG,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,qBAAqB,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,eAAuB,CAAC;QAC5B,IAAI,WAAmB,CAAC;QACxB,IAAI,eAAe,GAAW,qBAAqB,CAAC;QAEpD,+DAA+D;QAC/D,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,iCAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;YACxE,wEAAwE;YACxE,kFAAkF;YAClF,qGAAqG;YACrG,sBAAsB;YACtB,IAAI,eAAe,KAAK,EAAE,EAAE;gBAC3B,eAAe,GAAG,KAAK,CAAC;aACxB;YACD,eAAe,GAAG,GAAG,IAAI,CAAC,mBAAmB,uBAAuB,eAAe,EAAE,CAAC;YACtF,WAAW,GAAG,GAAG,IAAI,CAAC,qBAAqB,gBAAgB,eAAe,EAAE,CAAC;SAC7E;aAAM;YACN,MAAM,YAAY,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;YACzD,MAAM,oBAAoB,GAAG,WAAW,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;YAC7E,WAAW,GAAG,GAAG,IAAI,CAAC,qBAAqB,gBAAgB,YAAY,GAAG,oBAAoB,EAAE,CAAC;YACjG,eAAe,GAAG,GAAG,IAAI,CAAC,mBAAmB,uBAAuB,YAAY,EAAE,CAAC;SACnF;QAED,OAAO;YACN,SAAS,EAAE;gBACV,eAAe;gBACf,UAAU,EAAE,IAAI,CAAC,mBAAmB;gBACpC,UAAU,EAAE,GAAG,IAAI,CAAC,mBAAmB,oBAAoB;aAC3D;YACD,EAAE,EAAE,eAAe;YACnB,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,WAAW;SAChB,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,WAAyB,EAAE,WAAmB;QACzE,MAAM,UAAU,GAAG,kBAAkB,CACpC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,qBAAqB,eAAe,EAAE,EAAE,CAAC,CACzE,CAAC;QACF;;;;;WAKG;QACH,OAAO,GAAG,UAAU,IAAI,WAAW,EAAE,CAAC;IACvC,CAAC;CACD;AA3DD,wEA2DC;AAED;;;;GAIG;AACI,MAAM,iCAAiC,GAAG,CAAC,UAAmB,EAAY,EAAE,CAAC,CAAC;IACpF,GAAG,EAAE,UAAU,IAAI,EAAE;IACrB,OAAO,EAAE;QACR,CAAC,iCAAY,CAAC,SAAS,CAAC,EAAE,IAAI;KAC9B;CACD,CAAC,CAAC;AALU,QAAA,iCAAiC,qCAK3C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { DriverHeader, IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\n\n/**\n * Default endpoint port. Will be used by the service if the consumer does not specify a port.\n *\n * @public\n */\nexport const defaultTinyliciousPort = 7070;\n\n/**\n * Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.\n *\n * @public\n */\nexport const defaultTinyliciousEndpoint = \"http://localhost\";\n\n/**\n * InsecureTinyliciousUrlResolver knows how to get the URLs to the service (in this case Tinylicious) to use\n * for a given request. This particular implementation has a goal to avoid imposing requirements on the app's\n * URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):\n * documentId/containerRelativePathing\n *\n * @public\n */\nexport class InsecureTinyliciousUrlResolver implements IUrlResolver {\n\tprivate readonly fluidProtocolEndpoint: string;\n\tprivate readonly tinyliciousEndpoint: string;\n\tpublic constructor(port = defaultTinyliciousPort, endpoint = defaultTinyliciousEndpoint) {\n\t\tthis.tinyliciousEndpoint = `${endpoint}:${port}`;\n\t\tthis.fluidProtocolEndpoint = this.tinyliciousEndpoint.replace(/(^\\w+:|^)\\/\\//, \"fluid://\");\n\t}\n\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl> {\n\t\tconst relativeUrl = request.url.replace(`${this.tinyliciousEndpoint}/`, \"\");\n\t\tconst documentIdFromRequest = relativeUrl.split(\"/\")[0];\n\n\t\tlet deltaStorageUrl: string;\n\t\tlet documentUrl: string;\n\t\tlet finalDocumentId: string = documentIdFromRequest;\n\n\t\t// Special handling if the request is to create a new container\n\t\tif (request.headers && request.headers[DriverHeader.createNew] === true) {\n\t\t\t// Use the document ID passed by the application via the create request;\n\t\t\t// if none was passed, use the reserved keyword to let the driver generate the ID.\n\t\t\t// TODO: deprecate this capability for tinylicious as the r11s driver will stop using the document ID\n\t\t\t// in create requests.\n\t\t\tif (finalDocumentId === \"\") {\n\t\t\t\tfinalDocumentId = \"new\";\n\t\t\t}\n\t\t\tdeltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${finalDocumentId}`;\n\t\t\tdocumentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${finalDocumentId}`;\n\t\t} else {\n\t\t\tconst encodedDocId = encodeURIComponent(finalDocumentId);\n\t\t\tconst documentRelativePath = relativeUrl.slice(documentIdFromRequest.length);\n\t\t\tdocumentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;\n\t\t\tdeltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;\n\t\t}\n\n\t\treturn {\n\t\t\tendpoints: {\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl: this.tinyliciousEndpoint,\n\t\t\t\tstorageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,\n\t\t\t},\n\t\t\tid: finalDocumentId,\n\t\t\ttokens: {},\n\t\t\ttype: \"fluid\",\n\t\t\turl: documentUrl,\n\t\t};\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst documentId = decodeURIComponent(\n\t\t\tresolvedUrl.url.replace(`${this.fluidProtocolEndpoint}/tinylicious/`, \"\"),\n\t\t);\n\t\t/*\n\t\t * The detached container flow will ultimately call getAbsoluteUrl() with the resolved.url produced by\n\t\t * resolve(). The container expects getAbsoluteUrl's return value to be a URL that can then be roundtripped\n\t\t * back through resolve() again, and get the same result again. So we'll return a \"URL\" with the same format\n\t\t * described above.\n\t\t */\n\t\treturn `${documentId}/${relativeUrl}`;\n\t}\n}\n\n/**\n * Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.\n *\n * @public\n */\nexport const createTinyliciousCreateNewRequest = (documentId?: string): IRequest => ({\n\turl: documentId ?? \"\",\n\theaders: {\n\t\t[DriverHeader.createNew]: true,\n\t},\n});\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
|
+
import { ITokenProvider } from '@fluidframework/routerlicious-driver';
|
|
4
|
+
import { ITokenResponse } from '@fluidframework/routerlicious-driver';
|
|
5
|
+
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
6
|
+
import { ScopeType } from '@fluidframework/protocol-definitions';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const defaultTinyliciousPort = 7070;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
31
|
+
* to get up and running.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
36
|
+
/**
|
|
37
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
38
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
39
|
+
*
|
|
40
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
43
|
+
*/
|
|
44
|
+
private readonly scopes?;
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
48
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
49
|
+
*
|
|
50
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
53
|
+
*/
|
|
54
|
+
scopes?: ScopeType[] | undefined);
|
|
55
|
+
fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse>;
|
|
56
|
+
fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse>;
|
|
57
|
+
private getSignedToken;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* InsecureTinyliciousUrlResolver knows how to get the URLs to the service (in this case Tinylicious) to use
|
|
62
|
+
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
63
|
+
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
64
|
+
* documentId/containerRelativePathing
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
69
|
+
private readonly fluidProtocolEndpoint;
|
|
70
|
+
private readonly tinyliciousEndpoint;
|
|
71
|
+
constructor(port?: number, endpoint?: string);
|
|
72
|
+
resolve(request: IRequest): Promise<IResolvedUrl>;
|
|
73
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
|
+
import { ITokenProvider } from '@fluidframework/routerlicious-driver';
|
|
4
|
+
import { ITokenResponse } from '@fluidframework/routerlicious-driver';
|
|
5
|
+
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
6
|
+
import { ScopeType } from '@fluidframework/protocol-definitions';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const defaultTinyliciousPort = 7070;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
31
|
+
* to get up and running.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
36
|
+
/**
|
|
37
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
38
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
39
|
+
*
|
|
40
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
43
|
+
*/
|
|
44
|
+
private readonly scopes?;
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
48
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
49
|
+
*
|
|
50
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
53
|
+
*/
|
|
54
|
+
scopes?: ScopeType[] | undefined);
|
|
55
|
+
fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse>;
|
|
56
|
+
fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse>;
|
|
57
|
+
private getSignedToken;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* InsecureTinyliciousUrlResolver knows how to get the URLs to the service (in this case Tinylicious) to use
|
|
62
|
+
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
63
|
+
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
64
|
+
* documentId/containerRelativePathing
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
69
|
+
private readonly fluidProtocolEndpoint;
|
|
70
|
+
private readonly tinyliciousEndpoint;
|
|
71
|
+
constructor(port?: number, endpoint?: string);
|
|
72
|
+
resolve(request: IRequest): Promise<IResolvedUrl>;
|
|
73
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
|
+
import { ITokenProvider } from '@fluidframework/routerlicious-driver';
|
|
4
|
+
import { ITokenResponse } from '@fluidframework/routerlicious-driver';
|
|
5
|
+
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
6
|
+
import { ScopeType } from '@fluidframework/protocol-definitions';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const defaultTinyliciousPort = 7070;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
31
|
+
* to get up and running.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
36
|
+
/**
|
|
37
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
38
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
39
|
+
*
|
|
40
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
43
|
+
*/
|
|
44
|
+
private readonly scopes?;
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
48
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
49
|
+
*
|
|
50
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
53
|
+
*/
|
|
54
|
+
scopes?: ScopeType[] | undefined);
|
|
55
|
+
fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse>;
|
|
56
|
+
fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse>;
|
|
57
|
+
private getSignedToken;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* InsecureTinyliciousUrlResolver knows how to get the URLs to the service (in this case Tinylicious) to use
|
|
62
|
+
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
63
|
+
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
64
|
+
* documentId/containerRelativePathing
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
69
|
+
private readonly fluidProtocolEndpoint;
|
|
70
|
+
private readonly tinyliciousEndpoint;
|
|
71
|
+
constructor(port?: number, endpoint?: string);
|
|
72
|
+
resolve(request: IRequest): Promise<IResolvedUrl>;
|
|
73
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IRequest } from '@fluidframework/core-interfaces';
|
|
2
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
3
|
+
import { ITokenProvider } from '@fluidframework/routerlicious-driver';
|
|
4
|
+
import { ITokenResponse } from '@fluidframework/routerlicious-driver';
|
|
5
|
+
import { IUrlResolver } from '@fluidframework/driver-definitions';
|
|
6
|
+
import { ScopeType } from '@fluidframework/protocol-definitions';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const defaultTinyliciousPort = 7070;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
31
|
+
* to get up and running.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
36
|
+
/**
|
|
37
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
38
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
39
|
+
*
|
|
40
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
43
|
+
*/
|
|
44
|
+
private readonly scopes?;
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider
|
|
48
|
+
* will use the default scopes which are document read, write and summarizer write.
|
|
49
|
+
*
|
|
50
|
+
* @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
|
|
53
|
+
*/
|
|
54
|
+
scopes?: ScopeType[] | undefined);
|
|
55
|
+
fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse>;
|
|
56
|
+
fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse>;
|
|
57
|
+
private getSignedToken;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* InsecureTinyliciousUrlResolver knows how to get the URLs to the service (in this case Tinylicious) to use
|
|
62
|
+
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
63
|
+
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
64
|
+
* documentId/containerRelativePathing
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
69
|
+
private readonly fluidProtocolEndpoint;
|
|
70
|
+
private readonly tinyliciousEndpoint;
|
|
71
|
+
constructor(port?: number, endpoint?: string);
|
|
72
|
+
resolve(request: IRequest): Promise<IResolvedUrl>;
|
|
73
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { }
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -7,6 +7,8 @@ import { ITokenProvider, ITokenResponse } from "@fluidframework/routerlicious-dr
|
|
|
7
7
|
/**
|
|
8
8
|
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
9
9
|
* to get up and running.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
10
12
|
*/
|
|
11
13
|
export declare class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
12
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousTokenProvider.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousTokenProvider.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAItF;;;;;GAKG;AACH,qBAAa,gCAAiC,YAAW,cAAc;IAErE;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;;IARxB;;;;;;;OAOG;IACc,MAAM,CAAC,yBAAa;IAGzB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAOjF,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO7F,OAAO,CAAC,cAAc;CAkCtB"}
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ScopeType } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import { getRandomName } from "@fluidframework/server-services-client";
|
|
7
6
|
import { KJUR as jsrsasign } from "jsrsasign";
|
|
8
7
|
import { v4 as uuid } from "uuid";
|
|
9
8
|
/**
|
|
10
9
|
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
11
10
|
* to get up and running.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
12
13
|
*/
|
|
13
14
|
export class InsecureTinyliciousTokenProvider {
|
|
14
15
|
constructor(
|
|
@@ -36,9 +37,12 @@ export class InsecureTinyliciousTokenProvider {
|
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
getSignedToken(tenantId, documentId, lifetime = 60 * 60, ver = "1.0") {
|
|
40
|
+
const userId = uuid();
|
|
41
|
+
const match = userId.match(/^([\da-f]{8})-([\da-f]{4})/);
|
|
42
|
+
const userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.
|
|
39
43
|
// Current time in seconds
|
|
40
44
|
const now = Math.round(Date.now() / 1000);
|
|
41
|
-
const user = { id:
|
|
45
|
+
const user = { id: userId, name: userName };
|
|
42
46
|
const claims = {
|
|
43
47
|
documentId: documentId ?? "",
|
|
44
48
|
scopes: this.scopes ?? [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousTokenProvider.js","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,sCAAsC,CAAC;AAE/E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousTokenProvider.js","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,sCAAsC,CAAC;AAE/E,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;;;GAKG;AACH,MAAM,OAAO,gCAAgC;IAC5C;IACC;;;;;;;OAOG;IACc,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IACnC,CAAC;IAEG,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,UAAmB;QACnE,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC;SAC9C,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,UAAkB;QAClE,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC;SAC9C,CAAC;IACH,CAAC;IAEO,cAAc,CACrB,QAAgB,EAChB,UAA8B,EAC9B,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;QAEnB,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,uEAAuE;QAE5H,0BAA0B;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAE5C,MAAM,MAAM,GAAiB;YAC5B,UAAU,EAAE,UAAU,IAAI,EAAE;YAC5B,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC;YACtF,QAAQ;YACR,IAAI;YACJ,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,GAAG,GAAG,QAAQ;YACnB,GAAG;SACH,CAAC;QAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAClC,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;QAC5B,2BAA2B;QAC3B,2CAA2C;QAC3C,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ScopeType, ITokenClaims } from \"@fluidframework/protocol-definitions\";\nimport { ITokenProvider, ITokenResponse } from \"@fluidframework/routerlicious-driver\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * As the name implies this is not secure and should not be used in production. It simply makes the example easier\n * to get up and running.\n *\n * @public\n */\nexport class InsecureTinyliciousTokenProvider implements ITokenProvider {\n\tconstructor(\n\t\t/**\n\t\t * Optional. Override of scopes. If a param is not provided, InsecureTinyliciousTokenProvider\n\t\t * will use the default scopes which are document read, write and summarizer write.\n\t\t *\n\t\t * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}\n\t\t *\n\t\t * @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]\n\t\t */\n\t\tprivate readonly scopes?: ScopeType[],\n\t) {}\n\n\tpublic async fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.getSignedToken(tenantId, documentId),\n\t\t};\n\t}\n\n\tpublic async fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.getSignedToken(tenantId, documentId),\n\t\t};\n\t}\n\n\tprivate getSignedToken(\n\t\ttenantId: string,\n\t\tdocumentId: string | undefined,\n\t\tlifetime: number = 60 * 60,\n\t\tver: string = \"1.0\",\n\t): string {\n\t\tconst userId = uuid();\n\t\tconst match = userId.match(/^([\\da-f]{8})-([\\da-f]{4})/);\n\t\tconst userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.\n\n\t\t// Current time in seconds\n\t\tconst now = Math.round(Date.now() / 1000);\n\t\tconst user = { id: userId, name: userName };\n\n\t\tconst claims: ITokenClaims = {\n\t\t\tdocumentId: documentId ?? \"\",\n\t\t\tscopes: this.scopes ?? [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite],\n\t\t\ttenantId,\n\t\t\tuser,\n\t\t\tiat: now,\n\t\t\texp: now + lifetime,\n\t\t\tver,\n\t\t};\n\n\t\tconst utf8Key = { utf8: \"12345\" };\n\t\treturn jsrsasign.jws.JWS.sign(\n\t\t\t// External API uses `null`\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tnull,\n\t\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\t\tclaims,\n\t\t\tutf8Key,\n\t\t);\n\t}\n}\n"]}
|
|
@@ -6,10 +6,14 @@ import { IRequest } from "@fluidframework/core-interfaces";
|
|
|
6
6
|
import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
9
11
|
*/
|
|
10
12
|
export declare const defaultTinyliciousPort = 7070;
|
|
11
13
|
/**
|
|
12
14
|
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
13
17
|
*/
|
|
14
18
|
export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
15
19
|
/**
|
|
@@ -17,6 +21,8 @@ export declare const defaultTinyliciousEndpoint = "http://localhost";
|
|
|
17
21
|
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
18
22
|
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
19
23
|
* documentId/containerRelativePathing
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
20
26
|
*/
|
|
21
27
|
export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
22
28
|
private readonly fluidProtocolEndpoint;
|
|
@@ -25,5 +31,10 @@ export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
|
25
31
|
resolve(request: IRequest): Promise<IResolvedUrl>;
|
|
26
32
|
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
|
|
29
40
|
//# sourceMappingURL=insecureTinyliciousUrlResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAgB,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE9F
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAgB,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAE9F;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;;;GAOG;AACH,qBAAa,8BAA+B,YAAW,YAAY;IAClE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;gBAC1B,IAAI,SAAyB,EAAE,QAAQ,SAA6B;IAK1E,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAuCjD,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAY5F;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,gBAAiB,MAAM,KAAG,QAKtE,CAAC"}
|
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
import { DriverHeader } from "@fluidframework/driver-definitions";
|
|
6
6
|
/**
|
|
7
7
|
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
8
10
|
*/
|
|
9
11
|
export const defaultTinyliciousPort = 7070;
|
|
10
12
|
/**
|
|
11
13
|
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
12
16
|
*/
|
|
13
17
|
export const defaultTinyliciousEndpoint = "http://localhost";
|
|
14
18
|
/**
|
|
@@ -16,6 +20,8 @@ export const defaultTinyliciousEndpoint = "http://localhost";
|
|
|
16
20
|
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
17
21
|
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
18
22
|
* documentId/containerRelativePathing
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
19
25
|
*/
|
|
20
26
|
export class InsecureTinyliciousUrlResolver {
|
|
21
27
|
constructor(port = defaultTinyliciousPort, endpoint = defaultTinyliciousEndpoint) {
|
|
@@ -69,6 +75,11 @@ export class InsecureTinyliciousUrlResolver {
|
|
|
69
75
|
return `${documentId}/${relativeUrl}`;
|
|
70
76
|
}
|
|
71
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
72
83
|
export const createTinyliciousCreateNewRequest = (documentId) => ({
|
|
73
84
|
url: documentId ?? "",
|
|
74
85
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousUrlResolver.js","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAA8B,MAAM,oCAAoC,CAAC;AAE9F
|
|
1
|
+
{"version":3,"file":"insecureTinyliciousUrlResolver.js","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAA8B,MAAM,oCAAoC,CAAC;AAE9F;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,OAAO,8BAA8B;IAG1C,YAAmB,IAAI,GAAG,sBAAsB,EAAE,QAAQ,GAAG,0BAA0B;QACtF,IAAI,CAAC,mBAAmB,GAAG,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC;QACjD,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC5F,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,mBAAmB,GAAG,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,qBAAqB,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,eAAuB,CAAC;QAC5B,IAAI,WAAmB,CAAC;QACxB,IAAI,eAAe,GAAW,qBAAqB,CAAC;QAEpD,+DAA+D;QAC/D,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;YACxE,wEAAwE;YACxE,kFAAkF;YAClF,qGAAqG;YACrG,sBAAsB;YACtB,IAAI,eAAe,KAAK,EAAE,EAAE;gBAC3B,eAAe,GAAG,KAAK,CAAC;aACxB;YACD,eAAe,GAAG,GAAG,IAAI,CAAC,mBAAmB,uBAAuB,eAAe,EAAE,CAAC;YACtF,WAAW,GAAG,GAAG,IAAI,CAAC,qBAAqB,gBAAgB,eAAe,EAAE,CAAC;SAC7E;aAAM;YACN,MAAM,YAAY,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;YACzD,MAAM,oBAAoB,GAAG,WAAW,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;YAC7E,WAAW,GAAG,GAAG,IAAI,CAAC,qBAAqB,gBAAgB,YAAY,GAAG,oBAAoB,EAAE,CAAC;YACjG,eAAe,GAAG,GAAG,IAAI,CAAC,mBAAmB,uBAAuB,YAAY,EAAE,CAAC;SACnF;QAED,OAAO;YACN,SAAS,EAAE;gBACV,eAAe;gBACf,UAAU,EAAE,IAAI,CAAC,mBAAmB;gBACpC,UAAU,EAAE,GAAG,IAAI,CAAC,mBAAmB,oBAAoB;aAC3D;YACD,EAAE,EAAE,eAAe;YACnB,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,WAAW;SAChB,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,WAAyB,EAAE,WAAmB;QACzE,MAAM,UAAU,GAAG,kBAAkB,CACpC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,qBAAqB,eAAe,EAAE,EAAE,CAAC,CACzE,CAAC;QACF;;;;;WAKG;QACH,OAAO,GAAG,UAAU,IAAI,WAAW,EAAE,CAAC;IACvC,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,UAAmB,EAAY,EAAE,CAAC,CAAC;IACpF,GAAG,EAAE,UAAU,IAAI,EAAE;IACrB,OAAO,EAAE;QACR,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;KAC9B;CACD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { DriverHeader, IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\n\n/**\n * Default endpoint port. Will be used by the service if the consumer does not specify a port.\n *\n * @public\n */\nexport const defaultTinyliciousPort = 7070;\n\n/**\n * Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.\n *\n * @public\n */\nexport const defaultTinyliciousEndpoint = \"http://localhost\";\n\n/**\n * InsecureTinyliciousUrlResolver knows how to get the URLs to the service (in this case Tinylicious) to use\n * for a given request. This particular implementation has a goal to avoid imposing requirements on the app's\n * URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):\n * documentId/containerRelativePathing\n *\n * @public\n */\nexport class InsecureTinyliciousUrlResolver implements IUrlResolver {\n\tprivate readonly fluidProtocolEndpoint: string;\n\tprivate readonly tinyliciousEndpoint: string;\n\tpublic constructor(port = defaultTinyliciousPort, endpoint = defaultTinyliciousEndpoint) {\n\t\tthis.tinyliciousEndpoint = `${endpoint}:${port}`;\n\t\tthis.fluidProtocolEndpoint = this.tinyliciousEndpoint.replace(/(^\\w+:|^)\\/\\//, \"fluid://\");\n\t}\n\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl> {\n\t\tconst relativeUrl = request.url.replace(`${this.tinyliciousEndpoint}/`, \"\");\n\t\tconst documentIdFromRequest = relativeUrl.split(\"/\")[0];\n\n\t\tlet deltaStorageUrl: string;\n\t\tlet documentUrl: string;\n\t\tlet finalDocumentId: string = documentIdFromRequest;\n\n\t\t// Special handling if the request is to create a new container\n\t\tif (request.headers && request.headers[DriverHeader.createNew] === true) {\n\t\t\t// Use the document ID passed by the application via the create request;\n\t\t\t// if none was passed, use the reserved keyword to let the driver generate the ID.\n\t\t\t// TODO: deprecate this capability for tinylicious as the r11s driver will stop using the document ID\n\t\t\t// in create requests.\n\t\t\tif (finalDocumentId === \"\") {\n\t\t\t\tfinalDocumentId = \"new\";\n\t\t\t}\n\t\t\tdeltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${finalDocumentId}`;\n\t\t\tdocumentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${finalDocumentId}`;\n\t\t} else {\n\t\t\tconst encodedDocId = encodeURIComponent(finalDocumentId);\n\t\t\tconst documentRelativePath = relativeUrl.slice(documentIdFromRequest.length);\n\t\t\tdocumentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;\n\t\t\tdeltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;\n\t\t}\n\n\t\treturn {\n\t\t\tendpoints: {\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl: this.tinyliciousEndpoint,\n\t\t\t\tstorageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,\n\t\t\t},\n\t\t\tid: finalDocumentId,\n\t\t\ttokens: {},\n\t\t\ttype: \"fluid\",\n\t\t\turl: documentUrl,\n\t\t};\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst documentId = decodeURIComponent(\n\t\t\tresolvedUrl.url.replace(`${this.fluidProtocolEndpoint}/tinylicious/`, \"\"),\n\t\t);\n\t\t/*\n\t\t * The detached container flow will ultimately call getAbsoluteUrl() with the resolved.url produced by\n\t\t * resolve(). The container expects getAbsoluteUrl's return value to be a URL that can then be roundtripped\n\t\t * back through resolve() again, and get the same result again. So we'll return a \"URL\" with the same format\n\t\t * described above.\n\t\t */\n\t\treturn `${documentId}/${relativeUrl}`;\n\t}\n}\n\n/**\n * Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.\n *\n * @public\n */\nexport const createTinyliciousCreateNewRequest = (documentId?: string): IRequest => ({\n\turl: documentId ?? \"\",\n\theaders: {\n\t\t[DriverHeader.createNew]: true,\n\t},\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/tinylicious-driver",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.7.1.0",
|
|
4
4
|
"description": "Driver for tinylicious",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,35 +14,34 @@
|
|
|
14
14
|
"module": "lib/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.
|
|
18
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.
|
|
19
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.
|
|
20
|
-
"@fluidframework/protocol-definitions": "^
|
|
21
|
-
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.
|
|
22
|
-
"@fluidframework/server-services-client": "^1.0.1",
|
|
17
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.1.0 <2.0.0-internal.7.2.0",
|
|
18
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.1.0 <2.0.0-internal.7.2.0",
|
|
19
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.7.1.0 <2.0.0-internal.7.2.0",
|
|
20
|
+
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
21
|
+
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.7.1.0 <2.0.0-internal.7.2.0",
|
|
23
22
|
"jsrsasign": "^10.5.25",
|
|
24
23
|
"uuid": "^9.0.0"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@fluid-tools/build-cli": "^0.
|
|
28
|
-
"@fluidframework/build-common": "^2.0.
|
|
29
|
-
"@fluidframework/build-tools": "^0.
|
|
30
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
31
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.
|
|
32
|
-
"@fluidframework/test-tools": "^0.
|
|
33
|
-
"@fluidframework/tinylicious-driver-previous": "npm:@fluidframework/tinylicious-driver@2.0.0-internal.
|
|
34
|
-
"@microsoft/api-extractor": "^7.
|
|
26
|
+
"@fluid-tools/build-cli": "^0.25.0",
|
|
27
|
+
"@fluidframework/build-common": "^2.0.1",
|
|
28
|
+
"@fluidframework/build-tools": "^0.25.0",
|
|
29
|
+
"@fluidframework/eslint-config-fluid": "^3.0.0",
|
|
30
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.1.0 <2.0.0-internal.7.2.0",
|
|
31
|
+
"@fluidframework/test-tools": "^1.0.195075",
|
|
32
|
+
"@fluidframework/tinylicious-driver-previous": "npm:@fluidframework/tinylicious-driver@2.0.0-internal.7.0.0",
|
|
33
|
+
"@microsoft/api-extractor": "^7.37.0",
|
|
35
34
|
"@types/jsrsasign": "^8.0.8",
|
|
36
35
|
"@types/mocha": "^9.1.1",
|
|
37
36
|
"@types/node": "^16.18.38",
|
|
38
37
|
"@types/uuid": "^9.0.2",
|
|
39
38
|
"copyfiles": "^2.4.1",
|
|
40
39
|
"cross-env": "^7.0.3",
|
|
41
|
-
"eslint": "~8.
|
|
40
|
+
"eslint": "~8.50.0",
|
|
42
41
|
"mocha": "^10.2.0",
|
|
43
|
-
"prettier": "~
|
|
42
|
+
"prettier": "~3.0.3",
|
|
44
43
|
"rimraf": "^4.4.0",
|
|
45
|
-
"typescript": "~
|
|
44
|
+
"typescript": "~5.1.6"
|
|
46
45
|
},
|
|
47
46
|
"typeValidation": {
|
|
48
47
|
"broken": {}
|
|
@@ -51,10 +50,10 @@
|
|
|
51
50
|
"build": "fluid-build . --task build",
|
|
52
51
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
53
52
|
"build:compile": "fluid-build . --task compile",
|
|
54
|
-
"build:docs": "api-extractor run --local
|
|
53
|
+
"build:docs": "api-extractor run --local",
|
|
55
54
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
56
55
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
57
|
-
"ci:build:docs": "api-extractor run
|
|
56
|
+
"ci:build:docs": "api-extractor run",
|
|
58
57
|
"clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp' 'nyc'",
|
|
59
58
|
"eslint": "eslint --format stylish src",
|
|
60
59
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { ScopeType, ITokenClaims } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { ITokenProvider, ITokenResponse } from "@fluidframework/routerlicious-driver";
|
|
8
|
-
import { getRandomName } from "@fluidframework/server-services-client";
|
|
9
8
|
import { KJUR as jsrsasign } from "jsrsasign";
|
|
10
9
|
import { v4 as uuid } from "uuid";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* As the name implies this is not secure and should not be used in production. It simply makes the example easier
|
|
14
13
|
* to get up and running.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
15
16
|
*/
|
|
16
17
|
export class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
17
18
|
constructor(
|
|
@@ -46,9 +47,13 @@ export class InsecureTinyliciousTokenProvider implements ITokenProvider {
|
|
|
46
47
|
lifetime: number = 60 * 60,
|
|
47
48
|
ver: string = "1.0",
|
|
48
49
|
): string {
|
|
50
|
+
const userId = uuid();
|
|
51
|
+
const match = userId.match(/^([\da-f]{8})-([\da-f]{4})/);
|
|
52
|
+
const userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.
|
|
53
|
+
|
|
49
54
|
// Current time in seconds
|
|
50
55
|
const now = Math.round(Date.now() / 1000);
|
|
51
|
-
const user = { id:
|
|
56
|
+
const user = { id: userId, name: userName };
|
|
52
57
|
|
|
53
58
|
const claims: ITokenClaims = {
|
|
54
59
|
documentId: documentId ?? "",
|
|
@@ -8,11 +8,15 @@ import { DriverHeader, IResolvedUrl, IUrlResolver } from "@fluidframework/driver
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Default endpoint port. Will be used by the service if the consumer does not specify a port.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
11
13
|
*/
|
|
12
14
|
export const defaultTinyliciousPort = 7070;
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
16
20
|
*/
|
|
17
21
|
export const defaultTinyliciousEndpoint = "http://localhost";
|
|
18
22
|
|
|
@@ -21,6 +25,8 @@ export const defaultTinyliciousEndpoint = "http://localhost";
|
|
|
21
25
|
* for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
|
|
22
26
|
* URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
|
|
23
27
|
* documentId/containerRelativePathing
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
24
30
|
*/
|
|
25
31
|
export class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
26
32
|
private readonly fluidProtocolEndpoint: string;
|
|
@@ -83,6 +89,11 @@ export class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
86
97
|
export const createTinyliciousCreateNewRequest = (documentId?: string): IRequest => ({
|
|
87
98
|
url: documentId ?? "",
|
|
88
99
|
headers: {
|