@bsv/wallet-toolbox-mobile 2.4.3 → 2.4.4
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/out/src/CWIStyleWalletManager.d.ts +52 -5
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +500 -128
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/Wallet.d.ts +8 -0
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +23 -9
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts +20 -6
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +214 -34
- package/out/src/WalletAuthenticationManager.js.map +1 -1
- package/out/src/index.mobile.d.ts +1 -0
- package/out/src/index.mobile.d.ts.map +1 -1
- package/out/src/index.mobile.js +1 -0
- package/out/src/index.mobile.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +4 -3
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts +13 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js +24 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js.map +1 -0
- package/out/src/sdk/ActionBatch.interfaces.d.ts +105 -0
- package/out/src/sdk/ActionBatch.interfaces.d.ts.map +1 -0
- package/out/src/sdk/ActionBatch.interfaces.js +3 -0
- package/out/src/sdk/ActionBatch.interfaces.js.map +1 -0
- package/out/src/sdk/WalletStorage.interfaces.d.ts +18 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/index.d.ts +1 -0
- package/out/src/sdk/index.d.ts.map +1 -1
- package/out/src/sdk/index.js +1 -0
- package/out/src/sdk/index.js.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts +28 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js +313 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts +33 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js +693 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js.map +1 -0
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +2 -1
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +4 -1
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +28 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +49 -0
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +8 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +24 -0
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/methods/actionBatch.d.ts +14 -0
- package/out/src/storage/methods/actionBatch.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatch.js +644 -0
- package/out/src/storage/methods/actionBatch.js.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts +12 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.js +121 -0
- package/out/src/storage/methods/actionBatchBlobs.js.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts +15 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.js +310 -0
- package/out/src/storage/methods/actionBatchValidation.js.map +1 -0
- package/out/src/storage/methods/actionPlanning.d.ts +12 -0
- package/out/src/storage/methods/actionPlanning.d.ts.map +1 -0
- package/out/src/storage/methods/actionPlanning.js +48 -0
- package/out/src/storage/methods/actionPlanning.js.map +1 -0
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +9 -25
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.d.ts +9 -0
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.js +36 -1
- package/out/src/storage/remoting/StorageClientBase.js.map +1 -1
- package/out/src/storage/schema/tables/TableActionBatch.d.ts +24 -0
- package/out/src/storage/schema/tables/TableActionBatch.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableActionBatch.js +3 -0
- package/out/src/storage/schema/tables/TableActionBatch.js.map +1 -0
- package/out/src/storage/schema/tables/index.d.ts +1 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +1 -0
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/src/utility/actionBatchDigest.d.ts +9 -0
- package/out/src/utility/actionBatchDigest.d.ts.map +1 -0
- package/out/src/utility/actionBatchDigest.js +48 -0
- package/out/src/utility/actionBatchDigest.js.map +1 -0
- package/out/src/utility/beefForTxids.d.ts +9 -0
- package/out/src/utility/beefForTxids.d.ts.map +1 -0
- package/out/src/utility/beefForTxids.js +35 -0
- package/out/src/utility/beefForTxids.js.map +1 -0
- package/out/src/wab-client/WABClient.d.ts +36 -90
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +103 -151
- package/out/src/wab-client/WABClient.js.map +1 -1
- package/out/src/wab-client/WABTransport.d.ts +53 -0
- package/out/src/wab-client/WABTransport.d.ts.map +1 -0
- package/out/src/wab-client/WABTransport.js +300 -0
- package/out/src/wab-client/WABTransport.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +10 -10
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +16 -21
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +2 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +14 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WABTransport = exports.WABClientError = void 0;
|
|
4
|
+
const sdk_1 = require("@bsv/sdk");
|
|
5
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
6
|
+
const DEFAULT_MAX_REQUEST_BYTES = 1024 * 1024;
|
|
7
|
+
const DEFAULT_MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
8
|
+
const MAX_CONFIGURED_TIMEOUT_MS = 120_000;
|
|
9
|
+
const MAX_CONFIGURED_REQUEST_BYTES = 10 * 1024 * 1024;
|
|
10
|
+
const MAX_CONFIGURED_RESPONSE_BYTES = 10 * 1024 * 1024;
|
|
11
|
+
const defaultFetch = typeof globalThis !== 'undefined' && typeof globalThis.fetch === 'function'
|
|
12
|
+
? globalThis.fetch.bind(globalThis)
|
|
13
|
+
: undefined;
|
|
14
|
+
/**
|
|
15
|
+
* A privacy-safe WAB transport failure. Response bodies and request payloads
|
|
16
|
+
* are deliberately excluded from the error.
|
|
17
|
+
*/
|
|
18
|
+
class WABClientError extends Error {
|
|
19
|
+
code;
|
|
20
|
+
retryable;
|
|
21
|
+
status;
|
|
22
|
+
constructor(code, message, retryable, status, options) {
|
|
23
|
+
super(message, options);
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.retryable = retryable;
|
|
26
|
+
this.status = status;
|
|
27
|
+
this.name = 'WABClientError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.WABClientError = WABClientError;
|
|
31
|
+
function isLocalHostname(hostname) {
|
|
32
|
+
const normalized = hostname.toLowerCase();
|
|
33
|
+
return normalized === 'localhost' ||
|
|
34
|
+
normalized === '127.0.0.1' ||
|
|
35
|
+
normalized === '[::1]' ||
|
|
36
|
+
normalized.endsWith('.localhost');
|
|
37
|
+
}
|
|
38
|
+
function normalizeServerUrl(serverUrl) {
|
|
39
|
+
let parsed;
|
|
40
|
+
try {
|
|
41
|
+
parsed = new URL(serverUrl);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw new WABClientError('WAB_INVALID_CONFIGURATION', 'WAB server URL must be an absolute URL.', false);
|
|
45
|
+
}
|
|
46
|
+
if (parsed.username !== '' || parsed.password !== '' || parsed.search !== '' || parsed.hash !== '') {
|
|
47
|
+
throw new WABClientError('WAB_INVALID_CONFIGURATION', 'WAB server URL must not contain credentials, a query, or a fragment.', false);
|
|
48
|
+
}
|
|
49
|
+
if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && isLocalHostname(parsed.hostname))) {
|
|
50
|
+
throw new WABClientError('WAB_INVALID_CONFIGURATION', 'WAB server URL must use HTTPS. Plain HTTP is allowed only for localhost development.', false);
|
|
51
|
+
}
|
|
52
|
+
parsed.pathname = parsed.pathname.replace(/\/+$/, '');
|
|
53
|
+
return parsed;
|
|
54
|
+
}
|
|
55
|
+
function normalizePositiveInteger(value, fallback, maximum, name) {
|
|
56
|
+
const resolved = value ?? fallback;
|
|
57
|
+
if (!Number.isInteger(resolved) || resolved <= 0 || resolved > maximum) {
|
|
58
|
+
throw new WABClientError('WAB_INVALID_CONFIGURATION', `${name} must be a positive integer no greater than ${maximum}.`, false);
|
|
59
|
+
}
|
|
60
|
+
return resolved;
|
|
61
|
+
}
|
|
62
|
+
function assertSafePath(path) {
|
|
63
|
+
if (!/^\/[a-zA-Z0-9/_-]*$/.test(path) || path.includes('..')) {
|
|
64
|
+
throw new WABClientError('WAB_INVALID_REQUEST', 'Invalid WAB endpoint path.', false);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function isRetryableStatus(status) {
|
|
68
|
+
return status === 408 || status === 425 || status === 429 || status >= 500;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Centralized, bounded transport used by every WAB client operation.
|
|
72
|
+
*
|
|
73
|
+
* Only fixed endpoint metadata is reported. Request bodies and response bodies
|
|
74
|
+
* never cross the telemetry boundary.
|
|
75
|
+
*/
|
|
76
|
+
class WABTransport {
|
|
77
|
+
serverUrl;
|
|
78
|
+
serverOrigin;
|
|
79
|
+
telemetry;
|
|
80
|
+
fetchClient;
|
|
81
|
+
timeoutMs;
|
|
82
|
+
maxRequestBytes;
|
|
83
|
+
maxResponseBytes;
|
|
84
|
+
constructor(serverUrl, options = {}) {
|
|
85
|
+
const parsed = normalizeServerUrl(serverUrl);
|
|
86
|
+
this.serverUrl = `${parsed.origin}${parsed.pathname}`;
|
|
87
|
+
this.serverOrigin = parsed.origin;
|
|
88
|
+
const fetchClient = options.fetch ?? defaultFetch;
|
|
89
|
+
if (typeof fetchClient !== 'function') {
|
|
90
|
+
throw new WABClientError('WAB_INVALID_CONFIGURATION', 'WABClient requires a fetch implementation.', false);
|
|
91
|
+
}
|
|
92
|
+
this.fetchClient = fetchClient;
|
|
93
|
+
this.timeoutMs = normalizePositiveInteger(options.timeoutMs, DEFAULT_TIMEOUT_MS, MAX_CONFIGURED_TIMEOUT_MS, 'timeoutMs');
|
|
94
|
+
this.maxRequestBytes = normalizePositiveInteger(options.maxRequestBytes, DEFAULT_MAX_REQUEST_BYTES, MAX_CONFIGURED_REQUEST_BYTES, 'maxRequestBytes');
|
|
95
|
+
this.maxResponseBytes = normalizePositiveInteger(options.maxResponseBytes, DEFAULT_MAX_RESPONSE_BYTES, MAX_CONFIGURED_RESPONSE_BYTES, 'maxResponseBytes');
|
|
96
|
+
this.telemetry = new sdk_1.Telemetry(options.telemetry);
|
|
97
|
+
}
|
|
98
|
+
createCorrelationId() {
|
|
99
|
+
return this.telemetry.enabled ? this.telemetry.createCorrelationId() : undefined;
|
|
100
|
+
}
|
|
101
|
+
async request(path, options) {
|
|
102
|
+
assertSafePath(path);
|
|
103
|
+
const method = options.method ?? 'POST';
|
|
104
|
+
const correlationId = options.correlationId ?? this.createCorrelationId();
|
|
105
|
+
const startedAt = Date.now();
|
|
106
|
+
const controller = new AbortController();
|
|
107
|
+
let timer;
|
|
108
|
+
let timedOut = false;
|
|
109
|
+
this.telemetry.capture({
|
|
110
|
+
name: 'wallet-toolbox.wab.request.started',
|
|
111
|
+
component: 'wallet-toolbox.wab-transport',
|
|
112
|
+
severity: 'debug',
|
|
113
|
+
correlationId,
|
|
114
|
+
attributes: {
|
|
115
|
+
operation: options.operation,
|
|
116
|
+
method,
|
|
117
|
+
route: path,
|
|
118
|
+
serverOrigin: this.serverOrigin
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
let body;
|
|
122
|
+
try {
|
|
123
|
+
body = options.body === undefined ? undefined : JSON.stringify(options.body);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
const normalized = new WABClientError('WAB_INVALID_REQUEST', 'WAB request payload could not be encoded.', false, undefined, { cause: error });
|
|
127
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, normalized);
|
|
128
|
+
throw normalized;
|
|
129
|
+
}
|
|
130
|
+
if (options.body !== undefined && body === undefined) {
|
|
131
|
+
const error = new WABClientError('WAB_INVALID_REQUEST', 'WAB request payload must be JSON-serializable.', false);
|
|
132
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, error);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
if (body !== undefined && new TextEncoder().encode(body).byteLength > this.maxRequestBytes) {
|
|
136
|
+
const error = new WABClientError('WAB_REQUEST_TOO_LARGE', 'WAB request exceeded the configured size limit.', false);
|
|
137
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, error);
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
const requestPromise = new Promise((resolve) => {
|
|
141
|
+
resolve(this.fetchClient(`${this.serverUrl}${path}`, {
|
|
142
|
+
method,
|
|
143
|
+
headers: {
|
|
144
|
+
Accept: 'application/json',
|
|
145
|
+
...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
146
|
+
...(correlationId !== undefined ? { 'X-Correlation-ID': correlationId } : {})
|
|
147
|
+
},
|
|
148
|
+
...(body !== undefined ? { body } : {}),
|
|
149
|
+
signal: controller.signal,
|
|
150
|
+
credentials: 'omit',
|
|
151
|
+
redirect: 'error',
|
|
152
|
+
referrerPolicy: 'no-referrer'
|
|
153
|
+
}));
|
|
154
|
+
});
|
|
155
|
+
requestPromise.catch(() => { });
|
|
156
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
157
|
+
timer = setTimeout(() => {
|
|
158
|
+
timedOut = true;
|
|
159
|
+
controller.abort();
|
|
160
|
+
reject(new WABClientError('WAB_TIMEOUT', 'WAB request timed out.', true));
|
|
161
|
+
}, this.timeoutMs);
|
|
162
|
+
});
|
|
163
|
+
let response;
|
|
164
|
+
try {
|
|
165
|
+
response = await Promise.race([requestPromise, timeoutPromise]);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (timer !== undefined)
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
const normalized = error instanceof WABClientError
|
|
171
|
+
? error
|
|
172
|
+
: new WABClientError(timedOut ? 'WAB_TIMEOUT' : 'WAB_NETWORK_ERROR', timedOut ? 'WAB request timed out.' : 'WAB request failed before receiving a response.', true, undefined, { cause: error });
|
|
173
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, normalized);
|
|
174
|
+
throw normalized;
|
|
175
|
+
}
|
|
176
|
+
if (!response.ok) {
|
|
177
|
+
if (timer !== undefined)
|
|
178
|
+
clearTimeout(timer);
|
|
179
|
+
const error = new WABClientError('WAB_HTTP_ERROR', `WAB request failed with HTTP status ${response.status}.`, isRetryableStatus(response.status), response.status);
|
|
180
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, error);
|
|
181
|
+
void response.body?.cancel().catch(() => { });
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
let responseText;
|
|
185
|
+
try {
|
|
186
|
+
responseText = await Promise.race([
|
|
187
|
+
this.readBoundedResponse(response),
|
|
188
|
+
timeoutPromise
|
|
189
|
+
]);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
const normalized = error instanceof WABClientError
|
|
193
|
+
? error
|
|
194
|
+
: new WABClientError(timedOut ? 'WAB_TIMEOUT' : 'WAB_INVALID_RESPONSE', timedOut ? 'WAB request timed out.' : 'WAB response could not be read.', true, response.status, { cause: error });
|
|
195
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, normalized);
|
|
196
|
+
throw normalized;
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
if (timer !== undefined)
|
|
200
|
+
clearTimeout(timer);
|
|
201
|
+
}
|
|
202
|
+
let parsed;
|
|
203
|
+
try {
|
|
204
|
+
parsed = JSON.parse(responseText);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
const normalized = new WABClientError('WAB_INVALID_RESPONSE', 'WAB response was not valid JSON.', true, response.status, { cause: error });
|
|
208
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, normalized);
|
|
209
|
+
throw normalized;
|
|
210
|
+
}
|
|
211
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
212
|
+
const error = new WABClientError('WAB_INVALID_RESPONSE', 'WAB response must be a JSON object.', true, response.status);
|
|
213
|
+
this.captureFailure(options.operation, method, path, correlationId, startedAt, error);
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
this.telemetry.capture({
|
|
217
|
+
name: 'wallet-toolbox.wab.request.completed',
|
|
218
|
+
component: 'wallet-toolbox.wab-transport',
|
|
219
|
+
severity: 'info',
|
|
220
|
+
correlationId,
|
|
221
|
+
attributes: {
|
|
222
|
+
operation: options.operation,
|
|
223
|
+
method,
|
|
224
|
+
route: path,
|
|
225
|
+
serverOrigin: this.serverOrigin,
|
|
226
|
+
status: response.status,
|
|
227
|
+
responseBytes: new TextEncoder().encode(responseText).byteLength,
|
|
228
|
+
durationMs: Date.now() - startedAt
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return parsed;
|
|
232
|
+
}
|
|
233
|
+
async readBoundedResponse(response) {
|
|
234
|
+
const contentLength = Number(response.headers.get('content-length'));
|
|
235
|
+
if (Number.isFinite(contentLength) && contentLength > this.maxResponseBytes) {
|
|
236
|
+
try {
|
|
237
|
+
await response.body?.cancel();
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Best effort only.
|
|
241
|
+
}
|
|
242
|
+
throw new WABClientError('WAB_RESPONSE_TOO_LARGE', 'WAB response exceeded the configured size limit.', false, response.status);
|
|
243
|
+
}
|
|
244
|
+
const reader = response.body?.getReader();
|
|
245
|
+
if (reader == null) {
|
|
246
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
247
|
+
if (bytes.byteLength > this.maxResponseBytes) {
|
|
248
|
+
throw new WABClientError('WAB_RESPONSE_TOO_LARGE', 'WAB response exceeded the configured size limit.', false, response.status);
|
|
249
|
+
}
|
|
250
|
+
return new TextDecoder().decode(bytes);
|
|
251
|
+
}
|
|
252
|
+
const chunks = [];
|
|
253
|
+
let total = 0;
|
|
254
|
+
while (true) {
|
|
255
|
+
const { done, value } = await reader.read();
|
|
256
|
+
if (done)
|
|
257
|
+
break;
|
|
258
|
+
if (value == null)
|
|
259
|
+
continue;
|
|
260
|
+
total += value.byteLength;
|
|
261
|
+
if (total > this.maxResponseBytes) {
|
|
262
|
+
try {
|
|
263
|
+
await reader.cancel();
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// Best effort only.
|
|
267
|
+
}
|
|
268
|
+
throw new WABClientError('WAB_RESPONSE_TOO_LARGE', 'WAB response exceeded the configured size limit.', false, response.status);
|
|
269
|
+
}
|
|
270
|
+
chunks.push(value);
|
|
271
|
+
}
|
|
272
|
+
const bytes = new Uint8Array(total);
|
|
273
|
+
let offset = 0;
|
|
274
|
+
for (const chunk of chunks) {
|
|
275
|
+
bytes.set(chunk, offset);
|
|
276
|
+
offset += chunk.byteLength;
|
|
277
|
+
}
|
|
278
|
+
return new TextDecoder().decode(bytes);
|
|
279
|
+
}
|
|
280
|
+
captureFailure(operation, method, path, correlationId, startedAt, error) {
|
|
281
|
+
this.telemetry.capture({
|
|
282
|
+
name: 'wallet-toolbox.wab.request.failed',
|
|
283
|
+
component: 'wallet-toolbox.wab-transport',
|
|
284
|
+
severity: error.retryable ? 'warn' : 'error',
|
|
285
|
+
correlationId,
|
|
286
|
+
attributes: {
|
|
287
|
+
operation,
|
|
288
|
+
method,
|
|
289
|
+
route: path,
|
|
290
|
+
serverOrigin: this.serverOrigin,
|
|
291
|
+
retryable: error.retryable,
|
|
292
|
+
...(error.status !== undefined ? { status: error.status } : {}),
|
|
293
|
+
durationMs: Date.now() - startedAt
|
|
294
|
+
},
|
|
295
|
+
error
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
exports.WABTransport = WABTransport;
|
|
300
|
+
//# sourceMappingURL=WABTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WABTransport.js","sourceRoot":"","sources":["../../../../src/wab-client/WABTransport.ts"],"names":[],"mappings":";;;AAAA,kCAAqD;AAErD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACjC,MAAM,yBAAyB,GAAG,IAAI,GAAG,IAAI,CAAA;AAC7C,MAAM,0BAA0B,G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AE,mCAAmC;YACzC,SAAS,EAAE,8BAA8B;YACzC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;YAC5C,aAAa;YACb,UAAU,EAAE;gBACV,SAAS;gBACT,MAAM;gBACN,KAAK,EAAE,IAAI;gBACX,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/D,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACnC;YACD,KAAK;SACN,CAAC,CAAA;IACJ,CAAC;CACF;AAvTD,oCAuTC"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
* AuthMethodInteractor
|
|
3
|
-
*
|
|
4
|
-
* A base interface/class for client-side logic to interact with a server
|
|
5
|
-
* for a specific Auth Method's flow (start, complete).
|
|
6
|
-
*/
|
|
1
|
+
import { WABTransport } from '../WABTransport';
|
|
7
2
|
export interface AuthPayload {
|
|
8
|
-
[key: string]:
|
|
3
|
+
[key: string]: unknown;
|
|
9
4
|
}
|
|
10
5
|
export interface StartAuthResponse {
|
|
11
6
|
success: boolean;
|
|
12
7
|
message?: string;
|
|
13
|
-
data?:
|
|
8
|
+
data?: unknown;
|
|
14
9
|
}
|
|
15
10
|
export interface CompleteAuthResponse {
|
|
16
11
|
success: boolean;
|
|
17
12
|
message?: string;
|
|
18
13
|
presentationKey?: string;
|
|
14
|
+
/** Preferred explicit continuity signal for newer WAB servers. */
|
|
15
|
+
accountStatus?: 'new-user' | 'existing-user';
|
|
16
|
+
/** Compatibility signal accepted from WAB deployments using a boolean. */
|
|
17
|
+
existingUser?: boolean;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
20
|
* Abstract client-side interactor for an Auth Method.
|
|
@@ -25,6 +24,7 @@ export interface CompleteAuthResponse {
|
|
|
25
24
|
*/
|
|
26
25
|
export declare abstract class AuthMethodInteractor {
|
|
27
26
|
abstract methodType: string;
|
|
27
|
+
protected preparePayload(payload: AuthPayload): AuthPayload;
|
|
28
28
|
/**
|
|
29
29
|
* Shared POST helper for auth endpoints.
|
|
30
30
|
*/
|
|
@@ -32,10 +32,10 @@ export declare abstract class AuthMethodInteractor {
|
|
|
32
32
|
/**
|
|
33
33
|
* Start the flow (e.g. request an OTP or create a session).
|
|
34
34
|
*/
|
|
35
|
-
startAuth(serverUrl: string, presentationKey: string, payload: AuthPayload): Promise<StartAuthResponse>;
|
|
35
|
+
startAuth(serverUrl: string, presentationKey: string, payload: AuthPayload, transport?: WABTransport, correlationId?: string): Promise<StartAuthResponse>;
|
|
36
36
|
/**
|
|
37
37
|
* Complete the flow (e.g. confirm OTP).
|
|
38
38
|
*/
|
|
39
|
-
completeAuth(serverUrl: string, presentationKey: string, payload: AuthPayload): Promise<CompleteAuthResponse>;
|
|
39
|
+
completeAuth(serverUrl: string, presentationKey: string, payload: AuthPayload, transport?: WABTransport, correlationId?: string): Promise<CompleteAuthResponse>;
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=AuthMethodInteractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthMethodInteractor.d.ts","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/AuthMethodInteractor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AuthMethodInteractor.d.ts","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/AuthMethodInteractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kEAAkE;IAClE,aAAa,CAAC,EAAE,UAAU,GAAG,eAAe,CAAA;IAC5C,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,8BAAsB,oBAAoB;IACxC,SAAgB,UAAU,EAAE,MAAM,CAAA;IAElC,SAAS,CAAC,cAAc,CAAE,OAAO,EAAE,WAAW,GAAG,WAAW;IAI5D;;OAEG;YACW,QAAQ;IAoBtB;;OAEG;IACU,SAAS,CACpB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,WAAW,EACpB,SAAS,CAAC,EAAE,YAAY,EACxB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,iBAAiB,CAAC;IAW7B;;OAEG;IACU,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,WAAW,EACpB,SAAS,CAAC,EAAE,YAAY,EACxB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,oBAAoB,CAAC;CAUjC"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* AuthMethodInteractor
|
|
4
|
-
*
|
|
5
|
-
* A base interface/class for client-side logic to interact with a server
|
|
6
|
-
* for a specific Auth Method's flow (start, complete).
|
|
7
|
-
*/
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.AuthMethodInteractor = void 0;
|
|
4
|
+
const WABTransport_1 = require("../WABTransport");
|
|
10
5
|
/**
|
|
11
6
|
* Abstract client-side interactor for an Auth Method.
|
|
12
7
|
*
|
|
@@ -14,35 +9,35 @@ exports.AuthMethodInteractor = void 0;
|
|
|
14
9
|
* `/auth/start` and `/auth/complete` are handled here.
|
|
15
10
|
*/
|
|
16
11
|
class AuthMethodInteractor {
|
|
12
|
+
preparePayload(payload) {
|
|
13
|
+
return payload;
|
|
14
|
+
}
|
|
17
15
|
/**
|
|
18
16
|
* Shared POST helper for auth endpoints.
|
|
19
17
|
*/
|
|
20
|
-
async postAuth(serverUrl, endpoint, presentationKey, payload) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
async postAuth(serverUrl, endpoint, presentationKey, payload, transport, correlationId) {
|
|
19
|
+
const client = transport ?? new WABTransport_1.WABTransport(serverUrl);
|
|
20
|
+
return await client.request(`/auth/${endpoint}`, {
|
|
21
|
+
operation: `auth-${endpoint}`,
|
|
22
|
+
correlationId,
|
|
23
|
+
body: {
|
|
25
24
|
methodType: this.methodType,
|
|
26
25
|
presentationKey,
|
|
27
|
-
payload
|
|
28
|
-
}
|
|
26
|
+
payload: this.preparePayload(payload)
|
|
27
|
+
}
|
|
29
28
|
});
|
|
30
|
-
if (!res.ok) {
|
|
31
|
-
return { success: false, message: `HTTP error ${res.status}` };
|
|
32
|
-
}
|
|
33
|
-
return await res.json();
|
|
34
29
|
}
|
|
35
30
|
/**
|
|
36
31
|
* Start the flow (e.g. request an OTP or create a session).
|
|
37
32
|
*/
|
|
38
|
-
async startAuth(serverUrl, presentationKey, payload) {
|
|
39
|
-
return await this.postAuth(serverUrl, 'start', presentationKey, payload);
|
|
33
|
+
async startAuth(serverUrl, presentationKey, payload, transport, correlationId) {
|
|
34
|
+
return await this.postAuth(serverUrl, 'start', presentationKey, payload, transport, correlationId);
|
|
40
35
|
}
|
|
41
36
|
/**
|
|
42
37
|
* Complete the flow (e.g. confirm OTP).
|
|
43
38
|
*/
|
|
44
|
-
async completeAuth(serverUrl, presentationKey, payload) {
|
|
45
|
-
return await this.postAuth(serverUrl, 'complete', presentationKey, payload);
|
|
39
|
+
async completeAuth(serverUrl, presentationKey, payload, transport, correlationId) {
|
|
40
|
+
return await this.postAuth(serverUrl, 'complete', presentationKey, payload, transport, correlationId);
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
exports.AuthMethodInteractor = AuthMethodInteractor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthMethodInteractor.js","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/AuthMethodInteractor.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"AuthMethodInteractor.js","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/AuthMethodInteractor.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAsB9C;;;;;GAKG;AACH,MAAsB,oBAAoB;IAG9B,cAAc,CAAE,OAAoB;QAC5C,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,QAAQ,CACpB,SAAiB,EACjB,QAAgB,EAChB,eAAuB,EACvB,OAAoB,EACpB,SAAwB,EACxB,aAAsB;QAEtB,MAAM,MAAM,GAAG,SAAS,IAAI,IAAI,2BAAY,CAAC,SAAS,CAAC,CAAA;QACvD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAI,SAAS,QAAQ,EAAE,EAAE;YAClD,SAAS,EAAE,QAAQ,QAAQ,EAAE;YAC7B,aAAa;YACb,IAAI,EAAE;gBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,eAAe;gBACf,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;aACtC;SACF,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,SAAS,CACpB,SAAiB,EACjB,eAAuB,EACvB,OAAoB,EACpB,SAAwB,EACxB,aAAsB;QAEtB,OAAO,MAAM,IAAI,CAAC,QAAQ,CACxB,SAAS,EACT,OAAO,EACP,eAAe,EACf,OAAO,EACP,SAAS,EACT,aAAa,CACd,CAAA;IACH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,YAAY,CACvB,SAAiB,EACjB,eAAuB,EACvB,OAAoB,EACpB,SAAwB,EACxB,aAAsB;QAEtB,OAAO,MAAM,IAAI,CAAC,QAAQ,CACxB,SAAS,EACT,UAAU,EACV,eAAe,EACf,OAAO,EACP,SAAS,EACT,aAAa,CACd,CAAA;IACH,CAAC;CACF;AArED,oDAqEC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthMethodInteractor } from './AuthMethodInteractor';
|
|
1
|
+
import { AuthMethodInteractor, AuthPayload } from './AuthMethodInteractor';
|
|
2
2
|
/**
|
|
3
3
|
* TwilioPhoneInteractor
|
|
4
4
|
*
|
|
@@ -6,5 +6,6 @@ import { AuthMethodInteractor } from './AuthMethodInteractor';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class TwilioPhoneInteractor extends AuthMethodInteractor {
|
|
8
8
|
methodType: string;
|
|
9
|
+
protected preparePayload(payload: AuthPayload): AuthPayload;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=TwilioPhoneInteractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TwilioPhoneInteractor.d.ts","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/TwilioPhoneInteractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"TwilioPhoneInteractor.d.ts","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/TwilioPhoneInteractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAE1E;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,oBAAoB;IACtD,UAAU,SAAgB;cAEd,cAAc,CAAE,OAAO,EAAE,WAAW,GAAG,WAAW;CActE"}
|
|
@@ -9,6 +9,20 @@ const AuthMethodInteractor_1 = require("./AuthMethodInteractor");
|
|
|
9
9
|
*/
|
|
10
10
|
class TwilioPhoneInteractor extends AuthMethodInteractor_1.AuthMethodInteractor {
|
|
11
11
|
methodType = 'TwilioPhone';
|
|
12
|
+
preparePayload(payload) {
|
|
13
|
+
const phoneNumber = payload.phoneNumber;
|
|
14
|
+
if (typeof phoneNumber !== 'string') {
|
|
15
|
+
throw new TypeError('TwilioPhone authentication requires phoneNumber.');
|
|
16
|
+
}
|
|
17
|
+
const normalized = phoneNumber.trim();
|
|
18
|
+
if (!/^\+[1-9][0-9]{7,14}$/.test(normalized)) {
|
|
19
|
+
throw new TypeError('phoneNumber must use canonical E.164 format.');
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
...payload,
|
|
23
|
+
phoneNumber: normalized
|
|
24
|
+
};
|
|
25
|
+
}
|
|
12
26
|
}
|
|
13
27
|
exports.TwilioPhoneInteractor = TwilioPhoneInteractor;
|
|
14
28
|
//# sourceMappingURL=TwilioPhoneInteractor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TwilioPhoneInteractor.js","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/TwilioPhoneInteractor.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"TwilioPhoneInteractor.js","sourceRoot":"","sources":["../../../../../src/wab-client/auth-method-interactors/TwilioPhoneInteractor.ts"],"names":[],"mappings":";;;AAAA,iEAA0E;AAE1E;;;;GAIG;AACH,MAAa,qBAAsB,SAAQ,2CAAoB;IACtD,UAAU,GAAG,aAAa,CAAA;IAEd,cAAc,CAAE,OAAoB;QACrD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACvC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAA;QACzE,CAAC;QACD,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,EAAE,CAAA;QACrC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAA;QACrE,CAAC;QACD,OAAO;YACL,GAAG,OAAO;YACV,WAAW,EAAE,UAAU;SACxB,CAAA;IACH,CAAC;CACF;AAjBD,sDAiBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/wallet-toolbox-mobile",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"description": "Client only Wallet Storage",
|
|
5
5
|
"main": "./out/src/index.mobile.js",
|
|
6
6
|
"types": "./out/src/index.mobile.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"homepage": "https://github.com/bsv-blockchain/ts-stack/tree/main/packages/wallet/wallet-toolbox/mobile#readme",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"hash-wasm": "^4.12.0",
|
|
25
|
-
"idb": "^8.0.
|
|
25
|
+
"idb": "^8.0.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@bsv/sdk": "^2.1.8"
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@
|
|
36
|
+
"@types/node": "^26.1.1",
|
|
37
|
+
"typescript": "^6.0.3",
|
|
38
|
+
"@bsv/sdk": "^2.2.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc --build ../tsconfig.mobile.json"
|
|
37
42
|
}
|
|
38
43
|
}
|