@chucky.cloud/sdk 0.2.7 → 0.3.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/browser.cjs +1371 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +1 -0
- package/dist/browser.d.ts +1 -8
- package/dist/browser.js +1288 -11
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +1371 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1991 -0
- package/dist/index.d.ts +1971 -48
- package/dist/index.js +1288 -72
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +1371 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +1 -0
- package/dist/node.d.ts +1 -8
- package/dist/node.js +1288 -10
- package/dist/node.js.map +1 -1
- package/package.json +13 -7
- package/dist/browser.d.ts.map +0 -1
- package/dist/client/ChuckyClient.d.ts +0 -141
- package/dist/client/ChuckyClient.d.ts.map +0 -1
- package/dist/client/ChuckyClient.js +0 -209
- package/dist/client/ChuckyClient.js.map +0 -1
- package/dist/client/Session.d.ts +0 -167
- package/dist/client/Session.d.ts.map +0 -1
- package/dist/client/Session.js +0 -392
- package/dist/client/Session.js.map +0 -1
- package/dist/client/index.d.ts +0 -10
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -9
- package/dist/client/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/node.d.ts.map +0 -1
- package/dist/tools/McpServer.d.ts +0 -117
- package/dist/tools/McpServer.d.ts.map +0 -1
- package/dist/tools/McpServer.js +0 -142
- package/dist/tools/McpServer.js.map +0 -1
- package/dist/tools/index.d.ts +0 -9
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -8
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/tool.d.ts +0 -146
- package/dist/tools/tool.d.ts.map +0 -1
- package/dist/tools/tool.js +0 -232
- package/dist/tools/tool.js.map +0 -1
- package/dist/transport/Transport.d.ts +0 -82
- package/dist/transport/Transport.d.ts.map +0 -1
- package/dist/transport/Transport.js +0 -47
- package/dist/transport/Transport.js.map +0 -1
- package/dist/transport/WebSocketTransport.d.ts +0 -78
- package/dist/transport/WebSocketTransport.d.ts.map +0 -1
- package/dist/transport/WebSocketTransport.js +0 -258
- package/dist/transport/WebSocketTransport.js.map +0 -1
- package/dist/transport/index.d.ts +0 -10
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js +0 -8
- package/dist/transport/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -12
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -8
- package/dist/types/index.js.map +0 -1
- package/dist/types/messages.d.ts +0 -327
- package/dist/types/messages.d.ts.map +0 -1
- package/dist/types/messages.js +0 -133
- package/dist/types/messages.js.map +0 -1
- package/dist/types/options.d.ts +0 -212
- package/dist/types/options.d.ts.map +0 -1
- package/dist/types/options.js +0 -8
- package/dist/types/options.js.map +0 -1
- package/dist/types/results.d.ts +0 -186
- package/dist/types/results.d.ts.map +0 -1
- package/dist/types/results.js +0 -7
- package/dist/types/results.js.map +0 -1
- package/dist/types/token.d.ts +0 -124
- package/dist/types/token.d.ts.map +0 -1
- package/dist/types/token.js +0 -7
- package/dist/types/token.js.map +0 -1
- package/dist/types/tools.d.ts +0 -234
- package/dist/types/tools.d.ts.map +0 -1
- package/dist/types/tools.js +0 -31
- package/dist/types/tools.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -80
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -158
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -8
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/token.d.ts +0 -104
- package/dist/utils/token.d.ts.map +0 -1
- package/dist/utils/token.js +0 -209
- package/dist/utils/token.js.map +0 -1
package/dist/utils/errors.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Classes
|
|
3
|
-
*
|
|
4
|
-
* Custom error types for the Chucky SDK.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Base error class for Chucky SDK errors
|
|
8
|
-
*/
|
|
9
|
-
export declare class ChuckyError extends Error {
|
|
10
|
-
/** Error code */
|
|
11
|
-
readonly code: string;
|
|
12
|
-
/** Additional error details */
|
|
13
|
-
readonly details?: Record<string, unknown>;
|
|
14
|
-
constructor(message: string, code: string, details?: Record<string, unknown>);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Connection error
|
|
18
|
-
*/
|
|
19
|
-
export declare class ConnectionError extends ChuckyError {
|
|
20
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Authentication error
|
|
24
|
-
*/
|
|
25
|
-
export declare class AuthenticationError extends ChuckyError {
|
|
26
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Budget exceeded error
|
|
30
|
-
*/
|
|
31
|
-
export declare class BudgetExceededError extends ChuckyError {
|
|
32
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Concurrency limit error
|
|
36
|
-
*/
|
|
37
|
-
export declare class ConcurrencyLimitError extends ChuckyError {
|
|
38
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Rate limit error
|
|
42
|
-
*/
|
|
43
|
-
export declare class RateLimitError extends ChuckyError {
|
|
44
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Session error
|
|
48
|
-
*/
|
|
49
|
-
export declare class SessionError extends ChuckyError {
|
|
50
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Tool execution error
|
|
54
|
-
*/
|
|
55
|
-
export declare class ToolExecutionError extends ChuckyError {
|
|
56
|
-
/** Tool name */
|
|
57
|
-
readonly toolName: string;
|
|
58
|
-
constructor(message: string, toolName: string, details?: Record<string, unknown>);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Timeout error
|
|
62
|
-
*/
|
|
63
|
-
export declare class TimeoutError extends ChuckyError {
|
|
64
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Validation error
|
|
68
|
-
*/
|
|
69
|
-
export declare class ValidationError extends ChuckyError {
|
|
70
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Parse error code from error message
|
|
74
|
-
*/
|
|
75
|
-
export declare function parseErrorCode(message: string): string | null;
|
|
76
|
-
/**
|
|
77
|
-
* Create appropriate error from message and optional code
|
|
78
|
-
*/
|
|
79
|
-
export declare function createError(message: string, code?: string): ChuckyError;
|
|
80
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,iBAAiB;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAW7E;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE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ED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqB7D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAuBvE"}
|
package/dist/utils/errors.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Classes
|
|
3
|
-
*
|
|
4
|
-
* Custom error types for the Chucky SDK.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Base error class for Chucky SDK errors
|
|
8
|
-
*/
|
|
9
|
-
export class ChuckyError extends Error {
|
|
10
|
-
/** Error code */
|
|
11
|
-
code;
|
|
12
|
-
/** Additional error details */
|
|
13
|
-
details;
|
|
14
|
-
constructor(message, code, details) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = 'ChuckyError';
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.details = details;
|
|
19
|
-
// Maintains proper stack trace for where the error was thrown
|
|
20
|
-
if (Error.captureStackTrace) {
|
|
21
|
-
Error.captureStackTrace(this, ChuckyError);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Connection error
|
|
27
|
-
*/
|
|
28
|
-
export class ConnectionError extends ChuckyError {
|
|
29
|
-
constructor(message, details) {
|
|
30
|
-
super(message, 'CONNECTION_ERROR', details);
|
|
31
|
-
this.name = 'ConnectionError';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Authentication error
|
|
36
|
-
*/
|
|
37
|
-
export class AuthenticationError extends ChuckyError {
|
|
38
|
-
constructor(message, details) {
|
|
39
|
-
super(message, 'AUTHENTICATION_ERROR', details);
|
|
40
|
-
this.name = 'AuthenticationError';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Budget exceeded error
|
|
45
|
-
*/
|
|
46
|
-
export class BudgetExceededError extends ChuckyError {
|
|
47
|
-
constructor(message, details) {
|
|
48
|
-
super(message, 'BUDGET_EXCEEDED', details);
|
|
49
|
-
this.name = 'BudgetExceededError';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Concurrency limit error
|
|
54
|
-
*/
|
|
55
|
-
export class ConcurrencyLimitError extends ChuckyError {
|
|
56
|
-
constructor(message, details) {
|
|
57
|
-
super(message, 'CONCURRENCY_LIMIT', details);
|
|
58
|
-
this.name = 'ConcurrencyLimitError';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Rate limit error
|
|
63
|
-
*/
|
|
64
|
-
export class RateLimitError extends ChuckyError {
|
|
65
|
-
constructor(message, details) {
|
|
66
|
-
super(message, 'RATE_LIMIT', details);
|
|
67
|
-
this.name = 'RateLimitError';
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Session error
|
|
72
|
-
*/
|
|
73
|
-
export class SessionError extends ChuckyError {
|
|
74
|
-
constructor(message, details) {
|
|
75
|
-
super(message, 'SESSION_ERROR', details);
|
|
76
|
-
this.name = 'SessionError';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Tool execution error
|
|
81
|
-
*/
|
|
82
|
-
export class ToolExecutionError extends ChuckyError {
|
|
83
|
-
/** Tool name */
|
|
84
|
-
toolName;
|
|
85
|
-
constructor(message, toolName, details) {
|
|
86
|
-
super(message, 'TOOL_EXECUTION_ERROR', { ...details, toolName });
|
|
87
|
-
this.name = 'ToolExecutionError';
|
|
88
|
-
this.toolName = toolName;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Timeout error
|
|
93
|
-
*/
|
|
94
|
-
export class TimeoutError extends ChuckyError {
|
|
95
|
-
constructor(message, details) {
|
|
96
|
-
super(message, 'TIMEOUT', details);
|
|
97
|
-
this.name = 'TimeoutError';
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Validation error
|
|
102
|
-
*/
|
|
103
|
-
export class ValidationError extends ChuckyError {
|
|
104
|
-
constructor(message, details) {
|
|
105
|
-
super(message, 'VALIDATION_ERROR', details);
|
|
106
|
-
this.name = 'ValidationError';
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Parse error code from error message
|
|
111
|
-
*/
|
|
112
|
-
export function parseErrorCode(message) {
|
|
113
|
-
// Common error patterns
|
|
114
|
-
const patterns = [
|
|
115
|
-
{ pattern: /budget.*exceed/i, code: 'BUDGET_EXCEEDED' },
|
|
116
|
-
{ pattern: /concurrency.*limit/i, code: 'CONCURRENCY_LIMIT' },
|
|
117
|
-
{ pattern: /rate.*limit/i, code: 'RATE_LIMIT' },
|
|
118
|
-
{ pattern: /auth|unauthorized|forbidden/i, code: 'AUTHENTICATION_ERROR' },
|
|
119
|
-
{ pattern: /timeout/i, code: 'TIMEOUT' },
|
|
120
|
-
{ pattern: /connect|disconnect|websocket/i, code: 'CONNECTION_ERROR' },
|
|
121
|
-
{ pattern: /session/i, code: 'SESSION_ERROR' },
|
|
122
|
-
{ pattern: /tool/i, code: 'TOOL_EXECUTION_ERROR' },
|
|
123
|
-
{ pattern: /invalid|validation/i, code: 'VALIDATION_ERROR' },
|
|
124
|
-
];
|
|
125
|
-
for (const { pattern, code } of patterns) {
|
|
126
|
-
if (pattern.test(message)) {
|
|
127
|
-
return code;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Create appropriate error from message and optional code
|
|
134
|
-
*/
|
|
135
|
-
export function createError(message, code) {
|
|
136
|
-
const errorCode = code || parseErrorCode(message) || 'UNKNOWN_ERROR';
|
|
137
|
-
switch (errorCode) {
|
|
138
|
-
case 'CONNECTION_ERROR':
|
|
139
|
-
return new ConnectionError(message);
|
|
140
|
-
case 'AUTHENTICATION_ERROR':
|
|
141
|
-
return new AuthenticationError(message);
|
|
142
|
-
case 'BUDGET_EXCEEDED':
|
|
143
|
-
return new BudgetExceededError(message);
|
|
144
|
-
case 'CONCURRENCY_LIMIT':
|
|
145
|
-
return new ConcurrencyLimitError(message);
|
|
146
|
-
case 'RATE_LIMIT':
|
|
147
|
-
return new RateLimitError(message);
|
|
148
|
-
case 'SESSION_ERROR':
|
|
149
|
-
return new SessionError(message);
|
|
150
|
-
case 'TIMEOUT':
|
|
151
|
-
return new TimeoutError(message);
|
|
152
|
-
case 'VALIDATION_ERROR':
|
|
153
|
-
return new ValidationError(message);
|
|
154
|
-
default:
|
|
155
|
-
return new ChuckyError(message, errorCode);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/utils/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,iBAAiB;IACR,IAAI,CAAS;IACtB,+BAA+B;IACtB,OAAO,CAA2B;IAE3C,YAAY,OAAe,EAAE,IAAY,EAAE,OAAiC;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,8DAA8D;QAC9D,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C,YAAY,OAAe,EAAE,OAAiC;QAC5D,K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-
* Re-exports all utility functions.
|
|
5
|
-
*/
|
|
6
|
-
export { createToken, decodeToken, verifyToken, isTokenExpired, extractProjectId, createBudget, } from './token.js';
|
|
7
|
-
export { ChuckyError, ConnectionError, AuthenticationError, BudgetExceededError, ConcurrencyLimitError, RateLimitError, SessionError, ToolExecutionError, TimeoutError, ValidationError, parseErrorCode, createError, } from './errors.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
package/dist/utils/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utils Index
|
|
3
|
-
*
|
|
4
|
-
* Re-exports all utility functions.
|
|
5
|
-
*/
|
|
6
|
-
export { createToken, decodeToken, verifyToken, isTokenExpired, extractProjectId, createBudget, } from './token.js';
|
|
7
|
-
export { ChuckyError, ConnectionError, AuthenticationError, BudgetExceededError, ConcurrencyLimitError, RateLimitError, SessionError, ToolExecutionError, TimeoutError, ValidationError, parseErrorCode, createError, } from './errors.js';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
package/dist/utils/token.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token Utilities
|
|
3
|
-
*
|
|
4
|
-
* Helpers for creating and decoding JWT tokens for authentication.
|
|
5
|
-
* These are primarily for server-side use (Node.js).
|
|
6
|
-
*/
|
|
7
|
-
import type { CreateTokenOptions, DecodedToken, TokenBudget } from '../types/token.js';
|
|
8
|
-
/**
|
|
9
|
-
* Create a budget token (JWT) for authenticating with Chucky
|
|
10
|
-
*
|
|
11
|
-
* @param options - Token creation options
|
|
12
|
-
* @returns Signed JWT token
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* // Server-side token creation
|
|
17
|
-
* const token = await createToken({
|
|
18
|
-
* userId: 'user-123',
|
|
19
|
-
* projectId: '550e8400-e29b-41d4-a716-446655440000',
|
|
20
|
-
* secret: 'your-hmac-secret',
|
|
21
|
-
* budget: {
|
|
22
|
-
* ai: 1_000_000, // $1 in microdollars
|
|
23
|
-
* compute: 3600, // 1 hour
|
|
24
|
-
* window: 'day',
|
|
25
|
-
* windowStart: new Date().toISOString(),
|
|
26
|
-
* },
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare function createToken(options: CreateTokenOptions): Promise<string>;
|
|
31
|
-
/**
|
|
32
|
-
* Decode a token without verification
|
|
33
|
-
*
|
|
34
|
-
* @param token - JWT token to decode
|
|
35
|
-
* @returns Decoded token parts
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const decoded = decodeToken(token);
|
|
40
|
-
* console.log(decoded.payload.sub); // User ID
|
|
41
|
-
* console.log(decoded.payload.budget); // Budget limits
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare function decodeToken(token: string): DecodedToken;
|
|
45
|
-
/**
|
|
46
|
-
* Verify a token signature
|
|
47
|
-
*
|
|
48
|
-
* @param token - JWT token to verify
|
|
49
|
-
* @param secret - HMAC secret for verification
|
|
50
|
-
* @returns True if signature is valid
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const isValid = await verifyToken(token, 'your-hmac-secret');
|
|
55
|
-
* if (!isValid) {
|
|
56
|
-
* throw new Error('Invalid token');
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function verifyToken(token: string, secret: string): Promise<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* Check if a token is expired
|
|
63
|
-
*
|
|
64
|
-
* @param token - JWT token to check
|
|
65
|
-
* @returns True if token is expired
|
|
66
|
-
*/
|
|
67
|
-
export declare function isTokenExpired(token: string): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* @deprecated The project ID is now separate from the HMAC key for security reasons.
|
|
70
|
-
* Get your project ID from the Chucky portal (app.chucky.cloud) instead.
|
|
71
|
-
*
|
|
72
|
-
* Previously, the HMAC key embedded the project ID, but this exposed the secret
|
|
73
|
-
* in JWT tokens. Project IDs are now Convex document IDs visible in the portal.
|
|
74
|
-
*
|
|
75
|
-
* @param _hmacKey - Ignored (previously used to extract project ID)
|
|
76
|
-
* @throws Always throws an error directing users to get project ID from portal
|
|
77
|
-
*/
|
|
78
|
-
export declare function extractProjectId(_hmacKey: string): never;
|
|
79
|
-
/**
|
|
80
|
-
* Create a simple budget configuration
|
|
81
|
-
*
|
|
82
|
-
* @param options - Budget options
|
|
83
|
-
* @returns Budget configuration
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* const budget = createBudget({
|
|
88
|
-
* aiDollars: 1.00, // $1 AI budget
|
|
89
|
-
* computeHours: 1, // 1 hour compute
|
|
90
|
-
* window: 'day',
|
|
91
|
-
* });
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
export declare function createBudget(options: {
|
|
95
|
-
/** AI budget in dollars */
|
|
96
|
-
aiDollars: number;
|
|
97
|
-
/** Compute budget in hours */
|
|
98
|
-
computeHours: number;
|
|
99
|
-
/** Budget window */
|
|
100
|
-
window: 'hour' | 'day' | 'week' | 'month';
|
|
101
|
-
/** Window start (default: now) */
|
|
102
|
-
windowStart?: Date;
|
|
103
|
-
}): TokenBudget;
|
|
104
|
-
//# sourceMappingURL=token.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/utils/token.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAEV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAkF3B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsC9E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAYvD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUjF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAKxD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACpC,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IAC1C,kCAAkC;IAClC,WAAW,CAAC,EAAE,IAAI,CAAC;CACpB,GAAG,WAAW,CAOd"}
|
package/dist/utils/token.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token Utilities
|
|
3
|
-
*
|
|
4
|
-
* Helpers for creating and decoding JWT tokens for authentication.
|
|
5
|
-
* These are primarily for server-side use (Node.js).
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Base64URL encode a string
|
|
9
|
-
*/
|
|
10
|
-
function base64UrlEncode(data) {
|
|
11
|
-
let base64;
|
|
12
|
-
if (typeof data === 'string') {
|
|
13
|
-
// Use TextEncoder for string
|
|
14
|
-
const bytes = new TextEncoder().encode(data);
|
|
15
|
-
base64 = btoa(String.fromCharCode(...bytes));
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
base64 = btoa(String.fromCharCode(...data));
|
|
19
|
-
}
|
|
20
|
-
return base64
|
|
21
|
-
.replace(/\+/g, '-')
|
|
22
|
-
.replace(/\//g, '_')
|
|
23
|
-
.replace(/=+$/, '');
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Base64URL decode a string
|
|
27
|
-
*/
|
|
28
|
-
function base64UrlDecode(str) {
|
|
29
|
-
const base64 = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
30
|
-
const padding = '='.repeat((4 - (base64.length % 4)) % 4);
|
|
31
|
-
const bytes = atob(base64 + padding);
|
|
32
|
-
return bytes;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get crypto implementation (browser or Node.js)
|
|
36
|
-
*/
|
|
37
|
-
async function getCrypto() {
|
|
38
|
-
if (typeof crypto !== 'undefined' && crypto.subtle) {
|
|
39
|
-
return crypto;
|
|
40
|
-
}
|
|
41
|
-
// Node.js: use webcrypto
|
|
42
|
-
const nodeCrypto = await import('crypto');
|
|
43
|
-
return nodeCrypto.webcrypto;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Create HMAC-SHA256 signature
|
|
47
|
-
*/
|
|
48
|
-
async function createHmacSignature(secret, data) {
|
|
49
|
-
const { subtle } = await getCrypto();
|
|
50
|
-
const keyData = new TextEncoder().encode(secret);
|
|
51
|
-
const key = await subtle.importKey('raw', keyData, { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
52
|
-
const signature = await subtle.sign('HMAC', key, new TextEncoder().encode(data));
|
|
53
|
-
return base64UrlEncode(new Uint8Array(signature));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Verify HMAC-SHA256 signature
|
|
57
|
-
*/
|
|
58
|
-
async function verifyHmacSignature(secret, data, signature) {
|
|
59
|
-
const expectedSignature = await createHmacSignature(secret, data);
|
|
60
|
-
return signature === expectedSignature;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Create a budget token (JWT) for authenticating with Chucky
|
|
64
|
-
*
|
|
65
|
-
* @param options - Token creation options
|
|
66
|
-
* @returns Signed JWT token
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* // Server-side token creation
|
|
71
|
-
* const token = await createToken({
|
|
72
|
-
* userId: 'user-123',
|
|
73
|
-
* projectId: '550e8400-e29b-41d4-a716-446655440000',
|
|
74
|
-
* secret: 'your-hmac-secret',
|
|
75
|
-
* budget: {
|
|
76
|
-
* ai: 1_000_000, // $1 in microdollars
|
|
77
|
-
* compute: 3600, // 1 hour
|
|
78
|
-
* window: 'day',
|
|
79
|
-
* windowStart: new Date().toISOString(),
|
|
80
|
-
* },
|
|
81
|
-
* });
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
export async function createToken(options) {
|
|
85
|
-
const { userId, projectId, secret, expiresIn = 3600, budget, permissions, sdkConfig, } = options;
|
|
86
|
-
const now = Math.floor(Date.now() / 1000);
|
|
87
|
-
const payload = {
|
|
88
|
-
sub: userId,
|
|
89
|
-
iss: projectId,
|
|
90
|
-
iat: now,
|
|
91
|
-
exp: now + expiresIn,
|
|
92
|
-
budget,
|
|
93
|
-
...(permissions && { permissions }),
|
|
94
|
-
...(sdkConfig && { sdkConfig }),
|
|
95
|
-
};
|
|
96
|
-
// Create header
|
|
97
|
-
const header = {
|
|
98
|
-
alg: 'HS256',
|
|
99
|
-
typ: 'JWT',
|
|
100
|
-
};
|
|
101
|
-
// Encode header and payload
|
|
102
|
-
const encodedHeader = base64UrlEncode(JSON.stringify(header));
|
|
103
|
-
const encodedPayload = base64UrlEncode(JSON.stringify(payload));
|
|
104
|
-
// Create signature
|
|
105
|
-
const signatureInput = `${encodedHeader}.${encodedPayload}`;
|
|
106
|
-
const signature = await createHmacSignature(secret, signatureInput);
|
|
107
|
-
return `${encodedHeader}.${encodedPayload}.${signature}`;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Decode a token without verification
|
|
111
|
-
*
|
|
112
|
-
* @param token - JWT token to decode
|
|
113
|
-
* @returns Decoded token parts
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* const decoded = decodeToken(token);
|
|
118
|
-
* console.log(decoded.payload.sub); // User ID
|
|
119
|
-
* console.log(decoded.payload.budget); // Budget limits
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
export function decodeToken(token) {
|
|
123
|
-
const parts = token.split('.');
|
|
124
|
-
if (parts.length !== 3) {
|
|
125
|
-
throw new Error('Invalid token format');
|
|
126
|
-
}
|
|
127
|
-
const [encodedHeader, encodedPayload, signature] = parts;
|
|
128
|
-
const header = JSON.parse(base64UrlDecode(encodedHeader));
|
|
129
|
-
const payload = JSON.parse(base64UrlDecode(encodedPayload));
|
|
130
|
-
return { header, payload, signature };
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Verify a token signature
|
|
134
|
-
*
|
|
135
|
-
* @param token - JWT token to verify
|
|
136
|
-
* @param secret - HMAC secret for verification
|
|
137
|
-
* @returns True if signature is valid
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* const isValid = await verifyToken(token, 'your-hmac-secret');
|
|
142
|
-
* if (!isValid) {
|
|
143
|
-
* throw new Error('Invalid token');
|
|
144
|
-
* }
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
export async function verifyToken(token, secret) {
|
|
148
|
-
const parts = token.split('.');
|
|
149
|
-
if (parts.length !== 3) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
const [encodedHeader, encodedPayload, signature] = parts;
|
|
153
|
-
const signatureInput = `${encodedHeader}.${encodedPayload}`;
|
|
154
|
-
return verifyHmacSignature(secret, signatureInput, signature);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Check if a token is expired
|
|
158
|
-
*
|
|
159
|
-
* @param token - JWT token to check
|
|
160
|
-
* @returns True if token is expired
|
|
161
|
-
*/
|
|
162
|
-
export function isTokenExpired(token) {
|
|
163
|
-
try {
|
|
164
|
-
const decoded = decodeToken(token);
|
|
165
|
-
const now = Math.floor(Date.now() / 1000);
|
|
166
|
-
return decoded.payload.exp < now;
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
return true;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @deprecated The project ID is now separate from the HMAC key for security reasons.
|
|
174
|
-
* Get your project ID from the Chucky portal (app.chucky.cloud) instead.
|
|
175
|
-
*
|
|
176
|
-
* Previously, the HMAC key embedded the project ID, but this exposed the secret
|
|
177
|
-
* in JWT tokens. Project IDs are now Convex document IDs visible in the portal.
|
|
178
|
-
*
|
|
179
|
-
* @param _hmacKey - Ignored (previously used to extract project ID)
|
|
180
|
-
* @throws Always throws an error directing users to get project ID from portal
|
|
181
|
-
*/
|
|
182
|
-
export function extractProjectId(_hmacKey) {
|
|
183
|
-
throw new Error('extractProjectId() is deprecated. The project ID is now separate from the HMAC key for security. ' +
|
|
184
|
-
'Get your project ID from the Chucky portal (app.chucky.cloud) in your project settings.');
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Create a simple budget configuration
|
|
188
|
-
*
|
|
189
|
-
* @param options - Budget options
|
|
190
|
-
* @returns Budget configuration
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```typescript
|
|
194
|
-
* const budget = createBudget({
|
|
195
|
-
* aiDollars: 1.00, // $1 AI budget
|
|
196
|
-
* computeHours: 1, // 1 hour compute
|
|
197
|
-
* window: 'day',
|
|
198
|
-
* });
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
export function createBudget(options) {
|
|
202
|
-
return {
|
|
203
|
-
ai: Math.floor(options.aiDollars * 1_000_000), // Convert to microdollars
|
|
204
|
-
compute: Math.floor(options.computeHours * 3600), // Convert to seconds
|
|
205
|
-
window: options.window,
|
|
206
|
-
windowStart: (options.windowStart || new Date()).toISOString(),
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
//# sourceMappingURL=token.js.map
|
package/dist/utils/token.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/utils/token.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,SAAS,eAAe,CAAC,IAAyB;IAChD,IAAI,MAAc,CAAC;IAEnB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,6BAA6B;QAC7B,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,K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