@fluidframework/routerlicious-urlresolver 2.0.0-dev-rc.2.0.0.245554 → 2.0.0-dev-rc.3.0.0.250606

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.
@@ -1 +1 @@
1
- {"version":3,"file":"urlResolver.d.ts","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQvC;;GAEG;AACH,qBAAa,wBAAyB,YAAW,YAAY;IAE3D,OAAO,CAAC,QAAQ,CAAC,MAAM;IAGvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAJP,MAAM,EACpB;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAC5D,SAAS,EACK,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAC/B,OAAO,EAAE,MAAM;IAGjC;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA8G7D,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAgB5F;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,KAAK;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EA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E,EAAE,GAAG,EAAE,KAAK,EAAE;YACtB,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,QAAQ;SACb,CAAC;QACF,OAAO,QAAQ,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,WAAyB,EAAE,WAAmB;QACzE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAA,mBAAM,EAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAClE,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/D,IAAA,mBAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACzD,IAAA,mBAAM,EAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAE7D,IAAI,GAAG,GAAG,WAAW,CAAC;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACpB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAC3E,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;CACD;AA1ID,4DA0IC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IUser } from \"@fluidframework/protocol-definitions\";\nimport { Provider } from \"./nconf.cjs\";\n\nconst r11sServers = [\n\t\"www.wu2-ppe.prague.office-int.com\",\n\t\"www.wu2.prague.office-int.com\",\n\t\"www.eu.prague.office-int.com\",\n];\n\n/**\n * @internal\n */\nexport class RouterliciousUrlResolver implements IUrlResolver {\n\tconstructor(\n\t\tprivate readonly config:\n\t\t\t| { provider: Provider; tenantId: string; documentId: string }\n\t\t\t| undefined,\n\t\tprivate readonly getToken: () => Promise<string>,\n\t\tprivate readonly hostUrl: string,\n\t) {}\n\n\t/**\n\t * Handles a request and returns the relevant endpoints for the environment\n\t */\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tlet requestedUrl = request.url;\n\n\t\t// If we know the original hostname, reinsert it\n\t\tif (this.config && request.url.startsWith(\"/\")) {\n\t\t\trequestedUrl = `http://dummy:3000${request.url}`;\n\t\t}\n\n\t\tconst reqUrl = new URL(requestedUrl);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\n\t\t// If we don't have a valid server or a prescriptive config, we cannot resolve the URL\n\t\tif (\n\t\t\t!(\n\t\t\t\tr11sServers.includes(server) ||\n\t\t\t\t(server === \"localhost\" && reqUrl.port === \"3000\") ||\n\t\t\t\tthis.config\n\t\t\t)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = reqUrl.pathname.split(\"/\");\n\t\tlet tenantId: string;\n\t\tlet documentId: string;\n\t\tlet provider: Provider | undefined;\n\t\tif (this.config) {\n\t\t\ttenantId = this.config.tenantId;\n\t\t\tdocumentId = this.config.documentId;\n\t\t\tprovider = this.config.provider;\n\t\t} else if (path.length >= 4) {\n\t\t\ttenantId = path[2];\n\t\t\tdocumentId = path[3];\n\t\t} else {\n\t\t\ttenantId = \"fluid\";\n\t\t\tdocumentId = path[2];\n\t\t}\n\n\t\tconst token = await this.getToken();\n\n\t\tconst isLocalHost = server === \"localhost\";\n\t\tconst isInternalRequest = server.includes(\"gateway\"); // e.g. gateway:3000 || fierce-dog-gateway:3000\n\n\t\tconst serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);\n\n\t\tlet fluidUrl =\n\t\t\t\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config\n\t\t\t\t\t? new URL(this.config.provider.get(\"worker:serverUrl\")).host\n\t\t\t\t\t: serverSuffix\n\t\t\t}/` +\n\t\t\t`${encodeURIComponent(tenantId)}/` +\n\t\t\t`${encodeURIComponent(documentId)}`;\n\n\t\t// In case of any additional parameters add them back to the url\n\t\tif (reqUrl.search) {\n\t\t\tconst searchParams = reqUrl.search;\n\t\t\tif (searchParams) {\n\t\t\t\tfluidUrl += searchParams;\n\t\t\t}\n\t\t}\n\n\t\tlet storageUrl = \"\";\n\t\tlet ordererUrl = \"\";\n\t\tlet deltaStorageUrl = \"\";\n\n\t\t// There is no provider when using debugging tooling\n\t\tif (provider && isInternalRequest) {\n\t\t\tstorageUrl = provider.get(\"worker:internalBlobStorageUrl\");\n\t\t\tordererUrl = provider.get(\"worker:alfredUrl\");\n\t\t\tdeltaStorageUrl = `${provider.get(\"worker:alfredUrl\")}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (provider) {\n\t\t\tstorageUrl = provider\n\t\t\t\t.get(\"worker:blobStorageUrl\")\n\t\t\t\t.replace(\"historian:3000\", \"localhost:3001\");\n\t\t\tordererUrl = provider.get(\"worker:serverUrl\");\n\t\t\tdeltaStorageUrl = `${ordererUrl}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (isLocalHost) {\n\t\t\tstorageUrl = `http://localhost:3001`;\n\t\t\tordererUrl = `http://localhost:3003`;\n\t\t\tdeltaStorageUrl = `http://localhost:3003/deltas/${tenantId}/${documentId}`;\n\t\t} else {\n\t\t\tstorageUrl = `https://historian.${serverSuffix}`;\n\t\t\tordererUrl = `https://alfred.${serverSuffix}`;\n\t\t\tdeltaStorageUrl = `https://alfred.${serverSuffix}/deltas/${tenantId}/${documentId}`;\n\t\t}\n\n\t\tstorageUrl += `/repos/${tenantId}`;\n\t\tordererUrl += ``;\n\t\tdeltaStorageUrl += ``;\n\n\t\tconst resolved: IResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tstorageUrl,\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: { jwt: token },\n\t\t\ttype: \"fluid\",\n\t\t\turl: fluidUrl,\n\t\t};\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tassert(!!parsedUrl.pathname, 0x0b9 /* \"PathName should exist\" */);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tassert(!!tenantId, 0x0ba /* \"Tenant id should exist\" */);\n\t\tassert(!!documentId, 0x0bb /* \"Document id should exist\" */);\n\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\n\t\treturn `${this.hostUrl}/${encodeURIComponent(tenantId)}/${encodeURIComponent(\n\t\t\tdocumentId,\n\t\t)}/${url}`;\n\t}\n}\n\n/**\n * @internal\n */\nexport interface IAlfredUser extends IUser {\n\tdisplayName: string;\n\tname: string;\n}\n\n/**\n * @internal\n */\nexport interface IConfig {\n\tserverUrl: string;\n\tblobStorageUrl: string;\n\ttenantId: string;\n\tdocumentId: string;\n}\n"]}
1
+ {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAAoD;AAKpD,MAAM,WAAW,GAAG;IACnB,mCAAmC;IACnC,+BAA+B;IAC/B,8BAA8B;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAa,wBAAwB;IACpC,YACkB,MAEL,EACK,QAA+B,EAC/B,OAAe;QAJf,WAAM,GAAN,MAAM,CAEX;QACK,aAAQ,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AAK,CAAC,6BAA6B,CAAC,CAAC;QAClE,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/D,IAAA,mBAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACzD,IAAA,mBAAM,EAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAE7D,IAAI,GAAG,GAAG,WAAW,CAAC;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACpB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAC3E,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;CACD;AA1ID,4DA0IC","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 { assert } from \"@fluidframework/core-utils\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IUser } from \"@fluidframework/protocol-definitions\";\nimport { Provider } from \"./nconf.cjs\";\n\nconst r11sServers = [\n\t\"www.wu2-ppe.prague.office-int.com\",\n\t\"www.wu2.prague.office-int.com\",\n\t\"www.eu.prague.office-int.com\",\n];\n\n/**\n * @internal\n */\nexport class RouterliciousUrlResolver implements IUrlResolver {\n\tconstructor(\n\t\tprivate readonly config:\n\t\t\t| { provider: Provider; tenantId: string; documentId: string }\n\t\t\t| undefined,\n\t\tprivate readonly getToken: () => Promise<string>,\n\t\tprivate readonly hostUrl: string,\n\t) {}\n\n\t/**\n\t * Handles a request and returns the relevant endpoints for the environment\n\t */\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tlet requestedUrl = request.url;\n\n\t\t// If we know the original hostname, reinsert it\n\t\tif (this.config && request.url.startsWith(\"/\")) {\n\t\t\trequestedUrl = `http://dummy:3000${request.url}`;\n\t\t}\n\n\t\tconst reqUrl = new URL(requestedUrl);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\n\t\t// If we don't have a valid server or a prescriptive config, we cannot resolve the URL\n\t\tif (\n\t\t\t!(\n\t\t\t\tr11sServers.includes(server) ||\n\t\t\t\t(server === \"localhost\" && reqUrl.port === \"3000\") ||\n\t\t\t\tthis.config\n\t\t\t)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = reqUrl.pathname.split(\"/\");\n\t\tlet tenantId: string;\n\t\tlet documentId: string;\n\t\tlet provider: Provider | undefined;\n\t\tif (this.config) {\n\t\t\ttenantId = this.config.tenantId;\n\t\t\tdocumentId = this.config.documentId;\n\t\t\tprovider = this.config.provider;\n\t\t} else if (path.length >= 4) {\n\t\t\ttenantId = path[2];\n\t\t\tdocumentId = path[3];\n\t\t} else {\n\t\t\ttenantId = \"fluid\";\n\t\t\tdocumentId = path[2];\n\t\t}\n\n\t\tconst token = await this.getToken();\n\n\t\tconst isLocalHost = server === \"localhost\";\n\t\tconst isInternalRequest = server.includes(\"gateway\"); // e.g. gateway:3000 || fierce-dog-gateway:3000\n\n\t\tconst serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);\n\n\t\tlet fluidUrl =\n\t\t\t\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config\n\t\t\t\t\t? new URL(this.config.provider.get(\"worker:serverUrl\")).host\n\t\t\t\t\t: serverSuffix\n\t\t\t}/` +\n\t\t\t`${encodeURIComponent(tenantId)}/` +\n\t\t\t`${encodeURIComponent(documentId)}`;\n\n\t\t// In case of any additional parameters add them back to the url\n\t\tif (reqUrl.search) {\n\t\t\tconst searchParams = reqUrl.search;\n\t\t\tif (searchParams) {\n\t\t\t\tfluidUrl += searchParams;\n\t\t\t}\n\t\t}\n\n\t\tlet storageUrl = \"\";\n\t\tlet ordererUrl = \"\";\n\t\tlet deltaStorageUrl = \"\";\n\n\t\t// There is no provider when using debugging tooling\n\t\tif (provider && isInternalRequest) {\n\t\t\tstorageUrl = provider.get(\"worker:internalBlobStorageUrl\");\n\t\t\tordererUrl = provider.get(\"worker:alfredUrl\");\n\t\t\tdeltaStorageUrl = `${provider.get(\"worker:alfredUrl\")}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (provider) {\n\t\t\tstorageUrl = provider\n\t\t\t\t.get(\"worker:blobStorageUrl\")\n\t\t\t\t.replace(\"historian:3000\", \"localhost:3001\");\n\t\t\tordererUrl = provider.get(\"worker:serverUrl\");\n\t\t\tdeltaStorageUrl = `${ordererUrl}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (isLocalHost) {\n\t\t\tstorageUrl = `http://localhost:3001`;\n\t\t\tordererUrl = `http://localhost:3003`;\n\t\t\tdeltaStorageUrl = `http://localhost:3003/deltas/${tenantId}/${documentId}`;\n\t\t} else {\n\t\t\tstorageUrl = `https://historian.${serverSuffix}`;\n\t\t\tordererUrl = `https://alfred.${serverSuffix}`;\n\t\t\tdeltaStorageUrl = `https://alfred.${serverSuffix}/deltas/${tenantId}/${documentId}`;\n\t\t}\n\n\t\tstorageUrl += `/repos/${tenantId}`;\n\t\tordererUrl += ``;\n\t\tdeltaStorageUrl += ``;\n\n\t\tconst resolved: IResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tstorageUrl,\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: { jwt: token },\n\t\t\ttype: \"fluid\",\n\t\t\turl: fluidUrl,\n\t\t};\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tassert(!!parsedUrl.pathname, 0x0b9 /* \"PathName should exist\" */);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tassert(!!tenantId, 0x0ba /* \"Tenant id should exist\" */);\n\t\tassert(!!documentId, 0x0bb /* \"Document id should exist\" */);\n\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\n\t\treturn `${this.hostUrl}/${encodeURIComponent(tenantId)}/${encodeURIComponent(\n\t\t\tdocumentId,\n\t\t)}/${url}`;\n\t}\n}\n\n/**\n * @internal\n */\nexport interface IAlfredUser extends IUser {\n\tdisplayName: string;\n\tname: string;\n}\n\n/**\n * @internal\n */\nexport interface IConfig {\n\tserverUrl: string;\n\tblobStorageUrl: string;\n\ttenantId: string;\n\tdocumentId: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"routerlicious-urlResolver.spec.js","sourceRoot":"","sources":["../../src/test/routerlicious-urlResolver.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC;IACtB,MAAM,OAAO,GAAG,mBAAmB,CAAC;IACpC,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,WAAW,GAAG,IAAI,wBAAwB,CAC/C,SAAS,EACT,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAClC,OAAO,CACP,CAAC;QACF,MAAM,GAAG,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AC,CAAiB,CAAC;QACtE,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC3E,MAAM,CAAC,WAAW,CACjB,WAAW,EACX,GAAG,OAAO,kCAAkC,EAC5C,2BAA2B,CAC3B,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { Provider } from \"../nconf.cjs\";\nimport { RouterliciousUrlResolver } from \"../urlResolver.js\";\n\ndescribe(\"Routerlicious Url Resolver\", () => {\n\tconst token = \"dummy\";\n\tconst hostUrl = \"https://dummy.com\";\n\tit(\"Should resolve the Routerlicious urls correctly\", async () => {\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tundefined,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst url: string =\n\t\t\t\"https://www.wu2.prague.office-int.com/loader/fluid/thinkable-list?chaincode=@fluid-example/shared-text@0.11.14146\";\n\t\tconst resolved = (await urlResolver.resolve({ url })) as IResolvedUrl;\n\t\tassert.equal(resolved.tokens.jwt, token, \"Token does not match\");\n\t\tassert.equal(\n\t\t\tresolved.endpoints.storageUrl,\n\t\t\t\"https://historian.wu2.prague.office-int.com/repos/fluid\",\n\t\t\t\"Storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.deltaStorageUrl,\n\t\t\t\"https://alfred.wu2.prague.office-int.com/deltas/fluid/thinkable-list\",\n\t\t\t\"Delta storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.ordererUrl,\n\t\t\t\"https://alfred.wu2.prague.office-int.com\",\n\t\t\t\"Orderer url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.url,\n\t\t\t\"https://wu2.prague.office-int.com/fluid/thinkable-list?chaincode=@fluid-example/shared-text@0.11.14146\",\n\t\t\t\"FluidUrl does not match\",\n\t\t);\n\t});\n\n\tit(\"Should resolve the localhost urls correctly\", async () => {\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tundefined,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst url: string =\n\t\t\t\"http://localhost:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\";\n\t\tconst resolved = (await urlResolver.resolve({ url })) as IResolvedUrl;\n\t\tassert.equal(resolved.tokens.jwt, token, \"Token does not match\");\n\t\tassert.equal(\n\t\t\tresolved.endpoints.storageUrl,\n\t\t\t\"http://localhost:3001/repos/fluid\",\n\t\t\t\"Storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.deltaStorageUrl,\n\t\t\t\"http://localhost:3003/deltas/fluid/damp-competition\",\n\t\t\t\"Delta storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.ordererUrl,\n\t\t\t\"http://localhost:3003\",\n\t\t\t\"Orderer url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.url,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"FluidUrl does not match\",\n\t\t);\n\t});\n\n\tit(\"Should handle local External request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\ta: \"hell\",\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"http://localhost:3003\",\n\t\t\t\t\talfredUrl: \"http://alfred:3000\",\n\t\t\t\t\tblobStorageUrl: \"http://historian:3000\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://historian:3000\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"http://localhost:3001/repos/fluid\",\n\t\t\t\"Improperly Formed storageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"http://localhost:3003/deltas/fluid/damp-competition\",\n\t\t\t\"Improperly Formed deltaStorageUrl\",\n\t\t);\n\t\tassert.equal(endpoints.ordererUrl, \"http://localhost:3003\", \"Improperly Formed OrdererUrl\");\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"Improperly formed FluidURL\",\n\t\t);\n\t});\n\n\tit(\"Should handle local Internal request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"http://gateway:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"http://localhost:3003\",\n\t\t\t\t\talfredUrl: \"http://alfred:3000\",\n\t\t\t\t\tblobStorageUrl: \"http://historian:3000\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://historian:3000\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"http://historian:3000/repos/fluid\",\n\t\t\t\"Improperly Formed storageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"http://alfred:3000/deltas/fluid/damp-competition\",\n\t\t\t\"Improperly Formed deltaStorageUrl\",\n\t\t);\n\t\tassert.equal(endpoints.ordererUrl, \"http://alfred:3000\", \"Improperly Formed OrdererUrl\");\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"Improperly formed FluidURL\",\n\t\t);\n\t});\n\n\tit(\"Should handle Deployed Internal request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"http://angry-dog-gateway:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"http://localhost:3003\",\n\t\t\t\t\talfredUrl: \"http://wiggly-wombat-alfred:3000\",\n\t\t\t\t\tblobStorageUrl: \"http://historian:3000\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://smelly-wolf-historian:3000\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"http://smelly-wolf-historian:3000/repos/fluid\",\n\t\t\t\"Improperly Formed storageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"http://wiggly-wombat-alfred:3000/deltas/fluid/damp-competition\",\n\t\t\t\"Improperly Formed deltaStorageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.ordererUrl,\n\t\t\t\"http://wiggly-wombat-alfred:3000\",\n\t\t\t\"Improperly Formed OrdererUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"Improperly formed FluidURL\",\n\t\t);\n\t});\n\n\tit(\"Should handle deployed External request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"https://alfred.wu2-ppe.prague.office-int.com\",\n\t\t\t\t\talfredUrl: \"http://wiggly-wombat-alfred\",\n\t\t\t\t\tblobStorageUrl: \"https://historian.wu2-ppe.prague.office-int.com\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://smelly-wolf-historian\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"https://historian.wu2-ppe.prague.office-int.com/repos/fluid\",\n\t\t\t\"Storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"https://alfred.wu2-ppe.prague.office-int.com/deltas/fluid/damp-competition\",\n\t\t\t\"Delta storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.ordererUrl,\n\t\t\t\"https://alfred.wu2-ppe.prague.office-int.com\",\n\t\t\t\"Orderer url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://alfred.wu2-ppe.prague.office-int.com/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"FluidUrl does not match\",\n\t\t);\n\t});\n\n\tit(\"Should return the absolute url when requested\", async () => {\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tundefined,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst url: string =\n\t\t\t\"http://localhost:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\";\n\t\tconst resolved = (await urlResolver.resolve({ url })) as IResolvedUrl;\n\t\tconst absoluteUrl = await urlResolver.getAbsoluteUrl(resolved, \"relative\");\n\t\tassert.strictEqual(\n\t\t\tabsoluteUrl,\n\t\t\t`${hostUrl}/fluid/damp-competition/relative`,\n\t\t\t\"Absolute url should match\",\n\t\t);\n\t});\n});\n"]}
1
+ {"version":3,"file":"routerlicious-urlResolver.spec.js","sourceRoot":"","sources":["../../src/test/routerlicious-urlResolver.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC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,WAAW,GAAG,IAAI,wBAAwB,CAC/C,SAAS,EACT,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAClC,OAAO,CACP,CAAC;QACF,MAAM,GAAG,GACR,kGAAkG,CAAC;QACpG,MAAM,QAAQ,GAAG,CAAC,MAAM,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,CAAiB,CAAC;QACtE,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC3E,MAAM,CAAC,WAAW,CACjB,WAAW,EACX,GAAG,OAAO,kCAAkC,EAC5C,2BAA2B,CAC3B,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport { Provider } from \"../nconf.cjs\";\nimport { RouterliciousUrlResolver } from \"../urlResolver.js\";\n\ndescribe(\"Routerlicious Url Resolver\", () => {\n\tconst token = \"dummy\";\n\tconst hostUrl = \"https://dummy.com\";\n\tit(\"Should resolve the Routerlicious urls correctly\", async () => {\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tundefined,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst url: string =\n\t\t\t\"https://www.wu2.prague.office-int.com/loader/fluid/thinkable-list?chaincode=@fluid-example/shared-text@0.11.14146\";\n\t\tconst resolved = (await urlResolver.resolve({ url })) as IResolvedUrl;\n\t\tassert.equal(resolved.tokens.jwt, token, \"Token does not match\");\n\t\tassert.equal(\n\t\t\tresolved.endpoints.storageUrl,\n\t\t\t\"https://historian.wu2.prague.office-int.com/repos/fluid\",\n\t\t\t\"Storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.deltaStorageUrl,\n\t\t\t\"https://alfred.wu2.prague.office-int.com/deltas/fluid/thinkable-list\",\n\t\t\t\"Delta storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.ordererUrl,\n\t\t\t\"https://alfred.wu2.prague.office-int.com\",\n\t\t\t\"Orderer url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.url,\n\t\t\t\"https://wu2.prague.office-int.com/fluid/thinkable-list?chaincode=@fluid-example/shared-text@0.11.14146\",\n\t\t\t\"FluidUrl does not match\",\n\t\t);\n\t});\n\n\tit(\"Should resolve the localhost urls correctly\", async () => {\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tundefined,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst url: string =\n\t\t\t\"http://localhost:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\";\n\t\tconst resolved = (await urlResolver.resolve({ url })) as IResolvedUrl;\n\t\tassert.equal(resolved.tokens.jwt, token, \"Token does not match\");\n\t\tassert.equal(\n\t\t\tresolved.endpoints.storageUrl,\n\t\t\t\"http://localhost:3001/repos/fluid\",\n\t\t\t\"Storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.deltaStorageUrl,\n\t\t\t\"http://localhost:3003/deltas/fluid/damp-competition\",\n\t\t\t\"Delta storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.endpoints.ordererUrl,\n\t\t\t\"http://localhost:3003\",\n\t\t\t\"Orderer url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tresolved.url,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"FluidUrl does not match\",\n\t\t);\n\t});\n\n\tit(\"Should handle local External request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\ta: \"hell\",\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"http://localhost:3003\",\n\t\t\t\t\talfredUrl: \"http://alfred:3000\",\n\t\t\t\t\tblobStorageUrl: \"http://historian:3000\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://historian:3000\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"http://localhost:3001/repos/fluid\",\n\t\t\t\"Improperly Formed storageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"http://localhost:3003/deltas/fluid/damp-competition\",\n\t\t\t\"Improperly Formed deltaStorageUrl\",\n\t\t);\n\t\tassert.equal(endpoints.ordererUrl, \"http://localhost:3003\", \"Improperly Formed OrdererUrl\");\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"Improperly formed FluidURL\",\n\t\t);\n\t});\n\n\tit(\"Should handle local Internal request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"http://gateway:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"http://localhost:3003\",\n\t\t\t\t\talfredUrl: \"http://alfred:3000\",\n\t\t\t\t\tblobStorageUrl: \"http://historian:3000\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://historian:3000\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"http://historian:3000/repos/fluid\",\n\t\t\t\"Improperly Formed storageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"http://alfred:3000/deltas/fluid/damp-competition\",\n\t\t\t\"Improperly Formed deltaStorageUrl\",\n\t\t);\n\t\tassert.equal(endpoints.ordererUrl, \"http://alfred:3000\", \"Improperly Formed OrdererUrl\");\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"Improperly formed FluidURL\",\n\t\t);\n\t});\n\n\tit(\"Should handle Deployed Internal request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"http://angry-dog-gateway:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"http://localhost:3003\",\n\t\t\t\t\talfredUrl: \"http://wiggly-wombat-alfred:3000\",\n\t\t\t\t\tblobStorageUrl: \"http://historian:3000\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://smelly-wolf-historian:3000\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"http://smelly-wolf-historian:3000/repos/fluid\",\n\t\t\t\"Improperly Formed storageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"http://wiggly-wombat-alfred:3000/deltas/fluid/damp-competition\",\n\t\t\t\"Improperly Formed deltaStorageUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.ordererUrl,\n\t\t\t\"http://wiggly-wombat-alfred:3000\",\n\t\t\t\"Improperly Formed OrdererUrl\",\n\t\t);\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://localhost:3003/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"Improperly formed FluidURL\",\n\t\t);\n\t});\n\n\tit(\"Should handle deployed External request\", async () => {\n\t\tconst request: IRequest = {\n\t\t\turl: \"/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t};\n\n\t\tconst provider = new Provider({})\n\t\t\t.defaults({\n\t\t\t\tworker: {\n\t\t\t\t\tserverUrl: \"https://alfred.wu2-ppe.prague.office-int.com\",\n\t\t\t\t\talfredUrl: \"http://wiggly-wombat-alfred\",\n\t\t\t\t\tblobStorageUrl: \"https://historian.wu2-ppe.prague.office-int.com\",\n\t\t\t\t\tinternalBlobStorageUrl: \"http://smelly-wolf-historian\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t.use(\"memory\");\n\n\t\tconst config = {\n\t\t\tprovider,\n\t\t\ttenantId: \"fluid\",\n\t\t\tdocumentId: \"damp-competition\",\n\t\t};\n\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tconfig,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst { endpoints, url } = (await urlResolver.resolve(request)) as IResolvedUrl;\n\n\t\tassert.equal(\n\t\t\tendpoints.storageUrl,\n\t\t\t\"https://historian.wu2-ppe.prague.office-int.com/repos/fluid\",\n\t\t\t\"Storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.deltaStorageUrl,\n\t\t\t\"https://alfred.wu2-ppe.prague.office-int.com/deltas/fluid/damp-competition\",\n\t\t\t\"Delta storage url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\tendpoints.ordererUrl,\n\t\t\t\"https://alfred.wu2-ppe.prague.office-int.com\",\n\t\t\t\"Orderer url does not match\",\n\t\t);\n\t\tassert.equal(\n\t\t\turl,\n\t\t\t\"https://alfred.wu2-ppe.prague.office-int.com/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\",\n\t\t\t\"FluidUrl does not match\",\n\t\t);\n\t});\n\n\tit(\"Should return the absolute url when requested\", async () => {\n\t\tconst urlResolver = new RouterliciousUrlResolver(\n\t\t\tundefined,\n\t\t\tasync () => Promise.resolve(token),\n\t\t\thostUrl,\n\t\t);\n\t\tconst url: string =\n\t\t\t\"http://localhost:3000/loader/fluid/damp-competition?chaincode=@fluid-example/shared-text@^0.11.0\";\n\t\tconst resolved = (await urlResolver.resolve({ url })) as IResolvedUrl;\n\t\tconst absoluteUrl = await urlResolver.getAbsoluteUrl(resolved, \"relative\");\n\t\tassert.strictEqual(\n\t\t\tabsoluteUrl,\n\t\t\t`${hostUrl}/fluid/damp-competition/relative`,\n\t\t\t\"Absolute url should match\",\n\t\t);\n\t});\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"urlResolver.d.ts","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAA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,GAAG,CAAC,CAAC;QAC3C,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAClE,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/D,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACzD,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAE7D,IAAI,GAAG,GAAG,WAAW,CAAC;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACpB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAC3E,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IUser } from \"@fluidframework/protocol-definitions\";\nimport { Provider } from \"./nconf.cjs\";\n\nconst r11sServers = [\n\t\"www.wu2-ppe.prague.office-int.com\",\n\t\"www.wu2.prague.office-int.com\",\n\t\"www.eu.prague.office-int.com\",\n];\n\n/**\n * @internal\n */\nexport class RouterliciousUrlResolver implements IUrlResolver {\n\tconstructor(\n\t\tprivate readonly config:\n\t\t\t| { provider: Provider; tenantId: string; documentId: string }\n\t\t\t| undefined,\n\t\tprivate readonly getToken: () => Promise<string>,\n\t\tprivate readonly hostUrl: string,\n\t) {}\n\n\t/**\n\t * Handles a request and returns the relevant endpoints for the environment\n\t */\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tlet requestedUrl = request.url;\n\n\t\t// If we know the original hostname, reinsert it\n\t\tif (this.config && request.url.startsWith(\"/\")) {\n\t\t\trequestedUrl = `http://dummy:3000${request.url}`;\n\t\t}\n\n\t\tconst reqUrl = new URL(requestedUrl);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\n\t\t// If we don't have a valid server or a prescriptive config, we cannot resolve the URL\n\t\tif (\n\t\t\t!(\n\t\t\t\tr11sServers.includes(server) ||\n\t\t\t\t(server === \"localhost\" && reqUrl.port === \"3000\") ||\n\t\t\t\tthis.config\n\t\t\t)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = reqUrl.pathname.split(\"/\");\n\t\tlet tenantId: string;\n\t\tlet documentId: string;\n\t\tlet provider: Provider | undefined;\n\t\tif (this.config) {\n\t\t\ttenantId = this.config.tenantId;\n\t\t\tdocumentId = this.config.documentId;\n\t\t\tprovider = this.config.provider;\n\t\t} else if (path.length >= 4) {\n\t\t\ttenantId = path[2];\n\t\t\tdocumentId = path[3];\n\t\t} else {\n\t\t\ttenantId = \"fluid\";\n\t\t\tdocumentId = path[2];\n\t\t}\n\n\t\tconst token = await this.getToken();\n\n\t\tconst isLocalHost = server === \"localhost\";\n\t\tconst isInternalRequest = server.includes(\"gateway\"); // e.g. gateway:3000 || fierce-dog-gateway:3000\n\n\t\tconst serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);\n\n\t\tlet fluidUrl =\n\t\t\t\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config\n\t\t\t\t\t? new URL(this.config.provider.get(\"worker:serverUrl\")).host\n\t\t\t\t\t: serverSuffix\n\t\t\t}/` +\n\t\t\t`${encodeURIComponent(tenantId)}/` +\n\t\t\t`${encodeURIComponent(documentId)}`;\n\n\t\t// In case of any additional parameters add them back to the url\n\t\tif (reqUrl.search) {\n\t\t\tconst searchParams = reqUrl.search;\n\t\t\tif (searchParams) {\n\t\t\t\tfluidUrl += searchParams;\n\t\t\t}\n\t\t}\n\n\t\tlet storageUrl = \"\";\n\t\tlet ordererUrl = \"\";\n\t\tlet deltaStorageUrl = \"\";\n\n\t\t// There is no provider when using debugging tooling\n\t\tif (provider && isInternalRequest) {\n\t\t\tstorageUrl = provider.get(\"worker:internalBlobStorageUrl\");\n\t\t\tordererUrl = provider.get(\"worker:alfredUrl\");\n\t\t\tdeltaStorageUrl = `${provider.get(\"worker:alfredUrl\")}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (provider) {\n\t\t\tstorageUrl = provider\n\t\t\t\t.get(\"worker:blobStorageUrl\")\n\t\t\t\t.replace(\"historian:3000\", \"localhost:3001\");\n\t\t\tordererUrl = provider.get(\"worker:serverUrl\");\n\t\t\tdeltaStorageUrl = `${ordererUrl}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (isLocalHost) {\n\t\t\tstorageUrl = `http://localhost:3001`;\n\t\t\tordererUrl = `http://localhost:3003`;\n\t\t\tdeltaStorageUrl = `http://localhost:3003/deltas/${tenantId}/${documentId}`;\n\t\t} else {\n\t\t\tstorageUrl = `https://historian.${serverSuffix}`;\n\t\t\tordererUrl = `https://alfred.${serverSuffix}`;\n\t\t\tdeltaStorageUrl = `https://alfred.${serverSuffix}/deltas/${tenantId}/${documentId}`;\n\t\t}\n\n\t\tstorageUrl += `/repos/${tenantId}`;\n\t\tordererUrl += ``;\n\t\tdeltaStorageUrl += ``;\n\n\t\tconst resolved: IResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tstorageUrl,\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: { jwt: token },\n\t\t\ttype: \"fluid\",\n\t\t\turl: fluidUrl,\n\t\t};\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tassert(!!parsedUrl.pathname, 0x0b9 /* \"PathName should exist\" */);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tassert(!!tenantId, 0x0ba /* \"Tenant id should exist\" */);\n\t\tassert(!!documentId, 0x0bb /* \"Document id should exist\" */);\n\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\n\t\treturn `${this.hostUrl}/${encodeURIComponent(tenantId)}/${encodeURIComponent(\n\t\t\tdocumentId,\n\t\t)}/${url}`;\n\t}\n}\n\n/**\n * @internal\n */\nexport interface IAlfredUser extends IUser {\n\tdisplayName: string;\n\tname: string;\n}\n\n/**\n * @internal\n */\nexport interface IConfig {\n\tserverUrl: string;\n\tblobStorageUrl: string;\n\ttenantId: string;\n\tdocumentId: string;\n}\n"]}
1
+ {"version":3,"file":"urlResolver.js","sourceRoot":"","sources":["../src/urlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKpD,MAAM,WAAW,GAAG;IACnB,mCAAmC;IACnC,+BAA+B;IAC/B,8BAA8B;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACpC,YACkB,MAEL,EACK,QAA+B,EAC/B,OAAe;QAJf,WAAM,GAAN,MAAM,CAEX;QACK,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,YAAO,GAAP,OAAO,CAAQ;IAC9B,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,IAAI,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;QAE/B,gDAAgD;QAChD,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,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,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAE7D,IAAI,GAAG,GAAG,WAAW,CAAC;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACpB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAC3E,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;CACD","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 { assert } from \"@fluidframework/core-utils\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IUser } from \"@fluidframework/protocol-definitions\";\nimport { Provider } from \"./nconf.cjs\";\n\nconst r11sServers = [\n\t\"www.wu2-ppe.prague.office-int.com\",\n\t\"www.wu2.prague.office-int.com\",\n\t\"www.eu.prague.office-int.com\",\n];\n\n/**\n * @internal\n */\nexport class RouterliciousUrlResolver implements IUrlResolver {\n\tconstructor(\n\t\tprivate readonly config:\n\t\t\t| { provider: Provider; tenantId: string; documentId: string }\n\t\t\t| undefined,\n\t\tprivate readonly getToken: () => Promise<string>,\n\t\tprivate readonly hostUrl: string,\n\t) {}\n\n\t/**\n\t * Handles a request and returns the relevant endpoints for the environment\n\t */\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\tlet requestedUrl = request.url;\n\n\t\t// If we know the original hostname, reinsert it\n\t\tif (this.config && request.url.startsWith(\"/\")) {\n\t\t\trequestedUrl = `http://dummy:3000${request.url}`;\n\t\t}\n\n\t\tconst reqUrl = new URL(requestedUrl);\n\t\tconst server = reqUrl.hostname.toLowerCase();\n\n\t\t// If we don't have a valid server or a prescriptive config, we cannot resolve the URL\n\t\tif (\n\t\t\t!(\n\t\t\t\tr11sServers.includes(server) ||\n\t\t\t\t(server === \"localhost\" && reqUrl.port === \"3000\") ||\n\t\t\t\tthis.config\n\t\t\t)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = reqUrl.pathname.split(\"/\");\n\t\tlet tenantId: string;\n\t\tlet documentId: string;\n\t\tlet provider: Provider | undefined;\n\t\tif (this.config) {\n\t\t\ttenantId = this.config.tenantId;\n\t\t\tdocumentId = this.config.documentId;\n\t\t\tprovider = this.config.provider;\n\t\t} else if (path.length >= 4) {\n\t\t\ttenantId = path[2];\n\t\t\tdocumentId = path[3];\n\t\t} else {\n\t\t\ttenantId = \"fluid\";\n\t\t\tdocumentId = path[2];\n\t\t}\n\n\t\tconst token = await this.getToken();\n\n\t\tconst isLocalHost = server === \"localhost\";\n\t\tconst isInternalRequest = server.includes(\"gateway\"); // e.g. gateway:3000 || fierce-dog-gateway:3000\n\n\t\tconst serverSuffix = isLocalHost ? `${server}:3003` : server.substring(4);\n\n\t\tlet fluidUrl =\n\t\t\t\"https://\" +\n\t\t\t`${\n\t\t\t\tthis.config\n\t\t\t\t\t? new URL(this.config.provider.get(\"worker:serverUrl\")).host\n\t\t\t\t\t: serverSuffix\n\t\t\t}/` +\n\t\t\t`${encodeURIComponent(tenantId)}/` +\n\t\t\t`${encodeURIComponent(documentId)}`;\n\n\t\t// In case of any additional parameters add them back to the url\n\t\tif (reqUrl.search) {\n\t\t\tconst searchParams = reqUrl.search;\n\t\t\tif (searchParams) {\n\t\t\t\tfluidUrl += searchParams;\n\t\t\t}\n\t\t}\n\n\t\tlet storageUrl = \"\";\n\t\tlet ordererUrl = \"\";\n\t\tlet deltaStorageUrl = \"\";\n\n\t\t// There is no provider when using debugging tooling\n\t\tif (provider && isInternalRequest) {\n\t\t\tstorageUrl = provider.get(\"worker:internalBlobStorageUrl\");\n\t\t\tordererUrl = provider.get(\"worker:alfredUrl\");\n\t\t\tdeltaStorageUrl = `${provider.get(\"worker:alfredUrl\")}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (provider) {\n\t\t\tstorageUrl = provider\n\t\t\t\t.get(\"worker:blobStorageUrl\")\n\t\t\t\t.replace(\"historian:3000\", \"localhost:3001\");\n\t\t\tordererUrl = provider.get(\"worker:serverUrl\");\n\t\t\tdeltaStorageUrl = `${ordererUrl}/deltas/${encodeURIComponent(\n\t\t\t\ttenantId,\n\t\t\t)}/${encodeURIComponent(documentId)}`;\n\t\t} else if (isLocalHost) {\n\t\t\tstorageUrl = `http://localhost:3001`;\n\t\t\tordererUrl = `http://localhost:3003`;\n\t\t\tdeltaStorageUrl = `http://localhost:3003/deltas/${tenantId}/${documentId}`;\n\t\t} else {\n\t\t\tstorageUrl = `https://historian.${serverSuffix}`;\n\t\t\tordererUrl = `https://alfred.${serverSuffix}`;\n\t\t\tdeltaStorageUrl = `https://alfred.${serverSuffix}/deltas/${tenantId}/${documentId}`;\n\t\t}\n\n\t\tstorageUrl += `/repos/${tenantId}`;\n\t\tordererUrl += ``;\n\t\tdeltaStorageUrl += ``;\n\n\t\tconst resolved: IResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tstorageUrl,\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: { jwt: token },\n\t\t\ttype: \"fluid\",\n\t\t\turl: fluidUrl,\n\t\t};\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tassert(!!parsedUrl.pathname, 0x0b9 /* \"PathName should exist\" */);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tassert(!!tenantId, 0x0ba /* \"Tenant id should exist\" */);\n\t\tassert(!!documentId, 0x0bb /* \"Document id should exist\" */);\n\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\n\t\treturn `${this.hostUrl}/${encodeURIComponent(tenantId)}/${encodeURIComponent(\n\t\t\tdocumentId,\n\t\t)}/${url}`;\n\t}\n}\n\n/**\n * @internal\n */\nexport interface IAlfredUser extends IUser {\n\tdisplayName: string;\n\tname: string;\n}\n\n/**\n * @internal\n */\nexport interface IConfig {\n\tserverUrl: string;\n\tblobStorageUrl: string;\n\ttenantId: string;\n\tdocumentId: string;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/routerlicious-urlresolver",
3
- "version": "2.0.0-dev-rc.2.0.0.245554",
3
+ "version": "2.0.0-dev-rc.3.0.0.250606",
4
4
  "description": "Url Resolver for routerlicious urls.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -47,15 +47,16 @@
47
47
  "main": "dist/index.js",
48
48
  "types": "dist/index.d.ts",
49
49
  "dependencies": {
50
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.2.0.0.245554",
51
- "@fluidframework/core-utils": "2.0.0-dev-rc.2.0.0.245554",
52
- "@fluidframework/driver-definitions": "2.0.0-dev-rc.2.0.0.245554",
50
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.3.0.0.250606",
51
+ "@fluidframework/core-utils": "2.0.0-dev-rc.3.0.0.250606",
52
+ "@fluidframework/driver-definitions": "2.0.0-dev-rc.3.0.0.250606",
53
53
  "@fluidframework/protocol-definitions": "^3.2.0",
54
54
  "nconf": "^0.12.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@arethetypeswrong/cli": "^0.13.3",
58
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.2.0.0.245554",
58
+ "@biomejs/biome": "^1.6.2",
59
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.3.0.0.250606",
59
60
  "@fluid-tools/build-cli": "^0.34.0",
60
61
  "@fluidframework/build-common": "^2.0.3",
61
62
  "@fluidframework/build-tools": "^0.34.0",
@@ -105,16 +106,18 @@
105
106
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
106
107
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
107
108
  "check:are-the-types-wrong": "attw --pack . --entrypoints .",
109
+ "check:biome": "biome check .",
110
+ "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
108
111
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
109
112
  "ci:build:docs": "api-extractor run",
110
113
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
111
114
  "eslint": "eslint --format stylish src",
112
115
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
113
- "format": "npm run prettier:fix",
114
- "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
115
- "lint:fix": "npm run prettier:fix && npm run eslint:fix",
116
- "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
117
- "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
116
+ "format": "fluid-build --task format .",
117
+ "format:biome": "biome check --apply .",
118
+ "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
119
+ "lint": "fluid-build . --task lint",
120
+ "lint:fix": "fluid-build . --task eslint:fix --task format",
118
121
  "test": "npm run test:mocha",
119
122
  "test:mocha": "npm run test:mocha:esm && npm run test:mocha:cjs",
120
123
  "test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/core-utils";
7
6
  import { IRequest } from "@fluidframework/core-interfaces";
7
+ import { assert } from "@fluidframework/core-utils";
8
8
  import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
9
9
  import { IUser } from "@fluidframework/protocol-definitions";
10
10
  import { Provider } from "./nconf.cjs";