@azure/communication-common 2.4.2-alpha.20260211.1 → 2.5.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/README.md +47 -1
- package/dist/browser/autoRefreshTokenCredential.d.ts +20 -4
- package/dist/browser/autoRefreshTokenCredential.d.ts.map +1 -1
- package/dist/browser/autoRefreshTokenCredential.js +13 -4
- package/dist/browser/autoRefreshTokenCredential.js.map +1 -1
- package/dist/browser/azureCommunicationTokenCredential.d.ts +3 -2
- package/dist/browser/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/browser/azureCommunicationTokenCredential.js +3 -2
- package/dist/browser/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/browser/credential/communicationAccessKeyCredentialPolicy.d.ts.map +1 -1
- package/dist/browser/credential/communicationAccessKeyCredentialPolicy.js +6 -10
- package/dist/browser/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/browser/entraTokenCredential.d.ts.map +1 -1
- package/dist/browser/entraTokenCredential.js +12 -7
- package/dist/browser/entraTokenCredential.js.map +1 -1
- package/dist/browser/index.d.ts +4 -3
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/logger.d.ts +3 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/dist/browser/logger.js +6 -0
- package/dist/browser/logger.js.map +1 -0
- package/dist/browser/tokenParser.d.ts +9 -1
- package/dist/browser/tokenParser.d.ts.map +1 -1
- package/dist/browser/tokenParser.js +64 -3
- package/dist/browser/tokenParser.js.map +1 -1
- package/dist/commonjs/autoRefreshTokenCredential.d.ts +20 -4
- package/dist/commonjs/autoRefreshTokenCredential.d.ts.map +1 -1
- package/dist/commonjs/autoRefreshTokenCredential.js +118 -95
- package/dist/commonjs/autoRefreshTokenCredential.js.map +7 -1
- package/dist/commonjs/azureCommunicationTokenCredential.d.ts +3 -2
- package/dist/commonjs/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/commonjs/azureCommunicationTokenCredential.js +64 -47
- package/dist/commonjs/azureCommunicationTokenCredential.js.map +7 -1
- package/dist/commonjs/communicationTokenCredential.js +16 -5
- package/dist/commonjs/communicationTokenCredential.js.map +7 -1
- package/dist/commonjs/credential/clientArguments.js +46 -40
- package/dist/commonjs/credential/clientArguments.js.map +7 -1
- package/dist/commonjs/credential/communicationAccessKeyCredentialPolicy.d.ts.map +1 -1
- package/dist/commonjs/credential/communicationAccessKeyCredentialPolicy.js +53 -42
- package/dist/commonjs/credential/communicationAccessKeyCredentialPolicy.js.map +7 -1
- package/dist/commonjs/credential/communicationAuthPolicy.js +39 -26
- package/dist/commonjs/credential/communicationAuthPolicy.js.map +7 -1
- package/dist/commonjs/credential/connectionString.js +39 -28
- package/dist/commonjs/credential/connectionString.js.map +7 -1
- package/dist/commonjs/credential/index.js +28 -10
- package/dist/commonjs/credential/index.js.map +7 -1
- package/dist/commonjs/entraTokenCredential.d.ts.map +1 -1
- package/dist/commonjs/entraTokenCredential.js +137 -113
- package/dist/commonjs/entraTokenCredential.js.map +7 -1
- package/dist/commonjs/identifierModelSerializer.js +172 -159
- package/dist/commonjs/identifierModelSerializer.js.map +7 -1
- package/dist/commonjs/identifierModels.js +183 -205
- package/dist/commonjs/identifierModels.js.map +7 -1
- package/dist/commonjs/index.d.ts +4 -3
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +40 -12
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/logger.d.ts +3 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +29 -0
- package/dist/commonjs/logger.js.map +7 -0
- package/dist/commonjs/staticTokenCredential.js +36 -20
- package/dist/commonjs/staticTokenCredential.js.map +7 -1
- package/dist/commonjs/tokenParser.d.ts +9 -1
- package/dist/commonjs/tokenParser.d.ts.map +1 -1
- package/dist/commonjs/tokenParser.js +71 -13
- package/dist/commonjs/tokenParser.js.map +7 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/esm/autoRefreshTokenCredential.d.ts +20 -4
- package/dist/esm/autoRefreshTokenCredential.d.ts.map +1 -1
- package/dist/esm/autoRefreshTokenCredential.js +13 -4
- package/dist/esm/autoRefreshTokenCredential.js.map +1 -1
- package/dist/esm/azureCommunicationTokenCredential.d.ts +3 -2
- package/dist/esm/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/esm/azureCommunicationTokenCredential.js +3 -2
- package/dist/esm/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/esm/credential/communicationAccessKeyCredentialPolicy.d.ts.map +1 -1
- package/dist/esm/credential/communicationAccessKeyCredentialPolicy.js +6 -10
- package/dist/esm/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/esm/entraTokenCredential.d.ts.map +1 -1
- package/dist/esm/entraTokenCredential.js +12 -7
- package/dist/esm/entraTokenCredential.js.map +1 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.d.ts +3 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +6 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/tokenParser.d.ts +9 -1
- package/dist/esm/tokenParser.d.ts.map +1 -1
- package/dist/esm/tokenParser.js +64 -3
- package/dist/esm/tokenParser.js.map +1 -1
- package/dist/react-native/autoRefreshTokenCredential.d.ts +20 -4
- package/dist/react-native/autoRefreshTokenCredential.d.ts.map +1 -1
- package/dist/react-native/autoRefreshTokenCredential.js +13 -4
- package/dist/react-native/autoRefreshTokenCredential.js.map +1 -1
- package/dist/react-native/azureCommunicationTokenCredential.d.ts +3 -2
- package/dist/react-native/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/react-native/azureCommunicationTokenCredential.js +3 -2
- package/dist/react-native/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/react-native/credential/communicationAccessKeyCredentialPolicy.d.ts.map +1 -1
- package/dist/react-native/credential/communicationAccessKeyCredentialPolicy.js +6 -10
- package/dist/react-native/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/react-native/entraTokenCredential.d.ts.map +1 -1
- package/dist/react-native/entraTokenCredential.js +12 -7
- package/dist/react-native/entraTokenCredential.js.map +1 -1
- package/dist/react-native/index.d.ts +4 -3
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +1 -0
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/logger.d.ts +3 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +6 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/tokenParser.d.ts +9 -1
- package/dist/react-native/tokenParser.d.ts.map +1 -1
- package/dist/react-native/tokenParser.js +64 -3
- package/dist/react-native/tokenParser.js.map +1 -1
- package/package.json +34 -41
- package/dist/browser/credential/cryptoUtils-browser.d.mts.map +0 -1
- package/dist/browser/credential/cryptoUtils-browser.mjs.map +0 -1
- package/dist/browser/credential/cryptoUtils.d.ts +0 -3
- package/dist/browser/credential/cryptoUtils.js +0 -19
- package/dist/browser/credential/encodeUtils-browser.d.mts +0 -4
- package/dist/browser/credential/encodeUtils-browser.d.mts.map +0 -1
- package/dist/browser/credential/encodeUtils-browser.mjs +0 -19
- package/dist/browser/credential/encodeUtils-browser.mjs.map +0 -1
- package/dist/commonjs/credential/cryptoUtils.d.ts +0 -3
- package/dist/commonjs/credential/cryptoUtils.d.ts.map +0 -1
- package/dist/commonjs/credential/cryptoUtils.js +0 -14
- package/dist/commonjs/credential/cryptoUtils.js.map +0 -1
- package/dist/esm/credential/cryptoUtils.d.ts +0 -3
- package/dist/esm/credential/cryptoUtils.d.ts.map +0 -1
- package/dist/esm/credential/cryptoUtils.js +0 -9
- package/dist/esm/credential/cryptoUtils.js.map +0 -1
- package/dist/esm/credential/encodeUtils-browser.d.mts +0 -4
- package/dist/esm/credential/encodeUtils-browser.d.mts.map +0 -1
- package/dist/esm/credential/encodeUtils-browser.mjs +0 -19
- package/dist/esm/credential/encodeUtils-browser.mjs.map +0 -1
- package/dist/react-native/credential/cryptoUtils.d.ts +0 -3
- package/dist/react-native/credential/cryptoUtils.d.ts.map +0 -1
- package/dist/react-native/credential/cryptoUtils.js +0 -9
- package/dist/react-native/credential/cryptoUtils.js.map +0 -1
- package/dist/react-native/credential/encodeUtils-browser.d.mts +0 -4
- package/dist/react-native/credential/encodeUtils-browser.d.mts.map +0 -1
- package/dist/react-native/credential/encodeUtils-browser.mjs +0 -19
- package/dist/react-native/credential/encodeUtils-browser.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAG3F,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n CommunicationTokenCredential,\n CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nexport { AzureCommunicationTokenCredential } from \"./azureCommunicationTokenCredential.js\";\nexport { CommunicationTokenRefreshOptions } from \"./autoRefreshTokenCredential.js\";\nexport { EntraCommunicationTokenCredentialOptions } from \"./entraTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport * from \"./identifierModels.js\";\nexport * from \"./identifierModelSerializer.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAG3F,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport type {\n CommunicationTokenCredential,\n CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nexport { AzureCommunicationTokenCredential } from \"./azureCommunicationTokenCredential.js\";\nexport type { CommunicationTokenRefreshOptions } from \"./autoRefreshTokenCredential.js\";\nexport type { EntraCommunicationTokenCredentialOptions } from \"./entraTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport * from \"./identifierModels.js\";\nexport * from \"./identifierModelSerializer.js\";\nexport { RestError, isRestError } from \"@azure/core-rest-pipeline\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAKA,yDAAyD;AACzD,eAAO,MAAM,MAAM,qCAA6C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { createClientLogger } from "@azure/logger";
|
|
4
|
+
/** The `@azure/logger` instance used by this package. */
|
|
5
|
+
export const logger = createClientLogger("communication-common");
|
|
6
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,yDAAyD;AACzD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/** The `@azure/logger` instance used by this package. */\nexport const logger = createClientLogger(\"communication-common\");\n"]}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { AccessToken } from "@azure/core-auth";
|
|
2
|
-
|
|
2
|
+
/** Type guard for a caller-supplied {@link AccessToken} (carries a valid explicit expiry). */
|
|
3
|
+
export declare const isAccessToken: (value: unknown) => value is AccessToken;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a token into an {@link AccessToken}. Expiry is taken from a caller-supplied
|
|
6
|
+
* `AccessToken` if present, otherwise from the JWT `exp` claim. A token that cannot be decoded
|
|
7
|
+
* (e.g. an encrypted/opaque token) or that lacks a usable `exp` is accepted as-is with a fallback
|
|
8
|
+
* expiry of `now + undecodableTokenExpiryIntervalInSeconds`; an empty/blank token throws.
|
|
9
|
+
*/
|
|
10
|
+
export declare const parseToken: (token: string | AccessToken, undecodableTokenExpiryIntervalInSeconds?: number) => AccessToken;
|
|
3
11
|
//# sourceMappingURL=tokenParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenParser.d.ts","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"tokenParser.d.ts","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkBpD,8FAA8F;AAC9F,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,WAMI,CAAC;AA8B7D;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,GAAG,WAAW,EAC3B,0CAAyC,MAAuD,KAC/F,WA4BF,CAAC"}
|
|
@@ -1,11 +1,72 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { jwtDecode } from "jwt-decode";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { logger } from "./logger.js";
|
|
5
|
+
/**
|
|
6
|
+
* Default lifetime (in seconds) assumed for an encrypted/undecodable token when no expiry is
|
|
7
|
+
* supplied. Must stay in step with `defaultExpiringSoonInterval` (10 min) in
|
|
8
|
+
* autoRefreshTokenCredential.ts: the "refresh an opaque token at half-life" behavior relies on a
|
|
9
|
+
* fresh fallback token immediately landing in the expiring-soon window.
|
|
10
|
+
*/
|
|
11
|
+
const defaultUndecodableTokenExpiryIntervalInSeconds = 10 * 60;
|
|
12
|
+
let undecodableTokenWarningEmitted = false;
|
|
13
|
+
/** Type guard for a caller-supplied {@link AccessToken} (carries a valid explicit expiry). */
|
|
14
|
+
export const isAccessToken = (value) => typeof value === "object" &&
|
|
15
|
+
value !== null &&
|
|
16
|
+
typeof value.token === "string" &&
|
|
17
|
+
value.token.length > 0 &&
|
|
18
|
+
typeof value.expiresOnTimestamp === "number" &&
|
|
19
|
+
Number.isFinite(value.expiresOnTimestamp);
|
|
20
|
+
/**
|
|
21
|
+
* Accepts a token that can't be decoded (encrypted/opaque, or a JWT without a usable `exp`) and
|
|
22
|
+
* assigns a fallback expiry of `now + undecodableTokenExpiryIntervalInSeconds`. Emits a one-time
|
|
23
|
+
* warning; throws if the interval is not a positive, finite number.
|
|
24
|
+
*/
|
|
25
|
+
const resolveOpaqueToken = (token, undecodableTokenExpiryIntervalInSeconds) => {
|
|
26
|
+
if (!Number.isFinite(undecodableTokenExpiryIntervalInSeconds) ||
|
|
27
|
+
undecodableTokenExpiryIntervalInSeconds <= 0) {
|
|
28
|
+
throw new Error("undecodableTokenExpiryIntervalInSeconds must be a positive number.");
|
|
29
|
+
}
|
|
30
|
+
if (!undecodableTokenWarningEmitted) {
|
|
31
|
+
undecodableTokenWarningEmitted = true;
|
|
32
|
+
logger.warning(`Received a token that could not be decoded; treating it as opaque and assuming a ${undecodableTokenExpiryIntervalInSeconds}s lifetime. ` +
|
|
33
|
+
`Supply an AccessToken with an explicit expiry (e.g. from the token response 'expires_in') to control refresh scheduling.`);
|
|
34
|
+
}
|
|
6
35
|
return {
|
|
7
36
|
token,
|
|
8
|
-
expiresOnTimestamp:
|
|
37
|
+
expiresOnTimestamp: Date.now() + undecodableTokenExpiryIntervalInSeconds * 1000,
|
|
9
38
|
};
|
|
10
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Resolves a token into an {@link AccessToken}. Expiry is taken from a caller-supplied
|
|
42
|
+
* `AccessToken` if present, otherwise from the JWT `exp` claim. A token that cannot be decoded
|
|
43
|
+
* (e.g. an encrypted/opaque token) or that lacks a usable `exp` is accepted as-is with a fallback
|
|
44
|
+
* expiry of `now + undecodableTokenExpiryIntervalInSeconds`; an empty/blank token throws.
|
|
45
|
+
*/
|
|
46
|
+
export const parseToken = (token, undecodableTokenExpiryIntervalInSeconds = defaultUndecodableTokenExpiryIntervalInSeconds) => {
|
|
47
|
+
// Caller supplied an explicit expiry — use it as-is.
|
|
48
|
+
if (isAccessToken(token)) {
|
|
49
|
+
return token;
|
|
50
|
+
}
|
|
51
|
+
if (typeof token !== "string") {
|
|
52
|
+
throw new Error("Invalid token: expected a string or an AccessToken with a non-empty token and a finite expiresOnTimestamp.");
|
|
53
|
+
}
|
|
54
|
+
if (token.trim().length === 0) {
|
|
55
|
+
throw new Error("Invalid token: token must not be empty.");
|
|
56
|
+
}
|
|
57
|
+
// Prefer the expiry from a decodable JWT.
|
|
58
|
+
try {
|
|
59
|
+
const { exp } = jwtDecode(token);
|
|
60
|
+
if (typeof exp === "number" && Number.isFinite(exp)) {
|
|
61
|
+
return {
|
|
62
|
+
token,
|
|
63
|
+
expiresOnTimestamp: exp * 1000,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Not decodable — treated as an opaque token below.
|
|
69
|
+
}
|
|
70
|
+
return resolveOpaqueToken(token, undecodableTokenExpiryIntervalInSeconds);
|
|
71
|
+
};
|
|
11
72
|
//# sourceMappingURL=tokenParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenParser.js","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tokenParser.js","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC;;;;;GAKG;AACH,MAAM,8CAA8C,GAAG,EAAE,GAAG,EAAE,CAAC;AAE/D,IAAI,8BAA8B,GAAG,KAAK,CAAC;AAE3C,8FAA8F;AAC9F,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,OAAQ,KAAqB,CAAC,KAAK,KAAK,QAAQ;IAC/C,KAAqB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;IACvC,OAAQ,KAAqB,CAAC,kBAAkB,KAAK,QAAQ;IAC7D,MAAM,CAAC,QAAQ,CAAE,KAAqB,CAAC,kBAAkB,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CACzB,KAAa,EACb,uCAA+C,EAClC,EAAE;IACf,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,uCAAuC,CAAC;QACzD,uCAAuC,IAAI,CAAC,EAC5C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,IAAI,CAAC,8BAA8B,EAAE,CAAC;QACpC,8BAA8B,GAAG,IAAI,CAAC;QACtC,MAAM,CAAC,OAAO,CACZ,oFAAoF,uCAAuC,cAAc;YACvI,0HAA0H,CAC7H,CAAC;IACJ,CAAC;IACD,OAAO;QACL,KAAK;QACL,kBAAkB,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,uCAAuC,GAAG,IAAI;KAChF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAA2B,EAC3B,0CAAkD,8CAA8C,EACnF,EAAE;IACf,qDAAqD;IACrD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,0CAA0C;IAC1C,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAW,KAAK,CAAC,CAAC;QAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACpD,OAAO;gBACL,KAAK;gBACL,kBAAkB,EAAE,GAAG,GAAG,IAAI;aAC/B,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oDAAoD;IACtD,CAAC;IAED,OAAO,kBAAkB,CAAC,KAAK,EAAE,uCAAuC,CAAC,CAAC;AAC5E,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken } from \"@azure/core-auth\";\nimport { jwtDecode } from \"jwt-decode\";\nimport { logger } from \"./logger.js\";\n\ninterface JwtToken {\n exp: number;\n}\n\n/**\n * Default lifetime (in seconds) assumed for an encrypted/undecodable token when no expiry is\n * supplied. Must stay in step with `defaultExpiringSoonInterval` (10 min) in\n * autoRefreshTokenCredential.ts: the \"refresh an opaque token at half-life\" behavior relies on a\n * fresh fallback token immediately landing in the expiring-soon window.\n */\nconst defaultUndecodableTokenExpiryIntervalInSeconds = 10 * 60;\n\nlet undecodableTokenWarningEmitted = false;\n\n/** Type guard for a caller-supplied {@link AccessToken} (carries a valid explicit expiry). */\nexport const isAccessToken = (value: unknown): value is AccessToken =>\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as AccessToken).token === \"string\" &&\n (value as AccessToken).token.length > 0 &&\n typeof (value as AccessToken).expiresOnTimestamp === \"number\" &&\n Number.isFinite((value as AccessToken).expiresOnTimestamp);\n\n/**\n * Accepts a token that can't be decoded (encrypted/opaque, or a JWT without a usable `exp`) and\n * assigns a fallback expiry of `now + undecodableTokenExpiryIntervalInSeconds`. Emits a one-time\n * warning; throws if the interval is not a positive, finite number.\n */\nconst resolveOpaqueToken = (\n token: string,\n undecodableTokenExpiryIntervalInSeconds: number,\n): AccessToken => {\n if (\n !Number.isFinite(undecodableTokenExpiryIntervalInSeconds) ||\n undecodableTokenExpiryIntervalInSeconds <= 0\n ) {\n throw new Error(\"undecodableTokenExpiryIntervalInSeconds must be a positive number.\");\n }\n if (!undecodableTokenWarningEmitted) {\n undecodableTokenWarningEmitted = true;\n logger.warning(\n `Received a token that could not be decoded; treating it as opaque and assuming a ${undecodableTokenExpiryIntervalInSeconds}s lifetime. ` +\n `Supply an AccessToken with an explicit expiry (e.g. from the token response 'expires_in') to control refresh scheduling.`,\n );\n }\n return {\n token,\n expiresOnTimestamp: Date.now() + undecodableTokenExpiryIntervalInSeconds * 1000,\n };\n};\n\n/**\n * Resolves a token into an {@link AccessToken}. Expiry is taken from a caller-supplied\n * `AccessToken` if present, otherwise from the JWT `exp` claim. A token that cannot be decoded\n * (e.g. an encrypted/opaque token) or that lacks a usable `exp` is accepted as-is with a fallback\n * expiry of `now + undecodableTokenExpiryIntervalInSeconds`; an empty/blank token throws.\n */\nexport const parseToken = (\n token: string | AccessToken,\n undecodableTokenExpiryIntervalInSeconds: number = defaultUndecodableTokenExpiryIntervalInSeconds,\n): AccessToken => {\n // Caller supplied an explicit expiry — use it as-is.\n if (isAccessToken(token)) {\n return token;\n }\n if (typeof token !== \"string\") {\n throw new Error(\n \"Invalid token: expected a string or an AccessToken with a non-empty token and a finite expiresOnTimestamp.\",\n );\n }\n if (token.trim().length === 0) {\n throw new Error(\"Invalid token: token must not be empty.\");\n }\n\n // Prefer the expiry from a decodable JWT.\n try {\n const { exp } = jwtDecode<JwtToken>(token);\n if (typeof exp === \"number\" && Number.isFinite(exp)) {\n return {\n token,\n expiresOnTimestamp: exp * 1000,\n };\n }\n } catch {\n // Not decodable — treated as an opaque token below.\n }\n\n return resolveOpaqueToken(token, undecodableTokenExpiryIntervalInSeconds);\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/communication-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Common package for Azure Communication services.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "./dist/commonjs/index.js",
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
"README.md",
|
|
13
13
|
"LICENSE"
|
|
14
14
|
],
|
|
15
|
-
"repository":
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/Azure/azure-sdk-for-js",
|
|
18
|
+
"directory": "sdk/communication/communication-common"
|
|
19
|
+
},
|
|
16
20
|
"keywords": [
|
|
17
21
|
"azure",
|
|
18
22
|
"cloud",
|
|
@@ -26,59 +30,43 @@
|
|
|
26
30
|
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
|
27
31
|
},
|
|
28
32
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
33
|
+
"node": ">=22.0.0"
|
|
30
34
|
},
|
|
31
|
-
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-common/",
|
|
35
|
+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-common/README.md",
|
|
32
36
|
"sideEffects": false,
|
|
33
37
|
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
|
|
34
38
|
"dependencies": {
|
|
35
|
-
"@azure-rest/core-client": "
|
|
36
|
-
"@azure/abort-controller": "
|
|
37
|
-
"@azure/core-auth": "
|
|
38
|
-
"@azure/core-rest-pipeline": "
|
|
39
|
-
"@azure/core-tracing": "
|
|
40
|
-
"@azure/core-util": "
|
|
39
|
+
"@azure-rest/core-client": "^2.3.3",
|
|
40
|
+
"@azure/abort-controller": "^2.1.2",
|
|
41
|
+
"@azure/core-auth": "^1.9.0",
|
|
42
|
+
"@azure/core-rest-pipeline": "^1.17.0",
|
|
43
|
+
"@azure/core-tracing": "^1.2.0",
|
|
44
|
+
"@azure/core-util": "^1.11.0",
|
|
45
|
+
"@azure/logger": "^1.1.4",
|
|
41
46
|
"events": "^3.3.0",
|
|
42
47
|
"jwt-decode": "^4.0.0",
|
|
43
48
|
"tslib": "^2.8.1"
|
|
44
49
|
},
|
|
45
50
|
"devDependencies": {
|
|
46
51
|
"@azure/identity": "4.13.0",
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@vitest/
|
|
50
|
-
"@vitest/coverage-istanbul": "^4.0.8",
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
|
+
"@vitest/browser-playwright": "^4.1.2",
|
|
54
|
+
"@vitest/coverage-istanbul": "^4.1.2",
|
|
51
55
|
"cross-env": "^10.1.0",
|
|
52
|
-
"eslint": "^
|
|
56
|
+
"eslint": "^10.8.0",
|
|
53
57
|
"mockdate": "^3.0.5",
|
|
54
58
|
"nock": "^13.5.6",
|
|
55
|
-
"playwright": "^1.
|
|
56
|
-
"prettier": "^3.
|
|
59
|
+
"playwright": "^1.60.0",
|
|
60
|
+
"prettier": "^3.9.1",
|
|
61
|
+
"react-native": "^0.84.1",
|
|
57
62
|
"rimraf": "^6.1.0",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"@azure-tools/test-utils-vitest": "^2.0.1",
|
|
63
|
+
"typescript": "~6.0.2",
|
|
64
|
+
"vitest": "^4.1.2",
|
|
65
|
+
"@azure/dev-tool": "^1.0.0",
|
|
62
66
|
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
63
|
-
"@azure/
|
|
67
|
+
"@azure-tools/test-utils-vitest": "^2.0.1"
|
|
64
68
|
},
|
|
65
69
|
"type": "module",
|
|
66
|
-
"tshy": {
|
|
67
|
-
"exports": {
|
|
68
|
-
"./package.json": "./package.json",
|
|
69
|
-
".": "./src/index.ts"
|
|
70
|
-
},
|
|
71
|
-
"dialects": [
|
|
72
|
-
"esm",
|
|
73
|
-
"commonjs"
|
|
74
|
-
],
|
|
75
|
-
"esmDialects": [
|
|
76
|
-
"browser",
|
|
77
|
-
"react-native"
|
|
78
|
-
],
|
|
79
|
-
"selfLink": false,
|
|
80
|
-
"project": "../../../tsconfig.src.build.json"
|
|
81
|
-
},
|
|
82
70
|
"exports": {
|
|
83
71
|
"./package.json": "./package.json",
|
|
84
72
|
".": {
|
|
@@ -100,6 +88,11 @@
|
|
|
100
88
|
}
|
|
101
89
|
}
|
|
102
90
|
},
|
|
91
|
+
"imports": {
|
|
92
|
+
"#platform/*": {
|
|
93
|
+
"default": "./src/*.ts"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
103
96
|
"scripts": {
|
|
104
97
|
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
|
|
105
98
|
"build:samples": "echo Skipped.",
|
|
@@ -111,9 +104,9 @@
|
|
|
111
104
|
"lint": "eslint package.json src test",
|
|
112
105
|
"lint:fix": "eslint package.json src test --fix --fix-type [problem,suggestion]",
|
|
113
106
|
"pack": "pnpm pack 2>&1",
|
|
114
|
-
"test": "npm run test:node && npm run test:browser",
|
|
115
|
-
"test:browser": "
|
|
116
|
-
"test:node": "dev-tool run
|
|
107
|
+
"test": "tsc -b --noEmit && npm run test:node && npm run test:browser",
|
|
108
|
+
"test:browser": "dev-tool run test:vitest --no-test-proxy --browser",
|
|
109
|
+
"test:node": "dev-tool run test:vitest --no-test-proxy",
|
|
117
110
|
"test:node:live": "dev-tool run test:vitest --no-test-proxy",
|
|
118
111
|
"update-snippets": "dev-tool run update-snippets"
|
|
119
112
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils-browser.d.mts","sourceRoot":"","sources":["../../../src/credential/cryptoUtils-browser.mts"],"names":[],"mappings":"AASA,eAAO,MAAM,OAAO,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAI7D,CAAC;AAEF,eAAO,MAAM,OAAO,GAAU,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAO7E,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils-browser.mjs","sourceRoot":"","sources":["../../../src/credential/cryptoUtils-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,2BAA2B;AAE3B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;AAE9C,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,OAAe,EAAmB,EAAE;IAChE,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACxD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,MAAc,EAAE,OAAe,EAAmB,EAAE;IAChF,MAAM,YAAY,GAAqB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IACnF,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACjG,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IACnF,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"dom\" />\n\nimport { encodeBase64, encodeUTF8, encodeUTF8fromBase64 } from \"./encodeUtils-browser.mjs\";\n\nconst subtleCrypto = globalThis.crypto.subtle;\n\nexport const shaHash = async (content: string): Promise<string> => {\n const data = encodeUTF8(content);\n const hash = await subtleCrypto.digest(\"SHA-256\", data);\n return encodeBase64(hash);\n};\n\nexport const shaHMAC = async (secret: string, content: string): Promise<string> => {\n const importParams: HmacImportParams = { name: \"HMAC\", hash: { name: \"SHA-256\" } };\n const encodedMessage = encodeUTF8(content);\n const encodedKey = encodeUTF8fromBase64(secret);\n const cryptoKey = await subtleCrypto.importKey(\"raw\", encodedKey, importParams, false, [\"sign\"]);\n const signature = await subtleCrypto.sign(importParams, cryptoKey, encodedMessage);\n return encodeBase64(signature);\n};\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
/// <reference lib="dom" />
|
|
4
|
-
import { encodeBase64, encodeUTF8, encodeUTF8fromBase64 } from "./encodeUtils-browser.mjs";
|
|
5
|
-
const subtleCrypto = globalThis.crypto.subtle;
|
|
6
|
-
export const shaHash = async (content) => {
|
|
7
|
-
const data = encodeUTF8(content);
|
|
8
|
-
const hash = await subtleCrypto.digest("SHA-256", data);
|
|
9
|
-
return encodeBase64(hash);
|
|
10
|
-
};
|
|
11
|
-
export const shaHMAC = async (secret, content) => {
|
|
12
|
-
const importParams = { name: "HMAC", hash: { name: "SHA-256" } };
|
|
13
|
-
const encodedMessage = encodeUTF8(content);
|
|
14
|
-
const encodedKey = encodeUTF8fromBase64(secret);
|
|
15
|
-
const cryptoKey = await subtleCrypto.importKey("raw", encodedKey, importParams, false, ["sign"]);
|
|
16
|
-
const signature = await subtleCrypto.sign(importParams, cryptoKey, encodedMessage);
|
|
17
|
-
return encodeBase64(signature);
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=cryptoUtils-browser.mjs.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const encodeUTF8: (str: string) => Uint8Array<ArrayBuffer>;
|
|
2
|
-
export declare function encodeUTF8fromBase64(str: string): Uint8Array<ArrayBuffer>;
|
|
3
|
-
export declare function encodeBase64(value: ArrayBuffer): string;
|
|
4
|
-
//# sourceMappingURL=encodeUtils-browser.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encodeUtils-browser.d.mts","sourceRoot":"","sources":["../../../src/credential/encodeUtils-browser.mts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,UAAU,CAAC,WAAW,CAAkC,CAAC;AAElG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAMzE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
export const encodeUTF8 = (str) => new TextEncoder().encode(str);
|
|
4
|
-
export function encodeUTF8fromBase64(str) {
|
|
5
|
-
if (typeof atob !== "function") {
|
|
6
|
-
throw new Error("Your browser environment is missing the global `atob` function");
|
|
7
|
-
}
|
|
8
|
-
const binary = atob(str);
|
|
9
|
-
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
10
|
-
}
|
|
11
|
-
export function encodeBase64(value) {
|
|
12
|
-
if (typeof btoa !== "function") {
|
|
13
|
-
throw new Error("Your browser environment is missing the global `btoa` function");
|
|
14
|
-
}
|
|
15
|
-
const bytes = new Uint8Array(value);
|
|
16
|
-
const binary = String.fromCharCode.apply(null, [...bytes]);
|
|
17
|
-
return btoa(binary);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=encodeUtils-browser.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encodeUtils-browser.mjs","sourceRoot":"","sources":["../../../src/credential/encodeUtils-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAA2B,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAElG,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const encodeUTF8 = (str: string): Uint8Array<ArrayBuffer> => new TextEncoder().encode(str);\n\nexport function encodeUTF8fromBase64(str: string): Uint8Array<ArrayBuffer> {\n if (typeof atob !== \"function\") {\n throw new Error(\"Your browser environment is missing the global `atob` function\");\n }\n const binary = atob(str);\n return Uint8Array.from(binary, (char) => char.charCodeAt(0));\n}\n\nexport function encodeBase64(value: ArrayBuffer): string {\n if (typeof btoa !== \"function\") {\n throw new Error(\"Your browser environment is missing the global `btoa` function\");\n }\n const bytes = new Uint8Array(value);\n const binary = String.fromCharCode.apply(null, [...bytes]);\n return btoa(binary);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils.d.ts","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CACP,CAAC;AAExD,eAAO,MAAM,OAAO,GAAU,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAI7E,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT License.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.shaHMAC = exports.shaHash = void 0;
|
|
6
|
-
const node_crypto_1 = require("node:crypto");
|
|
7
|
-
const shaHash = async (content) => (0, node_crypto_1.createHash)("sha256").update(content).digest("base64");
|
|
8
|
-
exports.shaHash = shaHash;
|
|
9
|
-
const shaHMAC = async (secret, content) => {
|
|
10
|
-
const decodedSecret = Buffer.from(secret, "base64");
|
|
11
|
-
return (0, node_crypto_1.createHmac)("sha256", decodedSecret).update(content).digest("base64");
|
|
12
|
-
};
|
|
13
|
-
exports.shaHMAC = shaHMAC;
|
|
14
|
-
//# sourceMappingURL=cryptoUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils.js","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,6CAAqD;AAE9C,MAAM,OAAO,GAAG,KAAK,EAAE,OAAe,EAAmB,EAAE,CAChE,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAD3C,QAAA,OAAO,WACoC;AAEjD,MAAM,OAAO,GAAG,KAAK,EAAE,MAAc,EAAE,OAAe,EAAmB,EAAE;IAChF,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,OAAO,IAAA,wBAAU,EAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC,CAAC;AAJW,QAAA,OAAO,WAIlB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createHash, createHmac } from \"node:crypto\";\n\nexport const shaHash = async (content: string): Promise<string> =>\n createHash(\"sha256\").update(content).digest(\"base64\");\n\nexport const shaHMAC = async (secret: string, content: string): Promise<string> => {\n const decodedSecret = Buffer.from(secret, \"base64\");\n\n return createHmac(\"sha256\", decodedSecret).update(content).digest(\"base64\");\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils.d.ts","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CACP,CAAC;AAExD,eAAO,MAAM,OAAO,GAAU,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAI7E,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { createHash, createHmac } from "node:crypto";
|
|
4
|
-
export const shaHash = async (content) => createHash("sha256").update(content).digest("base64");
|
|
5
|
-
export const shaHMAC = async (secret, content) => {
|
|
6
|
-
const decodedSecret = Buffer.from(secret, "base64");
|
|
7
|
-
return createHmac("sha256", decodedSecret).update(content).digest("base64");
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=cryptoUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils.js","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,OAAe,EAAmB,EAAE,CAChE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,MAAc,EAAE,OAAe,EAAmB,EAAE;IAChF,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,OAAO,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createHash, createHmac } from \"node:crypto\";\n\nexport const shaHash = async (content: string): Promise<string> =>\n createHash(\"sha256\").update(content).digest(\"base64\");\n\nexport const shaHMAC = async (secret: string, content: string): Promise<string> => {\n const decodedSecret = Buffer.from(secret, \"base64\");\n\n return createHmac(\"sha256\", decodedSecret).update(content).digest(\"base64\");\n};\n"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const encodeUTF8: (str: string) => Uint8Array<ArrayBuffer>;
|
|
2
|
-
export declare function encodeUTF8fromBase64(str: string): Uint8Array<ArrayBuffer>;
|
|
3
|
-
export declare function encodeBase64(value: ArrayBuffer): string;
|
|
4
|
-
//# sourceMappingURL=encodeUtils-browser.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encodeUtils-browser.d.mts","sourceRoot":"","sources":["../../../src/credential/encodeUtils-browser.mts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,UAAU,CAAC,WAAW,CAAkC,CAAC;AAElG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAMzE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
export const encodeUTF8 = (str) => new TextEncoder().encode(str);
|
|
4
|
-
export function encodeUTF8fromBase64(str) {
|
|
5
|
-
if (typeof atob !== "function") {
|
|
6
|
-
throw new Error("Your browser environment is missing the global `atob` function");
|
|
7
|
-
}
|
|
8
|
-
const binary = atob(str);
|
|
9
|
-
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
10
|
-
}
|
|
11
|
-
export function encodeBase64(value) {
|
|
12
|
-
if (typeof btoa !== "function") {
|
|
13
|
-
throw new Error("Your browser environment is missing the global `btoa` function");
|
|
14
|
-
}
|
|
15
|
-
const bytes = new Uint8Array(value);
|
|
16
|
-
const binary = String.fromCharCode.apply(null, [...bytes]);
|
|
17
|
-
return btoa(binary);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=encodeUtils-browser.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encodeUtils-browser.mjs","sourceRoot":"","sources":["../../../src/credential/encodeUtils-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAA2B,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAElG,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const encodeUTF8 = (str: string): Uint8Array<ArrayBuffer> => new TextEncoder().encode(str);\n\nexport function encodeUTF8fromBase64(str: string): Uint8Array<ArrayBuffer> {\n if (typeof atob !== \"function\") {\n throw new Error(\"Your browser environment is missing the global `atob` function\");\n }\n const binary = atob(str);\n return Uint8Array.from(binary, (char) => char.charCodeAt(0));\n}\n\nexport function encodeBase64(value: ArrayBuffer): string {\n if (typeof btoa !== \"function\") {\n throw new Error(\"Your browser environment is missing the global `btoa` function\");\n }\n const bytes = new Uint8Array(value);\n const binary = String.fromCharCode.apply(null, [...bytes]);\n return btoa(binary);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils.d.ts","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CACP,CAAC;AAExD,eAAO,MAAM,OAAO,GAAU,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAI7E,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
import { createHash, createHmac } from "node:crypto";
|
|
4
|
-
export const shaHash = async (content) => createHash("sha256").update(content).digest("base64");
|
|
5
|
-
export const shaHMAC = async (secret, content) => {
|
|
6
|
-
const decodedSecret = Buffer.from(secret, "base64");
|
|
7
|
-
return createHmac("sha256", decodedSecret).update(content).digest("base64");
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=cryptoUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoUtils.js","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,OAAe,EAAmB,EAAE,CAChE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,MAAc,EAAE,OAAe,EAAmB,EAAE;IAChF,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,OAAO,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createHash, createHmac } from \"node:crypto\";\n\nexport const shaHash = async (content: string): Promise<string> =>\n createHash(\"sha256\").update(content).digest(\"base64\");\n\nexport const shaHMAC = async (secret: string, content: string): Promise<string> => {\n const decodedSecret = Buffer.from(secret, \"base64\");\n\n return createHmac(\"sha256\", decodedSecret).update(content).digest(\"base64\");\n};\n"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const encodeUTF8: (str: string) => Uint8Array<ArrayBuffer>;
|
|
2
|
-
export declare function encodeUTF8fromBase64(str: string): Uint8Array<ArrayBuffer>;
|
|
3
|
-
export declare function encodeBase64(value: ArrayBuffer): string;
|
|
4
|
-
//# sourceMappingURL=encodeUtils-browser.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encodeUtils-browser.d.mts","sourceRoot":"","sources":["../../../src/credential/encodeUtils-browser.mts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,UAAU,CAAC,WAAW,CAAkC,CAAC;AAElG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAMzE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
export const encodeUTF8 = (str) => new TextEncoder().encode(str);
|
|
4
|
-
export function encodeUTF8fromBase64(str) {
|
|
5
|
-
if (typeof atob !== "function") {
|
|
6
|
-
throw new Error("Your browser environment is missing the global `atob` function");
|
|
7
|
-
}
|
|
8
|
-
const binary = atob(str);
|
|
9
|
-
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
10
|
-
}
|
|
11
|
-
export function encodeBase64(value) {
|
|
12
|
-
if (typeof btoa !== "function") {
|
|
13
|
-
throw new Error("Your browser environment is missing the global `btoa` function");
|
|
14
|
-
}
|
|
15
|
-
const bytes = new Uint8Array(value);
|
|
16
|
-
const binary = String.fromCharCode.apply(null, [...bytes]);
|
|
17
|
-
return btoa(binary);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=encodeUtils-browser.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encodeUtils-browser.mjs","sourceRoot":"","sources":["../../../src/credential/encodeUtils-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAA2B,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAElG,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const encodeUTF8 = (str: string): Uint8Array<ArrayBuffer> => new TextEncoder().encode(str);\n\nexport function encodeUTF8fromBase64(str: string): Uint8Array<ArrayBuffer> {\n if (typeof atob !== \"function\") {\n throw new Error(\"Your browser environment is missing the global `atob` function\");\n }\n const binary = atob(str);\n return Uint8Array.from(binary, (char) => char.charCodeAt(0));\n}\n\nexport function encodeBase64(value: ArrayBuffer): string {\n if (typeof btoa !== \"function\") {\n throw new Error(\"Your browser environment is missing the global `btoa` function\");\n }\n const bytes = new Uint8Array(value);\n const binary = String.fromCharCode.apply(null, [...bytes]);\n return btoa(binary);\n}\n"]}
|