@bsv/wallet-toolbox 1.6.18 → 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.
Files changed (48) 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/Wallet.d.ts +4 -0
  5. package/mobile/out/src/Wallet.d.ts.map +1 -1
  6. package/mobile/out/src/Wallet.js +62 -21
  7. package/mobile/out/src/Wallet.js.map +1 -1
  8. package/mobile/out/src/index.client.d.ts +1 -0
  9. package/mobile/out/src/index.client.d.ts.map +1 -1
  10. package/mobile/out/src/index.client.js +1 -0
  11. package/mobile/out/src/index.client.js.map +1 -1
  12. package/mobile/out/src/index.mobile.d.ts +1 -0
  13. package/mobile/out/src/index.mobile.d.ts.map +1 -1
  14. package/mobile/out/src/index.mobile.js +1 -0
  15. package/mobile/out/src/index.mobile.js.map +1 -1
  16. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
  17. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
  18. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
  19. package/mobile/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
  20. package/mobile/package-lock.json +2 -2
  21. package/mobile/package.json +1 -1
  22. package/out/src/Wallet.d.ts +4 -0
  23. package/out/src/Wallet.d.ts.map +1 -1
  24. package/out/src/Wallet.js +62 -21
  25. package/out/src/Wallet.js.map +1 -1
  26. package/out/src/index.all.d.ts +1 -0
  27. package/out/src/index.all.d.ts.map +1 -1
  28. package/out/src/index.all.js +1 -0
  29. package/out/src/index.all.js.map +1 -1
  30. package/out/src/index.client.d.ts +1 -0
  31. package/out/src/index.client.d.ts.map +1 -1
  32. package/out/src/index.client.js +1 -0
  33. package/out/src/index.client.js.map +1 -1
  34. package/out/src/index.mobile.d.ts +1 -0
  35. package/out/src/index.mobile.d.ts.map +1 -1
  36. package/out/src/index.mobile.js +1 -0
  37. package/out/src/index.mobile.js.map +1 -1
  38. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
  39. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
  40. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
  41. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
  42. package/out/tsconfig.all.tsbuildinfo +1 -1
  43. package/package.json +1 -1
  44. package/src/Wallet.ts +87 -28
  45. package/src/index.all.ts +1 -0
  46. package/src/index.client.ts +1 -0
  47. package/src/index.mobile.ts +1 -0
  48. package/src/wab-client/auth-method-interactors/DevConsoleInteractor.ts +73 -0
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DevConsoleInteractor = void 0;
4
+ const AuthMethodInteractor_1 = require("./AuthMethodInteractor");
5
+ /**
6
+ * DevConsoleInteractor
7
+ *
8
+ * A client-side class that knows how to call the WAB server for DevConsole-based authentication.
9
+ * This is a development-only auth method that generates OTP codes and logs them to the console.
10
+ */
11
+ class DevConsoleInteractor extends AuthMethodInteractor_1.AuthMethodInteractor {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.methodType = 'DevConsole';
15
+ }
16
+ /**
17
+ * Start the DevConsole authentication on the server.
18
+ * - The server will generate an OTP code and log it to the console for development use.
19
+ * @param serverUrl - The base URL of the WAB server (e.g. http://localhost:3000)
20
+ * @param presentationKey - The 256-bit key the client is attempting to authenticate with
21
+ * @param payload - { phoneNumber: string } (identifier for the authentication)
22
+ * @returns - { success, message, data }
23
+ */
24
+ async startAuth(serverUrl, presentationKey, payload) {
25
+ const res = await fetch(`${serverUrl}/auth/start`, {
26
+ method: 'POST',
27
+ headers: { 'Content-Type': 'application/json' },
28
+ body: JSON.stringify({
29
+ methodType: this.methodType,
30
+ presentationKey,
31
+ payload
32
+ })
33
+ });
34
+ if (!res.ok) {
35
+ return {
36
+ success: false,
37
+ message: `HTTP error ${res.status}`
38
+ };
39
+ }
40
+ return res.json();
41
+ }
42
+ /**
43
+ * Complete the DevConsole authentication on the server.
44
+ * - The server will verify the OTP code that was generated and logged to the console.
45
+ * @param serverUrl - The base URL of the WAB server
46
+ * @param presentationKey - The 256-bit key
47
+ * @param payload - { phoneNumber: string, otp: string } (the identifier and OTP code from console)
48
+ * @returns - { success, message, presentationKey }
49
+ */
50
+ async completeAuth(serverUrl, presentationKey, payload) {
51
+ const res = await fetch(`${serverUrl}/auth/complete`, {
52
+ method: 'POST',
53
+ headers: { 'Content-Type': 'application/json' },
54
+ body: JSON.stringify({
55
+ methodType: this.methodType,
56
+ presentationKey,
57
+ payload
58
+ })
59
+ });
60
+ if (!res.ok) {
61
+ return {
62
+ success: false,
63
+ message: `HTTP error ${res.status}`
64
+ };
65
+ }
66
+ return res.json();
67
+ }
68
+ }
69
+ exports.DevConsoleInteractor = DevConsoleInteractor;
70
+ //# sourceMappingURL=DevConsoleInteractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevConsoleInteractor.js","sourceRoot":"","sources":["../../../../src/wab-client/auth-method-interactors/DevConsoleInteractor.ts"],"names":[],"mappings":";;;AAAA,iEAAmH;AAEnH;;;;;GAKG;AACH,MAAa,oBAAqB,SAAQ,2CAAoB;IAA9D;;QACS,eAAU,GAAG,YAAY,CAAA;IA+DlC,CAAC;IA7DC;;;;;;;OAOG;IACI,KAAK,CAAC,SAAS,CAAC,SAAiB,EAAE,eAAuB,EAAE,OAAoB;QACrF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,SAAS,aAAa,EAAE;YACjD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,eAAe;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