@auth0/ai 1.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.
Files changed (108) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +44 -0
  3. package/dist/cjs/TokenResponse.js +3 -0
  4. package/dist/cjs/TokenResponse.js.map +1 -0
  5. package/dist/cjs/authorizers/ciba/CIBAAuthorizationRequest.js +3 -0
  6. package/dist/cjs/authorizers/ciba/CIBAAuthorizationRequest.js.map +1 -0
  7. package/dist/cjs/authorizers/ciba/CIBAAuthorizerBase.js +201 -0
  8. package/dist/cjs/authorizers/ciba/CIBAAuthorizerBase.js.map +1 -0
  9. package/dist/cjs/authorizers/ciba/CIBAAuthorizerParams.js +3 -0
  10. package/dist/cjs/authorizers/ciba/CIBAAuthorizerParams.js.map +1 -0
  11. package/dist/cjs/authorizers/ciba/asyncLocalStorage.js +14 -0
  12. package/dist/cjs/authorizers/ciba/asyncLocalStorage.js.map +1 -0
  13. package/dist/cjs/authorizers/ciba/index.js +9 -0
  14. package/dist/cjs/authorizers/ciba/index.js.map +1 -0
  15. package/dist/cjs/authorizers/device-authorizer.js +130 -0
  16. package/dist/cjs/authorizers/device-authorizer.js.map +1 -0
  17. package/dist/cjs/authorizers/federated-connections/asyncLocalStorage.js +14 -0
  18. package/dist/cjs/authorizers/federated-connections/asyncLocalStorage.js.map +1 -0
  19. package/dist/cjs/authorizers/federated-connections/index.js +129 -0
  20. package/dist/cjs/authorizers/federated-connections/index.js.map +1 -0
  21. package/dist/cjs/authorizers/fga/fga-client.js +30 -0
  22. package/dist/cjs/authorizers/fga/fga-client.js.map +1 -0
  23. package/dist/cjs/authorizers/fga/fga-filter.js +94 -0
  24. package/dist/cjs/authorizers/fga/fga-filter.js.map +1 -0
  25. package/dist/cjs/authorizers/fga/index.js +37 -0
  26. package/dist/cjs/authorizers/fga/index.js.map +1 -0
  27. package/dist/cjs/authorizers/index.js +3 -0
  28. package/dist/cjs/authorizers/index.js.map +1 -0
  29. package/dist/cjs/credentials.js +3 -0
  30. package/dist/cjs/credentials.js.map +1 -0
  31. package/dist/cjs/errors.js +46 -0
  32. package/dist/cjs/errors.js.map +1 -0
  33. package/dist/cjs/index.js +22 -0
  34. package/dist/cjs/index.js.map +1 -0
  35. package/dist/cjs/interrupts/Auth0Interrupt.js +46 -0
  36. package/dist/cjs/interrupts/Auth0Interrupt.js.map +1 -0
  37. package/dist/cjs/interrupts/CIBAInterrupts.js +89 -0
  38. package/dist/cjs/interrupts/CIBAInterrupts.js.map +1 -0
  39. package/dist/cjs/interrupts/FederatedConnectionInterrupt.js +31 -0
  40. package/dist/cjs/interrupts/FederatedConnectionInterrupt.js.map +1 -0
  41. package/dist/cjs/interrupts/index.js +17 -0
  42. package/dist/cjs/interrupts/index.js.map +1 -0
  43. package/dist/cjs/parameters.js +13 -0
  44. package/dist/cjs/parameters.js.map +1 -0
  45. package/dist/esm/TokenResponse.d.ts +15 -0
  46. package/dist/esm/TokenResponse.js +2 -0
  47. package/dist/esm/TokenResponse.js.map +1 -0
  48. package/dist/esm/authorizers/ciba/CIBAAuthorizationRequest.d.ts +20 -0
  49. package/dist/esm/authorizers/ciba/CIBAAuthorizationRequest.js +2 -0
  50. package/dist/esm/authorizers/ciba/CIBAAuthorizationRequest.js.map +1 -0
  51. package/dist/esm/authorizers/ciba/CIBAAuthorizerBase.d.ts +31 -0
  52. package/dist/esm/authorizers/ciba/CIBAAuthorizerBase.js +197 -0
  53. package/dist/esm/authorizers/ciba/CIBAAuthorizerBase.js.map +1 -0
  54. package/dist/esm/authorizers/ciba/CIBAAuthorizerParams.d.ts +66 -0
  55. package/dist/esm/authorizers/ciba/CIBAAuthorizerParams.js +2 -0
  56. package/dist/esm/authorizers/ciba/CIBAAuthorizerParams.js.map +1 -0
  57. package/dist/esm/authorizers/ciba/asyncLocalStorage.d.ts +16 -0
  58. package/dist/esm/authorizers/ciba/asyncLocalStorage.js +10 -0
  59. package/dist/esm/authorizers/ciba/asyncLocalStorage.js.map +1 -0
  60. package/dist/esm/authorizers/ciba/index.d.ts +4 -0
  61. package/dist/esm/authorizers/ciba/index.js +3 -0
  62. package/dist/esm/authorizers/ciba/index.js.map +1 -0
  63. package/dist/esm/authorizers/device-authorizer.d.ts +15 -0
  64. package/dist/esm/authorizers/device-authorizer.js +90 -0
  65. package/dist/esm/authorizers/device-authorizer.js.map +1 -0
  66. package/dist/esm/authorizers/federated-connections/asyncLocalStorage.d.ts +26 -0
  67. package/dist/esm/authorizers/federated-connections/asyncLocalStorage.js +10 -0
  68. package/dist/esm/authorizers/federated-connections/asyncLocalStorage.js.map +1 -0
  69. package/dist/esm/authorizers/federated-connections/index.d.ts +38 -0
  70. package/dist/esm/authorizers/federated-connections/index.js +123 -0
  71. package/dist/esm/authorizers/federated-connections/index.js.map +1 -0
  72. package/dist/esm/authorizers/fga/fga-client.d.ts +16 -0
  73. package/dist/esm/authorizers/fga/fga-client.js +27 -0
  74. package/dist/esm/authorizers/fga/fga-client.js.map +1 -0
  75. package/dist/esm/authorizers/fga/fga-filter.d.ts +63 -0
  76. package/dist/esm/authorizers/fga/fga-filter.js +90 -0
  77. package/dist/esm/authorizers/fga/fga-filter.js.map +1 -0
  78. package/dist/esm/authorizers/fga/index.d.ts +21 -0
  79. package/dist/esm/authorizers/fga/index.js +33 -0
  80. package/dist/esm/authorizers/fga/index.js.map +1 -0
  81. package/dist/esm/authorizers/index.d.ts +13 -0
  82. package/dist/esm/authorizers/index.js +2 -0
  83. package/dist/esm/authorizers/index.js.map +1 -0
  84. package/dist/esm/credentials.d.ts +10 -0
  85. package/dist/esm/credentials.js +2 -0
  86. package/dist/esm/credentials.js.map +1 -0
  87. package/dist/esm/errors.d.ts +19 -0
  88. package/dist/esm/errors.js +37 -0
  89. package/dist/esm/errors.js.map +1 -0
  90. package/dist/esm/index.d.ts +9 -0
  91. package/dist/esm/index.js +6 -0
  92. package/dist/esm/index.js.map +1 -0
  93. package/dist/esm/interrupts/Auth0Interrupt.d.ts +37 -0
  94. package/dist/esm/interrupts/Auth0Interrupt.js +42 -0
  95. package/dist/esm/interrupts/Auth0Interrupt.js.map +1 -0
  96. package/dist/esm/interrupts/CIBAInterrupts.d.ts +62 -0
  97. package/dist/esm/interrupts/CIBAInterrupts.js +79 -0
  98. package/dist/esm/interrupts/CIBAInterrupts.js.map +1 -0
  99. package/dist/esm/interrupts/FederatedConnectionInterrupt.d.ts +33 -0
  100. package/dist/esm/interrupts/FederatedConnectionInterrupt.js +26 -0
  101. package/dist/esm/interrupts/FederatedConnectionInterrupt.js.map +1 -0
  102. package/dist/esm/interrupts/index.d.ts +4 -0
  103. package/dist/esm/interrupts/index.js +4 -0
  104. package/dist/esm/interrupts/index.js.map +1 -0
  105. package/dist/esm/parameters.d.ts +3 -0
  106. package/dist/esm/parameters.js +9 -0
  107. package/dist/esm/parameters.js.map +1 -0
  108. package/package.json +76 -0
@@ -0,0 +1,21 @@
1
+ import { ClientCheckRequest, OpenFgaClient } from "@openfga/sdk";
2
+ import { FGAClientParams } from "./fga-client";
3
+ export type { FGAClientParams };
4
+ export type FGAAuthorizerOptions<ToolExecuteArgs extends any[]> = {
5
+ buildQuery: (...args: ToolExecuteArgs) => Promise<ClientCheckRequest>;
6
+ onUnauthorized?: (...args: ToolExecuteArgs) => any;
7
+ };
8
+ export declare class FGAAuthorizerBase<ToolExecuteArgs extends any[]> {
9
+ private authorizeOptions;
10
+ fgaClient: OpenFgaClient;
11
+ constructor(fgaClientParams: FGAClientParams | undefined | null, authorizeOptions: FGAAuthorizerOptions<ToolExecuteArgs>);
12
+ /**
13
+ *
14
+ * Wraps the execute method of an AI tool to handle FGA authorization.
15
+ *
16
+ * @param execute - The tool execute method.
17
+ * @returns The wrapped execute method.
18
+ */
19
+ protect(execute: (...args: ToolExecuteArgs) => any): (...args: ToolExecuteArgs) => any;
20
+ }
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { ConsistencyPreference, } from "@openfga/sdk";
2
+ import { buildOpenFgaClient } from "./fga-client";
3
+ export class FGAAuthorizerBase {
4
+ constructor(fgaClientParams, authorizeOptions) {
5
+ this.authorizeOptions = authorizeOptions;
6
+ this.fgaClient = buildOpenFgaClient(fgaClientParams);
7
+ }
8
+ /**
9
+ *
10
+ * Wraps the execute method of an AI tool to handle FGA authorization.
11
+ *
12
+ * @param execute - The tool execute method.
13
+ * @returns The wrapped execute method.
14
+ */
15
+ protect(execute) {
16
+ return async (...args) => {
17
+ const check = await this.authorizeOptions.buildQuery(...args);
18
+ const { allowed } = await this.fgaClient.check(check, {
19
+ consistency: ConsistencyPreference.HigherConsistency,
20
+ });
21
+ if (!allowed) {
22
+ if (typeof this.authorizeOptions.onUnauthorized === "function") {
23
+ return this.authorizeOptions.onUnauthorized(...args);
24
+ }
25
+ else {
26
+ return "The user is not allowed to perform the action.";
27
+ }
28
+ }
29
+ return execute(...args);
30
+ };
31
+ }
32
+ }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/authorizers/fga/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GAEtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAmB,MAAM,cAAc,CAAC;AASnE,MAAM,OAAO,iBAAiB;IAG5B,YACE,eAAmD,EAC3C,gBAAuD;QAAvD,qBAAgB,GAAhB,gBAAgB,CAAuC;QAE/D,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CACL,OAA0C;QAE1C,OAAO,KAAK,EAAE,GAAG,IAAqB,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;YAC9D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE;gBACpD,WAAW,EAAE,qBAAqB,CAAC,iBAAiB;aACrD,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,IAAI,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;oBAC/D,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;gBACvD,CAAC;qBAAM,CAAC;oBACN,OAAO,gDAAgD,CAAC;gBAC1D,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n ClientCheckRequest,\n ConsistencyPreference,\n OpenFgaClient,\n} from \"@openfga/sdk\";\n\nimport { buildOpenFgaClient, FGAClientParams } from \"./fga-client\";\n\nexport type { FGAClientParams };\n\nexport type FGAAuthorizerOptions<ToolExecuteArgs extends any[]> = {\n buildQuery: (...args: ToolExecuteArgs) => Promise<ClientCheckRequest>;\n onUnauthorized?: (...args: ToolExecuteArgs) => any;\n};\n\nexport class FGAAuthorizerBase<ToolExecuteArgs extends any[]> {\n fgaClient: OpenFgaClient;\n\n constructor(\n fgaClientParams: FGAClientParams | undefined | null,\n private authorizeOptions: FGAAuthorizerOptions<ToolExecuteArgs>\n ) {\n this.fgaClient = buildOpenFgaClient(fgaClientParams);\n }\n\n /**\n *\n * Wraps the execute method of an AI tool to handle FGA authorization.\n *\n * @param execute - The tool execute method.\n * @returns The wrapped execute method.\n */\n protect(\n execute: (...args: ToolExecuteArgs) => any\n ): (...args: ToolExecuteArgs) => any {\n return async (...args: ToolExecuteArgs) => {\n const check = await this.authorizeOptions.buildQuery(...args);\n const { allowed } = await this.fgaClient.check(check, {\n consistency: ConsistencyPreference.HigherConsistency,\n });\n if (!allowed) {\n if (typeof this.authorizeOptions.onUnauthorized === \"function\") {\n return this.authorizeOptions.onUnauthorized(...args);\n } else {\n return \"The user is not allowed to perform the action.\";\n }\n }\n return execute(...args);\n };\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { AuthenticationClientOptions } from "auth0";
2
+ import * as jose from "jose";
3
+ export type AuthParams = {
4
+ allowed?: boolean;
5
+ accessToken?: string;
6
+ claims?: jose.JWTPayload;
7
+ };
8
+ export type ToolWithAuthHandler<I, O, C> = (authParams: AuthParams, input: I, config?: C) => Promise<O>;
9
+ export type AuthorizerParams = Omit<AuthenticationClientOptions, "domain" | "clientId"> & {
10
+ domain?: string;
11
+ clientId?: string;
12
+ };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/authorizers/index.ts"],"names":[],"mappings":"","sourcesContent":["import { AuthenticationClientOptions } from \"auth0\";\nimport * as jose from \"jose\";\n\nexport type AuthParams = {\n allowed?: boolean;\n accessToken?: string;\n claims?: jose.JWTPayload;\n};\n\nexport type ToolWithAuthHandler<I, O, C> = (\n authParams: AuthParams,\n input: I,\n config?: C\n) => Promise<O>;\n\nexport type AuthorizerParams = Omit<\n AuthenticationClientOptions,\n \"domain\" | \"clientId\"\n> & {\n domain?: string;\n clientId?: string;\n};\n"]}
@@ -0,0 +1,10 @@
1
+ export interface Credential {
2
+ type: string;
3
+ value: string;
4
+ }
5
+ export interface Credentials {
6
+ idToken?: Credential;
7
+ accessToken: Credential;
8
+ refreshToken?: Credential;
9
+ }
10
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":"","sourcesContent":["export interface Credential {\n type: string;\n value: string;\n}\n\nexport interface Credentials {\n idToken?: Credential;\n accessToken: Credential;\n refreshToken?: Credential;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ export declare class AccessDeniedError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class UserDoesNotHavePushNotificationsError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ export declare class AuthorizationRequestExpiredError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ export declare class AuthorizationPending extends Error {
11
+ constructor(message: string);
12
+ }
13
+ export declare class AuthorizationRequired extends Error {
14
+ constructor(message: string);
15
+ }
16
+ export declare class AuthorizationPollingError extends Error {
17
+ constructor(message: string);
18
+ }
19
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,37 @@
1
+ export class AccessDeniedError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = AccessDeniedError.name;
5
+ }
6
+ }
7
+ export class UserDoesNotHavePushNotificationsError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = UserDoesNotHavePushNotificationsError.name;
11
+ }
12
+ }
13
+ export class AuthorizationRequestExpiredError extends Error {
14
+ constructor(message) {
15
+ super(message);
16
+ this.name = AuthorizationRequestExpiredError.name;
17
+ }
18
+ }
19
+ export class AuthorizationPending extends Error {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = AuthorizationPending.name;
23
+ }
24
+ }
25
+ export class AuthorizationRequired extends Error {
26
+ constructor(message) {
27
+ super(message);
28
+ this.name = AuthorizationRequired.name;
29
+ }
30
+ }
31
+ export class AuthorizationPollingError extends Error {
32
+ constructor(message) {
33
+ super(message);
34
+ this.name = AuthorizationPollingError.name;
35
+ }
36
+ }
37
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC;IACrC,CAAC;CACF;AAED,MAAM,OAAO,qCAAsC,SAAQ,KAAK;IAC9D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC,IAAI,CAAC;IACzD,CAAC;CACF;AAED,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACzD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC,IAAI,CAAC;IACpD,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC;IACxC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC;IAC7C,CAAC;CACF","sourcesContent":["export class AccessDeniedError extends Error {\n constructor(message: string) {\n super(message);\n this.name = AccessDeniedError.name;\n }\n}\n\nexport class UserDoesNotHavePushNotificationsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = UserDoesNotHavePushNotificationsError.name;\n }\n}\n\nexport class AuthorizationRequestExpiredError extends Error {\n constructor(message: string) {\n super(message);\n this.name = AuthorizationRequestExpiredError.name;\n }\n}\n\nexport class AuthorizationPending extends Error {\n constructor(message: string) {\n super(message);\n this.name = AuthorizationPending.name;\n }\n}\n\nexport class AuthorizationRequired extends Error {\n constructor(message: string) {\n super(message);\n this.name = AuthorizationRequired.name;\n }\n}\n\nexport class AuthorizationPollingError extends Error {\n constructor(message: string) {\n super(message);\n this.name = AuthorizationPollingError.name;\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export type { AuthParams, AuthorizerParams } from "./authorizers";
2
+ export type * from "./credentials";
3
+ export * from "./authorizers/device-authorizer";
4
+ export * from "./errors";
5
+ export type { TokenResponse } from "./TokenResponse";
6
+ export * from "./authorizers/fga/fga-filter";
7
+ export * from "./authorizers/fga/fga-client";
8
+ export * from "./parameters";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ export * from "./authorizers/device-authorizer";
2
+ export * from "./errors";
3
+ export * from "./authorizers/fga/fga-filter";
4
+ export * from "./authorizers/fga/fga-client";
5
+ export * from "./parameters";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AAEzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC","sourcesContent":["export type { AuthParams, AuthorizerParams } from \"./authorizers\";\nexport type * from \"./credentials\";\nexport * from \"./authorizers/device-authorizer\";\nexport * from \"./errors\";\nexport type { TokenResponse } from \"./TokenResponse\";\nexport * from \"./authorizers/fga/fga-filter\";\nexport * from \"./authorizers/fga/fga-client\";\nexport * from \"./parameters\";\n"]}
@@ -0,0 +1,37 @@
1
+ export type Auth0InterruptData<T extends Auth0Interrupt> = Omit<Omit<T, keyof Error>, "toJSON"> & {
2
+ message: string;
3
+ };
4
+ export declare const InterruptName: "AUTH0_AI_INTERRUPT";
5
+ /**
6
+ * Auth0Interrupt is the base class for all interruptions
7
+ * in the Auth0 AI sdk.
8
+ *
9
+ * It is serializable to a JSON object.
10
+ */
11
+ export declare class Auth0Interrupt extends Error {
12
+ name: "AUTH0_AI_INTERRUPT";
13
+ code: string;
14
+ constructor(message: string, code: string);
15
+ /**
16
+ *
17
+ * Serialize the interrupt to a JSON object.
18
+ *
19
+ * @returns - The JSON object representation of the interrupt.
20
+ */
21
+ toJSON(): Auth0InterruptData<this>;
22
+ /**
23
+ *
24
+ * Checks if an interrupt is of a specific type asserting its data component.
25
+ *
26
+ * This method assert the data part of the interrupt.
27
+ *
28
+ * @param clazz - The class of the interrupt to check.
29
+ * @param interrupt - The interrupt to check.
30
+ *
31
+ * @returns - True if the interrupt is of the specified type.
32
+ */
33
+ static isInterrupt<T extends abstract new (...args: any) => any>(this: T & {
34
+ code?: string;
35
+ }, interrupt: any): interrupt is Auth0InterruptData<InstanceType<T>>;
36
+ }
37
+ //# sourceMappingURL=Auth0Interrupt.d.ts.map
@@ -0,0 +1,42 @@
1
+ export const InterruptName = "AUTH0_AI_INTERRUPT";
2
+ /**
3
+ * Auth0Interrupt is the base class for all interruptions
4
+ * in the Auth0 AI sdk.
5
+ *
6
+ * It is serializable to a JSON object.
7
+ */
8
+ export class Auth0Interrupt extends Error {
9
+ constructor(message, code) {
10
+ super(message);
11
+ this.name = InterruptName;
12
+ this.code = code;
13
+ }
14
+ /**
15
+ *
16
+ * Serialize the interrupt to a JSON object.
17
+ *
18
+ * @returns - The JSON object representation of the interrupt.
19
+ */
20
+ toJSON() {
21
+ return {
22
+ ...Object.fromEntries(Object.entries(this).filter(([key]) => key !== "stack" && key !== "toJSON")),
23
+ message: this.message,
24
+ };
25
+ }
26
+ /**
27
+ *
28
+ * Checks if an interrupt is of a specific type asserting its data component.
29
+ *
30
+ * This method assert the data part of the interrupt.
31
+ *
32
+ * @param clazz - The class of the interrupt to check.
33
+ * @param interrupt - The interrupt to check.
34
+ *
35
+ * @returns - True if the interrupt is of the specified type.
36
+ */
37
+ static isInterrupt(interrupt) {
38
+ return (interrupt.name === "AUTH0_AI_INTERRUPT" &&
39
+ (typeof this.code === "undefined" || interrupt.code === this.code));
40
+ }
41
+ }
42
+ //# sourceMappingURL=Auth0Interrupt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Auth0Interrupt.js","sourceRoot":"","sources":["../../../src/interrupts/Auth0Interrupt.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,aAAa,GAAG,oBAA6B,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAIvC,YAAY,OAAe,EAAE,IAAY;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJjB,SAAI,GAAG,aAAa,CAAC;QAKnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,MAAM;QACJ,OAAO;YACL,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CACzB,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,QAAQ,CAC/C,CACF;YACD,OAAO,EAAE,IAAI,CAAC,OAAO;SACM,CAAC;IAChC,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,CAEhB,SAAc;QAEd,OAAO,CACL,SAAS,CAAC,IAAI,KAAK,oBAAoB;YACvC,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,CACnE,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Define a type alias for the generalized type\nexport type Auth0InterruptData<T extends Auth0Interrupt> = Omit<\n Omit<T, keyof Error>,\n \"toJSON\"\n> & { message: string };\n\nexport const InterruptName = \"AUTH0_AI_INTERRUPT\" as const;\n\n/**\n * Auth0Interrupt is the base class for all interruptions\n * in the Auth0 AI sdk.\n *\n * It is serializable to a JSON object.\n */\nexport class Auth0Interrupt extends Error {\n name = InterruptName;\n code: string;\n\n constructor(message: string, code: string) {\n super(message);\n this.code = code;\n }\n\n /**\n *\n * Serialize the interrupt to a JSON object.\n *\n * @returns - The JSON object representation of the interrupt.\n */\n toJSON(): Auth0InterruptData<this> {\n return {\n ...Object.fromEntries(\n Object.entries(this).filter(\n ([key]) => key !== \"stack\" && key !== \"toJSON\"\n )\n ),\n message: this.message,\n } as Auth0InterruptData<this>;\n }\n\n /**\n *\n * Checks if an interrupt is of a specific type asserting its data component.\n *\n * This method assert the data part of the interrupt.\n *\n * @param clazz - The class of the interrupt to check.\n * @param interrupt - The interrupt to check.\n *\n * @returns - True if the interrupt is of the specified type.\n */\n static isInterrupt<T extends abstract new (...args: any) => any>(\n this: T & { code?: string },\n interrupt: any\n ): interrupt is Auth0InterruptData<InstanceType<T>> {\n return (\n interrupt.name === \"AUTH0_AI_INTERRUPT\" &&\n (typeof this.code === \"undefined\" || interrupt.code === this.code)\n );\n }\n}\n"]}
@@ -0,0 +1,62 @@
1
+ import { CIBAAuthorizationRequest } from "../authorizers/ciba/CIBAAuthorizationRequest";
2
+ import { Auth0Interrupt, Auth0InterruptData } from "./Auth0Interrupt";
3
+ export interface WithRequestData {
4
+ request: CIBAAuthorizationRequest;
5
+ }
6
+ /**
7
+ * Base class for CIBA interrupts.
8
+ */
9
+ export declare class CIBAInterrupt extends Auth0Interrupt {
10
+ constructor(message: string, code: string);
11
+ static isInterrupt<T extends abstract new (...args: any) => any>(this: T, interrupt: any): interrupt is Auth0InterruptData<InstanceType<T>>;
12
+ static hasRequestData(interrupt: any): interrupt is WithRequestData;
13
+ }
14
+ /**
15
+ * An interrupt that is thrown when the user denies the authorization request.
16
+ */
17
+ export declare class AccessDeniedInterrupt extends CIBAInterrupt implements WithRequestData {
18
+ readonly request: CIBAAuthorizationRequest;
19
+ static code: string;
20
+ constructor(message: string, request: CIBAAuthorizationRequest);
21
+ }
22
+ /**
23
+ * An interrupt that is thrown when the user does not have push notifications enabled.
24
+ */
25
+ export declare class UserDoesNotHavePushNotificationsInterrupt extends CIBAInterrupt {
26
+ static code: string;
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * An interrupt that is thrown when the authorization request has expired.
31
+ */
32
+ export declare class AuthorizationRequestExpiredInterrupt extends CIBAInterrupt implements WithRequestData {
33
+ readonly request: CIBAAuthorizationRequest;
34
+ static code: string;
35
+ constructor(message: string, request: CIBAAuthorizationRequest);
36
+ }
37
+ /**
38
+ * An interrupt that is thrown when the authorization is still pending
39
+ * and the Authorizer is in `mode: interrupt`.
40
+ */
41
+ export declare class AuthorizationPendingInterrupt extends CIBAInterrupt implements WithRequestData {
42
+ readonly request: CIBAAuthorizationRequest;
43
+ static code: string;
44
+ constructor(message: string, request: CIBAAuthorizationRequest);
45
+ }
46
+ /**
47
+ * An interrupt that is thrown when the authorization polling fails.
48
+ */
49
+ export declare class AuthorizationPollingInterrupt extends Auth0Interrupt implements WithRequestData {
50
+ readonly request: CIBAAuthorizationRequest;
51
+ static code: string;
52
+ constructor(message: string, request: CIBAAuthorizationRequest);
53
+ }
54
+ /**
55
+ * An interrupt that is thrown when the authorization polling fails.
56
+ */
57
+ export declare class InvalidGrantInterrupt extends Auth0Interrupt implements WithRequestData {
58
+ readonly request: CIBAAuthorizationRequest;
59
+ static code: string;
60
+ constructor(message: string, request: CIBAAuthorizationRequest);
61
+ }
62
+ //# sourceMappingURL=CIBAInterrupts.d.ts.map
@@ -0,0 +1,79 @@
1
+ import { Auth0Interrupt } from "./Auth0Interrupt";
2
+ /**
3
+ * Base class for CIBA interrupts.
4
+ */
5
+ export class CIBAInterrupt extends Auth0Interrupt {
6
+ constructor(message, code) {
7
+ super(message, code);
8
+ }
9
+ static isInterrupt(interrupt) {
10
+ return (interrupt &&
11
+ Auth0Interrupt.isInterrupt(interrupt) &&
12
+ typeof interrupt.code === "string" &&
13
+ interrupt.code.startsWith("CIBA_"));
14
+ }
15
+ static hasRequestData(interrupt) {
16
+ return CIBAInterrupt.isInterrupt(interrupt) && "request" in interrupt;
17
+ }
18
+ }
19
+ /**
20
+ * An interrupt that is thrown when the user denies the authorization request.
21
+ */
22
+ export class AccessDeniedInterrupt extends CIBAInterrupt {
23
+ constructor(message, request) {
24
+ super(message, AccessDeniedInterrupt.code);
25
+ this.request = request;
26
+ }
27
+ }
28
+ AccessDeniedInterrupt.code = "CIBA_ACCESS_DENIED";
29
+ /**
30
+ * An interrupt that is thrown when the user does not have push notifications enabled.
31
+ */
32
+ export class UserDoesNotHavePushNotificationsInterrupt extends CIBAInterrupt {
33
+ constructor(message) {
34
+ super(message, UserDoesNotHavePushNotificationsInterrupt.code);
35
+ }
36
+ }
37
+ UserDoesNotHavePushNotificationsInterrupt.code = "CIBA_USER_DOES_NOT_HAVE_PUSH_NOTIFICATIONS";
38
+ /**
39
+ * An interrupt that is thrown when the authorization request has expired.
40
+ */
41
+ export class AuthorizationRequestExpiredInterrupt extends CIBAInterrupt {
42
+ constructor(message, request) {
43
+ super(message, AuthorizationRequestExpiredInterrupt.code);
44
+ this.request = request;
45
+ }
46
+ }
47
+ AuthorizationRequestExpiredInterrupt.code = "CIBA_AUTHORIZATION_REQUEST_EXPIRED";
48
+ /**
49
+ * An interrupt that is thrown when the authorization is still pending
50
+ * and the Authorizer is in `mode: interrupt`.
51
+ */
52
+ export class AuthorizationPendingInterrupt extends CIBAInterrupt {
53
+ constructor(message, request) {
54
+ super(message, AuthorizationPendingInterrupt.code);
55
+ this.request = request;
56
+ }
57
+ }
58
+ AuthorizationPendingInterrupt.code = "CIBA_AUTHORIZATION_PENDING";
59
+ /**
60
+ * An interrupt that is thrown when the authorization polling fails.
61
+ */
62
+ export class AuthorizationPollingInterrupt extends Auth0Interrupt {
63
+ constructor(message, request) {
64
+ super(message, AuthorizationPollingInterrupt.code);
65
+ this.request = request;
66
+ }
67
+ }
68
+ AuthorizationPollingInterrupt.code = "CIBA_AUTHORIZATION_POLLING_ERROR";
69
+ /**
70
+ * An interrupt that is thrown when the authorization polling fails.
71
+ */
72
+ export class InvalidGrantInterrupt extends Auth0Interrupt {
73
+ constructor(message, request) {
74
+ super(message, AuthorizationPollingInterrupt.code);
75
+ this.request = request;
76
+ }
77
+ }
78
+ InvalidGrantInterrupt.code = "CIBA_INVALID_GRANT";
79
+ //# sourceMappingURL=CIBAInterrupts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CIBAInterrupts.js","sourceRoot":"","sources":["../../../src/interrupts/CIBAInterrupts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAsB,MAAM,kBAAkB,CAAC;AAMtE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IAC/C,YAAY,OAAe,EAAE,IAAY;QACvC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,WAAW,CAEhB,SAAc;QAEd,OAAO,CACL,SAAS;YACT,cAAc,CAAC,WAAW,CAAC,SAAS,CAAC;YACrC,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;YAClC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CACnC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,SAAc;QAClC,OAAO,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,SAAS,CAAC;IACxE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBACX,SAAQ,aAAa;IAIrB,YACE,OAAe,EACC,OAAiC;QAEjD,KAAK,CAAC,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAF3B,YAAO,GAAP,OAAO,CAA0B;IAGnD,CAAC;;AANa,0BAAI,GAAW,oBAA6B,CAAC;AAS7D;;GAEG;AACH,MAAM,OAAO,yCAA0C,SAAQ,aAAa;IAG1E,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,yCAAyC,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;;AAJa,8CAAI,GAChB,4CAAqD,CAAC;AAM1D;;GAEG;AACH,MAAM,OAAO,oCACX,SAAQ,aAAa;IAIrB,YACE,OAAe,EACC,OAAiC;QAEjD,KAAK,CAAC,OAAO,EAAE,oCAAoC,CAAC,IAAI,CAAC,CAAC;QAF1C,YAAO,GAAP,OAAO,CAA0B;IAGnD,CAAC;;AANa,yCAAI,GAAW,oCAA6C,CAAC;AAS7E;;;GAGG;AACH,MAAM,OAAO,6BACX,SAAQ,aAAa;IAIrB,YACE,OAAe,EACC,OAAiC;QAEjD,KAAK,CAAC,OAAO,EAAE,6BAA6B,CAAC,IAAI,CAAC,CAAC;QAFnC,YAAO,GAAP,OAAO,CAA0B;IAGnD,CAAC;;AANa,kCAAI,GAAW,4BAAqC,CAAC;AASrE;;GAEG;AACH,MAAM,OAAO,6BACX,SAAQ,cAAc;IAItB,YACE,OAAe,EACC,OAAiC;QAEjD,KAAK,CAAC,OAAO,EAAE,6BAA6B,CAAC,IAAI,CAAC,CAAC;QAFnC,YAAO,GAAP,OAAO,CAA0B;IAGnD,CAAC;;AANa,kCAAI,GAAW,kCAA2C,CAAC;AAS3E;;GAEG;AACH,MAAM,OAAO,qBACX,SAAQ,cAAc;IAItB,YACE,OAAe,EACC,OAAiC;QAEjD,KAAK,CAAC,OAAO,EAAE,6BAA6B,CAAC,IAAI,CAAC,CAAC;QAFnC,YAAO,GAAP,OAAO,CAA0B;IAGnD,CAAC;;AANa,0BAAI,GAAW,oBAA6B,CAAC","sourcesContent":["import { CIBAAuthorizationRequest } from \"../authorizers/ciba/CIBAAuthorizationRequest\";\nimport { Auth0Interrupt, Auth0InterruptData } from \"./Auth0Interrupt\";\n\nexport interface WithRequestData {\n request: CIBAAuthorizationRequest;\n}\n\n/**\n * Base class for CIBA interrupts.\n */\nexport class CIBAInterrupt extends Auth0Interrupt {\n constructor(message: string, code: string) {\n super(message, code);\n }\n\n static isInterrupt<T extends abstract new (...args: any) => any>(\n this: T,\n interrupt: any\n ): interrupt is Auth0InterruptData<InstanceType<T>> {\n return (\n interrupt &&\n Auth0Interrupt.isInterrupt(interrupt) &&\n typeof interrupt.code === \"string\" &&\n interrupt.code.startsWith(\"CIBA_\")\n );\n }\n\n static hasRequestData(interrupt: any): interrupt is WithRequestData {\n return CIBAInterrupt.isInterrupt(interrupt) && \"request\" in interrupt;\n }\n}\n\n/**\n * An interrupt that is thrown when the user denies the authorization request.\n */\nexport class AccessDeniedInterrupt\n extends CIBAInterrupt\n implements WithRequestData\n{\n public static code: string = \"CIBA_ACCESS_DENIED\" as const;\n constructor(\n message: string,\n public readonly request: CIBAAuthorizationRequest\n ) {\n super(message, AccessDeniedInterrupt.code);\n }\n}\n\n/**\n * An interrupt that is thrown when the user does not have push notifications enabled.\n */\nexport class UserDoesNotHavePushNotificationsInterrupt extends CIBAInterrupt {\n public static code: string =\n \"CIBA_USER_DOES_NOT_HAVE_PUSH_NOTIFICATIONS\" as const;\n constructor(message: string) {\n super(message, UserDoesNotHavePushNotificationsInterrupt.code);\n }\n}\n\n/**\n * An interrupt that is thrown when the authorization request has expired.\n */\nexport class AuthorizationRequestExpiredInterrupt\n extends CIBAInterrupt\n implements WithRequestData\n{\n public static code: string = \"CIBA_AUTHORIZATION_REQUEST_EXPIRED\" as const;\n constructor(\n message: string,\n public readonly request: CIBAAuthorizationRequest\n ) {\n super(message, AuthorizationRequestExpiredInterrupt.code);\n }\n}\n\n/**\n * An interrupt that is thrown when the authorization is still pending\n * and the Authorizer is in `mode: interrupt`.\n */\nexport class AuthorizationPendingInterrupt\n extends CIBAInterrupt\n implements WithRequestData\n{\n public static code: string = \"CIBA_AUTHORIZATION_PENDING\" as const;\n constructor(\n message: string,\n public readonly request: CIBAAuthorizationRequest\n ) {\n super(message, AuthorizationPendingInterrupt.code);\n }\n}\n\n/**\n * An interrupt that is thrown when the authorization polling fails.\n */\nexport class AuthorizationPollingInterrupt\n extends Auth0Interrupt\n implements WithRequestData\n{\n public static code: string = \"CIBA_AUTHORIZATION_POLLING_ERROR\" as const;\n constructor(\n message: string,\n public readonly request: CIBAAuthorizationRequest\n ) {\n super(message, AuthorizationPollingInterrupt.code);\n }\n}\n\n/**\n * An interrupt that is thrown when the authorization polling fails.\n */\nexport class InvalidGrantInterrupt\n extends Auth0Interrupt\n implements WithRequestData\n{\n public static code: string = \"CIBA_INVALID_GRANT\" as const;\n constructor(\n message: string,\n public readonly request: CIBAAuthorizationRequest\n ) {\n super(message, AuthorizationPollingInterrupt.code);\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import { Auth0Interrupt } from "./Auth0Interrupt";
2
+ /**
3
+ * Error thrown when a tool call requires an access token for an external service.
4
+ *
5
+ * Throw this error if the service returns Unauthorized for the current access token.
6
+ */
7
+ export declare class FederatedConnectionInterrupt extends Auth0Interrupt {
8
+ /**
9
+ * The auth0 connection name.
10
+ */
11
+ readonly connection: string;
12
+ /**
13
+ * The scopes required to access the external service as stated
14
+ * in the authorizer.
15
+ */
16
+ readonly scopes: string[];
17
+ /**
18
+ * The union between the current scopes of the Access Token plus the required scopes.
19
+ * This is the list of scopes that will be used to request a new Access Token.
20
+ */
21
+ readonly requiredScopes: string[];
22
+ static code: "FEDERATED_CONNECTION_ERROR";
23
+ constructor(message: string, connection: string, scopes: string[], requiredScopes: string[]);
24
+ }
25
+ /**
26
+ * Error thrown when a tool call requires an access token for an external service.
27
+ *
28
+ * The authorizer will automatically convert this class of error to FederatedConnectionInterrupt.
29
+ */
30
+ export declare class FederatedConnectionError extends Error {
31
+ constructor(message: string);
32
+ }
33
+ //# sourceMappingURL=FederatedConnectionInterrupt.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { Auth0Interrupt } from "./Auth0Interrupt";
2
+ /**
3
+ * Error thrown when a tool call requires an access token for an external service.
4
+ *
5
+ * Throw this error if the service returns Unauthorized for the current access token.
6
+ */
7
+ export class FederatedConnectionInterrupt extends Auth0Interrupt {
8
+ constructor(message, connection, scopes, requiredScopes) {
9
+ super(message, FederatedConnectionInterrupt.code);
10
+ this.connection = connection;
11
+ this.scopes = scopes;
12
+ this.requiredScopes = requiredScopes;
13
+ }
14
+ }
15
+ FederatedConnectionInterrupt.code = "FEDERATED_CONNECTION_ERROR";
16
+ /**
17
+ * Error thrown when a tool call requires an access token for an external service.
18
+ *
19
+ * The authorizer will automatically convert this class of error to FederatedConnectionInterrupt.
20
+ */
21
+ export class FederatedConnectionError extends Error {
22
+ constructor(message) {
23
+ super(message);
24
+ }
25
+ }
26
+ //# sourceMappingURL=FederatedConnectionInterrupt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FederatedConnectionInterrupt.js","sourceRoot":"","sources":["../../../src/interrupts/FederatedConnectionInterrupt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAoB9D,YACE,OAAe,EACf,UAAkB,EAClB,MAAgB,EAChB,cAAwB;QAExB,KAAK,CAAC,OAAO,EAAE,4BAA4B,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;;AAZa,iCAAI,GAAG,4BAAqC,CAAC;AAe7D;;;;GAIG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Auth0Interrupt } from \"./Auth0Interrupt\";\n\n/**\n * Error thrown when a tool call requires an access token for an external service.\n *\n * Throw this error if the service returns Unauthorized for the current access token.\n */\nexport class FederatedConnectionInterrupt extends Auth0Interrupt {\n /**\n * The auth0 connection name.\n */\n public readonly connection: string;\n\n /**\n * The scopes required to access the external service as stated\n * in the authorizer.\n */\n public readonly scopes: string[];\n\n /**\n * The union between the current scopes of the Access Token plus the required scopes.\n * This is the list of scopes that will be used to request a new Access Token.\n */\n public readonly requiredScopes: string[];\n\n public static code = \"FEDERATED_CONNECTION_ERROR\" as const;\n\n constructor(\n message: string,\n connection: string,\n scopes: string[],\n requiredScopes: string[]\n ) {\n super(message, FederatedConnectionInterrupt.code);\n this.connection = connection;\n this.scopes = scopes;\n this.requiredScopes = requiredScopes;\n }\n}\n\n/**\n * Error thrown when a tool call requires an access token for an external service.\n *\n * The authorizer will automatically convert this class of error to FederatedConnectionInterrupt.\n */\nexport class FederatedConnectionError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export { Auth0Interrupt } from "./Auth0Interrupt";
2
+ export { FederatedConnectionInterrupt, FederatedConnectionError, } from "./FederatedConnectionInterrupt";
3
+ export { CIBAInterrupt, AccessDeniedInterrupt, UserDoesNotHavePushNotificationsInterrupt, AuthorizationRequestExpiredInterrupt, AuthorizationPendingInterrupt, AuthorizationPollingInterrupt, InvalidGrantInterrupt, } from "./CIBAInterrupts";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { Auth0Interrupt } from "./Auth0Interrupt";
2
+ export { FederatedConnectionInterrupt, FederatedConnectionError, } from "./FederatedConnectionInterrupt";
3
+ export { CIBAInterrupt, AccessDeniedInterrupt, UserDoesNotHavePushNotificationsInterrupt, AuthorizationRequestExpiredInterrupt, AuthorizationPendingInterrupt, AuthorizationPollingInterrupt, InvalidGrantInterrupt, } from "./CIBAInterrupts";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interrupts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,yCAAyC,EACzC,oCAAoC,EACpC,6BAA6B,EAC7B,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC","sourcesContent":["export { Auth0Interrupt } from \"./Auth0Interrupt\";\n\nexport {\n FederatedConnectionInterrupt,\n FederatedConnectionError,\n} from \"./FederatedConnectionInterrupt\";\n\nexport {\n CIBAInterrupt,\n AccessDeniedInterrupt,\n UserDoesNotHavePushNotificationsInterrupt,\n AuthorizationRequestExpiredInterrupt,\n AuthorizationPendingInterrupt,\n AuthorizationPollingInterrupt,\n InvalidGrantInterrupt,\n} from \"./CIBAInterrupts\";\n"]}
@@ -0,0 +1,3 @@
1
+ export type AuthorizerToolParameter<ToolExecuteArgs extends any[], TResult = string> = TResult | ((...args: ToolExecuteArgs) => Promise<TResult> | TResult);
2
+ export declare const resolveParameter: <ToolExecuteArgs extends any[], TResult = string>(resolver: AuthorizerToolParameter<ToolExecuteArgs, TResult>, context: ToolExecuteArgs) => TResult | Promise<TResult>;
3
+ //# sourceMappingURL=parameters.d.ts.map
@@ -0,0 +1,9 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
2
+ const isCallback = (maybeFunction) => typeof maybeFunction === "function";
3
+ export const resolveParameter = (resolver, context) => {
4
+ if (isCallback(resolver)) {
5
+ return resolver(...context);
6
+ }
7
+ return resolver;
8
+ };
9
+ //# sourceMappingURL=parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,UAAU,GAAG,CACjB,aAA+C,EACpB,EAAE,CAAC,OAAO,aAAa,KAAK,UAAU,CAAC;AAOpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAI9B,QAA2D,EAC3D,OAAwB,EACI,EAAE;IAC9B,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC,GAAG,OAAO,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-function-type */\nconst isCallback = (\n maybeFunction: any | ((...args: any[]) => void)\n): maybeFunction is Function => typeof maybeFunction === \"function\";\n\nexport type AuthorizerToolParameter<\n ToolExecuteArgs extends any[],\n TResult = string\n> = TResult | ((...args: ToolExecuteArgs) => Promise<TResult> | TResult);\n\nexport const resolveParameter = <\n ToolExecuteArgs extends any[],\n TResult = string\n>(\n resolver: AuthorizerToolParameter<ToolExecuteArgs, TResult>,\n context: ToolExecuteArgs\n): TResult | Promise<TResult> => {\n if (isCallback(resolver)) {\n return resolver(...context);\n }\n return resolver;\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@auth0/ai",
3
+ "version": "1.0.0",
4
+ "description": "Auth0AI SDK for JavaScript",
5
+ "types": "dist/esm/index.d.ts",
6
+ "main": "dist/cjs/index.js",
7
+ "module": "./dist/esm/index.js",
8
+ "scripts": {
9
+ "build": "npm run clean && npm run build:esm && npm run build:cjs",
10
+ "build:esm": "tsc --outDir ./dist/esm",
11
+ "build:cjs": "tsc --module nodenext --moduleResolution nodenext --declaration false --declarationMap false --outDir ./dist/cjs",
12
+ "build:watch": "run-p 'build:esm -- --watch' 'build:cjs -- -watch'",
13
+ "clean": "rm -rf dist",
14
+ "lint": "eslint \"./**/*.ts*\"",
15
+ "type-check": "tsc --noEmit",
16
+ "test": "vitest run",
17
+ "semantic-release": "npx --no semantic-release"
18
+ },
19
+ "author": {
20
+ "name": "Auth0 Inc.",
21
+ "url": "https://auth0.com"
22
+ },
23
+ "files": [
24
+ "dist/**/*.{*js,*js.map,d.ts}"
25
+ ],
26
+ "exports": {
27
+ "./package.json": "./package.json",
28
+ ".": {
29
+ "types": "./dist/esm/index.d.ts",
30
+ "import": "./dist/esm/index.js",
31
+ "require": "./dist/cjs/index.js"
32
+ },
33
+ "./interrupts": {
34
+ "types": "./dist/esm/interrupts/index.d.ts",
35
+ "import": "./dist/esm/interrupts/index.js",
36
+ "require": "./dist/cjs/interrupts/index.js"
37
+ },
38
+ "./FederatedConnections": {
39
+ "types": "./dist/esm/authorizers/federated-connections/index.d.ts",
40
+ "import": "./dist/esm/authorizers/federated-connections/index.js",
41
+ "require": "./dist/cjs/authorizers/federated-connections/index.js"
42
+ },
43
+ "./CIBA": {
44
+ "types": "./dist/esm/authorizers/ciba/index.d.ts",
45
+ "import": "./dist/esm/authorizers/ciba/index.js",
46
+ "require": "./dist/cjs/authorizers/ciba/index.js"
47
+ },
48
+ "./FGA": {
49
+ "types": "./dist/esm/authorizers/fga/index.d.ts",
50
+ "import": "./dist/esm/authorizers/fga/index.js",
51
+ "require": "./dist/cjs/authorizers/fga/index.js"
52
+ }
53
+ },
54
+ "license": "Apache-2.0",
55
+ "devDependencies": {
56
+ "@eslint/js": "^9.18.0",
57
+ "@types/node": "^22.10.6",
58
+ "eslint": "^8.57.0",
59
+ "globals": "^15.11.0",
60
+ "typedoc": "^0.27.6",
61
+ "typescript": "^5.7.3",
62
+ "typescript-eslint": "^8.20.0",
63
+ "vitest": "^3.0.8"
64
+ },
65
+ "dependencies": {
66
+ "@openfga/sdk": "^0.8.0",
67
+ "auth0": "^4.18.0",
68
+ "enquirer": "^2.4.1",
69
+ "jose": "^5.9.6",
70
+ "open": "^10.1.0",
71
+ "openid-client": "^6.1.7"
72
+ },
73
+ "publishConfig": {
74
+ "access": "public"
75
+ }
76
+ }