@easyslip/sdk 0.0.0-stage → 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 (87) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +595 -2
  4. package/README.th.md +610 -0
  5. package/dist/cjs/client.d.ts +59 -0
  6. package/dist/cjs/client.js +150 -0
  7. package/dist/cjs/core/call.d.ts +18 -0
  8. package/dist/cjs/core/call.js +60 -0
  9. package/dist/cjs/core/error-codes.d.ts +8 -0
  10. package/dist/cjs/core/error-codes.js +87 -0
  11. package/dist/cjs/core/errors.d.ts +162 -0
  12. package/dist/cjs/core/errors.js +210 -0
  13. package/dist/cjs/core/files.d.ts +20 -0
  14. package/dist/cjs/core/files.js +131 -0
  15. package/dist/cjs/core/http.d.ts +65 -0
  16. package/dist/cjs/core/http.js +242 -0
  17. package/dist/cjs/core/meta.d.ts +33 -0
  18. package/dist/cjs/core/meta.js +52 -0
  19. package/dist/cjs/core/redact.d.ts +43 -0
  20. package/dist/cjs/core/redact.js +208 -0
  21. package/dist/cjs/core/runtime.d.ts +16 -0
  22. package/dist/cjs/core/runtime.js +86 -0
  23. package/dist/cjs/core/settings.d.ts +19 -0
  24. package/dist/cjs/core/settings.js +22 -0
  25. package/dist/cjs/core/sha256.d.ts +6 -0
  26. package/dist/cjs/core/sha256.js +101 -0
  27. package/dist/cjs/index.d.ts +13 -0
  28. package/dist/cjs/index.js +55 -0
  29. package/dist/cjs/models.d.ts +398 -0
  30. package/dist/cjs/models.js +234 -0
  31. package/dist/cjs/package.json +1 -0
  32. package/dist/cjs/resources/bank-accounts.d.ts +63 -0
  33. package/dist/cjs/resources/bank-accounts.js +126 -0
  34. package/dist/cjs/resources/banks.d.ts +10 -0
  35. package/dist/cjs/resources/banks.js +22 -0
  36. package/dist/cjs/resources/jobs.d.ts +64 -0
  37. package/dist/cjs/resources/jobs.js +177 -0
  38. package/dist/cjs/resources/v1.d.ts +88 -0
  39. package/dist/cjs/resources/v1.js +137 -0
  40. package/dist/cjs/resources/verify.d.ts +39 -0
  41. package/dist/cjs/resources/verify.js +105 -0
  42. package/dist/cjs/version.d.ts +2 -0
  43. package/dist/cjs/version.js +5 -0
  44. package/dist/cjs/webhooks.d.ts +26 -0
  45. package/dist/cjs/webhooks.js +92 -0
  46. package/dist/esm/client.d.ts +59 -0
  47. package/dist/esm/client.js +146 -0
  48. package/dist/esm/core/call.d.ts +18 -0
  49. package/dist/esm/core/call.js +52 -0
  50. package/dist/esm/core/error-codes.d.ts +8 -0
  51. package/dist/esm/core/error-codes.js +84 -0
  52. package/dist/esm/core/errors.d.ts +162 -0
  53. package/dist/esm/core/errors.js +184 -0
  54. package/dist/esm/core/files.d.ts +20 -0
  55. package/dist/esm/core/files.js +126 -0
  56. package/dist/esm/core/http.d.ts +65 -0
  57. package/dist/esm/core/http.js +235 -0
  58. package/dist/esm/core/meta.d.ts +33 -0
  59. package/dist/esm/core/meta.js +45 -0
  60. package/dist/esm/core/redact.d.ts +43 -0
  61. package/dist/esm/core/redact.js +198 -0
  62. package/dist/esm/core/runtime.d.ts +16 -0
  63. package/dist/esm/core/runtime.js +47 -0
  64. package/dist/esm/core/settings.d.ts +19 -0
  65. package/dist/esm/core/settings.js +19 -0
  66. package/dist/esm/core/sha256.d.ts +6 -0
  67. package/dist/esm/core/sha256.js +96 -0
  68. package/dist/esm/index.d.ts +13 -0
  69. package/dist/esm/index.js +7 -0
  70. package/dist/esm/models.d.ts +398 -0
  71. package/dist/esm/models.js +228 -0
  72. package/dist/esm/package.json +1 -0
  73. package/dist/esm/resources/bank-accounts.d.ts +63 -0
  74. package/dist/esm/resources/bank-accounts.js +122 -0
  75. package/dist/esm/resources/banks.d.ts +10 -0
  76. package/dist/esm/resources/banks.js +18 -0
  77. package/dist/esm/resources/jobs.d.ts +64 -0
  78. package/dist/esm/resources/jobs.js +173 -0
  79. package/dist/esm/resources/v1.d.ts +88 -0
  80. package/dist/esm/resources/v1.js +133 -0
  81. package/dist/esm/resources/verify.d.ts +39 -0
  82. package/dist/esm/resources/verify.js +100 -0
  83. package/dist/esm/version.d.ts +2 -0
  84. package/dist/esm/version.js +2 -0
  85. package/dist/esm/webhooks.d.ts +26 -0
  86. package/dist/esm/webhooks.js +86 -0
  87. package/package.json +80 -5
@@ -0,0 +1,33 @@
1
+ /** Rate limit counters from the `X-RateLimit-*` response headers. */
2
+ export interface RateLimit {
3
+ /** Requests allowed in the current window. */
4
+ readonly limit: number;
5
+ /** Requests left in the current window. */
6
+ readonly remaining: number;
7
+ /** When the window resets, as the API sends it (Unix seconds). */
8
+ readonly reset: number;
9
+ }
10
+ /** Response details that are not part of the returned data. */
11
+ export interface ResponseMeta {
12
+ /** HTTP status code. */
13
+ readonly status: number;
14
+ /** `x-request-id` header, else `cf-ray`, else null. Quote it when you contact support. */
15
+ readonly requestId: string | null;
16
+ /** The v2 envelope `message`, when the API sent one. */
17
+ readonly message: string | null;
18
+ /** Rate limit counters, when the API sent all three headers. */
19
+ readonly rateLimit: RateLimit | null;
20
+ /** Response headers with lower-case names. */
21
+ readonly headers: Readonly<Record<string, string>>;
22
+ }
23
+ /** A returned value with its response details on the non-enumerable `meta` property. */
24
+ export type WithMeta<T> = T & {
25
+ readonly meta: ResponseMeta;
26
+ };
27
+ /** Attaches `meta` without making it part of the value's JSON or its enumerable keys. */
28
+ export declare function attachMeta<T extends object>(value: T, meta: ResponseMeta): WithMeta<T>;
29
+ export declare function headersToRecord(headers: Headers | Record<string, string>): Record<string, string>;
30
+ export declare function requestIdFrom(headers: Readonly<Record<string, string>>): string | null;
31
+ export declare function rateLimitFrom(headers: Readonly<Record<string, string>>): RateLimit | null;
32
+ /** Seconds from a `Retry-After` header (delta seconds or HTTP date), or null. */
33
+ export declare function retryAfterFrom(headers: Readonly<Record<string, string>>, now?: number): number | null;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attachMeta = attachMeta;
4
+ exports.headersToRecord = headersToRecord;
5
+ exports.requestIdFrom = requestIdFrom;
6
+ exports.rateLimitFrom = rateLimitFrom;
7
+ exports.retryAfterFrom = retryAfterFrom;
8
+ /** Attaches `meta` without making it part of the value's JSON or its enumerable keys. */
9
+ function attachMeta(value, meta) {
10
+ Object.defineProperty(value, 'meta', { value: meta, enumerable: false });
11
+ return value;
12
+ }
13
+ function headersToRecord(headers) {
14
+ const out = {};
15
+ if (headers instanceof Headers) {
16
+ headers.forEach((value, key) => {
17
+ out[key.toLowerCase()] = value;
18
+ });
19
+ return out;
20
+ }
21
+ for (const [key, value] of Object.entries(headers))
22
+ out[key.toLowerCase()] = value;
23
+ return out;
24
+ }
25
+ function requestIdFrom(headers) {
26
+ return headers['x-request-id'] || headers['cf-ray'] || null;
27
+ }
28
+ function toInt(value) {
29
+ if (value === undefined || !/^\s*-?\d+\s*$/.test(value))
30
+ return null;
31
+ return Number.parseInt(value, 10);
32
+ }
33
+ function rateLimitFrom(headers) {
34
+ const limit = toInt(headers['x-ratelimit-limit']);
35
+ const remaining = toInt(headers['x-ratelimit-remaining']);
36
+ const reset = toInt(headers['x-ratelimit-reset']);
37
+ if (limit === null || remaining === null || reset === null)
38
+ return null;
39
+ return { limit, remaining, reset };
40
+ }
41
+ /** Seconds from a `Retry-After` header (delta seconds or HTTP date), or null. */
42
+ function retryAfterFrom(headers, now = Date.now()) {
43
+ const raw = headers['retry-after']?.trim();
44
+ if (!raw)
45
+ return null;
46
+ if (/^\d+$/.test(raw))
47
+ return Number.parseInt(raw, 10);
48
+ const at = Date.parse(raw);
49
+ if (Number.isNaN(at))
50
+ return null;
51
+ return Math.max(0, Math.ceil((at - now) / 1000));
52
+ }
@@ -0,0 +1,43 @@
1
+ /** What the SDK puts where it removed the API key or an Authorization value. */
2
+ export declare const REDACTED = "[REDACTED]";
3
+ /** Removes one API key. */
4
+ export interface Redactor {
5
+ /**
6
+ * Raw and percent-encoded spans of the key become `[REDACTED]`; if a decoded view
7
+ * of the result still carries the key, the whole text becomes `[REDACTED]`.
8
+ */
9
+ text(value: string): string;
10
+ /** Whether the text or one of its decoded views contains the key. */
11
+ carries(value: string): boolean;
12
+ }
13
+ export declare const noRedact: Redactor;
14
+ /** `%HH` (either hex case) becomes that byte; runs of bytes are read as UTF-8. */
15
+ export declare function percentDecode(text: string): string;
16
+ /** JSON string unescaping: `\uXXXX` (either hex case) and the short escapes. */
17
+ export declare function jsonUnescape(text: string): string;
18
+ /** Builds the redactor for one API key. Keys shorter than 4 characters are left alone. */
19
+ export declare function redactor(apiKey: string): Redactor;
20
+ /**
21
+ * Authorization and Proxy-Authorization are always `[REDACTED]`; any other value that
22
+ * carries the key becomes `[REDACTED]` as a whole.
23
+ */
24
+ export declare function redactHeaders(headers: Readonly<Record<string, string>>, redact: Redactor): Record<string, string>;
25
+ /**
26
+ * Applies `text` to every string of a parsed JSON value, object keys included. Returns the
27
+ * same value when nothing changed.
28
+ */
29
+ export declare function redactJson(value: unknown, redact: Redactor): unknown;
30
+ /**
31
+ * Redaction of a whole body: `body` is `text` parsed as JSON (undefined when it is not JSON). Returns
32
+ * the body that may be shown and the redacted parsed value.
33
+ */
34
+ export declare function redactBody(text: string, body: unknown, redact: Redactor): {
35
+ rawBody: string;
36
+ body: unknown;
37
+ };
38
+ /**
39
+ * A sanitized copy of a transport failure. It holds the type name, the message after `text`,
40
+ * `code` and `errno` when they are strings or numbers, and the sanitized copy of the
41
+ * original's own cause (at most 3 levels). Never the original or any other property.
42
+ */
43
+ export declare function sanitizeCause(cause: unknown, redact: Redactor, depth?: number): Error;
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ // Removes the configured API key from everything the SDK takes from a response or a transport
3
+ // error. The key is found by decoding, not by listing encodings.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.noRedact = exports.REDACTED = void 0;
6
+ exports.percentDecode = percentDecode;
7
+ exports.jsonUnescape = jsonUnescape;
8
+ exports.redactor = redactor;
9
+ exports.redactHeaders = redactHeaders;
10
+ exports.redactJson = redactJson;
11
+ exports.redactBody = redactBody;
12
+ exports.sanitizeCause = sanitizeCause;
13
+ /** What the SDK puts where it removed the API key or an Authorization value. */
14
+ exports.REDACTED = '[REDACTED]';
15
+ const AUTH_HEADERS = new Set(['authorization', 'proxy-authorization']);
16
+ const MAX_CAUSE_DEPTH = 3;
17
+ exports.noRedact = { text: (value) => value, carries: () => false };
18
+ const utf8 = new TextDecoder();
19
+ /** `%HH` (either hex case) becomes that byte; runs of bytes are read as UTF-8. */
20
+ function percentDecode(text) {
21
+ if (!text.includes('%'))
22
+ return text;
23
+ return text.replace(/(?:%[0-9a-fA-F]{2})+/g, (run) => {
24
+ const bytes = new Uint8Array(run.length / 3);
25
+ for (let i = 0; i < bytes.length; i++) {
26
+ bytes[i] = Number.parseInt(run.slice(i * 3 + 1, i * 3 + 3), 16);
27
+ }
28
+ return utf8.decode(bytes);
29
+ });
30
+ }
31
+ const JSON_ESCAPES = {
32
+ '"': '"',
33
+ '\\': '\\',
34
+ '/': '/',
35
+ b: '\b',
36
+ f: '\f',
37
+ n: '\n',
38
+ r: '\r',
39
+ t: '\t',
40
+ };
41
+ /** JSON string unescaping: `\uXXXX` (either hex case) and the short escapes. */
42
+ function jsonUnescape(text) {
43
+ if (!text.includes('\\'))
44
+ return text;
45
+ return text.replace(/\\(u[0-9a-fA-F]{4}|["\\/bfnrt])/g, (_, seq) => seq.length === 5
46
+ ? String.fromCharCode(Number.parseInt(seq.slice(1), 16))
47
+ : JSON_ESCAPES[seq]);
48
+ }
49
+ /** Matches the key with any subset of its characters percent-encoded, in either hex case. */
50
+ function percentPattern(apiKey) {
51
+ const hex = (byte) => [...byte.toString(16).padStart(2, '0')]
52
+ .map((d) => (/[a-f]/.test(d) ? `[${d}${d.toUpperCase()}]` : d))
53
+ .join('');
54
+ const parts = [...apiKey].map((char) => {
55
+ const literal = char.replace(/[.*+?^${}()|[\]\\/-]/g, '\\$&');
56
+ const encoded = [...new TextEncoder().encode(char)].map((b) => `%${hex(b)}`).join('');
57
+ return `(?:${literal}|${encoded})`;
58
+ });
59
+ return new RegExp(parts.join(''), 'g');
60
+ }
61
+ /** Builds the redactor for one API key. Keys shorter than 4 characters are left alone. */
62
+ function redactor(apiKey) {
63
+ if (apiKey.length < 4)
64
+ return exports.noRedact;
65
+ const pattern = percentPattern(apiKey);
66
+ const carries = (value) => {
67
+ // The text, its percent-decoding, its JSON unescaping, and each applied to the other,
68
+ // one level deep.
69
+ let views = [value];
70
+ const seen = new Set(views);
71
+ for (let level = 0; level <= 3; level++) {
72
+ if (views.some((view) => view.includes(apiKey)))
73
+ return true;
74
+ const next = [];
75
+ for (const view of views) {
76
+ for (const decoded of [percentDecode(view), jsonUnescape(view)]) {
77
+ if (!seen.has(decoded)) {
78
+ seen.add(decoded);
79
+ next.push(decoded);
80
+ }
81
+ }
82
+ }
83
+ if (next.length === 0)
84
+ return false;
85
+ views = next;
86
+ }
87
+ return false;
88
+ };
89
+ return {
90
+ carries,
91
+ text(value) {
92
+ if (!value)
93
+ return value;
94
+ const out = value.replace(pattern, exports.REDACTED);
95
+ return carries(out) ? exports.REDACTED : out;
96
+ },
97
+ };
98
+ }
99
+ /**
100
+ * Authorization and Proxy-Authorization are always `[REDACTED]`; any other value that
101
+ * carries the key becomes `[REDACTED]` as a whole.
102
+ */
103
+ function redactHeaders(headers, redact) {
104
+ const out = {};
105
+ for (const [name, value] of Object.entries(headers)) {
106
+ out[name] = AUTH_HEADERS.has(name.toLowerCase()) || redact.carries(value) ? exports.REDACTED : value;
107
+ }
108
+ return out;
109
+ }
110
+ function defineValue(target, key, value) {
111
+ Object.defineProperty(target, key, {
112
+ value,
113
+ enumerable: true,
114
+ writable: true,
115
+ configurable: true,
116
+ });
117
+ }
118
+ /**
119
+ * Applies `text` to every string of a parsed JSON value, object keys included. Returns the
120
+ * same value when nothing changed.
121
+ */
122
+ function redactJson(value, redact) {
123
+ if (typeof value === 'string')
124
+ return redact.text(value);
125
+ if (Array.isArray(value)) {
126
+ const out = value.map((item) => redactJson(item, redact));
127
+ return out.some((item, i) => item !== value[i]) ? out : value;
128
+ }
129
+ if (value === null || typeof value !== 'object')
130
+ return value;
131
+ let changed = false;
132
+ const out = {};
133
+ for (const [key, item] of Object.entries(value)) {
134
+ const safeKey = redact.text(key);
135
+ const safeItem = redactJson(item, redact);
136
+ if (safeKey !== key || safeItem !== item)
137
+ changed = true;
138
+ // defineProperty, so a "__proto__" key stays a plain key
139
+ defineValue(out, safeKey, safeItem);
140
+ }
141
+ return changed ? out : value;
142
+ }
143
+ /**
144
+ * Redaction of a whole body: `body` is `text` parsed as JSON (undefined when it is not JSON). Returns
145
+ * the body that may be shown and the redacted parsed value.
146
+ */
147
+ function redactBody(text, body, redact) {
148
+ if (body === undefined)
149
+ return { rawBody: redact.text(text), body };
150
+ const safe = redactJson(body, redact);
151
+ return { rawBody: safe === body ? text : JSON.stringify(safe), body: safe };
152
+ }
153
+ function read(source, key) {
154
+ try {
155
+ return source[key];
156
+ }
157
+ catch {
158
+ return undefined;
159
+ }
160
+ }
161
+ function typeName(source) {
162
+ if (source instanceof Error)
163
+ return String(read(source, 'name') ?? 'Error');
164
+ if (source === null)
165
+ return 'null';
166
+ if (typeof source !== 'object')
167
+ return typeof source;
168
+ const ctor = read(source, 'constructor');
169
+ return typeof ctor?.name === 'string' && ctor.name ? ctor.name : 'Object';
170
+ }
171
+ function messageOf(source) {
172
+ if (typeof source === 'string')
173
+ return source;
174
+ const message = read(source, 'message');
175
+ if (typeof message === 'string')
176
+ return message;
177
+ if (source instanceof Error || (source !== null && typeof source === 'object'))
178
+ return '';
179
+ return String(source);
180
+ }
181
+ /**
182
+ * A sanitized copy of a transport failure. It holds the type name, the message after `text`,
183
+ * `code` and `errno` when they are strings or numbers, and the sanitized copy of the
184
+ * original's own cause (at most 3 levels). Never the original or any other property.
185
+ */
186
+ function sanitizeCause(cause, redact, depth = 1) {
187
+ const copy = new Error(redact.text(messageOf(cause)));
188
+ copy.name = redact.text(typeName(cause));
189
+ copy.stack = `${copy.name}: ${copy.message}`;
190
+ for (const field of ['code', 'errno']) {
191
+ const value = cause !== null && typeof cause === 'object' ? read(cause, field) : undefined;
192
+ if (typeof value === 'string')
193
+ defineValue(copy, field, redact.text(value));
194
+ else if (typeof value === 'number') {
195
+ defineValue(copy, field, redact.carries(String(value)) ? exports.REDACTED : value);
196
+ }
197
+ }
198
+ const inner = cause !== null && typeof cause === 'object' ? read(cause, 'cause') : undefined;
199
+ if (inner !== undefined && depth < MAX_CAUSE_DEPTH) {
200
+ Object.defineProperty(copy, 'cause', {
201
+ value: sanitizeCause(inner, redact, depth + 1),
202
+ enumerable: false,
203
+ writable: true,
204
+ configurable: true,
205
+ });
206
+ }
207
+ return copy;
208
+ }
@@ -0,0 +1,16 @@
1
+ /** Reads an environment variable, or undefined when the runtime has none or denies access. */
2
+ export declare function readEnv(name: string): string | undefined;
3
+ /** `<runtime>/<version>` for the User-Agent header. */
4
+ export declare function runtimeToken(): string;
5
+ interface FsPromises {
6
+ readFile(path: string | URL): Promise<Uint8Array>;
7
+ stat(path: string | URL): Promise<{
8
+ size: number;
9
+ isFile(): boolean;
10
+ }>;
11
+ }
12
+ /** `node:fs/promises`, or null on runtimes without a file system. */
13
+ export declare function loadFs(): Promise<FsPromises | null>;
14
+ /** Waits `ms` milliseconds; rejects with the signal's reason when it aborts first. */
15
+ export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
16
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ // Small runtime probes that work on Node, Bun, Deno and edge runtimes without type packages.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.readEnv = readEnv;
38
+ exports.runtimeToken = runtimeToken;
39
+ exports.loadFs = loadFs;
40
+ exports.sleep = sleep;
41
+ const g = globalThis;
42
+ /** Reads an environment variable, or undefined when the runtime has none or denies access. */
43
+ function readEnv(name) {
44
+ try {
45
+ if (g.Deno?.env)
46
+ return g.Deno.env.get(name) || undefined;
47
+ return g.process?.env?.[name] || undefined;
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ }
53
+ /** `<runtime>/<version>` for the User-Agent header. */
54
+ function runtimeToken() {
55
+ if (g.Bun?.version)
56
+ return `bun/${g.Bun.version}`;
57
+ if (g.Deno?.version?.deno)
58
+ return `deno/${g.Deno.version.deno}`;
59
+ if (g.process?.versions?.node)
60
+ return `node/${g.process.versions.node}`;
61
+ return 'edge/unknown';
62
+ }
63
+ let fsPromise;
64
+ /** `node:fs/promises`, or null on runtimes without a file system. */
65
+ function loadFs() {
66
+ fsPromise ??= Promise.resolve(`${'node:fs/promises'}`).then(s => __importStar(require(s))).then((mod) => mod.default ?? mod, () => null);
67
+ return fsPromise;
68
+ }
69
+ /** Waits `ms` milliseconds; rejects with the signal's reason when it aborts first. */
70
+ function sleep(ms, signal) {
71
+ return new Promise((resolve, reject) => {
72
+ if (signal?.aborted) {
73
+ reject(signal.reason);
74
+ return;
75
+ }
76
+ const onAbort = () => {
77
+ clearTimeout(timer);
78
+ reject(signal?.reason);
79
+ };
80
+ const timer = setTimeout(() => {
81
+ signal?.removeEventListener('abort', onAbort);
82
+ resolve();
83
+ }, ms);
84
+ signal?.addEventListener('abort', onAbort, { once: true });
85
+ });
86
+ }
@@ -0,0 +1,19 @@
1
+ /** Default hosts, environment variable names and header names the SDK uses. */
2
+ export declare const settings: {
3
+ readonly baseUrls: {
4
+ readonly v1: 'https://api.easyslip.com/v1';
5
+ readonly v2: 'https://api.easyslip.com/v2';
6
+ };
7
+ readonly userAgentProduct: 'easyslip-js';
8
+ readonly webhook: {
9
+ readonly signatureHeader: 'X-EasySlip-Signature';
10
+ readonly signaturePrefix: 'sha256=';
11
+ };
12
+ readonly env: {
13
+ readonly apiKey: 'EASYSLIP_API_KEY';
14
+ readonly apiKeyFile: 'EASYSLIP_API_KEY_FILE';
15
+ readonly webhookSecret: 'EASYSLIP_WEBHOOK_SECRET';
16
+ readonly v1BaseUrl: 'EASYSLIP_V1_BASE_URL';
17
+ readonly v2BaseUrl: 'EASYSLIP_V2_BASE_URL';
18
+ };
19
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.settings = void 0;
4
+ /** Default hosts, environment variable names and header names the SDK uses. */
5
+ exports.settings = {
6
+ baseUrls: {
7
+ v1: 'https://api.easyslip.com/v1',
8
+ v2: 'https://api.easyslip.com/v2',
9
+ },
10
+ userAgentProduct: 'easyslip-js',
11
+ webhook: {
12
+ signatureHeader: 'X-EasySlip-Signature',
13
+ signaturePrefix: 'sha256=',
14
+ },
15
+ env: {
16
+ apiKey: 'EASYSLIP_API_KEY',
17
+ apiKeyFile: 'EASYSLIP_API_KEY_FILE',
18
+ webhookSecret: 'EASYSLIP_WEBHOOK_SECRET',
19
+ v1BaseUrl: 'EASYSLIP_V1_BASE_URL',
20
+ v2BaseUrl: 'EASYSLIP_V2_BASE_URL',
21
+ },
22
+ };
@@ -0,0 +1,6 @@
1
+ /** SHA-256 digest of `data`. */
2
+ export declare function sha256(data: Uint8Array): Uint8Array;
3
+ /** HMAC-SHA256 of `message` under `key`. */
4
+ export declare function hmacSha256(key: Uint8Array, message: Uint8Array): Uint8Array;
5
+ /** Lower-case hex of `bytes`. */
6
+ export declare function toHex(bytes: Uint8Array): string;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ // Synchronous SHA-256 and HMAC-SHA256 (FIPS 180-4, RFC 2104), so webhook checks need no
3
+ // async Web Crypto call and no Node built-in.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.sha256 = sha256;
6
+ exports.hmacSha256 = hmacSha256;
7
+ exports.toHex = toHex;
8
+ const K = new Uint32Array([
9
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
10
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
11
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
12
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
13
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
14
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
15
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
16
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
17
+ ]);
18
+ /** SHA-256 digest of `data`. */
19
+ function sha256(data) {
20
+ const bitLength = data.length * 8;
21
+ const padded = new Uint8Array((((data.length + 9 + 63) >> 6) << 6) >>> 0);
22
+ padded.set(data);
23
+ padded[data.length] = 0x80;
24
+ const view = new DataView(padded.buffer);
25
+ view.setUint32(padded.length - 8, Math.floor(bitLength / 0x100000000));
26
+ view.setUint32(padded.length - 4, bitLength >>> 0);
27
+ const h = new Uint32Array([
28
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab,
29
+ 0x5be0cd19,
30
+ ]);
31
+ const w = new Uint32Array(64);
32
+ for (let offset = 0; offset < padded.length; offset += 64) {
33
+ for (let i = 0; i < 16; i++)
34
+ w[i] = view.getUint32(offset + i * 4);
35
+ for (let i = 16; i < 64; i++) {
36
+ const w15 = w[i - 15];
37
+ const w2 = w[i - 2];
38
+ const s0 = ((w15 >>> 7) | (w15 << 25)) ^ ((w15 >>> 18) | (w15 << 14)) ^ (w15 >>> 3);
39
+ const s1 = ((w2 >>> 17) | (w2 << 15)) ^ ((w2 >>> 19) | (w2 << 13)) ^ (w2 >>> 10);
40
+ w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
41
+ }
42
+ let a = h[0];
43
+ let b = h[1];
44
+ let c = h[2];
45
+ let d = h[3];
46
+ let e = h[4];
47
+ let f = h[5];
48
+ let g = h[6];
49
+ let hh = h[7];
50
+ for (let i = 0; i < 64; i++) {
51
+ const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
52
+ const ch = (e & f) ^ (~e & g);
53
+ const t1 = (hh + S1 + ch + K[i] + w[i]) >>> 0;
54
+ const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
55
+ const maj = (a & b) ^ (a & c) ^ (b & c);
56
+ const t2 = (S0 + maj) >>> 0;
57
+ hh = g;
58
+ g = f;
59
+ f = e;
60
+ e = (d + t1) >>> 0;
61
+ d = c;
62
+ c = b;
63
+ b = a;
64
+ a = (t1 + t2) >>> 0;
65
+ }
66
+ h[0] = (h[0] + a) >>> 0;
67
+ h[1] = (h[1] + b) >>> 0;
68
+ h[2] = (h[2] + c) >>> 0;
69
+ h[3] = (h[3] + d) >>> 0;
70
+ h[4] = (h[4] + e) >>> 0;
71
+ h[5] = (h[5] + f) >>> 0;
72
+ h[6] = (h[6] + g) >>> 0;
73
+ h[7] = (h[7] + hh) >>> 0;
74
+ }
75
+ const out = new Uint8Array(32);
76
+ const outView = new DataView(out.buffer);
77
+ for (let i = 0; i < 8; i++)
78
+ outView.setUint32(i * 4, h[i]);
79
+ return out;
80
+ }
81
+ /** HMAC-SHA256 of `message` under `key`. */
82
+ function hmacSha256(key, message) {
83
+ const block = new Uint8Array(64);
84
+ block.set(key.length > 64 ? sha256(key) : key);
85
+ const inner = new Uint8Array(64 + message.length);
86
+ const outer = new Uint8Array(64 + 32);
87
+ for (let i = 0; i < 64; i++) {
88
+ inner[i] = block[i] ^ 0x36;
89
+ outer[i] = block[i] ^ 0x5c;
90
+ }
91
+ inner.set(message, 64);
92
+ outer.set(sha256(inner), 64);
93
+ return sha256(outer);
94
+ }
95
+ /** Lower-case hex of `bytes`. */
96
+ function toHex(bytes) {
97
+ let out = '';
98
+ for (const byte of bytes)
99
+ out += byte.toString(16).padStart(2, '0');
100
+ return out;
101
+ }
@@ -0,0 +1,13 @@
1
+ export { Client, Client as EasySlip, type ClientOptions } from './client.js';
2
+ export { ApiError, type ApiErrorInit, AuthenticationError, BatchSubmitError, ConflictError, DuplicateSlipError, EasySlipError, type ErrorDetails, InputError, type InputErrorCode, InvalidImageError, InvalidRequestError, InvalidUrlError, JobWaitTimeoutError, NetworkError, NotFoundError, PermissionDeniedError, QuotaExceededError, RateLimitError, RequestTimeoutError, ServerError, ServiceUnavailableError, SlipNotFoundError, SlipPendingError, WebhookSignatureError, } from './core/errors.js';
3
+ export { type FileInput, MAX_IMAGE_BYTES } from './core/files.js';
4
+ export type { FetchLike, RequestOptions, RetryClass } from './core/http.js';
5
+ export type { RateLimit, ResponseMeta, WithMeta } from './core/meta.js';
6
+ export * from './models.js';
7
+ export type { AccountType, BankAccounts, CreateBankAccountParams, ListBankAccountsParams, UpdateBankAccountParams, } from './resources/bank-accounts.js';
8
+ export type { Banks } from './resources/banks.js';
9
+ export { type AsyncVerifyOptions, BATCH_MAX, type BatchOptions, type BatchSlip, type Jobs, type WaitForJobOptions, } from './resources/jobs.js';
10
+ export type { BillPaymentQr, MerchantQr, PromptPayQr, QrCodeResult, QrRequest, QrType, TungNgernQr, V1, V1VerifyOptions, } from './resources/v1.js';
11
+ export type { Verify, VerifyCallOptions, VerifyOptions } from './resources/verify.js';
12
+ export { VERSION } from './version.js';
13
+ export { constructWebhookEvent, parseWebhookEvent, type SignatureHeader, verifyWebhookSignature, WEBHOOK_SIGNATURE_HEADER, type WebhookBody, } from './webhooks.js';
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.WEBHOOK_SIGNATURE_HEADER = exports.verifyWebhookSignature = exports.parseWebhookEvent = exports.constructWebhookEvent = exports.VERSION = exports.BATCH_MAX = exports.MAX_IMAGE_BYTES = exports.WebhookSignatureError = exports.SlipPendingError = exports.SlipNotFoundError = exports.ServiceUnavailableError = exports.ServerError = exports.RequestTimeoutError = exports.RateLimitError = exports.QuotaExceededError = exports.PermissionDeniedError = exports.NotFoundError = exports.NetworkError = exports.JobWaitTimeoutError = exports.InvalidUrlError = exports.InvalidRequestError = exports.InvalidImageError = exports.InputError = exports.EasySlipError = exports.DuplicateSlipError = exports.ConflictError = exports.BatchSubmitError = exports.AuthenticationError = exports.ApiError = exports.EasySlip = exports.Client = void 0;
18
+ var client_js_1 = require("./client.js");
19
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_1.Client; } });
20
+ Object.defineProperty(exports, "EasySlip", { enumerable: true, get: function () { return client_js_1.Client; } });
21
+ var errors_js_1 = require("./core/errors.js");
22
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return errors_js_1.ApiError; } });
23
+ Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_js_1.AuthenticationError; } });
24
+ Object.defineProperty(exports, "BatchSubmitError", { enumerable: true, get: function () { return errors_js_1.BatchSubmitError; } });
25
+ Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return errors_js_1.ConflictError; } });
26
+ Object.defineProperty(exports, "DuplicateSlipError", { enumerable: true, get: function () { return errors_js_1.DuplicateSlipError; } });
27
+ Object.defineProperty(exports, "EasySlipError", { enumerable: true, get: function () { return errors_js_1.EasySlipError; } });
28
+ Object.defineProperty(exports, "InputError", { enumerable: true, get: function () { return errors_js_1.InputError; } });
29
+ Object.defineProperty(exports, "InvalidImageError", { enumerable: true, get: function () { return errors_js_1.InvalidImageError; } });
30
+ Object.defineProperty(exports, "InvalidRequestError", { enumerable: true, get: function () { return errors_js_1.InvalidRequestError; } });
31
+ Object.defineProperty(exports, "InvalidUrlError", { enumerable: true, get: function () { return errors_js_1.InvalidUrlError; } });
32
+ Object.defineProperty(exports, "JobWaitTimeoutError", { enumerable: true, get: function () { return errors_js_1.JobWaitTimeoutError; } });
33
+ Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return errors_js_1.NetworkError; } });
34
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_js_1.NotFoundError; } });
35
+ Object.defineProperty(exports, "PermissionDeniedError", { enumerable: true, get: function () { return errors_js_1.PermissionDeniedError; } });
36
+ Object.defineProperty(exports, "QuotaExceededError", { enumerable: true, get: function () { return errors_js_1.QuotaExceededError; } });
37
+ Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_js_1.RateLimitError; } });
38
+ Object.defineProperty(exports, "RequestTimeoutError", { enumerable: true, get: function () { return errors_js_1.RequestTimeoutError; } });
39
+ Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return errors_js_1.ServerError; } });
40
+ Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_js_1.ServiceUnavailableError; } });
41
+ Object.defineProperty(exports, "SlipNotFoundError", { enumerable: true, get: function () { return errors_js_1.SlipNotFoundError; } });
42
+ Object.defineProperty(exports, "SlipPendingError", { enumerable: true, get: function () { return errors_js_1.SlipPendingError; } });
43
+ Object.defineProperty(exports, "WebhookSignatureError", { enumerable: true, get: function () { return errors_js_1.WebhookSignatureError; } });
44
+ var files_js_1 = require("./core/files.js");
45
+ Object.defineProperty(exports, "MAX_IMAGE_BYTES", { enumerable: true, get: function () { return files_js_1.MAX_IMAGE_BYTES; } });
46
+ __exportStar(require("./models.js"), exports);
47
+ var jobs_js_1 = require("./resources/jobs.js");
48
+ Object.defineProperty(exports, "BATCH_MAX", { enumerable: true, get: function () { return jobs_js_1.BATCH_MAX; } });
49
+ var version_js_1 = require("./version.js");
50
+ Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_js_1.VERSION; } });
51
+ var webhooks_js_1 = require("./webhooks.js");
52
+ Object.defineProperty(exports, "constructWebhookEvent", { enumerable: true, get: function () { return webhooks_js_1.constructWebhookEvent; } });
53
+ Object.defineProperty(exports, "parseWebhookEvent", { enumerable: true, get: function () { return webhooks_js_1.parseWebhookEvent; } });
54
+ Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return webhooks_js_1.verifyWebhookSignature; } });
55
+ Object.defineProperty(exports, "WEBHOOK_SIGNATURE_HEADER", { enumerable: true, get: function () { return webhooks_js_1.WEBHOOK_SIGNATURE_HEADER; } });