@bsv/sdk 1.2.11 → 1.2.13

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 (56) hide show
  1. package/README.md +5 -2
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/cjs/src/transaction/Broadcaster.js.map +1 -1
  4. package/dist/cjs/src/transaction/Transaction.js +2 -2
  5. package/dist/cjs/src/transaction/Transaction.js.map +1 -1
  6. package/dist/cjs/src/wallet/WalletClient.js +11 -1
  7. package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
  8. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +113 -0
  9. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -0
  10. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  11. package/dist/esm/src/transaction/Broadcaster.js.map +1 -1
  12. package/dist/esm/src/transaction/Transaction.js +3 -3
  13. package/dist/esm/src/transaction/Transaction.js.map +1 -1
  14. package/dist/esm/src/wallet/WalletClient.js +11 -1
  15. package/dist/esm/src/wallet/WalletClient.js.map +1 -1
  16. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +114 -0
  17. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -0
  18. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  19. package/dist/types/src/transaction/Broadcaster.d.ts +3 -0
  20. package/dist/types/src/transaction/Broadcaster.d.ts.map +1 -1
  21. package/dist/types/src/wallet/WalletClient.d.ts +1 -1
  22. package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
  23. package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts +189 -0
  24. package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -0
  25. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  26. package/dist/umd/bundle.js +1 -1
  27. package/docs/README.md +9 -0
  28. package/docs/swagger/dist/LICENSE +21 -0
  29. package/docs/swagger/dist/favicon-16x16.png +0 -0
  30. package/docs/swagger/dist/favicon-32x32.png +0 -0
  31. package/docs/swagger/dist/index.css +16 -0
  32. package/docs/swagger/dist/oauth2-redirect.html +79 -0
  33. package/docs/swagger/dist/swagger-initializer.js +20 -0
  34. package/docs/swagger/dist/swagger-ui-bundle.js +2 -0
  35. package/docs/swagger/dist/swagger-ui-bundle.js.map +1 -0
  36. package/docs/swagger/dist/swagger-ui-es-bundle-core.js +3 -0
  37. package/docs/swagger/dist/swagger-ui-es-bundle-core.js.map +1 -0
  38. package/docs/swagger/dist/swagger-ui-es-bundle.js +2 -0
  39. package/docs/swagger/dist/swagger-ui-es-bundle.js.map +1 -0
  40. package/docs/swagger/dist/swagger-ui-standalone-preset.js +2 -0
  41. package/docs/swagger/dist/swagger-ui-standalone-preset.js.map +1 -0
  42. package/docs/swagger/dist/swagger-ui.css +3 -0
  43. package/docs/swagger/dist/swagger-ui.css.map +1 -0
  44. package/docs/swagger/dist/swagger-ui.js +2 -0
  45. package/docs/swagger/dist/swagger-ui.js.map +1 -0
  46. package/docs/swagger/index.html +19 -0
  47. package/docs/swagger/swagger-ui.version +1 -0
  48. package/docs/swagger/swagger.yaml +1960 -0
  49. package/docs/transaction.md +1 -0
  50. package/docs/wallet.md +226 -1
  51. package/package.json +1 -1
  52. package/src/primitives/__tests/PrivateKey.test.ts +2 -2
  53. package/src/transaction/Broadcaster.ts +4 -0
  54. package/src/transaction/Transaction.ts +3 -3
  55. package/src/wallet/WalletClient.ts +10 -2
  56. package/src/wallet/substrates/HTTPWalletJSON.ts +143 -0
package/docs/README.md CHANGED
@@ -6,4 +6,13 @@ The documentation is split into various pages, each covering a set of related fu
6
6
  - [Script](./script.md) — Covers Bitcoin scripts, the templating system, serialization, and the Spend class (script interpreter)
7
7
  - [Transaction](./transaction.md) — Covers transaction construction, signing, broadcasters, fee models, merkle proofs, and SPV structures like BUMP
8
8
  - [Messages](./messages.md) — Covers generalizable message signing, verification, encryption and decryption
9
+ - [TOTP](./totp.md) - Covers Time-based One Time Password, useful for validating counterparties across unsecured mediums.
10
+ - [Wallet](./wallet-substrates.md) - Covers the Wallet Substrates for communication between applications and wallets using a standard interface.
11
+ - [Overlay Tools](./overlay-tools.md) - Covers the use of Overlays for broadcast of transactions based on topics, as well as distributed lookup of tokens.
9
12
  - [Compat](./compat.md) — Covers deprecated functionality for legacy systems like BIP32 and ECIES
13
+
14
+ ## Swagger
15
+
16
+ [BRC-100](https://brc.dev/100) defines a Unified, Vendor-Neutral, Unchanging, and Open BSV Blockchain Standard Wallet-to-Application Interface which is implemented in this library within the WalletClient class. The API is laid out here as a swagger openapi document to offer a fast-track to understanding the interface which is implemented across multiple substrates. The JSON api is generally considered a developer friendly introduction to the WalletClient, where an binary equivalent ABI may be preferred for production use cases.
17
+
18
+ - [Wallet JSON API Swagger](./swagger)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Peter Evans
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ html {
2
+ box-sizing: border-box;
3
+ overflow: -moz-scrollbars-vertical;
4
+ overflow-y: scroll;
5
+ }
6
+
7
+ *,
8
+ *:before,
9
+ *:after {
10
+ box-sizing: inherit;
11
+ }
12
+
13
+ body {
14
+ margin: 0;
15
+ background: #fafafa;
16
+ }
@@ -0,0 +1,79 @@
1
+ <!doctype html>
2
+ <html lang="en-US">
3
+ <head>
4
+ <title>Swagger UI: OAuth2 Redirect</title>
5
+ </head>
6
+ <body>
7
+ <script>
8
+ 'use strict';
9
+ function run () {
10
+ var oauth2 = window.opener.swaggerUIRedirectOauth2;
11
+ var sentState = oauth2.state;
12
+ var redirectUrl = oauth2.redirectUrl;
13
+ var isValid, qp, arr;
14
+
15
+ if (/code|token|error/.test(window.location.hash)) {
16
+ qp = window.location.hash.substring(1).replace('?', '&');
17
+ } else {
18
+ qp = location.search.substring(1);
19
+ }
20
+
21
+ arr = qp.split("&");
22
+ arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
23
+ qp = qp ? JSON.parse('{' + arr.join() + '}',
24
+ function (key, value) {
25
+ return key === "" ? value : decodeURIComponent(value);
26
+ }
27
+ ) : {};
28
+
29
+ isValid = qp.state === sentState;
30
+
31
+ if ((
32
+ oauth2.auth.schema.get("flow") === "accessCode" ||
33
+ oauth2.auth.schema.get("flow") === "authorizationCode" ||
34
+ oauth2.auth.schema.get("flow") === "authorization_code"
35
+ ) && !oauth2.auth.code) {
36
+ if (!isValid) {
37
+ oauth2.errCb({
38
+ authId: oauth2.auth.name,
39
+ source: "auth",
40
+ level: "warning",
41
+ message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server."
42
+ });
43
+ }
44
+
45
+ if (qp.code) {
46
+ delete oauth2.state;
47
+ oauth2.auth.code = qp.code;
48
+ oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
49
+ } else {
50
+ let oauthErrorMsg;
51
+ if (qp.error) {
52
+ oauthErrorMsg = "["+qp.error+"]: " +
53
+ (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
54
+ (qp.error_uri ? "More info: "+qp.error_uri : "");
55
+ }
56
+
57
+ oauth2.errCb({
58
+ authId: oauth2.auth.name,
59
+ source: "auth",
60
+ level: "error",
61
+ message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server."
62
+ });
63
+ }
64
+ } else {
65
+ oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
66
+ }
67
+ window.close();
68
+ }
69
+
70
+ if (document.readyState !== 'loading') {
71
+ run();
72
+ } else {
73
+ document.addEventListener('DOMContentLoaded', function () {
74
+ run();
75
+ });
76
+ }
77
+ </script>
78
+ </body>
79
+ </html>
@@ -0,0 +1,20 @@
1
+ window.onload = function() {
2
+ //<editor-fold desc="Changeable Configuration Block">
3
+
4
+ // the following lines will be replaced by docker/configurator, when it runs in a docker-container
5
+ window.ui = SwaggerUIBundle({
6
+ url: "swagger.yaml",
7
+ dom_id: '#swagger-ui',
8
+ deepLinking: true,
9
+ presets: [
10
+ SwaggerUIBundle.presets.apis,
11
+ SwaggerUIStandalonePreset
12
+ ],
13
+ plugins: [
14
+ SwaggerUIBundle.plugins.DownloadUrl
15
+ ],
16
+ layout: "StandaloneLayout"
17
+ });
18
+
19
+ //</editor-fold>
20
+ };