@bsv/wallet-toolbox 1.6.19 → 1.6.20
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/CHANGELOG.md +4 -0
- package/docs/client.md +93 -27
- package/docs/wallet.md +93 -27
- package/mobile/out/src/index.client.d.ts +1 -0
- package/mobile/out/src/index.client.d.ts.map +1 -1
- package/mobile/out/src/index.client.js +1 -0
- package/mobile/out/src/index.client.js.map +1 -1
- package/mobile/out/src/index.mobile.d.ts +1 -0
- package/mobile/out/src/index.mobile.d.ts.map +1 -1
- package/mobile/out/src/index.mobile.js +1 -0
- package/mobile/out/src/index.mobile.js.map +1 -1
- package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
- package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
- package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
- package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
- package/mobile/package-lock.json +2 -2
- package/mobile/package.json +1 -1
- package/out/src/index.all.d.ts +1 -0
- package/out/src/index.all.d.ts.map +1 -1
- package/out/src/index.all.js +1 -0
- package/out/src/index.all.js.map +1 -1
- package/out/src/index.client.d.ts +1 -0
- package/out/src/index.client.d.ts.map +1 -1
- package/out/src/index.client.js +1 -0
- package/out/src/index.client.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/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
- package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.all.ts +1 -0
- package/src/index.client.ts +1 -0
- package/src/index.mobile.ts +1 -0
- package/src/wab-client/auth-method-interactors/DevConsoleInteractor.ts +73 -0
package/package.json
CHANGED
package/src/index.all.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from './SimpleWalletManager'
|
|
|
19
19
|
export * from './wab-client/auth-method-interactors/AuthMethodInteractor'
|
|
20
20
|
export * from './wab-client/auth-method-interactors/PersonaIDInteractor'
|
|
21
21
|
export * from './wab-client/auth-method-interactors/TwilioPhoneInteractor'
|
|
22
|
+
export * from './wab-client/auth-method-interactors/DevConsoleInteractor'
|
|
22
23
|
export * from './wab-client/WABClient'
|
|
23
24
|
export * from './Wallet'
|
|
24
25
|
export * from './WalletAuthenticationManager'
|
package/src/index.client.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './SimpleWalletManager'
|
|
|
17
17
|
export * from './wab-client/auth-method-interactors/AuthMethodInteractor'
|
|
18
18
|
export * from './wab-client/auth-method-interactors/PersonaIDInteractor'
|
|
19
19
|
export * from './wab-client/auth-method-interactors/TwilioPhoneInteractor'
|
|
20
|
+
export * from './wab-client/auth-method-interactors/DevConsoleInteractor'
|
|
20
21
|
export * from './wab-client/WABClient'
|
|
21
22
|
export * from './Wallet'
|
|
22
23
|
export * from './WalletAuthenticationManager'
|
package/src/index.mobile.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './SimpleWalletManager'
|
|
|
13
13
|
export * from './wab-client/auth-method-interactors/AuthMethodInteractor'
|
|
14
14
|
export * from './wab-client/auth-method-interactors/PersonaIDInteractor'
|
|
15
15
|
export * from './wab-client/auth-method-interactors/TwilioPhoneInteractor'
|
|
16
|
+
export * from './wab-client/auth-method-interactors/DevConsoleInteractor'
|
|
16
17
|
export * from './wab-client/WABClient'
|
|
17
18
|
export * from './Wallet'
|
|
18
19
|
export * from './WalletAuthenticationManager'
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AuthMethodInteractor, AuthPayload, StartAuthResponse, CompleteAuthResponse } from './AuthMethodInteractor'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DevConsoleInteractor
|
|
5
|
+
*
|
|
6
|
+
* A client-side class that knows how to call the WAB server for DevConsole-based authentication.
|
|
7
|
+
* This is a development-only auth method that generates OTP codes and logs them to the console.
|
|
8
|
+
*/
|
|
9
|
+
export class DevConsoleInteractor extends AuthMethodInteractor {
|
|
10
|
+
public methodType = 'DevConsole'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Start the DevConsole authentication on the server.
|
|
14
|
+
* - The server will generate an OTP code and log it to the console for development use.
|
|
15
|
+
* @param serverUrl - The base URL of the WAB server (e.g. http://localhost:3000)
|
|
16
|
+
* @param presentationKey - The 256-bit key the client is attempting to authenticate with
|
|
17
|
+
* @param payload - { phoneNumber: string } (identifier for the authentication)
|
|
18
|
+
* @returns - { success, message, data }
|
|
19
|
+
*/
|
|
20
|
+
public async startAuth(serverUrl: string, presentationKey: string, payload: AuthPayload): Promise<StartAuthResponse> {
|
|
21
|
+
const res = await fetch(`${serverUrl}/auth/start`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: { 'Content-Type': 'application/json' },
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
methodType: this.methodType,
|
|
26
|
+
presentationKey,
|
|
27
|
+
payload
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
message: `HTTP error ${res.status}`
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return res.json()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Complete the DevConsole authentication on the server.
|
|
43
|
+
* - The server will verify the OTP code that was generated and logged to the console.
|
|
44
|
+
* @param serverUrl - The base URL of the WAB server
|
|
45
|
+
* @param presentationKey - The 256-bit key
|
|
46
|
+
* @param payload - { phoneNumber: string, otp: string } (the identifier and OTP code from console)
|
|
47
|
+
* @returns - { success, message, presentationKey }
|
|
48
|
+
*/
|
|
49
|
+
public async completeAuth(
|
|
50
|
+
serverUrl: string,
|
|
51
|
+
presentationKey: string,
|
|
52
|
+
payload: AuthPayload
|
|
53
|
+
): Promise<CompleteAuthResponse> {
|
|
54
|
+
const res = await fetch(`${serverUrl}/auth/complete`, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: { 'Content-Type': 'application/json' },
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
methodType: this.methodType,
|
|
59
|
+
presentationKey,
|
|
60
|
+
payload
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
message: `HTTP error ${res.status}`
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return res.json()
|
|
72
|
+
}
|
|
73
|
+
}
|