@auth0/ai 4.0.0 → 4.0.1
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/ciba/CIBAAuthorizerParams.js.map +1 -1
- package/dist/cjs/credentials.js +3 -0
- package/dist/cjs/credentials.js.map +1 -1
- package/dist/esm/authorizers/ciba/CIBAAuthorizerParams.d.ts +2 -2
- package/dist/esm/authorizers/ciba/CIBAAuthorizerParams.js.map +1 -1
- package/dist/esm/credentials.d.ts +8 -0
- package/dist/esm/credentials.js +3 -0
- package/dist/esm/credentials.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CIBAAuthorizerParams.js","sourceRoot":"","sources":["../../../../src/authorizers/ciba/CIBAAuthorizerParams.ts"],"names":[],"mappings":"","sourcesContent":["import { TokenSet } from \"../../credentials\";\nimport {\n AuthorizationPendingInterrupt,\n AuthorizationPollingInterrupt,\n CIBAInterrupt,\n} from \"../../interrupts\";\nimport { AuthorizerToolParameter } from \"../../parameters\";\nimport { Store } from \"../../stores\";\nimport { AuthContext, ToolCallContext } from \"../context\";\nimport { OnAuthorizationRequest } from \"../types\";\nimport { CIBAAuthorizationRequest } from \"./CIBAAuthorizationRequest\";\n\nexport type CIBAAuthorizerParams<ToolExecuteArgs extends any[]> = {\n /**\n * The scope to request authorization for.\n */\n scopes: string[];\n\n /**\n * The user ID to request authorization for.\n */\n userID: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The binding message to send to the user.\n */\n bindingMessage: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The authorization parameters for RAR request.\n */\n authorizationDetails?: AuthorizerToolParameter<\n ToolExecuteArgs,\n
|
|
1
|
+
{"version":3,"file":"CIBAAuthorizerParams.js","sourceRoot":"","sources":["../../../../src/authorizers/ciba/CIBAAuthorizerParams.ts"],"names":[],"mappings":"","sourcesContent":["import { AuthorizationDetails, TokenSet } from \"../../credentials\";\nimport {\n AuthorizationPendingInterrupt,\n AuthorizationPollingInterrupt,\n CIBAInterrupt,\n} from \"../../interrupts\";\nimport { AuthorizerToolParameter } from \"../../parameters\";\nimport { Store } from \"../../stores\";\nimport { AuthContext, ToolCallContext } from \"../context\";\nimport { OnAuthorizationRequest } from \"../types\";\nimport { CIBAAuthorizationRequest } from \"./CIBAAuthorizationRequest\";\n\nexport type CIBAAuthorizerParams<ToolExecuteArgs extends any[]> = {\n /**\n * The scope to request authorization for.\n */\n scopes: string[];\n\n /**\n * The user ID to request authorization for.\n */\n userID: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The binding message to send to the user.\n */\n bindingMessage: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The authorization parameters for RAR request.\n */\n authorizationDetails?: AuthorizerToolParameter<\n ToolExecuteArgs,\n AuthorizationDetails[]\n >;\n\n /**\n * The audience to request authorization for.\n */\n audience?: string;\n\n /**\n * The time in seconds for the authorization request to expire.\n *\n * Defaults to 300 (5 minutes).\n */\n requestedExpiry?: number;\n\n /**\n * The behavior when the authorization request is made.\n *\n * - `block`: The tool execution is blocked until the user completes the authorization.\n * - `interrupt`: The tool execution is interrupted until the user completes the authorization.\n * - a callback: Same as \"block\" but give access to the auth request and executing logic.\n *\n * Defaults to `interrupt`.\n * Note: The block mode is only useful for development purposes and should not be used in production.\n */\n onAuthorizationRequest?:\n | OnAuthorizationRequest\n | ((\n authReq: CIBAAuthorizationRequest,\n poll: Promise<TokenSet | undefined>,\n ) => Promise<void>);\n\n /**\n * AuthContext defines the scope of credential sharing:\n * - \"tool-call\": Credentials are valid only for a single invocation of the tool.\n * - \"tool\": Credentials are shared across multiple calls to the same tool within the same thread.\n * - \"thread\": Credentials are shared across all tools using the same authorizer within the current thread.\n * - \"agent\": Credentials are shared globally across all threads and tools in the agent.\n *\n * @default \"tool-call\"\n */\n credentialsContext?: AuthContext;\n\n /**\n *\n * Optional callback to generate a tool result when the invocation is not authorized.\n *\n * By default it will return the instance of the Error.\n *\n * @param args - The tool execution arguments.\n * @returns The response to return when the invocation is not authorized.\n */\n onUnauthorized?: (\n err: Error | CIBAInterrupt,\n ...args: ToolExecuteArgs\n ) => any;\n\n /**\n * Callback called before the authorization interrupt is thrown.\n * This callback is useful to setup CIBA pollers.\n *\n * @param interrupt - The interrupt that is about to be thrown.\n * @param args - The tool execution arguments.\n */\n onAuthorizationInterrupt?: (\n interrupt: AuthorizationPendingInterrupt | AuthorizationPollingInterrupt,\n context: ToolCallContext,\n ) => void | Promise<void>;\n\n /**\n * An store used to temporarly store the authorization response data\n * while the user is completing the authorization in another device.\n */\n store: Store;\n};\n"]}
|
package/dist/cjs/credentials.js
CHANGED
|
@@ -10,6 +10,9 @@ const tokenSetFromTokenResponse = (tr) => {
|
|
|
10
10
|
refreshToken: tr.refresh_token,
|
|
11
11
|
expiresIn: tr.expires_in,
|
|
12
12
|
scopes: tr.scope ? tr.scope.split(" ") : undefined,
|
|
13
|
+
...(tr.authorization_details
|
|
14
|
+
? { authorizationDetails: tr.authorization_details }
|
|
15
|
+
: {}),
|
|
13
16
|
};
|
|
14
17
|
};
|
|
15
18
|
exports.tokenSetFromTokenResponse = tokenSetFromTokenResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":";;;AA8CO,MAAM,yBAAyB,GAAG,CAAC,EAAiB,EAAY,EAAE;;IACvE,OAAO;QACL,SAAS,EAAE,MAAA,EAAE,CAAC,UAAU,mCAAI,QAAQ;QACpC,WAAW,EAAE,EAAE,CAAC,YAAY;QAC5B,OAAO,EAAE,EAAE,CAAC,QAAQ;QACpB,YAAY,EAAE,EAAE,CAAC,aAAa;QAC9B,SAAS,EAAE,EAAE,CAAC,UAAU;QACxB,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAClD,GAAG,CAAC,EAAE,CAAC,qBAAqB;YAC1B,CAAC,CAAC,EAAE,oBAAoB,EAAE,EAAE,CAAC,qBAAqB,EAAE;YACpD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,yBAAyB,6BAYpC","sourcesContent":["export interface AuthorizationDetails {\n readonly type: string;\n readonly [parameter: string]: unknown;\n}\n\nexport type TokenResponse = {\n /** Bearer token for API authorization */\n access_token: string;\n /** Refresh token (requires `offline_access` scope) */\n refresh_token?: string;\n /** JWT containing user identity claims */\n id_token: string;\n /** Typically \"Bearer\" */\n token_type?: string;\n /** Token validity in seconds (default: 86400) */\n expires_in: number;\n /** Granted permissions space */\n scope: string;\n /** Granted authorization details */\n authorization_details?: AuthorizationDetails[];\n};\n\n/**\n * Represents a set of authentication tokens returned after a successful authentication flow.\n *\n * @interface TokenSet\n * @property {string[]} [scopes] - Optional array of permission scopes granted for the token.\n * @property {string} [idToken] - Optional JWT ID token containing user claims.\n * @property {string} [refreshToken] - Optional token used to obtain new access tokens without re-authentication.\n * @property {number} [expiresIn] - Optional time in seconds until the access token expires.\n * @property {string} accessToken - The access token string used for API requests.\n * @property {string} tokenType - The type of the token, typically \"Bearer\".\n * @property {AuthorizationDetails[]} [authorizationDetails] - Optional array of authorization details granted for the token.\n */\nexport interface TokenSet {\n scopes?: string[];\n idToken?: string;\n refreshToken?: string;\n\n expiresIn?: number;\n accessToken: string;\n tokenType: string;\n\n authorizationDetails?: AuthorizationDetails[];\n}\n\nexport const tokenSetFromTokenResponse = (tr: TokenResponse): TokenSet => {\n return {\n tokenType: tr.token_type ?? \"Bearer\",\n accessToken: tr.access_token,\n idToken: tr.id_token,\n refreshToken: tr.refresh_token,\n expiresIn: tr.expires_in,\n scopes: tr.scope ? tr.scope.split(\" \") : undefined,\n ...(tr.authorization_details\n ? { authorizationDetails: tr.authorization_details }\n : {}),\n };\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TokenSet } from "../../credentials";
|
|
1
|
+
import { AuthorizationDetails, TokenSet } from "../../credentials";
|
|
2
2
|
import { AuthorizationPendingInterrupt, AuthorizationPollingInterrupt, CIBAInterrupt } from "../../interrupts";
|
|
3
3
|
import { AuthorizerToolParameter } from "../../parameters";
|
|
4
4
|
import { Store } from "../../stores";
|
|
@@ -21,7 +21,7 @@ export type CIBAAuthorizerParams<ToolExecuteArgs extends any[]> = {
|
|
|
21
21
|
/**
|
|
22
22
|
* The authorization parameters for RAR request.
|
|
23
23
|
*/
|
|
24
|
-
authorizationDetails?: AuthorizerToolParameter<ToolExecuteArgs,
|
|
24
|
+
authorizationDetails?: AuthorizerToolParameter<ToolExecuteArgs, AuthorizationDetails[]>;
|
|
25
25
|
/**
|
|
26
26
|
* The audience to request authorization for.
|
|
27
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CIBAAuthorizerParams.js","sourceRoot":"","sources":["../../../../src/authorizers/ciba/CIBAAuthorizerParams.ts"],"names":[],"mappings":"","sourcesContent":["import { TokenSet } from \"../../credentials\";\nimport {\n AuthorizationPendingInterrupt,\n AuthorizationPollingInterrupt,\n CIBAInterrupt,\n} from \"../../interrupts\";\nimport { AuthorizerToolParameter } from \"../../parameters\";\nimport { Store } from \"../../stores\";\nimport { AuthContext, ToolCallContext } from \"../context\";\nimport { OnAuthorizationRequest } from \"../types\";\nimport { CIBAAuthorizationRequest } from \"./CIBAAuthorizationRequest\";\n\nexport type CIBAAuthorizerParams<ToolExecuteArgs extends any[]> = {\n /**\n * The scope to request authorization for.\n */\n scopes: string[];\n\n /**\n * The user ID to request authorization for.\n */\n userID: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The binding message to send to the user.\n */\n bindingMessage: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The authorization parameters for RAR request.\n */\n authorizationDetails?: AuthorizerToolParameter<\n ToolExecuteArgs,\n
|
|
1
|
+
{"version":3,"file":"CIBAAuthorizerParams.js","sourceRoot":"","sources":["../../../../src/authorizers/ciba/CIBAAuthorizerParams.ts"],"names":[],"mappings":"","sourcesContent":["import { AuthorizationDetails, TokenSet } from \"../../credentials\";\nimport {\n AuthorizationPendingInterrupt,\n AuthorizationPollingInterrupt,\n CIBAInterrupt,\n} from \"../../interrupts\";\nimport { AuthorizerToolParameter } from \"../../parameters\";\nimport { Store } from \"../../stores\";\nimport { AuthContext, ToolCallContext } from \"../context\";\nimport { OnAuthorizationRequest } from \"../types\";\nimport { CIBAAuthorizationRequest } from \"./CIBAAuthorizationRequest\";\n\nexport type CIBAAuthorizerParams<ToolExecuteArgs extends any[]> = {\n /**\n * The scope to request authorization for.\n */\n scopes: string[];\n\n /**\n * The user ID to request authorization for.\n */\n userID: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The binding message to send to the user.\n */\n bindingMessage: AuthorizerToolParameter<ToolExecuteArgs>;\n\n /**\n * The authorization parameters for RAR request.\n */\n authorizationDetails?: AuthorizerToolParameter<\n ToolExecuteArgs,\n AuthorizationDetails[]\n >;\n\n /**\n * The audience to request authorization for.\n */\n audience?: string;\n\n /**\n * The time in seconds for the authorization request to expire.\n *\n * Defaults to 300 (5 minutes).\n */\n requestedExpiry?: number;\n\n /**\n * The behavior when the authorization request is made.\n *\n * - `block`: The tool execution is blocked until the user completes the authorization.\n * - `interrupt`: The tool execution is interrupted until the user completes the authorization.\n * - a callback: Same as \"block\" but give access to the auth request and executing logic.\n *\n * Defaults to `interrupt`.\n * Note: The block mode is only useful for development purposes and should not be used in production.\n */\n onAuthorizationRequest?:\n | OnAuthorizationRequest\n | ((\n authReq: CIBAAuthorizationRequest,\n poll: Promise<TokenSet | undefined>,\n ) => Promise<void>);\n\n /**\n * AuthContext defines the scope of credential sharing:\n * - \"tool-call\": Credentials are valid only for a single invocation of the tool.\n * - \"tool\": Credentials are shared across multiple calls to the same tool within the same thread.\n * - \"thread\": Credentials are shared across all tools using the same authorizer within the current thread.\n * - \"agent\": Credentials are shared globally across all threads and tools in the agent.\n *\n * @default \"tool-call\"\n */\n credentialsContext?: AuthContext;\n\n /**\n *\n * Optional callback to generate a tool result when the invocation is not authorized.\n *\n * By default it will return the instance of the Error.\n *\n * @param args - The tool execution arguments.\n * @returns The response to return when the invocation is not authorized.\n */\n onUnauthorized?: (\n err: Error | CIBAInterrupt,\n ...args: ToolExecuteArgs\n ) => any;\n\n /**\n * Callback called before the authorization interrupt is thrown.\n * This callback is useful to setup CIBA pollers.\n *\n * @param interrupt - The interrupt that is about to be thrown.\n * @param args - The tool execution arguments.\n */\n onAuthorizationInterrupt?: (\n interrupt: AuthorizationPendingInterrupt | AuthorizationPollingInterrupt,\n context: ToolCallContext,\n ) => void | Promise<void>;\n\n /**\n * An store used to temporarly store the authorization response data\n * while the user is completing the authorization in another device.\n */\n store: Store;\n};\n"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface AuthorizationDetails {
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly [parameter: string]: unknown;
|
|
4
|
+
}
|
|
1
5
|
export type TokenResponse = {
|
|
2
6
|
/** Bearer token for API authorization */
|
|
3
7
|
access_token: string;
|
|
@@ -11,6 +15,8 @@ export type TokenResponse = {
|
|
|
11
15
|
expires_in: number;
|
|
12
16
|
/** Granted permissions space */
|
|
13
17
|
scope: string;
|
|
18
|
+
/** Granted authorization details */
|
|
19
|
+
authorization_details?: AuthorizationDetails[];
|
|
14
20
|
};
|
|
15
21
|
/**
|
|
16
22
|
* Represents a set of authentication tokens returned after a successful authentication flow.
|
|
@@ -22,6 +28,7 @@ export type TokenResponse = {
|
|
|
22
28
|
* @property {number} [expiresIn] - Optional time in seconds until the access token expires.
|
|
23
29
|
* @property {string} accessToken - The access token string used for API requests.
|
|
24
30
|
* @property {string} tokenType - The type of the token, typically "Bearer".
|
|
31
|
+
* @property {AuthorizationDetails[]} [authorizationDetails] - Optional array of authorization details granted for the token.
|
|
25
32
|
*/
|
|
26
33
|
export interface TokenSet {
|
|
27
34
|
scopes?: string[];
|
|
@@ -30,6 +37,7 @@ export interface TokenSet {
|
|
|
30
37
|
expiresIn?: number;
|
|
31
38
|
accessToken: string;
|
|
32
39
|
tokenType: string;
|
|
40
|
+
authorizationDetails?: AuthorizationDetails[];
|
|
33
41
|
}
|
|
34
42
|
export declare const tokenSetFromTokenResponse: (tr: TokenResponse) => TokenSet;
|
|
35
43
|
//# sourceMappingURL=credentials.d.ts.map
|
package/dist/esm/credentials.js
CHANGED
|
@@ -7,6 +7,9 @@ export const tokenSetFromTokenResponse = (tr) => {
|
|
|
7
7
|
refreshToken: tr.refresh_token,
|
|
8
8
|
expiresIn: tr.expires_in,
|
|
9
9
|
scopes: tr.scope ? tr.scope.split(" ") : undefined,
|
|
10
|
+
...(tr.authorization_details
|
|
11
|
+
? { authorizationDetails: tr.authorization_details }
|
|
12
|
+
: {}),
|
|
10
13
|
};
|
|
11
14
|
};
|
|
12
15
|
//# sourceMappingURL=credentials.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":"AA8CA,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAiB,EAAY,EAAE;;IACvE,OAAO;QACL,SAAS,EAAE,MAAA,EAAE,CAAC,UAAU,mCAAI,QAAQ;QACpC,WAAW,EAAE,EAAE,CAAC,YAAY;QAC5B,OAAO,EAAE,EAAE,CAAC,QAAQ;QACpB,YAAY,EAAE,EAAE,CAAC,aAAa;QAC9B,SAAS,EAAE,EAAE,CAAC,UAAU;QACxB,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAClD,GAAG,CAAC,EAAE,CAAC,qBAAqB;YAC1B,CAAC,CAAC,EAAE,oBAAoB,EAAE,EAAE,CAAC,qBAAqB,EAAE;YACpD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["export interface AuthorizationDetails {\n readonly type: string;\n readonly [parameter: string]: unknown;\n}\n\nexport type TokenResponse = {\n /** Bearer token for API authorization */\n access_token: string;\n /** Refresh token (requires `offline_access` scope) */\n refresh_token?: string;\n /** JWT containing user identity claims */\n id_token: string;\n /** Typically \"Bearer\" */\n token_type?: string;\n /** Token validity in seconds (default: 86400) */\n expires_in: number;\n /** Granted permissions space */\n scope: string;\n /** Granted authorization details */\n authorization_details?: AuthorizationDetails[];\n};\n\n/**\n * Represents a set of authentication tokens returned after a successful authentication flow.\n *\n * @interface TokenSet\n * @property {string[]} [scopes] - Optional array of permission scopes granted for the token.\n * @property {string} [idToken] - Optional JWT ID token containing user claims.\n * @property {string} [refreshToken] - Optional token used to obtain new access tokens without re-authentication.\n * @property {number} [expiresIn] - Optional time in seconds until the access token expires.\n * @property {string} accessToken - The access token string used for API requests.\n * @property {string} tokenType - The type of the token, typically \"Bearer\".\n * @property {AuthorizationDetails[]} [authorizationDetails] - Optional array of authorization details granted for the token.\n */\nexport interface TokenSet {\n scopes?: string[];\n idToken?: string;\n refreshToken?: string;\n\n expiresIn?: number;\n accessToken: string;\n tokenType: string;\n\n authorizationDetails?: AuthorizationDetails[];\n}\n\nexport const tokenSetFromTokenResponse = (tr: TokenResponse): TokenSet => {\n return {\n tokenType: tr.token_type ?? \"Bearer\",\n accessToken: tr.access_token,\n idToken: tr.id_token,\n refreshToken: tr.refresh_token,\n expiresIn: tr.expires_in,\n scopes: tr.scope ? tr.scope.split(\" \") : undefined,\n ...(tr.authorization_details\n ? { authorizationDetails: tr.authorization_details }\n : {}),\n };\n};\n"]}
|