@fluidframework/azure-service-utils 0.59.2003 → 0.59.3000
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/api-extractor.json +9 -1
- package/dist/generateToken.d.ts +18 -5
- package/dist/generateToken.d.ts.map +1 -1
- package/dist/generateToken.js +21 -8
- package/dist/generateToken.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/generateToken.d.ts +18 -5
- package/lib/generateToken.d.ts.map +1 -1
- package/lib/generateToken.js +18 -5
- package/lib/generateToken.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +10 -7
- package/src/generateToken.ts +20 -6
- package/src/packageVersion.ts +1 -1
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "@fluidframework/build-common/api-extractor-common-report.json"
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-report.json",
|
|
4
|
+
"apiReport": {
|
|
5
|
+
"enabled": true,
|
|
6
|
+
"reportFolder": "<projectFolder>/../../../api-report/"
|
|
7
|
+
},
|
|
8
|
+
"docModel": {
|
|
9
|
+
"enabled": true,
|
|
10
|
+
"apiJsonFilePath": "<projectFolder>/../../_api-extractor-temp/doc-models/<unscopedPackageName>.api.json"
|
|
11
|
+
}
|
|
4
12
|
}
|
package/dist/generateToken.d.ts
CHANGED
|
@@ -4,11 +4,24 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IUser, ScopeType } from "@fluidframework/protocol-definitions";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* IMPORTANT: This function is duplicated in ./packages/runtime/test-runtime-utils/src/generateToken.ts. There is no
|
|
8
|
+
* need for different implementations, so they should be kept in sync if changes are needed.
|
|
9
|
+
*
|
|
10
|
+
* The reason they are duplicated is because we don't want the core Fluid libraries depending on the Azure libraries
|
|
11
|
+
* (enforced by layer-check), but both need to expose this function. The test-runtime-utils library is a test lib, which
|
|
12
|
+
* layer-check (correctly) reuires only be used as a dev dependency. But in the azure case, we want the function
|
|
13
|
+
* exported, so it needs to be sourced from either the package itself or a non-dev dependency.
|
|
14
|
+
*
|
|
15
|
+
* The previous solution to this was to import the function from azure-service-utils into test-runtime-utils, but that
|
|
16
|
+
* no longer works because the azure packages are in a separate release group.
|
|
17
|
+
*
|
|
18
|
+
* If a token needs to be generated on the client side, you should re-use this function. If you need service-side token
|
|
19
|
+
* generation, you should use the function available in the server-services-client package in order to avoid
|
|
20
|
+
* interdependencies between service and client packages.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Generates a JWT token to authorize access to a Routerlicious-based Fluid service. This function uses a browser
|
|
24
|
+
* friendly auth library (jsrsasign) and should only be used in client (browser) context.
|
|
12
25
|
*/
|
|
13
26
|
export declare function generateToken(tenantId: string, key: string, scopes: ScopeType[], documentId?: string, user?: IUser, lifetime?: number, ver?: string): string;
|
|
14
27
|
export declare function generateUser(): IUser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateToken.d.ts","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAgB,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAI3F
|
|
1
|
+
{"version":3,"file":"generateToken.d.ts","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAgB,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAI3F;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH,wBAAgB,aAAa,CACzB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EAAE,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,KAAK,EACZ,QAAQ,GAAE,MAAgB,EAC1B,GAAG,GAAE,MAAc,GAAG,MAAM,CAuB/B;AAED,wBAAgB,YAAY,IAAI,KAAK,CAOpC"}
|
package/dist/generateToken.js
CHANGED
|
@@ -8,11 +8,24 @@ exports.generateUser = exports.generateToken = void 0;
|
|
|
8
8
|
const jsrsasign_1 = require("jsrsasign");
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* IMPORTANT: This function is duplicated in ./packages/runtime/test-runtime-utils/src/generateToken.ts. There is no
|
|
12
|
+
* need for different implementations, so they should be kept in sync if changes are needed.
|
|
13
|
+
*
|
|
14
|
+
* The reason they are duplicated is because we don't want the core Fluid libraries depending on the Azure libraries
|
|
15
|
+
* (enforced by layer-check), but both need to expose this function. The test-runtime-utils library is a test lib, which
|
|
16
|
+
* layer-check (correctly) reuires only be used as a dev dependency. But in the azure case, we want the function
|
|
17
|
+
* exported, so it needs to be sourced from either the package itself or a non-dev dependency.
|
|
18
|
+
*
|
|
19
|
+
* The previous solution to this was to import the function from azure-service-utils into test-runtime-utils, but that
|
|
20
|
+
* no longer works because the azure packages are in a separate release group.
|
|
21
|
+
*
|
|
22
|
+
* If a token needs to be generated on the client side, you should re-use this function. If you need service-side token
|
|
23
|
+
* generation, you should use the function available in the server-services-client package in order to avoid
|
|
24
|
+
* interdependencies between service and client packages.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Generates a JWT token to authorize access to a Routerlicious-based Fluid service. This function uses a browser
|
|
28
|
+
* friendly auth library (jsrsasign) and should only be used in client (browser) context.
|
|
16
29
|
*/
|
|
17
30
|
function generateToken(tenantId, key, scopes, documentId, user, lifetime = 60 * 60, ver = "1.0") {
|
|
18
31
|
let userClaim = (user) ? user : generateUser();
|
|
@@ -30,7 +43,7 @@ function generateToken(tenantId, key, scopes, documentId, user, lifetime = 60 *
|
|
|
30
43
|
iat: now,
|
|
31
44
|
exp: now + lifetime,
|
|
32
45
|
ver,
|
|
33
|
-
jti: uuid_1.v4(),
|
|
46
|
+
jti: (0, uuid_1.v4)(),
|
|
34
47
|
};
|
|
35
48
|
const utf8Key = { utf8: key };
|
|
36
49
|
return jsrsasign_1.KJUR.jws.JWS.sign(null, JSON.stringify({ alg: "HS256", typ: "JWT" }), claims, utf8Key);
|
|
@@ -38,8 +51,8 @@ function generateToken(tenantId, key, scopes, documentId, user, lifetime = 60 *
|
|
|
38
51
|
exports.generateToken = generateToken;
|
|
39
52
|
function generateUser() {
|
|
40
53
|
const randomUser = {
|
|
41
|
-
id: uuid_1.v4(),
|
|
42
|
-
name: uuid_1.v4(),
|
|
54
|
+
id: (0, uuid_1.v4)(),
|
|
55
|
+
name: (0, uuid_1.v4)(),
|
|
43
56
|
};
|
|
44
57
|
return randomUser;
|
|
45
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yCAA8C;AAC9C,+BAAkC;AAElC
|
|
1
|
+
{"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yCAA8C;AAC9C,+BAAkC;AAElC;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH,SAAgB,aAAa,CACzB,QAAgB,EAChB,GAAW,EACX,MAAmB,EACnB,UAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;IACnB,IAAI,SAAS,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC/C,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE;QACnD,SAAS,GAAG,YAAY,EAAE,CAAC;KAC9B;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,CAAC;IAE/B,MAAM,MAAM,GAAoC;QAC5C,UAAU,EAAE,KAAK;QACjB,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,QAAQ;QACnB,GAAG;QACH,GAAG,EAAE,IAAA,SAAI,GAAE;KACd,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC9B,OAAO,gBAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACvG,CAAC;AA9BD,sCA8BC;AAED,SAAgB,YAAY;IACxB,MAAM,UAAU,GAAG;QACf,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,IAAI,EAAE,IAAA,SAAI,GAAE;KACf,CAAC;IAEF,OAAO,UAAU,CAAC;AACtB,CAAC;AAPD,oCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITokenClaims, IUser, ScopeType } from \"@fluidframework/protocol-definitions\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * IMPORTANT: This function is duplicated in ./packages/runtime/test-runtime-utils/src/generateToken.ts. There is no\n * need for different implementations, so they should be kept in sync if changes are needed.\n *\n * The reason they are duplicated is because we don't want the core Fluid libraries depending on the Azure libraries\n * (enforced by layer-check), but both need to expose this function. The test-runtime-utils library is a test lib, which\n * layer-check (correctly) reuires only be used as a dev dependency. But in the azure case, we want the function\n * exported, so it needs to be sourced from either the package itself or a non-dev dependency.\n *\n * The previous solution to this was to import the function from azure-service-utils into test-runtime-utils, but that\n * no longer works because the azure packages are in a separate release group.\n *\n * If a token needs to be generated on the client side, you should re-use this function. If you need service-side token\n * generation, you should use the function available in the server-services-client package in order to avoid\n * interdependencies between service and client packages.\n */\n\n/**\n * Generates a JWT token to authorize access to a Routerlicious-based Fluid service. This function uses a browser\n * friendly auth library (jsrsasign) and should only be used in client (browser) context.\n */\nexport function generateToken(\n tenantId: string,\n key: string,\n scopes: ScopeType[],\n documentId?: string,\n user?: IUser,\n lifetime: number = 60 * 60,\n ver: string = \"1.0\"): string {\n let userClaim = (user) ? user : generateUser();\n if (userClaim.id === \"\" || userClaim.id === undefined) {\n userClaim = generateUser();\n }\n\n // Current time in seconds\n const now = Math.round(Date.now() / 1000);\n const docId = documentId ?? \"\";\n\n const claims: ITokenClaims & { jti: string; } = {\n documentId: docId,\n scopes,\n tenantId,\n user: userClaim,\n iat: now,\n exp: now + lifetime,\n ver,\n jti: uuid(),\n };\n\n const utf8Key = { utf8: key };\n return jsrsasign.jws.JWS.sign(null, JSON.stringify({ alg: \"HS256\", typ: \"JWT\" }), claims, utf8Key);\n}\n\nexport function generateUser(): IUser {\n const randomUser = {\n id: uuid(),\n name: uuid(),\n };\n\n return randomUser;\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/azure-service-utils";
|
|
8
|
-
export declare const pkgVersion = "0.59.
|
|
8
|
+
export declare const pkgVersion = "0.59.3000";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/azure-service-utils";
|
|
11
|
-
exports.pkgVersion = "0.59.
|
|
11
|
+
exports.pkgVersion = "0.59.3000";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qCAAqC,CAAC;AAChD,QAAA,UAAU,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/azure-service-utils\";\nexport const pkgVersion = \"0.59.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qCAAqC,CAAC;AAChD,QAAA,UAAU,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/azure-service-utils\";\nexport const pkgVersion = \"0.59.3000\";\n"]}
|
package/lib/generateToken.d.ts
CHANGED
|
@@ -4,11 +4,24 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IUser, ScopeType } from "@fluidframework/protocol-definitions";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* IMPORTANT: This function is duplicated in ./packages/runtime/test-runtime-utils/src/generateToken.ts. There is no
|
|
8
|
+
* need for different implementations, so they should be kept in sync if changes are needed.
|
|
9
|
+
*
|
|
10
|
+
* The reason they are duplicated is because we don't want the core Fluid libraries depending on the Azure libraries
|
|
11
|
+
* (enforced by layer-check), but both need to expose this function. The test-runtime-utils library is a test lib, which
|
|
12
|
+
* layer-check (correctly) reuires only be used as a dev dependency. But in the azure case, we want the function
|
|
13
|
+
* exported, so it needs to be sourced from either the package itself or a non-dev dependency.
|
|
14
|
+
*
|
|
15
|
+
* The previous solution to this was to import the function from azure-service-utils into test-runtime-utils, but that
|
|
16
|
+
* no longer works because the azure packages are in a separate release group.
|
|
17
|
+
*
|
|
18
|
+
* If a token needs to be generated on the client side, you should re-use this function. If you need service-side token
|
|
19
|
+
* generation, you should use the function available in the server-services-client package in order to avoid
|
|
20
|
+
* interdependencies between service and client packages.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Generates a JWT token to authorize access to a Routerlicious-based Fluid service. This function uses a browser
|
|
24
|
+
* friendly auth library (jsrsasign) and should only be used in client (browser) context.
|
|
12
25
|
*/
|
|
13
26
|
export declare function generateToken(tenantId: string, key: string, scopes: ScopeType[], documentId?: string, user?: IUser, lifetime?: number, ver?: string): string;
|
|
14
27
|
export declare function generateUser(): IUser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateToken.d.ts","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAgB,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAI3F
|
|
1
|
+
{"version":3,"file":"generateToken.d.ts","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAgB,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAI3F;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH,wBAAgB,aAAa,CACzB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EAAE,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,KAAK,EACZ,QAAQ,GAAE,MAAgB,EAC1B,GAAG,GAAE,MAAc,GAAG,MAAM,CAuB/B;AAED,wBAAgB,YAAY,IAAI,KAAK,CAOpC"}
|
package/lib/generateToken.js
CHANGED
|
@@ -5,11 +5,24 @@
|
|
|
5
5
|
import { KJUR as jsrsasign } from "jsrsasign";
|
|
6
6
|
import { v4 as uuid } from "uuid";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* IMPORTANT: This function is duplicated in ./packages/runtime/test-runtime-utils/src/generateToken.ts. There is no
|
|
9
|
+
* need for different implementations, so they should be kept in sync if changes are needed.
|
|
10
|
+
*
|
|
11
|
+
* The reason they are duplicated is because we don't want the core Fluid libraries depending on the Azure libraries
|
|
12
|
+
* (enforced by layer-check), but both need to expose this function. The test-runtime-utils library is a test lib, which
|
|
13
|
+
* layer-check (correctly) reuires only be used as a dev dependency. But in the azure case, we want the function
|
|
14
|
+
* exported, so it needs to be sourced from either the package itself or a non-dev dependency.
|
|
15
|
+
*
|
|
16
|
+
* The previous solution to this was to import the function from azure-service-utils into test-runtime-utils, but that
|
|
17
|
+
* no longer works because the azure packages are in a separate release group.
|
|
18
|
+
*
|
|
19
|
+
* If a token needs to be generated on the client side, you should re-use this function. If you need service-side token
|
|
20
|
+
* generation, you should use the function available in the server-services-client package in order to avoid
|
|
21
|
+
* interdependencies between service and client packages.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Generates a JWT token to authorize access to a Routerlicious-based Fluid service. This function uses a browser
|
|
25
|
+
* friendly auth library (jsrsasign) and should only be used in client (browser) context.
|
|
13
26
|
*/
|
|
14
27
|
export function generateToken(tenantId, key, scopes, documentId, user, lifetime = 60 * 60, ver = "1.0") {
|
|
15
28
|
let userClaim = (user) ? user : generateUser();
|
package/lib/generateToken.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH,MAAM,UAAU,aAAa,CACzB,QAAgB,EAChB,GAAW,EACX,MAAmB,EACnB,UAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;IACnB,IAAI,SAAS,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC/C,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE;QACnD,SAAS,GAAG,YAAY,EAAE,CAAC;KAC9B;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,CAAC;IAE/B,MAAM,MAAM,GAAoC;QAC5C,UAAU,EAAE,KAAK;QACjB,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,QAAQ;QACnB,GAAG;QACH,GAAG,EAAE,IAAI,EAAE;KACd,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC9B,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACvG,CAAC;AAED,MAAM,UAAU,YAAY;IACxB,MAAM,UAAU,GAAG;QACf,EAAE,EAAE,IAAI,EAAE;QACV,IAAI,EAAE,IAAI,EAAE;KACf,CAAC;IAEF,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITokenClaims, IUser, ScopeType } from \"@fluidframework/protocol-definitions\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * IMPORTANT: This function is duplicated in ./packages/runtime/test-runtime-utils/src/generateToken.ts. There is no\n * need for different implementations, so they should be kept in sync if changes are needed.\n *\n * The reason they are duplicated is because we don't want the core Fluid libraries depending on the Azure libraries\n * (enforced by layer-check), but both need to expose this function. The test-runtime-utils library is a test lib, which\n * layer-check (correctly) reuires only be used as a dev dependency. But in the azure case, we want the function\n * exported, so it needs to be sourced from either the package itself or a non-dev dependency.\n *\n * The previous solution to this was to import the function from azure-service-utils into test-runtime-utils, but that\n * no longer works because the azure packages are in a separate release group.\n *\n * If a token needs to be generated on the client side, you should re-use this function. If you need service-side token\n * generation, you should use the function available in the server-services-client package in order to avoid\n * interdependencies between service and client packages.\n */\n\n/**\n * Generates a JWT token to authorize access to a Routerlicious-based Fluid service. This function uses a browser\n * friendly auth library (jsrsasign) and should only be used in client (browser) context.\n */\nexport function generateToken(\n tenantId: string,\n key: string,\n scopes: ScopeType[],\n documentId?: string,\n user?: IUser,\n lifetime: number = 60 * 60,\n ver: string = \"1.0\"): string {\n let userClaim = (user) ? user : generateUser();\n if (userClaim.id === \"\" || userClaim.id === undefined) {\n userClaim = generateUser();\n }\n\n // Current time in seconds\n const now = Math.round(Date.now() / 1000);\n const docId = documentId ?? \"\";\n\n const claims: ITokenClaims & { jti: string; } = {\n documentId: docId,\n scopes,\n tenantId,\n user: userClaim,\n iat: now,\n exp: now + lifetime,\n ver,\n jti: uuid(),\n };\n\n const utf8Key = { utf8: key };\n return jsrsasign.jws.JWS.sign(null, JSON.stringify({ alg: \"HS256\", typ: \"JWT\" }), claims, utf8Key);\n}\n\nexport function generateUser(): IUser {\n const randomUser = {\n id: uuid(),\n name: uuid(),\n };\n\n return randomUser;\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/azure-service-utils";
|
|
8
|
-
export declare const pkgVersion = "0.59.
|
|
8
|
+
export declare const pkgVersion = "0.59.3000";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/azure-service-utils\";\nexport const pkgVersion = \"0.59.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/azure-service-utils\";\nexport const pkgVersion = \"0.59.3000\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/azure-service-utils",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.3000",
|
|
4
4
|
"description": "Helper service-side utilities for connecting to Azure Fluid Relay service",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
19
19
|
"build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
|
|
20
20
|
"build:compile": "concurrently npm:build:commonjs npm:build:esnext",
|
|
21
|
-
"build:docs": "api-extractor run --local
|
|
21
|
+
"build:docs": "api-extractor run --local",
|
|
22
22
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
23
23
|
"build:full": "npm run build",
|
|
24
24
|
"build:full:compile": "npm run build:compile",
|
|
25
25
|
"build:genver": "gen-version",
|
|
26
26
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
27
|
-
"ci:build:docs": "api-extractor run
|
|
27
|
+
"ci:build:docs": "api-extractor run",
|
|
28
28
|
"clean": "rimraf dist *.tsbuildinfo *.build.log",
|
|
29
29
|
"eslint": "eslint --format stylish src",
|
|
30
30
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
@@ -42,9 +42,10 @@
|
|
|
42
42
|
"uuid": "^8.3.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@fluidframework/azure-service-utils-previous": "npm:@fluidframework/azure-service-utils@0.59.
|
|
45
|
+
"@fluidframework/azure-service-utils-previous": "npm:@fluidframework/azure-service-utils@0.59.2000",
|
|
46
46
|
"@fluidframework/build-common": "^0.23.0",
|
|
47
|
-
"@fluidframework/
|
|
47
|
+
"@fluidframework/build-tools": "^0.2.70857",
|
|
48
|
+
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
48
49
|
"@microsoft/api-extractor": "^7.22.2",
|
|
49
50
|
"@rushstack/eslint-config": "^2.5.1",
|
|
50
51
|
"@types/jsrsasign": "^8.0.8",
|
|
@@ -57,17 +58,19 @@
|
|
|
57
58
|
"eslint-plugin-eslint-comments": "~3.2.0",
|
|
58
59
|
"eslint-plugin-import": "~2.25.4",
|
|
59
60
|
"eslint-plugin-jest": "~26.1.3",
|
|
61
|
+
"eslint-plugin-jsdoc": "~39.3.0",
|
|
60
62
|
"eslint-plugin-mocha": "~10.0.3",
|
|
61
63
|
"eslint-plugin-promise": "~6.0.0",
|
|
62
64
|
"eslint-plugin-react": "~7.28.0",
|
|
63
65
|
"eslint-plugin-tsdoc": "~0.2.14",
|
|
64
66
|
"eslint-plugin-unicorn": "~40.0.0",
|
|
67
|
+
"eslint-plugin-unused-imports": "~2.0.0",
|
|
65
68
|
"rimraf": "^2.6.2",
|
|
66
|
-
"typescript": "~4.
|
|
69
|
+
"typescript": "~4.5.5",
|
|
67
70
|
"typescript-formatter": "7.1.0"
|
|
68
71
|
},
|
|
69
72
|
"typeValidation": {
|
|
70
|
-
"version": "0.59.
|
|
73
|
+
"version": "0.59.3000",
|
|
71
74
|
"broken": {}
|
|
72
75
|
}
|
|
73
76
|
}
|
package/src/generateToken.ts
CHANGED
|
@@ -8,11 +8,25 @@ import { KJUR as jsrsasign } from "jsrsasign";
|
|
|
8
8
|
import { v4 as uuid } from "uuid";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* IMPORTANT: This function is duplicated in ./packages/runtime/test-runtime-utils/src/generateToken.ts. There is no
|
|
12
|
+
* need for different implementations, so they should be kept in sync if changes are needed.
|
|
13
|
+
*
|
|
14
|
+
* The reason they are duplicated is because we don't want the core Fluid libraries depending on the Azure libraries
|
|
15
|
+
* (enforced by layer-check), but both need to expose this function. The test-runtime-utils library is a test lib, which
|
|
16
|
+
* layer-check (correctly) reuires only be used as a dev dependency. But in the azure case, we want the function
|
|
17
|
+
* exported, so it needs to be sourced from either the package itself or a non-dev dependency.
|
|
18
|
+
*
|
|
19
|
+
* The previous solution to this was to import the function from azure-service-utils into test-runtime-utils, but that
|
|
20
|
+
* no longer works because the azure packages are in a separate release group.
|
|
21
|
+
*
|
|
22
|
+
* If a token needs to be generated on the client side, you should re-use this function. If you need service-side token
|
|
23
|
+
* generation, you should use the function available in the server-services-client package in order to avoid
|
|
24
|
+
* interdependencies between service and client packages.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generates a JWT token to authorize access to a Routerlicious-based Fluid service. This function uses a browser
|
|
29
|
+
* friendly auth library (jsrsasign) and should only be used in client (browser) context.
|
|
16
30
|
*/
|
|
17
31
|
export function generateToken(
|
|
18
32
|
tenantId: string,
|
|
@@ -31,7 +45,7 @@ export function generateToken(
|
|
|
31
45
|
const now = Math.round(Date.now() / 1000);
|
|
32
46
|
const docId = documentId ?? "";
|
|
33
47
|
|
|
34
|
-
const claims: ITokenClaims & { jti: string } = {
|
|
48
|
+
const claims: ITokenClaims & { jti: string; } = {
|
|
35
49
|
documentId: docId,
|
|
36
50
|
scopes,
|
|
37
51
|
tenantId,
|
package/src/packageVersion.ts
CHANGED