@fluidframework/azure-service-utils 2.53.0 → 2.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/azure-service-utils
2
2
 
3
+ ## 2.60.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.53.0
4
8
 
5
9
  Dependency updates only.
@@ -1,10 +1,10 @@
1
- ## Alpha API Report File for "@fluidframework/azure-service-utils"
1
+ ## Beta API Report File for "@fluidframework/azure-service-utils"
2
2
 
3
3
  > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
4
 
5
5
  ```ts
6
6
 
7
- // @alpha @legacy
7
+ // @beta @legacy
8
8
  export function generateToken(tenantId: string, key: string, scopes: ScopeType[], documentId?: string, user?: IUser, lifetime?: number, ver?: string): string;
9
9
 
10
10
  export { IUser }
@@ -45,7 +45,7 @@ import type { ScopeType } from "@fluidframework/driver-definitions/internal";
45
45
  * Default: `1.0`.
46
46
  *
47
47
  * @legacy
48
- * @alpha
48
+ * @beta
49
49
  */
50
50
  export declare function generateToken(tenantId: string, key: string, scopes: ScopeType[], documentId?: string, user?: IUser, lifetime?: number, ver?: string): string;
51
51
  /**
@@ -48,7 +48,7 @@ const uuid_1 = require("uuid");
48
48
  * Default: `1.0`.
49
49
  *
50
50
  * @legacy
51
- * @alpha
51
+ * @beta
52
52
  */
53
53
  function generateToken(tenantId, key, scopes, documentId, user, lifetime = 60 * 60,
54
54
  // Naming intended to match `ITokenClaims.ver`
@@ -1 +1 @@
1
- {"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,yCAA8C;AAC9C,+BAAkC;AAElC;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,aAAa,CAC5B,QAAgB,EAChB,GAAW,EACX,MAAmB,EACnB,UAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE;AAC1B,8CAA8C;AAC9C,yDAAyD;AACzD,MAAc,KAAK;IAEnB,IAAI,SAAS,GAAG,IAAI,IAAI,YAAY,EAAE,CAAC;IACvC,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACvD,SAAS,GAAG,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAmC;QAC9C,UAAU,EAAE,UAAU,IAAI,EAAE;QAC5B,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;KACX,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAE9B,OAAO,gBAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;IAC5B,yBAAyB;IACzB,2CAA2C;IAC3C,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAxCD,sCAwCC;AAED;;;GAGG;AACH,SAAgB,YAAY;IAC3B,MAAM,UAAU,GAAG;QAClB,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,IAAI,EAAE,IAAA,SAAI,GAAE;KACZ,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC;AAPD,oCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { ITokenClaims, ScopeType } from \"@fluidframework/driver-definitions/internal\";\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 {@link https://en.wikipedia.org/wiki/JSON_Web_Token | JSON Web Token} (JWT)\n * to authorize access to a Routerlicious-based Fluid service.\n *\n * @remarks Note: this function uses a browser friendly auth library\n * ({@link https://www.npmjs.com/package/jsrsasign | jsrsasign}) and may only be used in client (browser) context.\n * It is **not** Node.js-compatible.\n *\n * @param tenantId - See {@link @fluidframework/protocol-definitions#ITokenClaims.tenantId}\n * @param key - API key to authenticate user. Must be {@link https://en.wikipedia.org/wiki/UTF-8 | UTF-8}-encoded.\n * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}\n * @param documentId - See {@link @fluidframework/protocol-definitions#ITokenClaims.documentId}.\n * If not specified, the token will not be associated with a document, and an empty string will be used.\n * @param user - User with whom generated tokens will be associated.\n * If not specified, the token will not be associated with a user, and a randomly generated mock user will be\n * used instead.\n * See {@link @fluidframework/protocol-definitions#ITokenClaims.user}\n * @param lifetime - Used to generate the {@link @fluidframework/protocol-definitions#ITokenClaims.exp | expiration}.\n * Expiration = now + lifetime.\n * Expressed in seconds.\n * Default: 3600 (1 hour).\n * @param ver - See {@link @fluidframework/protocol-definitions#ITokenClaims.ver}.\n * Default: `1.0`.\n *\n * @legacy\n * @alpha\n */\nexport function generateToken(\n\ttenantId: string,\n\tkey: string,\n\tscopes: ScopeType[],\n\tdocumentId?: string,\n\tuser?: IUser,\n\tlifetime: number = 60 * 60,\n\t// Naming intended to match `ITokenClaims.ver`\n\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\tver: string = \"1.0\",\n): string {\n\tlet userClaim = user ?? generateUser();\n\tif (userClaim.id === \"\" || userClaim.id === undefined) {\n\t\tuserClaim = generateUser();\n\t}\n\n\t// Current time in seconds\n\tconst now = Math.round(Date.now() / 1000);\n\n\tconst claims: ITokenClaims & { jti: string } = {\n\t\tdocumentId: documentId ?? \"\",\n\t\tscopes,\n\t\ttenantId,\n\t\tuser: userClaim,\n\t\tiat: now,\n\t\texp: now + lifetime,\n\t\tver,\n\t\tjti: uuid(),\n\t};\n\n\tconst utf8Key = { utf8: key };\n\n\treturn jsrsasign.jws.JWS.sign(\n\t\t// External API uses null\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\tnull,\n\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\tclaims,\n\t\tutf8Key,\n\t);\n}\n\n/**\n * Generates an arbitrary (\"random\") {@link @fluidframework/protocol-definitions#IUser} by generating a\n * random UUID for its {@link @fluidframework/protocol-definitions#IUser.id} and `name` properties.\n */\nexport function generateUser(): IUser {\n\tconst randomUser = {\n\t\tid: uuid(),\n\t\tname: uuid(),\n\t};\n\n\treturn randomUser;\n}\n"]}
1
+ {"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,yCAA8C;AAC9C,+BAAkC;AAElC;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,aAAa,CAC5B,QAAgB,EAChB,GAAW,EACX,MAAmB,EACnB,UAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE;AAC1B,8CAA8C;AAC9C,yDAAyD;AACzD,MAAc,KAAK;IAEnB,IAAI,SAAS,GAAG,IAAI,IAAI,YAAY,EAAE,CAAC;IACvC,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACvD,SAAS,GAAG,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAmC;QAC9C,UAAU,EAAE,UAAU,IAAI,EAAE;QAC5B,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;KACX,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAE9B,OAAO,gBAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;IAC5B,yBAAyB;IACzB,2CAA2C;IAC3C,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAxCD,sCAwCC;AAED;;;GAGG;AACH,SAAgB,YAAY;IAC3B,MAAM,UAAU,GAAG;QAClB,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,IAAI,EAAE,IAAA,SAAI,GAAE;KACZ,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC;AAPD,oCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { ITokenClaims, ScopeType } from \"@fluidframework/driver-definitions/internal\";\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 {@link https://en.wikipedia.org/wiki/JSON_Web_Token | JSON Web Token} (JWT)\n * to authorize access to a Routerlicious-based Fluid service.\n *\n * @remarks Note: this function uses a browser friendly auth library\n * ({@link https://www.npmjs.com/package/jsrsasign | jsrsasign}) and may only be used in client (browser) context.\n * It is **not** Node.js-compatible.\n *\n * @param tenantId - See {@link @fluidframework/protocol-definitions#ITokenClaims.tenantId}\n * @param key - API key to authenticate user. Must be {@link https://en.wikipedia.org/wiki/UTF-8 | UTF-8}-encoded.\n * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}\n * @param documentId - See {@link @fluidframework/protocol-definitions#ITokenClaims.documentId}.\n * If not specified, the token will not be associated with a document, and an empty string will be used.\n * @param user - User with whom generated tokens will be associated.\n * If not specified, the token will not be associated with a user, and a randomly generated mock user will be\n * used instead.\n * See {@link @fluidframework/protocol-definitions#ITokenClaims.user}\n * @param lifetime - Used to generate the {@link @fluidframework/protocol-definitions#ITokenClaims.exp | expiration}.\n * Expiration = now + lifetime.\n * Expressed in seconds.\n * Default: 3600 (1 hour).\n * @param ver - See {@link @fluidframework/protocol-definitions#ITokenClaims.ver}.\n * Default: `1.0`.\n *\n * @legacy\n * @beta\n */\nexport function generateToken(\n\ttenantId: string,\n\tkey: string,\n\tscopes: ScopeType[],\n\tdocumentId?: string,\n\tuser?: IUser,\n\tlifetime: number = 60 * 60,\n\t// Naming intended to match `ITokenClaims.ver`\n\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\tver: string = \"1.0\",\n): string {\n\tlet userClaim = user ?? generateUser();\n\tif (userClaim.id === \"\" || userClaim.id === undefined) {\n\t\tuserClaim = generateUser();\n\t}\n\n\t// Current time in seconds\n\tconst now = Math.round(Date.now() / 1000);\n\n\tconst claims: ITokenClaims & { jti: string } = {\n\t\tdocumentId: documentId ?? \"\",\n\t\tscopes,\n\t\ttenantId,\n\t\tuser: userClaim,\n\t\tiat: now,\n\t\texp: now + lifetime,\n\t\tver,\n\t\tjti: uuid(),\n\t};\n\n\tconst utf8Key = { utf8: key };\n\n\treturn jsrsasign.jws.JWS.sign(\n\t\t// External API uses null\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\tnull,\n\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\tclaims,\n\t\tutf8Key,\n\t);\n}\n\n/**\n * Generates an arbitrary (\"random\") {@link @fluidframework/protocol-definitions#IUser} by generating a\n * random UUID for its {@link @fluidframework/protocol-definitions#IUser.id} and `name` properties.\n */\nexport function generateUser(): IUser {\n\tconst randomUser = {\n\t\tid: uuid(),\n\t\tname: uuid(),\n\t};\n\n\treturn randomUser;\n}\n"]}
@@ -45,7 +45,7 @@ import type { ScopeType } from "@fluidframework/driver-definitions/internal";
45
45
  * Default: `1.0`.
46
46
  *
47
47
  * @legacy
48
- * @alpha
48
+ * @beta
49
49
  */
50
50
  export declare function generateToken(tenantId: string, key: string, scopes: ScopeType[], documentId?: string, user?: IUser, lifetime?: number, ver?: string): string;
51
51
  /**
@@ -45,7 +45,7 @@ import { v4 as uuid } from "uuid";
45
45
  * Default: `1.0`.
46
46
  *
47
47
  * @legacy
48
- * @alpha
48
+ * @beta
49
49
  */
50
50
  export function generateToken(tenantId, key, scopes, documentId, user, lifetime = 60 * 60,
51
51
  // Naming intended to match `ITokenClaims.ver`
@@ -1 +1 @@
1
- {"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,aAAa,CAC5B,QAAgB,EAChB,GAAW,EACX,MAAmB,EACnB,UAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE;AAC1B,8CAA8C;AAC9C,yDAAyD;AACzD,MAAc,KAAK;IAEnB,IAAI,SAAS,GAAG,IAAI,IAAI,YAAY,EAAE,CAAC;IACvC,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACvD,SAAS,GAAG,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAmC;QAC9C,UAAU,EAAE,UAAU,IAAI,EAAE;QAC5B,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,QAAQ;QACnB,GAAG;QACH,GAAG,EAAE,IAAI,EAAE;KACX,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAE9B,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;IAC5B,yBAAyB;IACzB,2CAA2C;IAC3C,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC3B,MAAM,UAAU,GAAG;QAClB,EAAE,EAAE,IAAI,EAAE;QACV,IAAI,EAAE,IAAI,EAAE;KACZ,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { ITokenClaims, ScopeType } from \"@fluidframework/driver-definitions/internal\";\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 {@link https://en.wikipedia.org/wiki/JSON_Web_Token | JSON Web Token} (JWT)\n * to authorize access to a Routerlicious-based Fluid service.\n *\n * @remarks Note: this function uses a browser friendly auth library\n * ({@link https://www.npmjs.com/package/jsrsasign | jsrsasign}) and may only be used in client (browser) context.\n * It is **not** Node.js-compatible.\n *\n * @param tenantId - See {@link @fluidframework/protocol-definitions#ITokenClaims.tenantId}\n * @param key - API key to authenticate user. Must be {@link https://en.wikipedia.org/wiki/UTF-8 | UTF-8}-encoded.\n * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}\n * @param documentId - See {@link @fluidframework/protocol-definitions#ITokenClaims.documentId}.\n * If not specified, the token will not be associated with a document, and an empty string will be used.\n * @param user - User with whom generated tokens will be associated.\n * If not specified, the token will not be associated with a user, and a randomly generated mock user will be\n * used instead.\n * See {@link @fluidframework/protocol-definitions#ITokenClaims.user}\n * @param lifetime - Used to generate the {@link @fluidframework/protocol-definitions#ITokenClaims.exp | expiration}.\n * Expiration = now + lifetime.\n * Expressed in seconds.\n * Default: 3600 (1 hour).\n * @param ver - See {@link @fluidframework/protocol-definitions#ITokenClaims.ver}.\n * Default: `1.0`.\n *\n * @legacy\n * @alpha\n */\nexport function generateToken(\n\ttenantId: string,\n\tkey: string,\n\tscopes: ScopeType[],\n\tdocumentId?: string,\n\tuser?: IUser,\n\tlifetime: number = 60 * 60,\n\t// Naming intended to match `ITokenClaims.ver`\n\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\tver: string = \"1.0\",\n): string {\n\tlet userClaim = user ?? generateUser();\n\tif (userClaim.id === \"\" || userClaim.id === undefined) {\n\t\tuserClaim = generateUser();\n\t}\n\n\t// Current time in seconds\n\tconst now = Math.round(Date.now() / 1000);\n\n\tconst claims: ITokenClaims & { jti: string } = {\n\t\tdocumentId: documentId ?? \"\",\n\t\tscopes,\n\t\ttenantId,\n\t\tuser: userClaim,\n\t\tiat: now,\n\t\texp: now + lifetime,\n\t\tver,\n\t\tjti: uuid(),\n\t};\n\n\tconst utf8Key = { utf8: key };\n\n\treturn jsrsasign.jws.JWS.sign(\n\t\t// External API uses null\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\tnull,\n\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\tclaims,\n\t\tutf8Key,\n\t);\n}\n\n/**\n * Generates an arbitrary (\"random\") {@link @fluidframework/protocol-definitions#IUser} by generating a\n * random UUID for its {@link @fluidframework/protocol-definitions#IUser.id} and `name` properties.\n */\nexport function generateUser(): IUser {\n\tconst randomUser = {\n\t\tid: uuid(),\n\t\tname: uuid(),\n\t};\n\n\treturn randomUser;\n}\n"]}
1
+ {"version":3,"file":"generateToken.js","sourceRoot":"","sources":["../src/generateToken.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,aAAa,CAC5B,QAAgB,EAChB,GAAW,EACX,MAAmB,EACnB,UAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE;AAC1B,8CAA8C;AAC9C,yDAAyD;AACzD,MAAc,KAAK;IAEnB,IAAI,SAAS,GAAG,IAAI,IAAI,YAAY,EAAE,CAAC;IACvC,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACvD,SAAS,GAAG,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAmC;QAC9C,UAAU,EAAE,UAAU,IAAI,EAAE;QAC5B,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,QAAQ;QACnB,GAAG;QACH,GAAG,EAAE,IAAI,EAAE;KACX,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAE9B,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;IAC5B,yBAAyB;IACzB,2CAA2C;IAC3C,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC3B,MAAM,UAAU,GAAG;QAClB,EAAE,EAAE,IAAI,EAAE;QACV,IAAI,EAAE,IAAI,EAAE;KACZ,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { ITokenClaims, ScopeType } from \"@fluidframework/driver-definitions/internal\";\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 {@link https://en.wikipedia.org/wiki/JSON_Web_Token | JSON Web Token} (JWT)\n * to authorize access to a Routerlicious-based Fluid service.\n *\n * @remarks Note: this function uses a browser friendly auth library\n * ({@link https://www.npmjs.com/package/jsrsasign | jsrsasign}) and may only be used in client (browser) context.\n * It is **not** Node.js-compatible.\n *\n * @param tenantId - See {@link @fluidframework/protocol-definitions#ITokenClaims.tenantId}\n * @param key - API key to authenticate user. Must be {@link https://en.wikipedia.org/wiki/UTF-8 | UTF-8}-encoded.\n * @param scopes - See {@link @fluidframework/protocol-definitions#ITokenClaims.scopes}\n * @param documentId - See {@link @fluidframework/protocol-definitions#ITokenClaims.documentId}.\n * If not specified, the token will not be associated with a document, and an empty string will be used.\n * @param user - User with whom generated tokens will be associated.\n * If not specified, the token will not be associated with a user, and a randomly generated mock user will be\n * used instead.\n * See {@link @fluidframework/protocol-definitions#ITokenClaims.user}\n * @param lifetime - Used to generate the {@link @fluidframework/protocol-definitions#ITokenClaims.exp | expiration}.\n * Expiration = now + lifetime.\n * Expressed in seconds.\n * Default: 3600 (1 hour).\n * @param ver - See {@link @fluidframework/protocol-definitions#ITokenClaims.ver}.\n * Default: `1.0`.\n *\n * @legacy\n * @beta\n */\nexport function generateToken(\n\ttenantId: string,\n\tkey: string,\n\tscopes: ScopeType[],\n\tdocumentId?: string,\n\tuser?: IUser,\n\tlifetime: number = 60 * 60,\n\t// Naming intended to match `ITokenClaims.ver`\n\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\tver: string = \"1.0\",\n): string {\n\tlet userClaim = user ?? generateUser();\n\tif (userClaim.id === \"\" || userClaim.id === undefined) {\n\t\tuserClaim = generateUser();\n\t}\n\n\t// Current time in seconds\n\tconst now = Math.round(Date.now() / 1000);\n\n\tconst claims: ITokenClaims & { jti: string } = {\n\t\tdocumentId: documentId ?? \"\",\n\t\tscopes,\n\t\ttenantId,\n\t\tuser: userClaim,\n\t\tiat: now,\n\t\texp: now + lifetime,\n\t\tver,\n\t\tjti: uuid(),\n\t};\n\n\tconst utf8Key = { utf8: key };\n\n\treturn jsrsasign.jws.JWS.sign(\n\t\t// External API uses null\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\tnull,\n\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\tclaims,\n\t\tutf8Key,\n\t);\n}\n\n/**\n * Generates an arbitrary (\"random\") {@link @fluidframework/protocol-definitions#IUser} by generating a\n * random UUID for its {@link @fluidframework/protocol-definitions#IUser.id} and `name` properties.\n */\nexport function generateUser(): IUser {\n\tconst randomUser = {\n\t\tid: uuid(),\n\t\tname: uuid(),\n\t};\n\n\treturn randomUser;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/azure-service-utils",
3
- "version": "2.53.0",
3
+ "version": "2.60.0",
4
4
  "description": "Helper service-side utilities for connecting to Azure Fluid Relay service",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  "main": "lib/index.js",
48
48
  "types": "lib/public.d.ts",
49
49
  "dependencies": {
50
- "@fluidframework/driver-definitions": "~2.53.0",
50
+ "@fluidframework/driver-definitions": "~2.60.0",
51
51
  "jsrsasign": "^11.0.0",
52
52
  "uuid": "^11.1.0"
53
53
  },
@@ -55,10 +55,10 @@
55
55
  "@arethetypeswrong/cli": "^0.17.1",
56
56
  "@biomejs/biome": "~1.9.3",
57
57
  "@fluid-tools/build-cli": "^0.57.0",
58
- "@fluidframework/azure-service-utils-previous": "npm:@fluidframework/azure-service-utils@2.52.0",
58
+ "@fluidframework/azure-service-utils-previous": "npm:@fluidframework/azure-service-utils@2.53.0",
59
59
  "@fluidframework/build-common": "^2.0.3",
60
60
  "@fluidframework/build-tools": "^0.57.0",
61
- "@fluidframework/eslint-config-fluid": "^5.7.4",
61
+ "@fluidframework/eslint-config-fluid": "^6.0.0",
62
62
  "@microsoft/api-extractor": "7.52.8",
63
63
  "@types/jsrsasign": "^10.5.12",
64
64
  "concurrently": "^8.2.1",
@@ -50,7 +50,7 @@ import { v4 as uuid } from "uuid";
50
50
  * Default: `1.0`.
51
51
  *
52
52
  * @legacy
53
- * @alpha
53
+ * @beta
54
54
  */
55
55
  export function generateToken(
56
56
  tenantId: string,