@bsv/wallet-toolbox-mobile 2.4.2 → 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/WalletPermissionsManager.d.ts +15 -0
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +76 -28
- package/out/src/WalletPermissionsManager.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
|
@@ -1,112 +1,58 @@
|
|
|
1
|
+
import { AuthMethodInteractor, AuthPayload, CompleteAuthResponse, StartAuthResponse } from './auth-method-interactors/AuthMethodInteractor';
|
|
2
|
+
import { WABTransport, WABTransportOptions } from './WABTransport';
|
|
3
|
+
export interface WABClientOptions extends WABTransportOptions {
|
|
4
|
+
}
|
|
5
|
+
export interface WABServerInfo {
|
|
6
|
+
supportedAuthMethods?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface WABOperationResponse {
|
|
10
|
+
success: boolean;
|
|
11
|
+
message?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface WABFaucetResponse extends WABOperationResponse {
|
|
15
|
+
paymentData?: {
|
|
16
|
+
k?: string;
|
|
17
|
+
tx?: number[];
|
|
18
|
+
txid?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Provides high-level methods to:
|
|
5
|
-
* - Retrieve server info (supported auth methods, faucet info)
|
|
6
|
-
* - Generate a random presentation key
|
|
7
|
-
* - Start/Complete authentication with a chosen AuthMethodInteractor
|
|
8
|
-
* - Link/unlink methods
|
|
9
|
-
* - Request faucet
|
|
10
|
-
* - Delete user
|
|
22
|
+
* Production-oriented WAB client with one security and observability boundary
|
|
23
|
+
* for every endpoint.
|
|
11
24
|
*/
|
|
12
|
-
import { AuthMethodInteractor } from './auth-method-interactors/AuthMethodInteractor';
|
|
13
25
|
export declare class WABClient {
|
|
14
|
-
|
|
15
|
-
constructor(serverUrl: string);
|
|
16
|
-
|
|
17
|
-
* Return the WAB server info
|
|
18
|
-
*/
|
|
19
|
-
getInfo(): Promise<any>;
|
|
20
|
-
/**
|
|
21
|
-
* Generate a random 256-bit presentation key as a hex string (client side).
|
|
22
|
-
*/
|
|
26
|
+
readonly transport: WABTransport;
|
|
27
|
+
constructor(serverUrl: string, options?: WABClientOptions);
|
|
28
|
+
getInfo(): Promise<WABServerInfo>;
|
|
23
29
|
generateRandomPresentationKey(): string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
completeAuthMethod(authMethod: AuthMethodInteractor, presentationKey: string, payload: any): Promise<any>;
|
|
32
|
-
/**
|
|
33
|
-
* List user-linked methods
|
|
34
|
-
*/
|
|
35
|
-
listLinkedMethods(presentationKey: string): Promise<any>;
|
|
36
|
-
/**
|
|
37
|
-
* Unlink a given Auth Method by ID
|
|
38
|
-
*/
|
|
39
|
-
unlinkMethod(presentationKey: string, authMethodId: number): Promise<any>;
|
|
40
|
-
/**
|
|
41
|
-
* Request faucet
|
|
42
|
-
*/
|
|
43
|
-
requestFaucet(presentationKey: string): Promise<any>;
|
|
44
|
-
/**
|
|
45
|
-
* Delete user
|
|
46
|
-
*/
|
|
47
|
-
deleteUser(presentationKey: string): Promise<any>;
|
|
48
|
-
/**
|
|
49
|
-
* Start OTP verification for share operations
|
|
50
|
-
* This initiates the auth flow (e.g., sends SMS code via Twilio)
|
|
51
|
-
*
|
|
52
|
-
* @param methodType The auth method type (e.g., "TwilioPhone", "DevConsole")
|
|
53
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
54
|
-
* @param payload Auth method specific data (e.g., { phoneNumber: "+1..." })
|
|
55
|
-
*/
|
|
56
|
-
startShareAuth(methodType: string, userIdHash: string, payload: any): Promise<{
|
|
30
|
+
startAuthMethod(authMethod: AuthMethodInteractor, presentationKey: string, payload: AuthPayload, correlationId?: string): Promise<StartAuthResponse>;
|
|
31
|
+
completeAuthMethod(authMethod: AuthMethodInteractor, presentationKey: string, payload: AuthPayload, correlationId?: string): Promise<CompleteAuthResponse>;
|
|
32
|
+
listLinkedMethods(presentationKey: string): Promise<WABOperationResponse>;
|
|
33
|
+
unlinkMethod(presentationKey: string, authMethodId: number): Promise<WABOperationResponse>;
|
|
34
|
+
requestFaucet(presentationKey: string): Promise<WABFaucetResponse>;
|
|
35
|
+
deleteUser(presentationKey: string): Promise<WABOperationResponse>;
|
|
36
|
+
startShareAuth(methodType: string, userIdHash: string, payload: AuthPayload): Promise<{
|
|
57
37
|
success: boolean;
|
|
58
38
|
message: string;
|
|
59
39
|
}>;
|
|
60
|
-
|
|
61
|
-
* Store a Shamir share (Share B) on the server
|
|
62
|
-
* Requires prior OTP verification via startShareAuth
|
|
63
|
-
*
|
|
64
|
-
* @param methodType The auth method type used for verification
|
|
65
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
66
|
-
* @param shareB The Shamir share to store (format: x.y.threshold.integrity)
|
|
67
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
68
|
-
*/
|
|
69
|
-
storeShare(methodType: string, payload: any, shareB: string, userIdHash: string): Promise<{
|
|
40
|
+
storeShare(methodType: string, payload: AuthPayload, shareB: string, userIdHash: string): Promise<{
|
|
70
41
|
success: boolean;
|
|
71
42
|
message: string;
|
|
72
43
|
userId?: number;
|
|
73
44
|
}>;
|
|
74
|
-
|
|
75
|
-
* Retrieve a Shamir share (Share B) from the server
|
|
76
|
-
* Requires OTP verification
|
|
77
|
-
*
|
|
78
|
-
* @param methodType The auth method type used for verification
|
|
79
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
80
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
81
|
-
*/
|
|
82
|
-
retrieveShare(methodType: string, payload: any, userIdHash: string): Promise<{
|
|
45
|
+
retrieveShare(methodType: string, payload: AuthPayload, userIdHash: string): Promise<{
|
|
83
46
|
success: boolean;
|
|
84
47
|
shareB?: string;
|
|
85
48
|
message: string;
|
|
86
49
|
}>;
|
|
87
|
-
|
|
88
|
-
* Update a Shamir share (for key rotation)
|
|
89
|
-
* Requires OTP verification
|
|
90
|
-
*
|
|
91
|
-
* @param methodType The auth method type used for verification
|
|
92
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
93
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
94
|
-
* @param newShareB The new Shamir share to store
|
|
95
|
-
*/
|
|
96
|
-
updateShare(methodType: string, payload: any, userIdHash: string, newShareB: string): Promise<{
|
|
50
|
+
updateShare(methodType: string, payload: AuthPayload, userIdHash: string, newShareB: string): Promise<{
|
|
97
51
|
success: boolean;
|
|
98
52
|
message: string;
|
|
99
53
|
shareVersion?: number;
|
|
100
54
|
}>;
|
|
101
|
-
|
|
102
|
-
* Delete a Shamir user's account and stored share
|
|
103
|
-
* Requires OTP verification
|
|
104
|
-
*
|
|
105
|
-
* @param methodType The auth method type used for verification
|
|
106
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
107
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
108
|
-
*/
|
|
109
|
-
deleteShamirUser(methodType: string, payload: any, userIdHash: string): Promise<{
|
|
55
|
+
deleteShamirUser(methodType: string, payload: AuthPayload, userIdHash: string): Promise<{
|
|
110
56
|
success: boolean;
|
|
111
57
|
message: string;
|
|
112
58
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WABClient.d.ts","sourceRoot":"","sources":["../../../../src/wab-client/WABClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WABClient.d.ts","sourceRoot":"","sources":["../../../../src/wab-client/WABClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAElE,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;CAAG;AAEhE,MAAM,WAAW,aAAa;IAC5B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,WAAW,CAAC,EAAE;QACZ,CAAC,CAAC,EAAE,MAAM,CAAA;QACV,EAAE,CAAC,EAAE,MAAM,EAAE,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;CACF;AA8BD;;;GAGG;AACH,qBAAa,SAAS;IACpB,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAA;gBAEnB,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;IAIjD,OAAO,IAAK,OAAO,CAAC,aAAa,CAAC;IAOxC,6BAA6B,IAAK,MAAM;IAIlC,eAAe,CAC1B,UAAU,EAAE,oBAAoB,EAChC,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,WAAW,EACpB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,iBAAiB,CAAC;IAWhB,kBAAkB,CAC7B,UAAU,EAAE,oBAAoB,EACh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AY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAU3D,gBAAgB,CAC3B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CASlD"}
|
|
@@ -2,186 +2,138 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WABClient = void 0;
|
|
4
4
|
const sdk_1 = require("@bsv/sdk");
|
|
5
|
+
const WABTransport_1 = require("./WABTransport");
|
|
6
|
+
function assertHexIdentifier(value, name) {
|
|
7
|
+
if (!/^[0-9a-fA-F]{64}$/.test(value)) {
|
|
8
|
+
throw new TypeError(`${name} must be a 32-byte hexadecimal string.`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function assertMethodType(methodType) {
|
|
12
|
+
if (!/^[a-zA-Z0-9_-]{1,64}$/.test(methodType)) {
|
|
13
|
+
throw new TypeError('methodType contains unsupported characters.');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function normalizeAuthPayload(methodType, payload) {
|
|
17
|
+
if (methodType !== 'TwilioPhone')
|
|
18
|
+
return payload;
|
|
19
|
+
const phoneNumber = payload.phoneNumber;
|
|
20
|
+
if (typeof phoneNumber !== 'string') {
|
|
21
|
+
throw new TypeError('TwilioPhone authentication requires phoneNumber.');
|
|
22
|
+
}
|
|
23
|
+
const normalized = phoneNumber.trim();
|
|
24
|
+
if (!/^\+[1-9][0-9]{7,14}$/.test(normalized)) {
|
|
25
|
+
throw new TypeError('phoneNumber must use canonical E.164 format.');
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...payload,
|
|
29
|
+
phoneNumber: normalized
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Production-oriented WAB client with one security and observability boundary
|
|
34
|
+
* for every endpoint.
|
|
35
|
+
*/
|
|
5
36
|
class WABClient {
|
|
6
|
-
|
|
7
|
-
constructor(serverUrl) {
|
|
8
|
-
this.
|
|
37
|
+
transport;
|
|
38
|
+
constructor(serverUrl, options = {}) {
|
|
39
|
+
this.transport = new WABTransport_1.WABTransport(serverUrl, options);
|
|
9
40
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Return the WAB server info
|
|
12
|
-
*/
|
|
13
41
|
async getInfo() {
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
return await this.transport.request('/info', {
|
|
43
|
+
method: 'GET',
|
|
44
|
+
operation: 'get-info'
|
|
45
|
+
});
|
|
16
46
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Generate a random 256-bit presentation key as a hex string (client side).
|
|
19
|
-
*/
|
|
20
47
|
generateRandomPresentationKey() {
|
|
21
48
|
return sdk_1.PrivateKey.fromRandom().toHex();
|
|
22
49
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
async completeAuthMethod(authMethod, presentationKey, payload) {
|
|
33
|
-
return await authMethod.completeAuth(this.serverUrl, presentationKey, payload);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* List user-linked methods
|
|
37
|
-
*/
|
|
50
|
+
async startAuthMethod(authMethod, presentationKey, payload, correlationId) {
|
|
51
|
+
assertHexIdentifier(presentationKey, 'presentationKey');
|
|
52
|
+
return await authMethod.startAuth(this.transport.serverUrl, presentationKey, payload, this.transport, correlationId);
|
|
53
|
+
}
|
|
54
|
+
async completeAuthMethod(authMethod, presentationKey, payload, correlationId) {
|
|
55
|
+
assertHexIdentifier(presentationKey, 'presentationKey');
|
|
56
|
+
return await authMethod.completeAuth(this.transport.serverUrl, presentationKey, payload, this.transport, correlationId);
|
|
57
|
+
}
|
|
38
58
|
async listLinkedMethods(presentationKey) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
body:
|
|
59
|
+
assertHexIdentifier(presentationKey, 'presentationKey');
|
|
60
|
+
return await this.transport.request('/user/linkedMethods', {
|
|
61
|
+
operation: 'list-linked-methods',
|
|
62
|
+
body: { presentationKey }
|
|
43
63
|
});
|
|
44
|
-
return await res.json();
|
|
45
64
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Unlink a given Auth Method by ID
|
|
48
|
-
*/
|
|
49
65
|
async unlinkMethod(presentationKey, authMethodId) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
assertHexIdentifier(presentationKey, 'presentationKey');
|
|
67
|
+
if (!Number.isSafeInteger(authMethodId) || authMethodId <= 0) {
|
|
68
|
+
throw new TypeError('authMethodId must be a positive safe integer.');
|
|
69
|
+
}
|
|
70
|
+
return await this.transport.request('/user/unlinkMethod', {
|
|
71
|
+
operation: 'unlink-method',
|
|
72
|
+
body: { presentationKey, authMethodId }
|
|
54
73
|
});
|
|
55
|
-
return await res.json();
|
|
56
74
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Request faucet
|
|
59
|
-
*/
|
|
60
75
|
async requestFaucet(presentationKey) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
body:
|
|
76
|
+
assertHexIdentifier(presentationKey, 'presentationKey');
|
|
77
|
+
return await this.transport.request('/faucet/request', {
|
|
78
|
+
operation: 'request-faucet',
|
|
79
|
+
body: { presentationKey }
|
|
65
80
|
});
|
|
66
|
-
return await res.json();
|
|
67
81
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Delete user
|
|
70
|
-
*/
|
|
71
82
|
async deleteUser(presentationKey) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
body:
|
|
83
|
+
assertHexIdentifier(presentationKey, 'presentationKey');
|
|
84
|
+
return await this.transport.request('/user/delete', {
|
|
85
|
+
operation: 'delete-user',
|
|
86
|
+
body: { presentationKey }
|
|
76
87
|
});
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
// ============================================================
|
|
80
|
-
// Shamir Share Management (2-of-3 Key Recovery System)
|
|
81
|
-
// ============================================================
|
|
82
|
-
/**
|
|
83
|
-
* Start OTP verification for share operations
|
|
84
|
-
* This initiates the auth flow (e.g., sends SMS code via Twilio)
|
|
85
|
-
*
|
|
86
|
-
* @param methodType The auth method type (e.g., "TwilioPhone", "DevConsole")
|
|
87
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
88
|
-
* @param payload Auth method specific data (e.g., { phoneNumber: "+1..." })
|
|
89
|
-
*/
|
|
88
|
+
}
|
|
90
89
|
async startShareAuth(methodType, userIdHash, payload) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
assertMethodType(methodType);
|
|
91
|
+
assertHexIdentifier(userIdHash, 'userIdHash');
|
|
92
|
+
const normalizedPayload = normalizeAuthPayload(methodType, payload);
|
|
93
|
+
return await this.transport.request('/auth/start', {
|
|
94
|
+
operation: 'start-share-auth',
|
|
95
|
+
body: {
|
|
95
96
|
methodType,
|
|
96
|
-
presentationKey: userIdHash,
|
|
97
|
-
payload
|
|
98
|
-
}
|
|
97
|
+
presentationKey: userIdHash,
|
|
98
|
+
payload: normalizedPayload
|
|
99
|
+
}
|
|
99
100
|
});
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Store a Shamir share (Share B) on the server
|
|
104
|
-
* Requires prior OTP verification via startShareAuth
|
|
105
|
-
*
|
|
106
|
-
* @param methodType The auth method type used for verification
|
|
107
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
108
|
-
* @param shareB The Shamir share to store (format: x.y.threshold.integrity)
|
|
109
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
110
|
-
*/
|
|
101
|
+
}
|
|
111
102
|
async storeShare(methodType, payload, shareB, userIdHash) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
shareB,
|
|
119
|
-
userIdHash
|
|
120
|
-
})
|
|
103
|
+
assertMethodType(methodType);
|
|
104
|
+
assertHexIdentifier(userIdHash, 'userIdHash');
|
|
105
|
+
const normalizedPayload = normalizeAuthPayload(methodType, payload);
|
|
106
|
+
return await this.transport.request('/share/store', {
|
|
107
|
+
operation: 'store-share',
|
|
108
|
+
body: { methodType, payload: normalizedPayload, shareB, userIdHash }
|
|
121
109
|
});
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Retrieve a Shamir share (Share B) from the server
|
|
126
|
-
* Requires OTP verification
|
|
127
|
-
*
|
|
128
|
-
* @param methodType The auth method type used for verification
|
|
129
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
130
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
131
|
-
*/
|
|
110
|
+
}
|
|
132
111
|
async retrieveShare(methodType, payload, userIdHash) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
userIdHash
|
|
140
|
-
})
|
|
112
|
+
assertMethodType(methodType);
|
|
113
|
+
assertHexIdentifier(userIdHash, 'userIdHash');
|
|
114
|
+
const normalizedPayload = normalizeAuthPayload(methodType, payload);
|
|
115
|
+
return await this.transport.request('/share/retrieve', {
|
|
116
|
+
operation: 'retrieve-share',
|
|
117
|
+
body: { methodType, payload: normalizedPayload, userIdHash }
|
|
141
118
|
});
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Update a Shamir share (for key rotation)
|
|
146
|
-
* Requires OTP verification
|
|
147
|
-
*
|
|
148
|
-
* @param methodType The auth method type used for verification
|
|
149
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
150
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
151
|
-
* @param newShareB The new Shamir share to store
|
|
152
|
-
*/
|
|
119
|
+
}
|
|
153
120
|
async updateShare(methodType, payload, userIdHash, newShareB) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
userIdHash,
|
|
161
|
-
newShareB
|
|
162
|
-
})
|
|
121
|
+
assertMethodType(methodType);
|
|
122
|
+
assertHexIdentifier(userIdHash, 'userIdHash');
|
|
123
|
+
const normalizedPayload = normalizeAuthPayload(methodType, payload);
|
|
124
|
+
return await this.transport.request('/share/update', {
|
|
125
|
+
operation: 'update-share',
|
|
126
|
+
body: { methodType, payload: normalizedPayload, userIdHash, newShareB }
|
|
163
127
|
});
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Delete a Shamir user's account and stored share
|
|
168
|
-
* Requires OTP verification
|
|
169
|
-
*
|
|
170
|
-
* @param methodType The auth method type used for verification
|
|
171
|
-
* @param payload Contains the OTP code and auth method specific data
|
|
172
|
-
* @param userIdHash SHA256 hash of the user's identity key
|
|
173
|
-
*/
|
|
128
|
+
}
|
|
174
129
|
async deleteShamirUser(methodType, payload, userIdHash) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
userIdHash
|
|
182
|
-
})
|
|
130
|
+
assertMethodType(methodType);
|
|
131
|
+
assertHexIdentifier(userIdHash, 'userIdHash');
|
|
132
|
+
const normalizedPayload = normalizeAuthPayload(methodType, payload);
|
|
133
|
+
return await this.transport.request('/share/delete', {
|
|
134
|
+
operation: 'delete-share-user',
|
|
135
|
+
body: { methodType, payload: normalizedPayload, userIdHash }
|
|
183
136
|
});
|
|
184
|
-
return await res.json();
|
|
185
137
|
}
|
|
186
138
|
}
|
|
187
139
|
exports.WABClient = WABClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WABClient.js","sourceRoot":"","sources":["../../../../src/wab-client/WABClient.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file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E,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAC3B,UAAkB,EAClB,OAAoB,EACpB,UAAkB;QAElB,gBAAgB,CAAC,UAAU,CAAC,CAAA;QAC5B,mBAAmB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;QAC7C,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QACnE,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE;YACnD,SAAS,EAAE,mBAAmB;YAC9B,IAAI,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE;SAC7D,CAAC,CAAA;IACJ,CAAC;CACF;AAnKD,8BAmKC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Telemetry, TelemetryConfig } from '@bsv/sdk';
|
|
2
|
+
export type WABClientErrorCode = 'WAB_INVALID_CONFIGURATION' | 'WAB_INVALID_REQUEST' | 'WAB_NETWORK_ERROR' | 'WAB_TIMEOUT' | 'WAB_HTTP_ERROR' | 'WAB_REQUEST_TOO_LARGE' | 'WAB_RESPONSE_TOO_LARGE' | 'WAB_INVALID_RESPONSE';
|
|
3
|
+
/**
|
|
4
|
+
* A privacy-safe WAB transport failure. Response bodies and request payloads
|
|
5
|
+
* are deliberately excluded from the error.
|
|
6
|
+
*/
|
|
7
|
+
export declare class WABClientError extends Error {
|
|
8
|
+
readonly code: WABClientErrorCode;
|
|
9
|
+
readonly retryable: boolean;
|
|
10
|
+
readonly status?: number | undefined;
|
|
11
|
+
constructor(code: WABClientErrorCode, message: string, retryable: boolean, status?: number | undefined, options?: {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export interface WABTransportOptions {
|
|
16
|
+
/** Injectable fetch implementation for React Native, tests, and custom runtimes. */
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
/** Hard wall-clock request timeout. Defaults to 10 seconds. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
/** Maximum encoded JSON request size. Defaults to 1 MiB. */
|
|
21
|
+
maxRequestBytes?: number;
|
|
22
|
+
/** Maximum accepted JSON response size. Defaults to 1 MiB. */
|
|
23
|
+
maxResponseBytes?: number;
|
|
24
|
+
/** Optional privacy-bounded telemetry integration. */
|
|
25
|
+
telemetry?: TelemetryConfig;
|
|
26
|
+
}
|
|
27
|
+
export interface WABRequestOptions {
|
|
28
|
+
method?: 'GET' | 'POST';
|
|
29
|
+
body?: unknown;
|
|
30
|
+
operation: string;
|
|
31
|
+
correlationId?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Centralized, bounded transport used by every WAB client operation.
|
|
35
|
+
*
|
|
36
|
+
* Only fixed endpoint metadata is reported. Request bodies and response bodies
|
|
37
|
+
* never cross the telemetry boundary.
|
|
38
|
+
*/
|
|
39
|
+
export declare class WABTransport {
|
|
40
|
+
readonly serverUrl: string;
|
|
41
|
+
readonly serverOrigin: string;
|
|
42
|
+
readonly telemetry: Telemetry;
|
|
43
|
+
private readonly fetchClient;
|
|
44
|
+
private readonly timeoutMs;
|
|
45
|
+
private readonly maxRequestBytes;
|
|
46
|
+
private readonly maxResponseBytes;
|
|
47
|
+
constructor(serverUrl: string, options?: WABTransportOptions);
|
|
48
|
+
createCorrelationId(): string | undefined;
|
|
49
|
+
request<T>(path: string, options: WABRequestOptions): Promise<T>;
|
|
50
|
+
private readBoundedResponse;
|
|
51
|
+
private captureFailure;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=WABTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WABTransport.d.ts","sourceRoot":"","sources":["../../../../src/wab-client/WABTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAcrD,MAAM,MAAM,kBAAkB,GAC1B,2BAA2B,GAC3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