@auth0/ai 2.1.1 → 3.0.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/dist/cjs/authorizers/federated-connections/asyncLocalStorage.js +23 -1
- package/dist/cjs/authorizers/federated-connections/asyncLocalStorage.js.map +1 -1
- package/dist/cjs/authorizers/federated-connections/index.js +3 -2
- package/dist/cjs/authorizers/federated-connections/index.js.map +1 -1
- package/dist/esm/authorizers/federated-connections/asyncLocalStorage.d.ts +14 -0
- package/dist/esm/authorizers/federated-connections/asyncLocalStorage.js +21 -0
- package/dist/esm/authorizers/federated-connections/asyncLocalStorage.js.map +1 -1
- package/dist/esm/authorizers/federated-connections/index.d.ts +1 -1
- package/dist/esm/authorizers/federated-connections/index.js +1 -1
- package/dist/esm/authorizers/federated-connections/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCredentialsForConnection = exports.asyncLocalStorage = void 0;
|
|
3
|
+
exports.getAccessTokenForConnection = exports.getCredentialsForConnection = exports.asyncLocalStorage = void 0;
|
|
4
4
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
|
+
const interrupts_1 = require("../../interrupts");
|
|
5
6
|
exports.asyncLocalStorage = new node_async_hooks_1.AsyncLocalStorage();
|
|
7
|
+
/**
|
|
8
|
+
* Returns the entire tokenset for the current connection.
|
|
9
|
+
*
|
|
10
|
+
* Use `getAccessTokenForConnection` if you only need the access token.
|
|
11
|
+
*
|
|
12
|
+
* @returns {TokenSet} The current token set.
|
|
13
|
+
*/
|
|
6
14
|
const getCredentialsForConnection = () => {
|
|
7
15
|
const store = exports.asyncLocalStorage.getStore();
|
|
8
16
|
if (typeof store === "undefined") {
|
|
@@ -11,4 +19,18 @@ const getCredentialsForConnection = () => {
|
|
|
11
19
|
return store === null || store === void 0 ? void 0 : store.credentials;
|
|
12
20
|
};
|
|
13
21
|
exports.getCredentialsForConnection = getCredentialsForConnection;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* Get the access token for the current connection.
|
|
25
|
+
*
|
|
26
|
+
* @returns The access token for the current connection.
|
|
27
|
+
*/
|
|
28
|
+
const getAccessTokenForConnection = () => {
|
|
29
|
+
const credentials = (0, exports.getCredentialsForConnection)();
|
|
30
|
+
if (!credentials || !credentials.accessToken) {
|
|
31
|
+
throw new interrupts_1.FederatedConnectionError("No credentials found");
|
|
32
|
+
}
|
|
33
|
+
return credentials.accessToken;
|
|
34
|
+
};
|
|
35
|
+
exports.getAccessTokenForConnection = getAccessTokenForConnection;
|
|
14
36
|
//# sourceMappingURL=asyncLocalStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncLocalStorage.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/asyncLocalStorage.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;
|
|
1
|
+
{"version":3,"file":"asyncLocalStorage.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/asyncLocalStorage.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAGrD,iDAA4D;AA8B/C,QAAA,iBAAiB,GAAG,IAAI,oCAAiB,EAAqB,CAAC;AAE5E;;;;;;GAMG;AACI,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAC9C,MAAM,KAAK,GAAG,yBAAiB,CAAC,QAAQ,EAAE,CAAC;IAC3C,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,CAAC;AAC5B,CAAC,CAAC;AARW,QAAA,2BAA2B,+BAQtC;AAEF;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAC9C,MAAM,WAAW,GAAG,IAAA,mCAA2B,GAAE,CAAC;IAClD,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAC7C,MAAM,IAAI,qCAAwB,CAAC,sBAAsB,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,WAAW,CAAC,WAAW,CAAC;AACjC,CAAC,CAAC;AANW,QAAA,2BAA2B,+BAMtC","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport { TokenSet } from \"../../credentials\";\nimport { FederatedConnectionError } from \"../../interrupts\";\nimport { ToolCallContext } from \"../context\";\n\nexport type AsyncStorageValue = {\n /**\n * The Federated Connection access token.\n */\n credentials?: TokenSet;\n\n /**\n * The tool execution context.\n */\n context: ToolCallContext;\n\n /**\n * The federated connection name.\n */\n connection: string;\n\n /**\n * The scopes required to access the federated connection.\n */\n scopes: string[];\n\n /**\n * The scopes that the current access token has.\n */\n currentScopes?: string[];\n};\n\nexport const asyncLocalStorage = new AsyncLocalStorage<AsyncStorageValue>();\n\n/**\n * Returns the entire tokenset for the current connection.\n *\n * Use `getAccessTokenForConnection` if you only need the access token.\n *\n * @returns {TokenSet} The current token set.\n */\nexport const getCredentialsForConnection = () => {\n const store = asyncLocalStorage.getStore();\n if (typeof store === \"undefined\") {\n throw new Error(\n \"The tool must be wrapped with the withTokenForConnections function.\"\n );\n }\n return store?.credentials;\n};\n\n/**\n *\n * Get the access token for the current connection.\n *\n * @returns The access token for the current connection.\n */\nexport const getAccessTokenForConnection = () => {\n const credentials = getCredentialsForConnection();\n if (!credentials || !credentials.accessToken) {\n throw new FederatedConnectionError(\"No credentials found\");\n }\n return credentials.accessToken;\n};\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FederatedConnectionAuthorizerBase = exports.getAccessTokenForConnection = exports.asyncLocalStorage = void 0;
|
|
3
|
+
exports.FederatedConnectionAuthorizerBase = exports.getAccessTokenForConnection = exports.getCredentialsForConnection = exports.asyncLocalStorage = void 0;
|
|
4
4
|
var asyncLocalStorage_1 = require("./asyncLocalStorage");
|
|
5
5
|
Object.defineProperty(exports, "asyncLocalStorage", { enumerable: true, get: function () { return asyncLocalStorage_1.asyncLocalStorage; } });
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "getCredentialsForConnection", { enumerable: true, get: function () { return asyncLocalStorage_1.getCredentialsForConnection; } });
|
|
7
|
+
Object.defineProperty(exports, "getAccessTokenForConnection", { enumerable: true, get: function () { return asyncLocalStorage_1.getAccessTokenForConnection; } });
|
|
7
8
|
var FederatedConnectionAuthorizerBase_1 = require("./FederatedConnectionAuthorizerBase");
|
|
8
9
|
Object.defineProperty(exports, "FederatedConnectionAuthorizerBase", { enumerable: true, get: function () { return FederatedConnectionAuthorizerBase_1.FederatedConnectionAuthorizerBase; } });
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/index.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/index.ts"],"names":[],"mappings":";;;AAEA,yDAI6B;AAH3B,sHAAA,iBAAiB,OAAA;AACjB,gIAAA,2BAA2B,OAAA;AAC3B,gIAAA,2BAA2B,OAAA;AAG7B,yFAAwF;AAA/E,sJAAA,iCAAiC,OAAA","sourcesContent":["export type { AsyncStorageValue } from \"./asyncLocalStorage\";\n\nexport {\n asyncLocalStorage,\n getCredentialsForConnection,\n getAccessTokenForConnection,\n} from \"./asyncLocalStorage\";\n\nexport { FederatedConnectionAuthorizerBase } from \"./FederatedConnectionAuthorizerBase\";\n\nexport type { FederatedConnectionAuthorizerParams } from \"./FederatedConnectionAuthorizerParams\";\n"]}
|
|
@@ -24,5 +24,19 @@ export type AsyncStorageValue = {
|
|
|
24
24
|
currentScopes?: string[];
|
|
25
25
|
};
|
|
26
26
|
export declare const asyncLocalStorage: AsyncLocalStorage<AsyncStorageValue>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the entire tokenset for the current connection.
|
|
29
|
+
*
|
|
30
|
+
* Use `getAccessTokenForConnection` if you only need the access token.
|
|
31
|
+
*
|
|
32
|
+
* @returns {TokenSet} The current token set.
|
|
33
|
+
*/
|
|
27
34
|
export declare const getCredentialsForConnection: () => TokenSet | undefined;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* Get the access token for the current connection.
|
|
38
|
+
*
|
|
39
|
+
* @returns The access token for the current connection.
|
|
40
|
+
*/
|
|
41
|
+
export declare const getAccessTokenForConnection: () => string;
|
|
28
42
|
//# sourceMappingURL=asyncLocalStorage.d.ts.map
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { FederatedConnectionError } from "../../interrupts";
|
|
2
3
|
export const asyncLocalStorage = new AsyncLocalStorage();
|
|
4
|
+
/**
|
|
5
|
+
* Returns the entire tokenset for the current connection.
|
|
6
|
+
*
|
|
7
|
+
* Use `getAccessTokenForConnection` if you only need the access token.
|
|
8
|
+
*
|
|
9
|
+
* @returns {TokenSet} The current token set.
|
|
10
|
+
*/
|
|
3
11
|
export const getCredentialsForConnection = () => {
|
|
4
12
|
const store = asyncLocalStorage.getStore();
|
|
5
13
|
if (typeof store === "undefined") {
|
|
@@ -7,4 +15,17 @@ export const getCredentialsForConnection = () => {
|
|
|
7
15
|
}
|
|
8
16
|
return store === null || store === void 0 ? void 0 : store.credentials;
|
|
9
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* Get the access token for the current connection.
|
|
21
|
+
*
|
|
22
|
+
* @returns The access token for the current connection.
|
|
23
|
+
*/
|
|
24
|
+
export const getAccessTokenForConnection = () => {
|
|
25
|
+
const credentials = getCredentialsForConnection();
|
|
26
|
+
if (!credentials || !credentials.accessToken) {
|
|
27
|
+
throw new FederatedConnectionError("No credentials found");
|
|
28
|
+
}
|
|
29
|
+
return credentials.accessToken;
|
|
30
|
+
};
|
|
10
31
|
//# sourceMappingURL=asyncLocalStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncLocalStorage.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/asyncLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"asyncLocalStorage.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/asyncLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AA8B5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAqB,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAC9C,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IAC3C,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAC9C,MAAM,WAAW,GAAG,2BAA2B,EAAE,CAAC;IAClD,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAC7C,MAAM,IAAI,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,WAAW,CAAC,WAAW,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport { TokenSet } from \"../../credentials\";\nimport { FederatedConnectionError } from \"../../interrupts\";\nimport { ToolCallContext } from \"../context\";\n\nexport type AsyncStorageValue = {\n /**\n * The Federated Connection access token.\n */\n credentials?: TokenSet;\n\n /**\n * The tool execution context.\n */\n context: ToolCallContext;\n\n /**\n * The federated connection name.\n */\n connection: string;\n\n /**\n * The scopes required to access the federated connection.\n */\n scopes: string[];\n\n /**\n * The scopes that the current access token has.\n */\n currentScopes?: string[];\n};\n\nexport const asyncLocalStorage = new AsyncLocalStorage<AsyncStorageValue>();\n\n/**\n * Returns the entire tokenset for the current connection.\n *\n * Use `getAccessTokenForConnection` if you only need the access token.\n *\n * @returns {TokenSet} The current token set.\n */\nexport const getCredentialsForConnection = () => {\n const store = asyncLocalStorage.getStore();\n if (typeof store === \"undefined\") {\n throw new Error(\n \"The tool must be wrapped with the withTokenForConnections function.\"\n );\n }\n return store?.credentials;\n};\n\n/**\n *\n * Get the access token for the current connection.\n *\n * @returns The access token for the current connection.\n */\nexport const getAccessTokenForConnection = () => {\n const credentials = getCredentialsForConnection();\n if (!credentials || !credentials.accessToken) {\n throw new FederatedConnectionError(\"No credentials found\");\n }\n return credentials.accessToken;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { AsyncStorageValue } from "./asyncLocalStorage";
|
|
2
|
-
export { asyncLocalStorage, getCredentialsForConnection
|
|
2
|
+
export { asyncLocalStorage, getCredentialsForConnection, getAccessTokenForConnection, } from "./asyncLocalStorage";
|
|
3
3
|
export { FederatedConnectionAuthorizerBase } from "./FederatedConnectionAuthorizerBase";
|
|
4
4
|
export type { FederatedConnectionAuthorizerParams } from "./FederatedConnectionAuthorizerParams";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { asyncLocalStorage, getCredentialsForConnection
|
|
1
|
+
export { asyncLocalStorage, getCredentialsForConnection, getAccessTokenForConnection, } from "./asyncLocalStorage";
|
|
2
2
|
export { FederatedConnectionAuthorizerBase } from "./FederatedConnectionAuthorizerBase";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/authorizers/federated-connections/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC","sourcesContent":["export type { AsyncStorageValue } from \"./asyncLocalStorage\";\n\nexport {\n asyncLocalStorage,\n getCredentialsForConnection,\n getAccessTokenForConnection,\n} from \"./asyncLocalStorage\";\n\nexport { FederatedConnectionAuthorizerBase } from \"./FederatedConnectionAuthorizerBase\";\n\nexport type { FederatedConnectionAuthorizerParams } from \"./FederatedConnectionAuthorizerParams\";\n"]}
|