@fluidframework/tinylicious-driver 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.eslintrc.js +8 -10
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +117 -0
  4. package/README.md +69 -0
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +4 -0
  7. package/api-report/tinylicious-driver.api.md +44 -0
  8. package/dist/index.cjs +15 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/{insecureTinyliciousTokenProvider.js → insecureTinyliciousTokenProvider.cjs} +14 -13
  13. package/dist/insecureTinyliciousTokenProvider.cjs.map +1 -0
  14. package/dist/insecureTinyliciousTokenProvider.d.ts +3 -2
  15. package/dist/insecureTinyliciousTokenProvider.d.ts.map +1 -1
  16. package/dist/{insecureTinyliciousUrlResolver.js → insecureTinyliciousUrlResolver.cjs} +31 -33
  17. package/dist/insecureTinyliciousUrlResolver.cjs.map +1 -0
  18. package/dist/insecureTinyliciousUrlResolver.d.ts +10 -3
  19. package/dist/insecureTinyliciousUrlResolver.d.ts.map +1 -1
  20. package/dist/tinylicious-driver-alpha.d.ts +18 -0
  21. package/dist/tinylicious-driver-beta.d.ts +22 -0
  22. package/dist/tinylicious-driver-public.d.ts +22 -0
  23. package/dist/tinylicious-driver-untrimmed.d.ts +71 -0
  24. package/dist/tsdoc-metadata.json +11 -0
  25. package/lib/index.d.mts +7 -0
  26. package/lib/index.d.mts.map +1 -0
  27. package/lib/index.mjs +7 -0
  28. package/lib/index.mjs.map +1 -0
  29. package/lib/{insecureTinyliciousTokenProvider.d.ts → insecureTinyliciousTokenProvider.d.mts} +3 -2
  30. package/lib/insecureTinyliciousTokenProvider.d.mts.map +1 -0
  31. package/lib/{insecureTinyliciousTokenProvider.js → insecureTinyliciousTokenProvider.mjs} +14 -13
  32. package/lib/insecureTinyliciousTokenProvider.mjs.map +1 -0
  33. package/lib/{insecureTinyliciousUrlResolver.d.ts → insecureTinyliciousUrlResolver.d.mts} +10 -3
  34. package/lib/insecureTinyliciousUrlResolver.d.mts.map +1 -0
  35. package/lib/{insecureTinyliciousUrlResolver.js → insecureTinyliciousUrlResolver.mjs} +32 -34
  36. package/lib/insecureTinyliciousUrlResolver.mjs.map +1 -0
  37. package/lib/tinylicious-driver-alpha.d.mts +18 -0
  38. package/lib/tinylicious-driver-beta.d.mts +22 -0
  39. package/lib/tinylicious-driver-public.d.mts +22 -0
  40. package/lib/tinylicious-driver-untrimmed.d.mts +71 -0
  41. package/package.json +83 -44
  42. package/prettier.config.cjs +8 -0
  43. package/src/index.ts +7 -2
  44. package/src/insecureTinyliciousTokenProvider.ts +57 -64
  45. package/src/insecureTinyliciousUrlResolver.ts +68 -83
  46. package/tsc-multi.test.json +4 -0
  47. package/tsconfig.json +11 -13
  48. package/dist/index.js +0 -19
  49. package/dist/index.js.map +0 -1
  50. package/dist/insecureTinyliciousTokenProvider.js.map +0 -1
  51. package/dist/insecureTinyliciousUrlResolver.js.map +0 -1
  52. package/lib/index.d.ts +0 -7
  53. package/lib/index.d.ts.map +0 -1
  54. package/lib/index.js +0 -7
  55. package/lib/index.js.map +0 -1
  56. package/lib/insecureTinyliciousTokenProvider.d.ts.map +0 -1
  57. package/lib/insecureTinyliciousTokenProvider.js.map +0 -1
  58. package/lib/insecureTinyliciousUrlResolver.d.ts.map +0 -1
  59. package/lib/insecureTinyliciousUrlResolver.js.map +0 -1
  60. package/tsconfig.esnext.json +0 -7
package/.eslintrc.js CHANGED
@@ -4,13 +4,11 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- "extends": [
8
- require.resolve("@fluidframework/eslint-config-fluid")
9
- ],
10
- "parserOptions": {
11
- "project": ["./tsconfig.json", "./src/test/tsconfig.json"]
12
- },
13
- "rules": {
14
- "@typescript-eslint/strict-boolean-expressions": "off"
15
- }
16
- }
7
+ extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
8
+ parserOptions: {
9
+ project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
+ },
11
+ rules: {
12
+ "@typescript-eslint/strict-boolean-expressions": "off",
13
+ },
14
+ };
package/.mocharc.js ADDED
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
9
+
10
+ const packageDir = __dirname;
11
+ const config = getFluidTestMochaConfig(packageDir);
12
+ module.exports = config;
package/CHANGELOG.md ADDED
@@ -0,0 +1,117 @@
1
+ # @fluidframework/tinylicious-driver
2
+
3
+ ## 2.0.0-internal.8.0.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.7.4.0
8
+
9
+ Dependency updates only.
10
+
11
+ ## 2.0.0-internal.7.3.0
12
+
13
+ Dependency updates only.
14
+
15
+ ## 2.0.0-internal.7.2.0
16
+
17
+ Dependency updates only.
18
+
19
+ ## 2.0.0-internal.7.1.0
20
+
21
+ Dependency updates only.
22
+
23
+ ## 2.0.0-internal.7.0.0
24
+
25
+ ### Major Changes
26
+
27
+ - Dependencies on @fluidframework/protocol-definitions package updated to 3.0.0 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
28
+
29
+ This included the following changes from the protocol-definitions release:
30
+
31
+ - Updating signal interfaces for some planned improvements. The intention is split the interface between signals
32
+ submitted by clients to the server and the resulting signals sent from the server to clients.
33
+ - A new optional type member is available on the ISignalMessage interface and a new ISentSignalMessage interface has
34
+ been added, which will be the typing for signals sent from the client to the server. Both extend a new
35
+ ISignalMessageBase interface that contains common members.
36
+ - The @fluidframework/common-definitions package dependency has been updated to version 1.0.0.
37
+
38
+ - Server upgrade: dependencies on Fluid server packages updated to 2.0.1 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
39
+
40
+ Dependencies on the following Fluid server package have been updated to version 2.0.1:
41
+
42
+ - @fluidframework/gitresources: 2.0.1
43
+ - @fluidframework/server-kafka-orderer: 2.0.1
44
+ - @fluidframework/server-lambdas: 2.0.1
45
+ - @fluidframework/server-lambdas-driver: 2.0.1
46
+ - @fluidframework/server-local-server: 2.0.1
47
+ - @fluidframework/server-memory-orderer: 2.0.1
48
+ - @fluidframework/protocol-base: 2.0.1
49
+ - @fluidframework/server-routerlicious: 2.0.1
50
+ - @fluidframework/server-routerlicious-base: 2.0.1
51
+ - @fluidframework/server-services: 2.0.1
52
+ - @fluidframework/server-services-client: 2.0.1
53
+ - @fluidframework/server-services-core: 2.0.1
54
+ - @fluidframework/server-services-ordering-kafkanode: 2.0.1
55
+ - @fluidframework/server-services-ordering-rdkafka: 2.0.1
56
+ - @fluidframework/server-services-ordering-zookeeper: 2.0.1
57
+ - @fluidframework/server-services-shared: 2.0.1
58
+ - @fluidframework/server-services-telemetry: 2.0.1
59
+ - @fluidframework/server-services-utils: 2.0.1
60
+ - @fluidframework/server-test-utils: 2.0.1
61
+ - tinylicious: 2.0.1
62
+
63
+ - Minimum TypeScript version now 5.1.6 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
64
+
65
+ The minimum supported TypeScript version for Fluid 2.0 clients is now 5.1.6.
66
+
67
+ ## 2.0.0-internal.6.4.0
68
+
69
+ Dependency updates only.
70
+
71
+ ## 2.0.0-internal.6.3.0
72
+
73
+ Dependency updates only.
74
+
75
+ ## 2.0.0-internal.6.2.0
76
+
77
+ Dependency updates only.
78
+
79
+ ## 2.0.0-internal.6.1.0
80
+
81
+ Dependency updates only.
82
+
83
+ ## 2.0.0-internal.6.0.0
84
+
85
+ ### Major Changes
86
+
87
+ - Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
88
+
89
+ Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
90
+
91
+ ## 2.0.0-internal.5.4.0
92
+
93
+ Dependency updates only.
94
+
95
+ ## 2.0.0-internal.5.3.0
96
+
97
+ Dependency updates only.
98
+
99
+ ## 2.0.0-internal.5.2.0
100
+
101
+ Dependency updates only.
102
+
103
+ ## 2.0.0-internal.5.1.0
104
+
105
+ Dependency updates only.
106
+
107
+ ## 2.0.0-internal.5.0.0
108
+
109
+ Dependency updates only.
110
+
111
+ ## 2.0.0-internal.4.4.0
112
+
113
+ Dependency updates only.
114
+
115
+ ## 2.0.0-internal.4.1.0
116
+
117
+ Dependency updates only.
package/README.md CHANGED
@@ -1 +1,70 @@
1
1
  # @fluidframework/tinylicious-driver
2
+
3
+ <!-- AUTO-GENERATED-CONTENT:START (LIBRARY_PACKAGE_README:scripts=FALSE) -->
4
+
5
+ <!-- prettier-ignore-start -->
6
+ <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
7
+
8
+ ## Using Fluid Framework libraries
9
+
10
+ When taking a dependency on a Fluid Framework library, we recommend using a `^` (caret) version range, such as `^1.3.4`.
11
+ While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
12
+ library consumers should always prefer `^`.
13
+
14
+ Note that when depending on a library version of the form `2.0.0-internal.x.y.z`, called the Fluid internal version scheme,
15
+ you must use a `>= <` dependency range (such as `>=2.0.0-internal.x.y.z <2.0.0-internal.w.0.0` where `w` is `x+1`).
16
+ Standard `^` and `~` ranges will not work as expected.
17
+ See the [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
18
+ package for more information including tools to convert between version schemes.
19
+
20
+ ## Installation
21
+
22
+ To get started, install the package by running the following command:
23
+
24
+ ```bash
25
+ npm i @fluidframework/tinylicious-driver
26
+ ```
27
+
28
+ ## API Documentation
29
+
30
+ API documentation for **@fluidframework/tinylicious-driver** is available at <https://fluidframework.com/docs/apis/tinylicious-driver>.
31
+
32
+ ## Contribution Guidelines
33
+
34
+ There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
35
+
36
+ - Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
37
+ - [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
38
+ - Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
39
+ - [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
40
+
41
+ Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
42
+
43
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
44
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
45
+
46
+ This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
47
+ Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
48
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
49
+
50
+ ## Help
51
+
52
+ Not finding what you're looking for in this README? Check out our [GitHub
53
+ Wiki](https://github.com/microsoft/FluidFramework/wiki) or [fluidframework.com](https://fluidframework.com/docs/).
54
+
55
+ Still not finding what you're looking for? Please [file an
56
+ issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
57
+
58
+ Thank you!
59
+
60
+ ## Trademark
61
+
62
+ This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
63
+
64
+ Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
65
+
66
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
67
+
68
+ <!-- prettier-ignore-end -->
69
+
70
+ <!-- AUTO-GENERATED-CONTENT:END -->
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "../../../common/build/build-common/api-extractor-lint.json"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "../../../common/build/build-common/api-extractor-base.json"
4
+ }
@@ -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
+ // @internal
15
+ export const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
16
+
17
+ // @internal
18
+ export const defaultTinyliciousEndpoint = "http://localhost";
19
+
20
+ // @internal
21
+ export const defaultTinyliciousPort = 7070;
22
+
23
+ // @internal
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
+ // @internal
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
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.InsecureTinyliciousUrlResolver = exports.defaultTinyliciousPort = exports.defaultTinyliciousEndpoint = exports.createTinyliciousCreateNewRequest = exports.InsecureTinyliciousTokenProvider = void 0;
8
+ var insecureTinyliciousTokenProvider_1 = require("./insecureTinyliciousTokenProvider.cjs");
9
+ Object.defineProperty(exports, "InsecureTinyliciousTokenProvider", { enumerable: true, get: function () { return insecureTinyliciousTokenProvider_1.InsecureTinyliciousTokenProvider; } });
10
+ var insecureTinyliciousUrlResolver_1 = require("./insecureTinyliciousUrlResolver.cjs");
11
+ Object.defineProperty(exports, "createTinyliciousCreateNewRequest", { enumerable: true, get: function () { return insecureTinyliciousUrlResolver_1.createTinyliciousCreateNewRequest; } });
12
+ Object.defineProperty(exports, "defaultTinyliciousEndpoint", { enumerable: true, get: function () { return insecureTinyliciousUrlResolver_1.defaultTinyliciousEndpoint; } });
13
+ Object.defineProperty(exports, "defaultTinyliciousPort", { enumerable: true, get: function () { return insecureTinyliciousUrlResolver_1.defaultTinyliciousPort; } });
14
+ Object.defineProperty(exports, "InsecureTinyliciousUrlResolver", { enumerable: true, get: function () { return insecureTinyliciousUrlResolver_1.InsecureTinyliciousUrlResolver; } });
15
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2FAAsF;AAA7E,oJAAA,gCAAgC,OAAA;AACzC,uFAK0C;AAJzC,mJAAA,iCAAiC,OAAA;AACjC,4IAAA,0BAA0B,OAAA;AAC1B,wIAAA,sBAAsB,OAAA;AACtB,gJAAA,8BAA8B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { InsecureTinyliciousTokenProvider } from \"./insecureTinyliciousTokenProvider\";\nexport {\n\tcreateTinyliciousCreateNewRequest,\n\tdefaultTinyliciousEndpoint,\n\tdefaultTinyliciousPort,\n\tInsecureTinyliciousUrlResolver,\n} from \"./insecureTinyliciousUrlResolver\";\n"]}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export * from "./insecureTinyliciousUrlResolver";
6
- export * from "./insecureTinyliciousTokenProvider";
5
+ export { InsecureTinyliciousTokenProvider } from "./insecureTinyliciousTokenProvider";
6
+ export { createTinyliciousCreateNewRequest, defaultTinyliciousEndpoint, defaultTinyliciousPort, InsecureTinyliciousUrlResolver, } from "./insecureTinyliciousUrlResolver";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EACN,iCAAiC,EACjC,0BAA0B,EAC1B,sBAAsB,EACtB,8BAA8B,GAC9B,MAAM,kCAAkC,CAAC"}
@@ -6,12 +6,12 @@
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
+ * @internal
15
15
  */
16
16
  class InsecureTinyliciousTokenProvider {
17
17
  constructor(
@@ -21,7 +21,7 @@ class InsecureTinyliciousTokenProvider {
21
21
  *
22
22
  * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
23
23
  *
24
- * @defaultValue - [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
24
+ * @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
25
25
  */
26
26
  scopes) {
27
27
  this.scopes = scopes;
@@ -39,17 +39,15 @@ class InsecureTinyliciousTokenProvider {
39
39
  };
40
40
  }
41
41
  getSignedToken(tenantId, documentId, lifetime = 60 * 60, ver = "1.0") {
42
- var _a;
42
+ const userId = (0, uuid_1.v4)();
43
+ const match = userId.match(/^([\da-f]{8})-([\da-f]{4})/);
44
+ const userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.
43
45
  // Current time in seconds
44
- const now = Math.round(new Date().getTime() / 1000);
45
- const user = { id: (0, uuid_1.v4)(), name: (0, server_services_client_1.getRandomName)() };
46
+ const now = Math.round(Date.now() / 1000);
47
+ const user = { id: userId, name: userName };
46
48
  const claims = {
47
- documentId: documentId !== null && documentId !== void 0 ? documentId : "",
48
- scopes: (_a = this.scopes) !== null && _a !== void 0 ? _a : [
49
- protocol_definitions_1.ScopeType.DocRead,
50
- protocol_definitions_1.ScopeType.DocWrite,
51
- protocol_definitions_1.ScopeType.SummaryWrite,
52
- ],
49
+ documentId: documentId ?? "",
50
+ scopes: this.scopes ?? [protocol_definitions_1.ScopeType.DocRead, protocol_definitions_1.ScopeType.DocWrite, protocol_definitions_1.ScopeType.SummaryWrite],
53
51
  tenantId,
54
52
  user,
55
53
  iat: now,
@@ -57,8 +55,11 @@ class InsecureTinyliciousTokenProvider {
57
55
  ver,
58
56
  };
59
57
  const utf8Key = { utf8: "12345" };
60
- return jsrsasign_1.KJUR.jws.JWS.sign(null, JSON.stringify({ alg: "HS256", typ: "JWT" }), claims, utf8Key);
58
+ return jsrsasign_1.KJUR.jws.JWS.sign(
59
+ // External API uses `null`
60
+ // eslint-disable-next-line unicorn/no-null
61
+ null, JSON.stringify({ alg: "HS256", typ: "JWT" }), claims, utf8Key);
61
62
  }
62
63
  }
63
64
  exports.InsecureTinyliciousTokenProvider = InsecureTinyliciousTokenProvider;
64
- //# sourceMappingURL=insecureTinyliciousTokenProvider.js.map
65
+ //# sourceMappingURL=insecureTinyliciousTokenProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insecureTinyliciousTokenProvider.cjs","sourceRoot":"","sources":["../src/insecureTinyliciousTokenProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAA+E;AAE/E,yCAA8C;AAC9C,+BAAkC;AAElC;;;;GAIG;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 * @internal\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"]}
@@ -7,6 +7,7 @@ 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
+ * @internal
10
11
  */
11
12
  export declare class InsecureTinyliciousTokenProvider implements ITokenProvider {
12
13
  /**
@@ -15,7 +16,7 @@ export declare class InsecureTinyliciousTokenProvider implements ITokenProvider
15
16
  *
16
17
  * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
17
18
  *
18
- * @defaultValue - [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
19
+ * @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
19
20
  */
20
21
  private readonly scopes?;
21
22
  constructor(
@@ -25,7 +26,7 @@ export declare class InsecureTinyliciousTokenProvider implements ITokenProvider
25
26
  *
26
27
  * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}
27
28
  *
28
- * @defaultValue - [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
29
+ * @defaultValue [ ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite ]
29
30
  */
30
31
  scopes?: ScopeType[] | undefined);
31
32
  fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse>;
@@ -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,EACH,cAAc,EACd,cAAc,EACjB,MAAM,sCAAsC,CAAC;AAK9C;;;GAGG;AACH,qBAAa,gCAAiC,YAAW,cAAc;IAE/D;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;;IARxB;;;;;;;OAOG;IACc,MAAM,CAAC,yBAAa;IAG5B,iBAAiB,CAC1B,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,cAAc,CAAC;IAOb,iBAAiB,CAC1B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,CAAC;IAO1B,OAAO,CAAC,cAAc;CAgCzB"}
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;;;;GAIG;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"}
@@ -8,10 +8,12 @@ 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
+ * @internal
11
12
  */
12
13
  exports.defaultTinyliciousPort = 7070;
13
14
  /**
14
15
  * Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
16
+ * @internal
15
17
  */
16
18
  exports.defaultTinyliciousEndpoint = "http://localhost";
17
19
  /**
@@ -19,6 +21,7 @@ exports.defaultTinyliciousEndpoint = "http://localhost";
19
21
  * for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
20
22
  * URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
21
23
  * documentId/containerRelativePathing
24
+ * @internal
22
25
  */
23
26
  class InsecureTinyliciousUrlResolver {
24
27
  constructor(port = exports.defaultTinyliciousPort, endpoint = exports.defaultTinyliciousEndpoint) {
@@ -26,49 +29,40 @@ class InsecureTinyliciousUrlResolver {
26
29
  this.fluidProtocolEndpoint = this.tinyliciousEndpoint.replace(/(^\w+:|^)\/\//, "fluid://");
27
30
  }
28
31
  async resolve(request) {
29
- var _a;
30
- // determine whether the request is for creating of a new container.
31
- // such request has the `createNew` header set to true and doesn't have a container ID.
32
+ const relativeUrl = request.url.replace(`${this.tinyliciousEndpoint}/`, "");
33
+ const documentIdFromRequest = relativeUrl.split("/")[0];
34
+ let deltaStorageUrl;
35
+ let documentUrl;
36
+ let finalDocumentId = documentIdFromRequest;
37
+ // Special handling if the request is to create a new container
32
38
  if (request.headers && request.headers[driver_definitions_1.DriverHeader.createNew] === true) {
33
- // honor the document ID passed by the application via the create request
34
- // otherwise use the reserved keyword to let the driver generate the ID.
39
+ // Use the document ID passed by the application via the create request;
40
+ // if none was passed, use the reserved keyword to let the driver generate the ID.
35
41
  // TODO: deprecate this capability for tinylicious as the r11s driver will stop using the document ID
36
42
  // in create requests.
37
- const newDocumentId = (_a = request.url) !== null && _a !== void 0 ? _a : "new";
38
- return {
39
- endpoints: {
40
- deltaStorageUrl: `${this.tinyliciousEndpoint}/deltas/tinylicious/${newDocumentId}`,
41
- ordererUrl: this.tinyliciousEndpoint,
42
- storageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,
43
- },
44
- // id is a mandatory attribute, but it's ignored by the driver for new container requests.
45
- id: request.url,
46
- // tokens attribute is redundant as all tokens are generated via ITokenProvider
47
- tokens: {},
48
- type: "fluid",
49
- url: `${this.fluidProtocolEndpoint}/tinylicious/${newDocumentId}`,
50
- };
43
+ if (finalDocumentId === "") {
44
+ finalDocumentId = "new";
45
+ }
46
+ deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${finalDocumentId}`;
47
+ documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${finalDocumentId}`;
51
48
  }
52
- // for an existing container we'll parse the request URL to determine the document ID.
53
- const url = request.url.replace(`${this.tinyliciousEndpoint}/`, "");
54
- const documentId = url.split("/")[0];
55
- const encodedDocId = encodeURIComponent(documentId);
56
- const documentRelativePath = url.slice(documentId.length);
57
- const documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;
58
- const deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;
59
- const storageUrl = `${this.tinyliciousEndpoint}/repos/tinylicious`;
60
- const response = {
49
+ else {
50
+ const encodedDocId = encodeURIComponent(finalDocumentId);
51
+ const documentRelativePath = relativeUrl.slice(documentIdFromRequest.length);
52
+ documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;
53
+ deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;
54
+ }
55
+ return {
61
56
  endpoints: {
62
57
  deltaStorageUrl,
63
58
  ordererUrl: this.tinyliciousEndpoint,
64
- storageUrl,
59
+ storageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,
65
60
  },
66
- id: documentId,
61
+ id: finalDocumentId,
67
62
  tokens: {},
68
63
  type: "fluid",
69
64
  url: documentUrl,
70
65
  };
71
- return response;
72
66
  }
73
67
  async getAbsoluteUrl(resolvedUrl, relativeUrl) {
74
68
  const documentId = decodeURIComponent(resolvedUrl.url.replace(`${this.fluidProtocolEndpoint}/tinylicious/`, ""));
@@ -82,11 +76,15 @@ class InsecureTinyliciousUrlResolver {
82
76
  }
83
77
  }
84
78
  exports.InsecureTinyliciousUrlResolver = InsecureTinyliciousUrlResolver;
79
+ /**
80
+ * Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
81
+ * @internal
82
+ */
85
83
  const createTinyliciousCreateNewRequest = (documentId) => ({
86
- url: documentId !== null && documentId !== void 0 ? documentId : "",
84
+ url: documentId ?? "",
87
85
  headers: {
88
86
  [driver_definitions_1.DriverHeader.createNew]: true,
89
87
  },
90
88
  });
91
89
  exports.createTinyliciousCreateNewRequest = createTinyliciousCreateNewRequest;
92
- //# sourceMappingURL=insecureTinyliciousUrlResolver.js.map
90
+ //# sourceMappingURL=insecureTinyliciousUrlResolver.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insecureTinyliciousUrlResolver.cjs","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAA8F;AAE9F;;;GAGG;AACU,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;GAGG;AACU,QAAA,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D;;;;;;GAMG;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;;;GAGG;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 * @internal\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 * @internal\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 * @internal\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 * @internal\n */\nexport const createTinyliciousCreateNewRequest = (documentId?: string): IRequest => ({\n\turl: documentId ?? \"\",\n\theaders: {\n\t\t[DriverHeader.createNew]: true,\n\t},\n});\n"]}
@@ -3,13 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IRequest } from "@fluidframework/core-interfaces";
6
- import { IFluidResolvedUrl, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
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
+ * @internal
9
10
  */
10
11
  export declare const defaultTinyliciousPort = 7070;
11
12
  /**
12
13
  * Default endpoint URL base. Will be used by the service if the consumer does not specify an endpoint.
14
+ * @internal
13
15
  */
14
16
  export declare const defaultTinyliciousEndpoint = "http://localhost";
15
17
  /**
@@ -17,13 +19,18 @@ export declare const defaultTinyliciousEndpoint = "http://localhost";
17
19
  * for a given request. This particular implementation has a goal to avoid imposing requirements on the app's
18
20
  * URL shape, so it expects the request url to have this format (as opposed to a more traditional URL):
19
21
  * documentId/containerRelativePathing
22
+ * @internal
20
23
  */
21
24
  export declare class InsecureTinyliciousUrlResolver implements IUrlResolver {
22
25
  private readonly fluidProtocolEndpoint;
23
26
  private readonly tinyliciousEndpoint;
24
27
  constructor(port?: number, endpoint?: string);
25
28
  resolve(request: IRequest): Promise<IResolvedUrl>;
26
- getAbsoluteUrl(resolvedUrl: IFluidResolvedUrl, relativeUrl: string): Promise<string>;
29
+ getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
27
30
  }
28
- export declare const createTinyliciousCreateNewRequest: (documentId?: string | undefined) => IRequest;
31
+ /**
32
+ * Creates a Routerlicious {@link @fluidframework/core-interfaces#IRequest}.
33
+ * @internal
34
+ */
35
+ export declare const createTinyliciousCreateNewRequest: (documentId?: string) => IRequest;
29
36
  //# 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,EAEH,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACf,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;GAKG;AACH,qBAAa,8BAA+B,YAAW,YAAY;IAC/D,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;gBAEzC,IAAI,SAAyB,EAC7B,QAAQ,SAA6B;IAM5B,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAkDjD,cAAc,CAAC,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAYpG;AAED,eAAO,MAAM,iCAAiC,uCACnB,QAOtB,CAAC"}
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;;;GAGG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;;GAMG;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;;;GAGG;AACH,eAAO,MAAM,iCAAiC,gBAAiB,MAAM,KAAG,QAKtE,CAAC"}
@@ -0,0 +1,18 @@
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
+ /* Excluded from this release type: createTinyliciousCreateNewRequest */
9
+
10
+ /* Excluded from this release type: defaultTinyliciousEndpoint */
11
+
12
+ /* Excluded from this release type: defaultTinyliciousPort */
13
+
14
+ /* Excluded from this release type: InsecureTinyliciousTokenProvider */
15
+
16
+ /* Excluded from this release type: InsecureTinyliciousUrlResolver */
17
+
18
+ export { }
@@ -0,0 +1,22 @@
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
+ /* Excluded from this release type: createTinyliciousCreateNewRequest */
9
+
10
+ /* Excluded from this release type: defaultTinyliciousEndpoint */
11
+
12
+ /* Excluded from this release type: defaultTinyliciousPort */
13
+
14
+ /* Excluded from this release type: InsecureTinyliciousTokenProvider */
15
+
16
+ /* Excluded from this release type: InsecureTinyliciousUrlResolver */
17
+
18
+ /* Excluded from this release type: IResolvedUrl */
19
+
20
+ /* Excluded from this release type: IUrlResolver */
21
+
22
+ export { }