@curless/agentbank-core 0.0.2 → 0.1.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/encoding.d.ts +4 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +30 -0
- package/dist/encoding.js.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -1
- package/dist/http.d.ts +8 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +52 -6
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,KAAG,MAMpC,CAAC;AAGF,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,KAAG,MACgC,CAAC;AAKzE,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAMxC,CAAC"}
|
package/dist/encoding.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Portable base64 / base64url for every runtime the SDKs target: Node has
|
|
2
|
+
// Buffer; Workers / Deno / edge have atob + btoa + TextEncoder/Decoder. One
|
|
3
|
+
// implementation here so the buyer / merchant / protocol packages encode
|
|
4
|
+
// identically instead of each shipping its own guarded copy (which is how
|
|
5
|
+
// protocols-sdk ended up with an unguarded Buffer that crashed on Workers).
|
|
6
|
+
const hasBuffer = typeof Buffer !== 'undefined';
|
|
7
|
+
// utf8 string → standard base64.
|
|
8
|
+
export const toBase64 = (s) => {
|
|
9
|
+
if (hasBuffer)
|
|
10
|
+
return Buffer.from(s, 'utf8').toString('base64');
|
|
11
|
+
const bytes = new TextEncoder().encode(s);
|
|
12
|
+
let bin = '';
|
|
13
|
+
for (const b of bytes)
|
|
14
|
+
bin += String.fromCharCode(b);
|
|
15
|
+
return btoa(bin);
|
|
16
|
+
};
|
|
17
|
+
// utf8 string → base64url, unpadded — for tokens and wire credentials.
|
|
18
|
+
export const toBase64Url = (s) => toBase64(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
19
|
+
// base64 (standard OR url-safe) → utf8 string. Throws on malformed input on
|
|
20
|
+
// edge runtimes (atob); Node's Buffer is lenient, matching the prior per-
|
|
21
|
+
// package behaviour. Accepting url-safe input too means one decoder for both.
|
|
22
|
+
export const fromBase64 = (b64) => {
|
|
23
|
+
const std = b64.replace(/-/g, '+').replace(/_/g, '/');
|
|
24
|
+
if (hasBuffer)
|
|
25
|
+
return Buffer.from(std, 'base64').toString('utf8');
|
|
26
|
+
const bin = atob(std);
|
|
27
|
+
const bytes = Uint8Array.from(bin, (ch) => ch.charCodeAt(0));
|
|
28
|
+
return new TextDecoder().decode(bytes);
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD,iCAAiC;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAU,EAAE;IAC5C,IAAI,SAAS;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChE,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAU,EAAE,CAC/C,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEzE,4EAA4E;AAC5E,0EAA0E;AAC1E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE;IAChD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACtD,IAAI,SAAS;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export declare class AgentbankError extends Error {
|
|
|
3
3
|
readonly code: string;
|
|
4
4
|
readonly details?: unknown;
|
|
5
5
|
constructor(status: number, code: string, message: string, details?: unknown);
|
|
6
|
+
static is(err: unknown): err is AgentbankError;
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAOA,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAOA,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IAc5E,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc;CAQ/C"}
|
package/dist/errors.js
CHANGED
|
@@ -16,5 +16,17 @@ export class AgentbankError extends Error {
|
|
|
16
16
|
this.code = code;
|
|
17
17
|
this.details = details;
|
|
18
18
|
}
|
|
19
|
+
// Cross-version-safe type guard. `instanceof` silently fails when two copies
|
|
20
|
+
// of @curless/agentbank-core coexist in one node_modules (e.g. a consumer on
|
|
21
|
+
// core@0.1.0 and an SDK that pinned core@0.0.x) — they're different class
|
|
22
|
+
// objects. This checks the shape instead, so an error from ANY core version
|
|
23
|
+
// is recognized. Prefer `AgentbankError.is(err)` over `err instanceof` at
|
|
24
|
+
// package boundaries.
|
|
25
|
+
static is(err) {
|
|
26
|
+
return (err instanceof Error &&
|
|
27
|
+
err.name === 'AgentbankError' &&
|
|
28
|
+
typeof err.code === 'string' &&
|
|
29
|
+
typeof err.status === 'number');
|
|
30
|
+
}
|
|
19
31
|
}
|
|
20
32
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,wEAAwE;AACxE,wEAAwE;AACxE,qDAAqD;AACrD,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAS;IACf,IAAI,CAAS;IACb,OAAO,CAAW;IAE3B,YAAY,MAAc,EAAE,IAAY,EAAE,OAAe,EAAE,OAAiB;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,wEAAwE;AACxE,wEAAwE;AACxE,qDAAqD;AACrD,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAS;IACf,IAAI,CAAS;IACb,OAAO,CAAW;IAE3B,YAAY,MAAc,EAAE,IAAY,EAAE,OAAe,EAAE,OAAiB;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,4EAA4E;IAC5E,0EAA0E;IAC1E,sBAAsB;IACtB,MAAM,CAAC,EAAE,CAAC,GAAY;QACpB,OAAO,CACL,GAAG,YAAY,KAAK;YACpB,GAAG,CAAC,IAAI,KAAK,gBAAgB;YAC7B,OAAQ,GAA+B,CAAC,IAAI,KAAK,QAAQ;YACzD,OAAQ,GAA+B,CAAC,MAAM,KAAK,QAAQ,CAC5D,CAAC;IACJ,CAAC;CACF"}
|
package/dist/http.d.ts
CHANGED
|
@@ -5,8 +5,15 @@ export type RequestOptions = {
|
|
|
5
5
|
body?: unknown;
|
|
6
6
|
idempotencyKey?: string;
|
|
7
7
|
skipAuth?: boolean;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
12
|
+
export type SendJsonOptions = {
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
timeoutMs?: number;
|
|
8
15
|
};
|
|
9
16
|
export declare const buildUrl: (baseUrl: string, path: string, query?: RequestOptions["query"]) => string;
|
|
10
17
|
export declare const toError: (status: number, json: unknown) => AgentbankError;
|
|
11
|
-
export declare const sendJson: <T>(fetchImpl: FetchLike, url: string, method: string, headers: Record<string, string>, body: unknown) => Promise<T>;
|
|
18
|
+
export declare const sendJson: <T>(fetchImpl: FetchLike, url: string, method: string, headers: Record<string, string>, body: unknown, opts?: SendJsonOptions) => Promise<T>;
|
|
12
19
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAA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O,CAAC,KAC9B,MAQF,CAAC;AAIF,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,EAAE,MAAM,OAAO,KAAG,cAiBvD,CAAC;AAUF,eAAO,MAAM,QAAQ,GAAU,CAAC,EAC9B,WAAW,SAAS,EACpB,KAAK,MAAM,EACX,QAAQ,MAAM,EACd,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,MAAM,OAAO,EACb,OAAM,eAAoB,KACzB,OAAO,CAAC,CAAC,CA+DX,CAAC"}
|
package/dist/http.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { AgentbankError } from './errors.js';
|
|
2
|
+
// A payment API client must never hang forever on a stalled server — a stuck
|
|
3
|
+
// request looks identical to "charge in flight" to the caller. 30s is generous
|
|
4
|
+
// for every agentbank route (the slowest are rail captures) while still
|
|
5
|
+
// bounding the worst case.
|
|
6
|
+
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
2
7
|
// Build a fully-qualified URL with query params (undefined values dropped).
|
|
3
8
|
export const buildUrl = (baseUrl, path, query) => {
|
|
4
9
|
const url = new URL(`${baseUrl}${path}`);
|
|
@@ -28,12 +33,53 @@ export const toError = (status, json) => {
|
|
|
28
33
|
// Send a JSON request, parse the JSON response, and throw AgentbankError on a
|
|
29
34
|
// non-2xx. Headers (incl. auth) are built by the caller. Body is JSON-encoded
|
|
30
35
|
// unless undefined.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
//
|
|
37
|
+
// EVERY failure leaves here as AgentbankError — HTTP errors with their real
|
|
38
|
+
// status, and transport-level failures with status 0 and a discriminating
|
|
39
|
+
// code ('timeout' | 'aborted' | 'network_error'). One catch type for SDK
|
|
40
|
+
// consumers; `error.status === 0` means "no HTTP response happened".
|
|
41
|
+
export const sendJson = async (fetchImpl, url, method, headers, body, opts = {}) => {
|
|
42
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
43
|
+
// Combine the caller's signal with the deadline by hand — AbortSignal.any
|
|
44
|
+
// needs Node 20.3+, and this package targets Node 18 + edge runtimes.
|
|
45
|
+
const ctrl = new AbortController();
|
|
46
|
+
const onCallerAbort = () => ctrl.abort();
|
|
47
|
+
if (opts.signal) {
|
|
48
|
+
if (opts.signal.aborted)
|
|
49
|
+
ctrl.abort();
|
|
50
|
+
else
|
|
51
|
+
opts.signal.addEventListener('abort', onCallerAbort, { once: true });
|
|
52
|
+
}
|
|
53
|
+
let timedOut = false;
|
|
54
|
+
const timer = timeoutMs > 0
|
|
55
|
+
? setTimeout(() => {
|
|
56
|
+
timedOut = true;
|
|
57
|
+
ctrl.abort();
|
|
58
|
+
}, timeoutMs)
|
|
59
|
+
: undefined;
|
|
60
|
+
let res;
|
|
61
|
+
try {
|
|
62
|
+
res = await fetchImpl(url, {
|
|
63
|
+
method,
|
|
64
|
+
headers,
|
|
65
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
66
|
+
signal: ctrl.signal,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
if (timedOut) {
|
|
71
|
+
throw new AgentbankError(0, 'timeout', `request timed out after ${timeoutMs}ms: ${method} ${url}`);
|
|
72
|
+
}
|
|
73
|
+
if (opts.signal?.aborted) {
|
|
74
|
+
throw new AgentbankError(0, 'aborted', 'request aborted by caller');
|
|
75
|
+
}
|
|
76
|
+
throw new AgentbankError(0, 'network_error', `request failed before a response: ${err.message}`, { cause: String(err) });
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
if (timer !== undefined)
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
opts.signal?.removeEventListener('abort', onCallerAbort);
|
|
82
|
+
}
|
|
37
83
|
const text = await res.text();
|
|
38
84
|
// Parse defensively: a non-2xx upstream (a gateway 502 HTML page, a proxy
|
|
39
85
|
// error, an empty body) often isn't JSON. Don't let JSON.parse throw a raw
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAuB7C,6EAA6E;AAC7E,+EAA+E;AAC/E,wEAAwE;AACxE,2BAA2B;AAC3B,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAOzC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,OAAe,EACf,IAAY,EACZ,KAA+B,EACvB,EAAE;IACV,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC,CAAC;IACzC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,KAAK,SAAS;gBAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF,6EAA6E;AAC7E,2DAA2D;AAC3D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,IAAa,EAAkB,EAAE;IACvE,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAA+B,CAAC;QAC1C,IAAI,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC3C,MAAM,CAAC,GAAG,C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,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,0EAA0E;IAC1E,2EAA2E;IAC3E,4EAA4E;IAC5E,2EAA2E;IAC3E,yEAAyE;IACzE,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAClD,MAAM,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7C,OAAO,IAAS,CAAC;AACnB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { hmacSha256Hex, randomHex, timingSafeEqualHex } from './crypto.js';
|
|
2
|
+
export { fromBase64, toBase64, toBase64Url } from './encoding.js';
|
|
2
3
|
export { AgentbankError } from './errors.js';
|
|
3
|
-
export { type FetchLike, type RequestOptions, buildUrl, sendJson, toError } from './http.js';
|
|
4
|
+
export { DEFAULT_TIMEOUT_MS, type FetchLike, type RequestOptions, type SendJsonOptions, buildUrl, sendJson, toError, } from './http.js';
|
|
4
5
|
export type { BalanceTransaction, Customer, CustomerStatus, LedgerEntryView, Paginated, PaymentIntent, PaymentIntentLedger, PaymentIntentStatus, PaymentLink, PaymentLinkItem, PaymentLinkStatus, PaymentProtocol, } from './types.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,QAAQ,EACR,QAAQ,EACR,OAAO,GACR,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// there's one implementation: one crypto path, one error class, one HTTP +
|
|
4
4
|
// type surface.
|
|
5
5
|
export { hmacSha256Hex, randomHex, timingSafeEqualHex } from './crypto.js';
|
|
6
|
+
export { fromBase64, toBase64, toBase64Url } from './encoding.js';
|
|
6
7
|
export { AgentbankError } from './errors.js';
|
|
7
|
-
export { buildUrl, sendJson, toError } from './http.js';
|
|
8
|
+
export { DEFAULT_TIMEOUT_MS, buildUrl, sendJson, toError, } from './http.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,2EAA2E;AAC3E,gBAAgB;AAChB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,2EAA2E;AAC3E,gBAAgB;AAChB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAIlB,QAAQ,EACR,QAAQ,EACR,OAAO,GACR,MAAM,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curless/agentbank-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Shared runtime primitives for the agentbank SDKs. Edge-safe crypto (Web Crypto API, no node:crypto) so the buyer / merchant / protocol SDKs run unchanged on Node 18+, Vercel Edge, Cloudflare Workers and Deno.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.10.1",
|
|
26
26
|
"typescript": "^5.6.3",
|
|
27
|
-
"vitest": "^2.
|
|
27
|
+
"vitest": "^3.2.6"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=18"
|
|
@@ -36,6 +36,12 @@
|
|
|
36
36
|
"edge-runtime",
|
|
37
37
|
"hmac"
|
|
38
38
|
],
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://gitlab.com/robin-ruan/agentbank.git",
|
|
42
|
+
"directory": "packages/core"
|
|
43
|
+
},
|
|
44
|
+
"author": "robin",
|
|
39
45
|
"scripts": {
|
|
40
46
|
"build": "tsc",
|
|
41
47
|
"typecheck": "tsc --noEmit",
|