@fluidframework/tinylicious-driver 2.0.0-internal.6.2.0 → 2.0.0-internal.6.3.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/.mocharc.js +12 -0
- package/CHANGELOG.md +4 -0
- package/api-extractor.json +4 -0
- package/dist/insecureTinyliciousUrlResolver.d.ts.map +1 -1
- package/dist/insecureTinyliciousUrlResolver.js +22 -30
- package/dist/insecureTinyliciousUrlResolver.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/insecureTinyliciousUrlResolver.d.ts.map +1 -1
- package/lib/insecureTinyliciousUrlResolver.js +22 -30
- package/lib/insecureTinyliciousUrlResolver.js.map +1 -1
- package/package.json +15 -12
- package/src/insecureTinyliciousUrlResolver.ts +23 -31
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
CHANGED
|
@@ -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;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;GAKG;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;
|
|
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;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;GAKG;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,eAAO,MAAM,iCAAiC,uCAA0B,QAKtE,CAAC"}
|
|
@@ -26,48 +26,40 @@ class InsecureTinyliciousUrlResolver {
|
|
|
26
26
|
this.fluidProtocolEndpoint = this.tinyliciousEndpoint.replace(/(^\w+:|^)\/\//, "fluid://");
|
|
27
27
|
}
|
|
28
28
|
async resolve(request) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const relativeUrl = request.url.replace(`${this.tinyliciousEndpoint}/`, "");
|
|
30
|
+
const documentIdFromRequest = relativeUrl.split("/")[0];
|
|
31
|
+
let deltaStorageUrl;
|
|
32
|
+
let documentUrl;
|
|
33
|
+
let finalDocumentId = documentIdFromRequest;
|
|
34
|
+
// Special handling if the request is to create a new container
|
|
31
35
|
if (request.headers && request.headers[driver_definitions_1.DriverHeader.createNew] === true) {
|
|
32
|
-
//
|
|
33
|
-
//
|
|
36
|
+
// Use the document ID passed by the application via the create request;
|
|
37
|
+
// if none was passed, use the reserved keyword to let the driver generate the ID.
|
|
34
38
|
// TODO: deprecate this capability for tinylicious as the r11s driver will stop using the document ID
|
|
35
39
|
// in create requests.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
storageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,
|
|
42
|
-
},
|
|
43
|
-
// id is a mandatory attribute, but it's ignored by the driver for new container requests.
|
|
44
|
-
id: request.url,
|
|
45
|
-
// tokens attribute is redundant as all tokens are generated via ITokenProvider
|
|
46
|
-
tokens: {},
|
|
47
|
-
type: "fluid",
|
|
48
|
-
url: `${this.fluidProtocolEndpoint}/tinylicious/${newDocumentId}`,
|
|
49
|
-
};
|
|
40
|
+
if (finalDocumentId === "") {
|
|
41
|
+
finalDocumentId = "new";
|
|
42
|
+
}
|
|
43
|
+
deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${finalDocumentId}`;
|
|
44
|
+
documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${finalDocumentId}`;
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const storageUrl = `${this.tinyliciousEndpoint}/repos/tinylicious`;
|
|
59
|
-
const response = {
|
|
46
|
+
else {
|
|
47
|
+
const encodedDocId = encodeURIComponent(finalDocumentId);
|
|
48
|
+
const documentRelativePath = relativeUrl.slice(documentIdFromRequest.length);
|
|
49
|
+
documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;
|
|
50
|
+
deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
60
53
|
endpoints: {
|
|
61
54
|
deltaStorageUrl,
|
|
62
55
|
ordererUrl: this.tinyliciousEndpoint,
|
|
63
|
-
storageUrl
|
|
56
|
+
storageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,
|
|
64
57
|
},
|
|
65
|
-
id:
|
|
58
|
+
id: finalDocumentId,
|
|
66
59
|
tokens: {},
|
|
67
60
|
type: "fluid",
|
|
68
61
|
url: documentUrl,
|
|
69
62
|
};
|
|
70
|
-
return response;
|
|
71
63
|
}
|
|
72
64
|
async getAbsoluteUrl(resolvedUrl, relativeUrl) {
|
|
73
65
|
const documentId = decodeURIComponent(resolvedUrl.url.replace(`${this.fluidProtocolEndpoint}/tinylicious/`, ""));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousUrlResolver.js","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAA8F;AAE9F;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;GAEG;AACU,QAAA,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D;;;;;GAKG;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;QACr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B,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;AAEM,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 */\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 */\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 */\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\nexport const createTinyliciousCreateNewRequest = (documentId?: string): IRequest => ({\n\turl: documentId ?? \"\",\n\theaders: {\n\t\t[DriverHeader.createNew]: true,\n\t},\n});\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.34.9"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -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;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;GAKG;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;
|
|
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;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;GAKG;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,eAAO,MAAM,iCAAiC,uCAA0B,QAKtE,CAAC"}
|
|
@@ -23,48 +23,40 @@ export class InsecureTinyliciousUrlResolver {
|
|
|
23
23
|
this.fluidProtocolEndpoint = this.tinyliciousEndpoint.replace(/(^\w+:|^)\/\//, "fluid://");
|
|
24
24
|
}
|
|
25
25
|
async resolve(request) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const relativeUrl = request.url.replace(`${this.tinyliciousEndpoint}/`, "");
|
|
27
|
+
const documentIdFromRequest = relativeUrl.split("/")[0];
|
|
28
|
+
let deltaStorageUrl;
|
|
29
|
+
let documentUrl;
|
|
30
|
+
let finalDocumentId = documentIdFromRequest;
|
|
31
|
+
// Special handling if the request is to create a new container
|
|
28
32
|
if (request.headers && request.headers[DriverHeader.createNew] === true) {
|
|
29
|
-
//
|
|
30
|
-
//
|
|
33
|
+
// Use the document ID passed by the application via the create request;
|
|
34
|
+
// if none was passed, use the reserved keyword to let the driver generate the ID.
|
|
31
35
|
// TODO: deprecate this capability for tinylicious as the r11s driver will stop using the document ID
|
|
32
36
|
// in create requests.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
storageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,
|
|
39
|
-
},
|
|
40
|
-
// id is a mandatory attribute, but it's ignored by the driver for new container requests.
|
|
41
|
-
id: request.url,
|
|
42
|
-
// tokens attribute is redundant as all tokens are generated via ITokenProvider
|
|
43
|
-
tokens: {},
|
|
44
|
-
type: "fluid",
|
|
45
|
-
url: `${this.fluidProtocolEndpoint}/tinylicious/${newDocumentId}`,
|
|
46
|
-
};
|
|
37
|
+
if (finalDocumentId === "") {
|
|
38
|
+
finalDocumentId = "new";
|
|
39
|
+
}
|
|
40
|
+
deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${finalDocumentId}`;
|
|
41
|
+
documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${finalDocumentId}`;
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const storageUrl = `${this.tinyliciousEndpoint}/repos/tinylicious`;
|
|
56
|
-
const response = {
|
|
43
|
+
else {
|
|
44
|
+
const encodedDocId = encodeURIComponent(finalDocumentId);
|
|
45
|
+
const documentRelativePath = relativeUrl.slice(documentIdFromRequest.length);
|
|
46
|
+
documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;
|
|
47
|
+
deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
57
50
|
endpoints: {
|
|
58
51
|
deltaStorageUrl,
|
|
59
52
|
ordererUrl: this.tinyliciousEndpoint,
|
|
60
|
-
storageUrl
|
|
53
|
+
storageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,
|
|
61
54
|
},
|
|
62
|
-
id:
|
|
55
|
+
id: finalDocumentId,
|
|
63
56
|
tokens: {},
|
|
64
57
|
type: "fluid",
|
|
65
58
|
url: documentUrl,
|
|
66
59
|
};
|
|
67
|
-
return response;
|
|
68
60
|
}
|
|
69
61
|
async getAbsoluteUrl(resolvedUrl, relativeUrl) {
|
|
70
62
|
const documentId = decodeURIComponent(resolvedUrl.url.replace(`${this.fluidProtocolEndpoint}/tinylicious/`, ""));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureTinyliciousUrlResolver.js","sourceRoot":"","sources":["../src/insecureTinyliciousUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAA8B,MAA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,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,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 */\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 */\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 */\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\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.6.
|
|
3
|
+
"version": "2.0.0-internal.6.3.0",
|
|
4
4
|
"description": "Driver for tinylicious",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,28 +14,29 @@
|
|
|
14
14
|
"module": "lib/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.
|
|
18
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.6.
|
|
19
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.6.
|
|
17
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
|
|
18
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
|
|
19
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
|
|
20
20
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
21
|
-
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.6.
|
|
22
|
-
"@fluidframework/server-services-client": "^1.0.
|
|
21
|
+
"@fluidframework/routerlicious-driver": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
|
|
22
|
+
"@fluidframework/server-services-client": "^1.0.1",
|
|
23
23
|
"jsrsasign": "^10.5.25",
|
|
24
24
|
"uuid": "^9.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@fluid-tools/build-cli": "^0.
|
|
27
|
+
"@fluid-tools/build-cli": "^0.22.0",
|
|
28
28
|
"@fluidframework/build-common": "^2.0.0",
|
|
29
|
-
"@fluidframework/build-tools": "^0.
|
|
29
|
+
"@fluidframework/build-tools": "^0.22.0",
|
|
30
30
|
"@fluidframework/eslint-config-fluid": "^2.1.0",
|
|
31
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.
|
|
31
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
|
|
32
32
|
"@fluidframework/test-tools": "^0.2.158186",
|
|
33
33
|
"@fluidframework/tinylicious-driver-previous": "npm:@fluidframework/tinylicious-driver@2.0.0-internal.6.1.1",
|
|
34
|
+
"@microsoft/api-extractor": "^7.34.4",
|
|
34
35
|
"@types/jsrsasign": "^8.0.8",
|
|
35
36
|
"@types/mocha": "^9.1.1",
|
|
36
37
|
"@types/node": "^16.18.38",
|
|
37
38
|
"@types/uuid": "^9.0.2",
|
|
38
|
-
"
|
|
39
|
+
"copyfiles": "^2.4.1",
|
|
39
40
|
"cross-env": "^7.0.3",
|
|
40
41
|
"eslint": "~8.6.0",
|
|
41
42
|
"mocha": "^10.2.0",
|
|
@@ -50,9 +51,11 @@
|
|
|
50
51
|
"build": "fluid-build . --task build",
|
|
51
52
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
52
53
|
"build:compile": "fluid-build . --task compile",
|
|
54
|
+
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
53
55
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
54
56
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
55
|
-
"
|
|
57
|
+
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
58
|
+
"clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp' 'nyc'",
|
|
56
59
|
"eslint": "eslint --format stylish src",
|
|
57
60
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
58
61
|
"format": "npm run prettier:fix",
|
|
@@ -61,7 +64,7 @@
|
|
|
61
64
|
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
62
65
|
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
63
66
|
"test": "npm run test:mocha",
|
|
64
|
-
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup
|
|
67
|
+
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
|
|
65
68
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
66
69
|
"tsc": "tsc",
|
|
67
70
|
"typetests:gen": "fluid-type-test-generator",
|
|
@@ -31,50 +31,42 @@ export class InsecureTinyliciousUrlResolver implements IUrlResolver {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
public async resolve(request: IRequest): Promise<IResolvedUrl> {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const relativeUrl = request.url.replace(`${this.tinyliciousEndpoint}/`, "");
|
|
35
|
+
const documentIdFromRequest = relativeUrl.split("/")[0];
|
|
36
|
+
|
|
37
|
+
let deltaStorageUrl: string;
|
|
38
|
+
let documentUrl: string;
|
|
39
|
+
let finalDocumentId: string = documentIdFromRequest;
|
|
40
|
+
|
|
41
|
+
// Special handling if the request is to create a new container
|
|
36
42
|
if (request.headers && request.headers[DriverHeader.createNew] === true) {
|
|
37
|
-
//
|
|
38
|
-
//
|
|
43
|
+
// Use the document ID passed by the application via the create request;
|
|
44
|
+
// if none was passed, use the reserved keyword to let the driver generate the ID.
|
|
39
45
|
// TODO: deprecate this capability for tinylicious as the r11s driver will stop using the document ID
|
|
40
46
|
// in create requests.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
tokens: {},
|
|
52
|
-
type: "fluid",
|
|
53
|
-
url: `${this.fluidProtocolEndpoint}/tinylicious/${newDocumentId}`,
|
|
54
|
-
};
|
|
47
|
+
if (finalDocumentId === "") {
|
|
48
|
+
finalDocumentId = "new";
|
|
49
|
+
}
|
|
50
|
+
deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${finalDocumentId}`;
|
|
51
|
+
documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${finalDocumentId}`;
|
|
52
|
+
} else {
|
|
53
|
+
const encodedDocId = encodeURIComponent(finalDocumentId);
|
|
54
|
+
const documentRelativePath = relativeUrl.slice(documentIdFromRequest.length);
|
|
55
|
+
documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;
|
|
56
|
+
deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;
|
|
55
57
|
}
|
|
56
|
-
// for an existing container we'll parse the request URL to determine the document ID.
|
|
57
|
-
const url = request.url.replace(`${this.tinyliciousEndpoint}/`, "");
|
|
58
|
-
const documentId = url.split("/")[0];
|
|
59
|
-
const encodedDocId = encodeURIComponent(documentId);
|
|
60
|
-
const documentRelativePath = url.slice(documentId.length);
|
|
61
|
-
|
|
62
|
-
const documentUrl = `${this.fluidProtocolEndpoint}/tinylicious/${encodedDocId}${documentRelativePath}`;
|
|
63
|
-
const deltaStorageUrl = `${this.tinyliciousEndpoint}/deltas/tinylicious/${encodedDocId}`;
|
|
64
|
-
const storageUrl = `${this.tinyliciousEndpoint}/repos/tinylicious`;
|
|
65
58
|
|
|
66
|
-
|
|
59
|
+
return {
|
|
67
60
|
endpoints: {
|
|
68
61
|
deltaStorageUrl,
|
|
69
62
|
ordererUrl: this.tinyliciousEndpoint,
|
|
70
|
-
storageUrl
|
|
63
|
+
storageUrl: `${this.tinyliciousEndpoint}/repos/tinylicious`,
|
|
71
64
|
},
|
|
72
|
-
id:
|
|
65
|
+
id: finalDocumentId,
|
|
73
66
|
tokens: {},
|
|
74
67
|
type: "fluid",
|
|
75
68
|
url: documentUrl,
|
|
76
69
|
};
|
|
77
|
-
return response;
|
|
78
70
|
}
|
|
79
71
|
|
|
80
72
|
public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
|