@bsv/wallet-toolbox 1.6.19 → 1.6.21

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 (39) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/docs/client.md +93 -27
  3. package/docs/wallet.md +93 -27
  4. package/mobile/out/src/index.client.d.ts +1 -0
  5. package/mobile/out/src/index.client.d.ts.map +1 -1
  6. package/mobile/out/src/index.client.js +1 -0
  7. package/mobile/out/src/index.client.js.map +1 -1
  8. package/mobile/out/src/index.mobile.d.ts +1 -0
  9. package/mobile/out/src/index.mobile.d.ts.map +1 -1
  10. package/mobile/out/src/index.mobile.js +1 -0
  11. package/mobile/out/src/index.mobile.js.map +1 -1
  12. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
  13. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
  14. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
  15. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
  16. package/mobile/package-lock.json +6 -7
  17. package/mobile/package.json +2 -2
  18. package/out/src/index.all.d.ts +1 -0
  19. package/out/src/index.all.d.ts.map +1 -1
  20. package/out/src/index.all.js +1 -0
  21. package/out/src/index.all.js.map +1 -1
  22. package/out/src/index.client.d.ts +1 -0
  23. package/out/src/index.client.d.ts.map +1 -1
  24. package/out/src/index.client.js +1 -0
  25. package/out/src/index.client.js.map +1 -1
  26. package/out/src/index.mobile.d.ts +1 -0
  27. package/out/src/index.mobile.d.ts.map +1 -1
  28. package/out/src/index.mobile.js +1 -0
  29. package/out/src/index.mobile.js.map +1 -1
  30. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
  31. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
  32. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
  33. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
  34. package/out/tsconfig.all.tsbuildinfo +1 -1
  35. package/package.json +2 -2
  36. package/src/index.all.ts +1 -0
  37. package/src/index.client.ts +1 -0
  38. package/src/index.mobile.ts +1 -0
  39. package/src/wab-client/auth-method-interactors/DevConsoleInteractor.ts +73 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/wallet-toolbox",
3
- "version": "1.6.19",
3
+ "version": "1.6.21",
4
4
  "description": "BRC100 conforming wallet, wallet storage and wallet signer components",
5
5
  "main": "./out/src/index.js",
6
6
  "types": "./out/src/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@bsv/auth-express-middleware": "^1.2.3",
34
34
  "@bsv/payment-express-middleware": "^1.2.3",
35
- "@bsv/sdk": "^1.6.24",
35
+ "@bsv/sdk": "^1.7.3",
36
36
  "express": "^4.21.2",
37
37
  "idb": "^8.0.2",
38
38
  "knex": "^3.1.0",
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'
@@ -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'
@@ -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
+ }