tapass 0.0.0-stage → 0.1.0

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 (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/dist/grpc/emit_subscription_error.d.ts +21 -0
  4. package/dist/grpc/emit_subscription_error.d.ts.map +1 -0
  5. package/dist/grpc/emit_subscription_error.js +26 -0
  6. package/dist/grpc/emit_subscription_error.js.map +1 -0
  7. package/dist/grpc/grpc_services.d.ts +46 -0
  8. package/dist/grpc/grpc_services.d.ts.map +1 -0
  9. package/dist/grpc/grpc_services.js +45 -0
  10. package/dist/grpc/grpc_services.js.map +1 -0
  11. package/dist/grpc/handle_remove_listener.d.ts +18 -0
  12. package/dist/grpc/handle_remove_listener.d.ts.map +1 -0
  13. package/dist/grpc/handle_remove_listener.js +22 -0
  14. package/dist/grpc/handle_remove_listener.js.map +1 -0
  15. package/dist/grpc/index.d.ts +32 -0
  16. package/dist/grpc/index.d.ts.map +1 -0
  17. package/dist/grpc/index.js +6 -0
  18. package/dist/grpc/index.js.map +1 -0
  19. package/dist/index.d.ts +4 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +3 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/tapd_grpc/api_for_proto.d.ts +28 -0
  24. package/dist/tapd_grpc/api_for_proto.d.ts.map +1 -0
  25. package/dist/tapd_grpc/api_for_proto.js +24 -0
  26. package/dist/tapd_grpc/api_for_proto.js.map +1 -0
  27. package/dist/tapd_grpc/authenticated_tapd_grpc.d.ts +35 -0
  28. package/dist/tapd_grpc/authenticated_tapd_grpc.d.ts.map +1 -0
  29. package/dist/tapd_grpc/authenticated_tapd_grpc.js +76 -0
  30. package/dist/tapd_grpc/authenticated_tapd_grpc.js.map +1 -0
  31. package/dist/tapd_grpc/decode_serialized.d.ts +18 -0
  32. package/dist/tapd_grpc/decode_serialized.d.ts.map +1 -0
  33. package/dist/tapd_grpc/decode_serialized.js +23 -0
  34. package/dist/tapd_grpc/decode_serialized.js.map +1 -0
  35. package/dist/tapd_grpc/grpc_credentials.d.ts +24 -0
  36. package/dist/tapd_grpc/grpc_credentials.d.ts.map +1 -0
  37. package/dist/tapd_grpc/grpc_credentials.js +39 -0
  38. package/dist/tapd_grpc/grpc_credentials.js.map +1 -0
  39. package/dist/tapd_grpc/grpc_options.d.ts +10 -0
  40. package/dist/tapd_grpc/grpc_options.d.ts.map +1 -0
  41. package/dist/tapd_grpc/grpc_options.js +9 -0
  42. package/dist/tapd_grpc/grpc_options.js.map +1 -0
  43. package/dist/tapd_grpc/grpc_ssl.d.ts +19 -0
  44. package/dist/tapd_grpc/grpc_ssl.d.ts.map +1 -0
  45. package/dist/tapd_grpc/grpc_ssl.js +18 -0
  46. package/dist/tapd_grpc/grpc_ssl.js.map +1 -0
  47. package/dist/tapd_grpc/index.d.ts +6 -0
  48. package/dist/tapd_grpc/index.d.ts.map +1 -0
  49. package/dist/tapd_grpc/index.js +2 -0
  50. package/dist/tapd_grpc/index.js.map +1 -0
  51. package/dist/tapd_grpc/types.d.ts +35 -0
  52. package/dist/tapd_grpc/types.d.ts.map +1 -0
  53. package/dist/tapd_grpc/types.js +2 -0
  54. package/dist/tapd_grpc/types.js.map +1 -0
  55. package/dist/tapd_methods/address/create_asset_address.d.ts +76 -0
  56. package/dist/tapd_methods/address/create_asset_address.d.ts.map +1 -0
  57. package/dist/tapd_methods/address/create_asset_address.js +159 -0
  58. package/dist/tapd_methods/address/create_asset_address.js.map +1 -0
  59. package/dist/tapd_methods/address/index.d.ts +4 -0
  60. package/dist/tapd_methods/address/index.d.ts.map +1 -0
  61. package/dist/tapd_methods/address/index.js +2 -0
  62. package/dist/tapd_methods/address/index.js.map +1 -0
  63. package/dist/tapd_methods/index.d.ts +2 -0
  64. package/dist/tapd_methods/index.d.ts.map +1 -0
  65. package/dist/tapd_methods/index.js +2 -0
  66. package/dist/tapd_methods/index.js.map +1 -0
  67. package/dist/tapd_requests/index.d.ts +4 -0
  68. package/dist/tapd_requests/index.d.ts.map +1 -0
  69. package/dist/tapd_requests/index.js +4 -0
  70. package/dist/tapd_requests/index.js.map +1 -0
  71. package/dist/tapd_requests/is_connection_failure.d.ts +23 -0
  72. package/dist/tapd_requests/is_connection_failure.d.ts.map +1 -0
  73. package/dist/tapd_requests/is_connection_failure.js +40 -0
  74. package/dist/tapd_requests/is_connection_failure.js.map +1 -0
  75. package/dist/tapd_requests/is_permission_denied.d.ts +19 -0
  76. package/dist/tapd_requests/is_permission_denied.d.ts.map +1 -0
  77. package/dist/tapd_requests/is_permission_denied.js +16 -0
  78. package/dist/tapd_requests/is_permission_denied.js.map +1 -0
  79. package/dist/tapd_requests/is_tapd.d.ts +19 -0
  80. package/dist/tapd_requests/is_tapd.d.ts.map +1 -0
  81. package/dist/tapd_requests/is_tapd.js +16 -0
  82. package/dist/tapd_requests/is_tapd.js.map +1 -0
  83. package/dist/typescript/index.d.ts +16 -0
  84. package/dist/typescript/index.d.ts.map +1 -0
  85. package/dist/typescript/index.js +2 -0
  86. package/dist/typescript/index.js.map +1 -0
  87. package/package.json +71 -3
  88. package/protos/VERSIONS +2 -0
  89. package/protos/lnrpc/lightning.proto +5380 -0
  90. package/protos/lnrpc/routerrpc/router.proto +1115 -0
  91. package/protos/taprpc/assetwalletrpc/assetwallet.proto +631 -0
  92. package/protos/taprpc/authmailboxrpc/mailbox.proto +281 -0
  93. package/protos/taprpc/mintrpc/mint.proto +452 -0
  94. package/protos/taprpc/portfoliopilotrpc/portfolio_pilot.proto +410 -0
  95. package/protos/taprpc/priceoraclerpc/price_oracle.proto +262 -0
  96. package/protos/taprpc/rfqrpc/rfq.proto +614 -0
  97. package/protos/taprpc/tapchannelrpc/tapchannel.proto +490 -0
  98. package/protos/taprpc/tapcommon.proto +47 -0
  99. package/protos/taprpc/tapdevrpc/tapdev.proto +120 -0
  100. package/protos/taprpc/taprootassets.proto +2117 -0
  101. package/protos/taprpc/universerpc/universe.proto +1101 -0
  102. package/src/grpc/emit_subscription_error.ts +39 -0
  103. package/src/grpc/grpc_services.ts +45 -0
  104. package/src/grpc/handle_remove_listener.ts +35 -0
  105. package/src/grpc/index.ts +18 -0
  106. package/src/index.ts +3 -0
  107. package/src/tapd_grpc/api_for_proto.ts +42 -0
  108. package/src/tapd_grpc/authenticated_tapd_grpc.ts +88 -0
  109. package/src/tapd_grpc/decode_serialized.ts +25 -0
  110. package/src/tapd_grpc/grpc_credentials.ts +48 -0
  111. package/src/tapd_grpc/grpc_options.ts +10 -0
  112. package/src/tapd_grpc/grpc_ssl.ts +20 -0
  113. package/src/tapd_grpc/index.ts +5 -0
  114. package/src/tapd_grpc/types.ts +35 -0
  115. package/src/tapd_methods/address/create_asset_address.ts +244 -0
  116. package/src/tapd_methods/address/index.ts +3 -0
  117. package/src/tapd_methods/index.ts +1 -0
  118. package/src/tapd_requests/index.ts +3 -0
  119. package/src/tapd_requests/is_connection_failure.ts +48 -0
  120. package/src/tapd_requests/is_permission_denied.ts +18 -0
  121. package/src/tapd_requests/is_tapd.ts +22 -0
  122. package/src/typescript/asyncjs_util.d.ts +14 -0
  123. package/src/typescript/index.ts +22 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 bnonni
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.
package/README.md CHANGED
@@ -1,3 +1,98 @@
1
- # Temporary Holding Version
1
+ # tapass
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Methods for the Taproot Assets daemon (tapd), in the style of
4
+ [lightning](https://github.com/alexbosworth/lightning).
5
+
6
+ ## Install
7
+
8
+ npm install tapass
9
+
10
+ tapass needs Node.js 22.12 or later.
11
+
12
+ ## tapd Authentication
13
+
14
+ To connect to tapd, you need the TLS certificate and a macaroon. Encode each
15
+ file as base64:
16
+
17
+ base64 -w0 ~/.tapd/tls.cert
18
+ base64 -w0 ~/.tapd/data/mainnet/admin.macaroon
19
+
20
+ Then make an authenticated tapd object:
21
+
22
+ ```js
23
+ import {authenticatedTapdGrpc} from 'tapass';
24
+
25
+ const {tapd} = authenticatedTapdGrpc({
26
+ cert: 'base64 encoded tls.cert',
27
+ macaroon: 'base64 encoded admin.macaroon',
28
+ socket: '127.0.0.1:10029',
29
+ });
30
+ ```
31
+
32
+ ## Methods
33
+
34
+ - [createAssetAddress](#createassetaddress): Create a Taproot Assets address
35
+ to receive an asset
36
+
37
+ ### createAssetAddress
38
+
39
+ Create a Taproot Assets address to receive an asset
40
+
41
+ Requires `addresses:write` permission
42
+
43
+ An `asset_id` or a `group_key` is required, but not both
44
+
45
+ When there is a `group_key` and no `version`, tapd makes a V2 address
46
+
47
+ {
48
+ [amount]: <Asset Units To Receive Numeric String>
49
+ [asset_id]: <Asset Id Hex String>
50
+ [group_key]: <Asset Group Key Hex String>
51
+ [proof_courier]: <Proof Courier Address String>
52
+ tapd: <Authenticated tapd API Object>
53
+ [version]: <Address Version Number> // 0 || 1 || 2
54
+ }
55
+
56
+ @returns via cbk or Promise
57
+ {
58
+ address: <Encoded Taproot Assets Address String>
59
+ amount: <Asset Units To Receive Numeric String>
60
+ [asset_id]: <Asset Id Hex String>
61
+ asset_version: <Asset Version Number>
62
+ [group_key]: <Asset Group Key Hex String>
63
+ internal_key: <Internal Key Hex String>
64
+ is_collectible: <Asset Is Collectible Bool>
65
+ proof_courier: <Proof Courier Address String>
66
+ script_key: <Script Key Hex String>
67
+ [tapscript_sibling]: <Tapscript Sibling Preimage Hex String>
68
+ taproot_output_key: <Taproot Output Key Hex String>
69
+ version: <Address Version Number>
70
+ }
71
+
72
+ Example:
73
+
74
+ ```js
75
+ import {createAssetAddress} from 'tapass';
76
+
77
+ const {address} = await createAssetAddress({amount: '100', asset_id, tapd});
78
+ ```
79
+
80
+ ## Errors
81
+
82
+ Methods return errors as arrays: `[code, 'ErrorMessage', {err}]`.
83
+
84
+ - `400`: An argument is not correct.
85
+ - `403`: The macaroon does not have the permission for the method.
86
+ - `404`: tapd does not have the item, for example an asset.
87
+ - `503`: tapd returned an error, or tapd is not available.
88
+
89
+ ## Development
90
+
91
+ pnpm install
92
+ pnpm test
93
+ pnpm lint
94
+ pnpm build
95
+
96
+ To copy the protos of a different tapd release into `protos/`:
97
+
98
+ pnpm sync-protos v0.8.5
@@ -0,0 +1,21 @@
1
+ import type { EventEmitter } from 'node:events';
2
+ import type { ClientReadableStream } from '@grpc/grpc-js';
3
+ type Args = {
4
+ emitter: EventEmitter;
5
+ subscription: ClientReadableStream<unknown>;
6
+ };
7
+ export default _default;
8
+ /** Get a function that emits an error from a gRPC subscription proxy
9
+
10
+ {
11
+ emitter: <Event Subscription Proxy Object>
12
+ subscription: <gRPC Subscription Object>
13
+ }
14
+
15
+ @returns
16
+ <Error Emission Function>
17
+ */
18
+ declare function _default({ emitter, subscription }: Args): (err?: {
19
+ details?: string;
20
+ }) => void;
21
+ //# sourceMappingURL=emit_subscription_error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit_subscription_error.d.ts","sourceRoot":"","sources":["../../src/grpc/emit_subscription_error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAIxD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAC7C,CAAC;;AAEF;;;;;;;;;EASE;0BACc,EAAC,OAAO,EAAE,YAAY,EAAC,EAAE,IAAI,UAC7B;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC"}
@@ -0,0 +1,26 @@
1
+ const cancelError = 'Cancelled on client';
2
+ /** Get a function that emits an error from a gRPC subscription proxy
3
+
4
+ {
5
+ emitter: <Event Subscription Proxy Object>
6
+ subscription: <gRPC Subscription Object>
7
+ }
8
+
9
+ @returns
10
+ <Error Emission Function>
11
+ */
12
+ export default ({ emitter, subscription }) => {
13
+ return (err) => {
14
+ subscription.cancel();
15
+ if (!!err && err.details === cancelError) {
16
+ subscription.removeAllListeners();
17
+ }
18
+ // Exit early when there are no error listeners
19
+ if (!emitter.listenerCount('error')) {
20
+ return;
21
+ }
22
+ emitter.emit('error', err);
23
+ return;
24
+ };
25
+ };
26
+ //# sourceMappingURL=emit_subscription_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit_subscription_error.js","sourceRoot":"","sources":["../../src/grpc/emit_subscription_error.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAO1C;;;;;;;;;EASE;AACF,eAAe,CAAC,EAAC,OAAO,EAAE,YAAY,EAAO,EAAE,EAAE;IAC/C,OAAO,CAAC,GAAwB,EAAE,EAAE;QAClC,YAAY,CAAC,MAAM,EAAE,CAAC;QAEtB,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;YACzC,YAAY,CAAC,kBAAkB,EAAE,CAAC;QACpC,CAAC;QAED,+CAA+C;QAC/C,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAE3B,OAAO;IACT,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /** gRPC settings for tapd
2
+
3
+ `includeDirs` and `protoFiles` paths are relative to `protosDir`.
4
+ `protosDir` is relative to the `tapd_grpc` directory.
5
+ */
6
+ declare const _default: {
7
+ readonly defaultSocket: 'localhost:10029';
8
+ readonly grpcSslCipherSuites: 'HIGH+ECDSA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384';
9
+ readonly includeDirs: readonly ['taprpc', 'lnrpc'];
10
+ readonly keepaliveTimeMs: 60000;
11
+ readonly keepaliveTimeoutMs: 120000;
12
+ readonly maxReceiveMessageLength: 924288000;
13
+ readonly packageTypes: {
14
+ readonly AssetWallet: 'assetwalletrpc';
15
+ readonly Mailbox: 'authmailboxrpc';
16
+ readonly Mint: 'mintrpc';
17
+ readonly Rfq: 'rfqrpc';
18
+ readonly TapDev: 'tapdevrpc';
19
+ readonly TaprootAssetChannels: 'tapchannelrpc';
20
+ readonly TaprootAssets: 'taprpc';
21
+ readonly Universe: 'universerpc';
22
+ };
23
+ readonly protoFiles: {
24
+ readonly AssetWallet: 'taprpc/assetwalletrpc/assetwallet.proto';
25
+ readonly Mailbox: 'taprpc/authmailboxrpc/mailbox.proto';
26
+ readonly Mint: 'taprpc/mintrpc/mint.proto';
27
+ readonly Rfq: 'taprpc/rfqrpc/rfq.proto';
28
+ readonly TapDev: 'taprpc/tapdevrpc/tapdev.proto';
29
+ readonly TaprootAssetChannels: 'taprpc/tapchannelrpc/tapchannel.proto';
30
+ readonly TaprootAssets: 'taprpc/taprootassets.proto';
31
+ readonly Universe: 'taprpc/universerpc/universe.proto';
32
+ };
33
+ readonly protosDir: '../../protos/';
34
+ readonly serviceTypes: {
35
+ readonly assetwallet: 'AssetWallet';
36
+ readonly default: 'TaprootAssets';
37
+ readonly mailbox: 'Mailbox';
38
+ readonly mint: 'Mint';
39
+ readonly rfq: 'Rfq';
40
+ readonly tapchannel: 'TaprootAssetChannels';
41
+ readonly tapdev: 'TapDev';
42
+ readonly universe: 'Universe';
43
+ };
44
+ };
45
+ export default _default;
46
+ //# sourceMappingURL=grpc_services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc_services.d.ts","sourceRoot":"","sources":["../../src/grpc/grpc_services.ts"],"names":[],"mappings":"AAAA;;;;EAIE;;aAEA,aAAa,EAAE,iBAAiB;aAChC,mBAAmB,EACjB,oOAAoO;aACtO,WAAW,YAAG,QAAQ,EAAE,OAAO;aAC/B,eAAe,EAAE,KAAK;aACtB,kBAAkB,EAAE,MAAM;aAC1B,uBAAuB,EAAE,SAAS;aAClC,YAAY;iBACV,WAAW,EAAE,gBAAgB;iBAC7B,OAAO,EAAE,gBAAgB;iBACzB,IAAI,EAAE,SAAS;iBACf,GAAG,EAAE,QAAQ;iBACb,MAAM,EAAE,WAAW;iBACnB,oBAAoB,EAAE,eAAe;iBACrC,aAAa,EAAE,QAAQ;iBACvB,QAAQ,EAAE,aAAa;;aAEzB,UAAU;iBACR,WAAW,EAAE,yCAAyC;iBACtD,OAAO,EAAE,qCAAqC;iBAC9C,IAAI,EAAE,2BAA2B;iBACjC,GAAG,EAAE,yBAAyB;iBAC9B,MAAM,EAAE,+BAA+B;iBACvC,oBAAoB,EAAE,uCAAuC;iBAC7D,aAAa,EAAE,4BAA4B;iBAC3C,QAAQ,EAAE,mCAAmC;;aAE/C,SAAS,EAAE,eAAe;aAC1B,YAAY;iBACV,WAAW,EAAE,aAAa;iBAC1B,OAAO,EAAE,eAAe;iBACxB,OAAO,EAAE,SAAS;iBAClB,IAAI,EAAE,MAAM;iBACZ,GAAG,EAAE,KAAK;iBACV,UAAU,EAAE,sBAAsB;iBAClC,MAAM,EAAE,QAAQ;iBAChB,QAAQ,EAAE,UAAU"}
@@ -0,0 +1,45 @@
1
+ /** gRPC settings for tapd
2
+
3
+ `includeDirs` and `protoFiles` paths are relative to `protosDir`.
4
+ `protosDir` is relative to the `tapd_grpc` directory.
5
+ */
6
+ export default {
7
+ defaultSocket: 'localhost:10029',
8
+ grpcSslCipherSuites: 'HIGH+ECDSA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384',
9
+ includeDirs: ['taprpc', 'lnrpc'],
10
+ keepaliveTimeMs: 60000,
11
+ keepaliveTimeoutMs: 120000,
12
+ maxReceiveMessageLength: 924288000,
13
+ packageTypes: {
14
+ AssetWallet: 'assetwalletrpc',
15
+ Mailbox: 'authmailboxrpc',
16
+ Mint: 'mintrpc',
17
+ Rfq: 'rfqrpc',
18
+ TapDev: 'tapdevrpc',
19
+ TaprootAssetChannels: 'tapchannelrpc',
20
+ TaprootAssets: 'taprpc',
21
+ Universe: 'universerpc',
22
+ },
23
+ protoFiles: {
24
+ AssetWallet: 'taprpc/assetwalletrpc/assetwallet.proto',
25
+ Mailbox: 'taprpc/authmailboxrpc/mailbox.proto',
26
+ Mint: 'taprpc/mintrpc/mint.proto',
27
+ Rfq: 'taprpc/rfqrpc/rfq.proto',
28
+ TapDev: 'taprpc/tapdevrpc/tapdev.proto',
29
+ TaprootAssetChannels: 'taprpc/tapchannelrpc/tapchannel.proto',
30
+ TaprootAssets: 'taprpc/taprootassets.proto',
31
+ Universe: 'taprpc/universerpc/universe.proto',
32
+ },
33
+ protosDir: '../../protos/',
34
+ serviceTypes: {
35
+ assetwallet: 'AssetWallet',
36
+ default: 'TaprootAssets',
37
+ mailbox: 'Mailbox',
38
+ mint: 'Mint',
39
+ rfq: 'Rfq',
40
+ tapchannel: 'TaprootAssetChannels',
41
+ tapdev: 'TapDev',
42
+ universe: 'Universe',
43
+ },
44
+ };
45
+ //# sourceMappingURL=grpc_services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc_services.js","sourceRoot":"","sources":["../../src/grpc/grpc_services.ts"],"names":[],"mappings":"AAAA;;;;EAIE;AACF,eAAe;IACb,aAAa,EAAE,iBAAiB;IAChC,mBAAmB,EACjB,oOAAoO;IACtO,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IAChC,eAAe,EAAE,KAAK;IACtB,kBAAkB,EAAE,MAAM;IAC1B,uBAAuB,EAAE,SAAS;IAClC,YAAY,EAAE;QACZ,WAAW,EAAE,gBAAgB;QAC7B,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,QAAQ;QACb,MAAM,EAAE,WAAW;QACnB,oBAAoB,EAAE,eAAe;QACrC,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,aAAa;KACxB;IACD,UAAU,EAAE;QACV,WAAW,EAAE,yCAAyC;QACtD,OAAO,EAAE,qCAAqC;QAC9C,IAAI,EAAE,2BAA2B;QACjC,GAAG,EAAE,yBAAyB;QAC9B,MAAM,EAAE,+BAA+B;QACvC,oBAAoB,EAAE,uCAAuC;QAC7D,aAAa,EAAE,4BAA4B;QAC3C,QAAQ,EAAE,mCAAmC;KAC9C;IACD,SAAS,EAAE,eAAe;IAC1B,YAAY,EAAE;QACZ,WAAW,EAAE,aAAa;QAC1B,OAAO,EAAE,eAAe;QACxB,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,UAAU,EAAE,sBAAsB;QAClC,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;KACrB;CACO,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { EventEmitter } from 'node:events';
2
+ import type { ClientReadableStream } from '@grpc/grpc-js';
3
+ type Args = {
4
+ emitter: EventEmitter;
5
+ events: string[];
6
+ subscription: ClientReadableStream<unknown>;
7
+ };
8
+ export default _default;
9
+ /** Cancel a gRPC subscription when all its event listeners are removed
10
+
11
+ {
12
+ emitter: <EventEmitter Subscription Proxy Object>
13
+ events: [<Event Name String>]
14
+ subscription: <gRPC Subscription Object>
15
+ }
16
+ */
17
+ declare function _default({ emitter, events, subscription }: Args): void;
18
+ //# sourceMappingURL=handle_remove_listener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle_remove_listener.d.ts","sourceRoot":"","sources":["../../src/grpc/handle_remove_listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAIxD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAC7C,CAAC;;AAEF;;;;;;;EAOE;0BACc,EAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAC,EAAE,IAAI"}
@@ -0,0 +1,22 @@
1
+ const sumOf = (arr) => arr.reduce((sum, n) => sum + n, Number());
2
+ /** Cancel a gRPC subscription when all its event listeners are removed
3
+
4
+ {
5
+ emitter: <EventEmitter Subscription Proxy Object>
6
+ events: [<Event Name String>]
7
+ subscription: <gRPC Subscription Object>
8
+ }
9
+ */
10
+ export default ({ emitter, events, subscription }) => {
11
+ // Cancel the subscription when all listeners are removed
12
+ emitter.on('removeListener', () => {
13
+ const counts = events.map(n => emitter.listenerCount(n));
14
+ // Exit early when there are still active listeners
15
+ if (!!sumOf(counts)) {
16
+ return;
17
+ }
18
+ subscription.cancel();
19
+ return;
20
+ });
21
+ };
22
+ //# sourceMappingURL=handle_remove_listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle_remove_listener.js","sourceRoot":"","sources":["../../src/grpc/handle_remove_listener.ts"],"names":[],"mappings":"AAIA,MAAM,KAAK,GAAG,CAAC,GAAa,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAQ3E;;;;;;;EAOE;AACF,eAAe,CAAC,EAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAO,EAAE,EAAE;IACvD,yDAAyD;IACzD,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAChC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzD,mDAAmD;QACnD,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,YAAY,CAAC,MAAM,EAAE,CAAC;QAEtB,OAAO;IACT,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import emitSubscriptionError from './emit_subscription_error.js';
2
+ import handleRemoveListener from './handle_remove_listener.js';
3
+ export declare const defaultSocket: "localhost:10029", grpcSslCipherSuites: "HIGH+ECDSA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384", includeDirs: readonly ["taprpc", "lnrpc"], keepaliveTimeMs: 60000, keepaliveTimeoutMs: 120000, maxReceiveMessageLength: 924288000, packageTypes: {
4
+ readonly AssetWallet: 'assetwalletrpc';
5
+ readonly Mailbox: 'authmailboxrpc';
6
+ readonly Mint: 'mintrpc';
7
+ readonly Rfq: 'rfqrpc';
8
+ readonly TapDev: 'tapdevrpc';
9
+ readonly TaprootAssetChannels: 'tapchannelrpc';
10
+ readonly TaprootAssets: 'taprpc';
11
+ readonly Universe: 'universerpc';
12
+ }, protoFiles: {
13
+ readonly AssetWallet: 'taprpc/assetwalletrpc/assetwallet.proto';
14
+ readonly Mailbox: 'taprpc/authmailboxrpc/mailbox.proto';
15
+ readonly Mint: 'taprpc/mintrpc/mint.proto';
16
+ readonly Rfq: 'taprpc/rfqrpc/rfq.proto';
17
+ readonly TapDev: 'taprpc/tapdevrpc/tapdev.proto';
18
+ readonly TaprootAssetChannels: 'taprpc/tapchannelrpc/tapchannel.proto';
19
+ readonly TaprootAssets: 'taprpc/taprootassets.proto';
20
+ readonly Universe: 'taprpc/universerpc/universe.proto';
21
+ }, protosDir: "../../protos/", serviceTypes: {
22
+ readonly assetwallet: 'AssetWallet';
23
+ readonly default: 'TaprootAssets';
24
+ readonly mailbox: 'Mailbox';
25
+ readonly mint: 'Mint';
26
+ readonly rfq: 'Rfq';
27
+ readonly tapchannel: 'TaprootAssetChannels';
28
+ readonly tapdev: 'TapDev';
29
+ readonly universe: 'Universe';
30
+ };
31
+ export { emitSubscriptionError, handleRemoveListener };
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,8BAA8B,CAAC;AAEjE,OAAO,oBAAoB,MAAM,6BAA6B,CAAC;AAE/D,eAAO,MACL,aAAa,qBACb,mBAAmB,wOACnB,WAAW,gCACX,eAAe,SACf,kBAAkB,UAClB,uBAAuB,aACvB,YAAY;;;;;;;;;GACZ,UAAU;;;;;;;;;GACV,SAAS,mBACT,YAAY;;;;;;;;;CACE,CAAC;AAEjB,OAAO,EAAC,qBAAqB,EAAE,oBAAoB,EAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import emitSubscriptionError from './emit_subscription_error.js';
2
+ import grpcServices from './grpc_services.js';
3
+ import handleRemoveListener from './handle_remove_listener.js';
4
+ export const { defaultSocket, grpcSslCipherSuites, includeDirs, keepaliveTimeMs, keepaliveTimeoutMs, maxReceiveMessageLength, packageTypes, protoFiles, protosDir, serviceTypes, } = grpcServices;
5
+ export { emitSubscriptionError, handleRemoveListener };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/grpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,8BAA8B,CAAC;AACjE,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,oBAAoB,MAAM,6BAA6B,CAAC;AAE/D,MAAM,CAAC,MAAM,EACX,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,YAAY,GACb,GAAG,YAAY,CAAC;AAEjB,OAAO,EAAC,qBAAqB,EAAE,oBAAoB,EAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './tapd_grpc/index.js';
2
+ export * from './tapd_methods/index.js';
3
+ export type * from './typescript/index.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,mBAAmB,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './tapd_grpc/index.js';
2
+ export * from './tapd_methods/index.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ChannelCredentials, ChannelOptions } from '@grpc/grpc-js';
2
+ type Args = {
3
+ credentials: ChannelCredentials;
4
+ includes: string[];
5
+ params: ChannelOptions;
6
+ path: string;
7
+ service: string;
8
+ socket: string;
9
+ type: string;
10
+ };
11
+ export default _default;
12
+ /** Get an api for a proto file
13
+
14
+ {
15
+ credentials: <gRPC Credentials Object>
16
+ includes: [<Proto Import Directory Path String>]
17
+ params: <gRPC Channel Options Object>
18
+ path: <Proto File Path String>
19
+ service: <Service Name String>
20
+ socket: <Host:Port Network Address String>
21
+ type: <RPC Type String>
22
+ }
23
+
24
+ @returns
25
+ <API Object>
26
+ */
27
+ declare function _default(args: Args): any;
28
+ //# sourceMappingURL=api_for_proto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api_for_proto.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/api_for_proto.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAKtE,KAAK,IAAI,GAAG;IACV,WAAW,EAAE,kBAAkB,CAAC;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;;AAEF;;;;;;;;;;;;;;EAcE;0BACc,IAAI,EAAE,IAAI"}
@@ -0,0 +1,24 @@
1
+ import grpc from '@grpc/grpc-js';
2
+ import { loadSync } from '@grpc/proto-loader';
3
+ import grpcOptions from './grpc_options.js';
4
+ /** Get an api for a proto file
5
+
6
+ {
7
+ credentials: <gRPC Credentials Object>
8
+ includes: [<Proto Import Directory Path String>]
9
+ params: <gRPC Channel Options Object>
10
+ path: <Proto File Path String>
11
+ service: <Service Name String>
12
+ socket: <Host:Port Network Address String>
13
+ type: <RPC Type String>
14
+ }
15
+
16
+ @returns
17
+ <API Object>
18
+ */
19
+ export default (args) => {
20
+ const options = { ...grpcOptions, includeDirs: args.includes };
21
+ const rpc = grpc.loadPackageDefinition(loadSync(args.path, options));
22
+ return new rpc[args.type][args.service](args.socket, args.credentials, args.params);
23
+ };
24
+ //# sourceMappingURL=api_for_proto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api_for_proto.js","sourceRoot":"","sources":["../../src/tapd_grpc/api_for_proto.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,eAAe,CAAC;AAEjC,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAE5C,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAY5C;;;;;;;;;;;;;;EAcE;AACF,eAAe,CAAC,IAAU,EAAE,EAAE;IAC5B,MAAM,OAAO,GAAG,EAAC,GAAG,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAC,CAAC;IAE7D,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAQ,CAAC;IAE5E,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CACrC,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,MAAM,CACZ,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { AuthenticatedTapd } from './types.js';
2
+ import type { TapdAuthentication } from './types.js';
3
+ export default _default;
4
+ /** Initiate a gRPC API Methods Object for authenticated methods
5
+
6
+ Both the cert and macaroon expect the entire serialized tapd generated file
7
+
8
+ {
9
+ [cert]: <Base64 or Hex Serialized tapd TLS Cert String>
10
+ [macaroon]: <Base64 or Hex Serialized Macaroon String>
11
+ [path]: <Path to Protos Directory With taprpc and lnrpc Directories String>
12
+ [socket]: <Host:Port Network Address String>
13
+ }
14
+
15
+ @throws
16
+ <Error>
17
+
18
+ @returns
19
+ {
20
+ tapd: {
21
+ assetwallet: <AssetWallet API Methods Object>
22
+ default: <TaprootAssets API Methods Object>
23
+ mailbox: <Mailbox API Methods Object>
24
+ mint: <Mint API Methods Object>
25
+ rfq: <Rfq API Methods Object>
26
+ tapchannel: <TaprootAssetChannels API Methods Object>
27
+ tapdev: <TapDev API Methods Object>
28
+ universe: <Universe API Methods Object>
29
+ }
30
+ }
31
+ */
32
+ declare function _default(args: TapdAuthentication): {
33
+ tapd: AuthenticatedTapd;
34
+ };
35
+ //# sourceMappingURL=authenticated_tapd_grpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authenticated_tapd_grpc.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/authenticated_tapd_grpc.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;;AAOnD;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BE;0BACc,IAAI,EAAE,kBAAkB,GAAG;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAC"}
@@ -0,0 +1,76 @@
1
+ import { join } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { defaultSocket } from '../grpc/index.js';
4
+ import { grpcSslCipherSuites } from '../grpc/index.js';
5
+ import { includeDirs } from '../grpc/index.js';
6
+ import { keepaliveTimeMs } from '../grpc/index.js';
7
+ import { keepaliveTimeoutMs } from '../grpc/index.js';
8
+ import { packageTypes } from '../grpc/index.js';
9
+ import { protoFiles } from '../grpc/index.js';
10
+ import { protosDir } from '../grpc/index.js';
11
+ import { serviceTypes } from '../grpc/index.js';
12
+ import apiForProto from './api_for_proto.js';
13
+ import grpcCredentials from './grpc_credentials.js';
14
+ const defaultProtosPath = fileURLToPath(new URL(protosDir, import.meta.url));
15
+ const { GRPC_SSL_CIPHER_SUITES } = process.env;
16
+ const { keys } = Object;
17
+ /** Initiate a gRPC API Methods Object for authenticated methods
18
+
19
+ Both the cert and macaroon expect the entire serialized tapd generated file
20
+
21
+ {
22
+ [cert]: <Base64 or Hex Serialized tapd TLS Cert String>
23
+ [macaroon]: <Base64 or Hex Serialized Macaroon String>
24
+ [path]: <Path to Protos Directory With taprpc and lnrpc Directories String>
25
+ [socket]: <Host:Port Network Address String>
26
+ }
27
+
28
+ @throws
29
+ <Error>
30
+
31
+ @returns
32
+ {
33
+ tapd: {
34
+ assetwallet: <AssetWallet API Methods Object>
35
+ default: <TaprootAssets API Methods Object>
36
+ mailbox: <Mailbox API Methods Object>
37
+ mint: <Mint API Methods Object>
38
+ rfq: <Rfq API Methods Object>
39
+ tapchannel: <TaprootAssetChannels API Methods Object>
40
+ tapdev: <TapDev API Methods Object>
41
+ universe: <Universe API Methods Object>
42
+ }
43
+ }
44
+ */
45
+ export default (args) => {
46
+ const { credentials } = grpcCredentials(args);
47
+ const protosPath = args.path || defaultProtosPath;
48
+ if (!!args.cert && GRPC_SSL_CIPHER_SUITES !== grpcSslCipherSuites) {
49
+ process.env.GRPC_SSL_CIPHER_SUITES = grpcSslCipherSuites;
50
+ }
51
+ const includes = includeDirs.map(dir => join(protosPath, dir));
52
+ const params = {
53
+ 'grpc.keepalive_time_ms': keepaliveTimeMs,
54
+ 'grpc.keepalive_timeout_ms': keepaliveTimeoutMs,
55
+ 'grpc.max_receive_message_length': -1,
56
+ 'grpc.max_send_message_length': -1,
57
+ };
58
+ const types = keys(serviceTypes);
59
+ // Assemble different services from their proto files
60
+ return {
61
+ tapd: types.reduce((services, type) => {
62
+ const service = serviceTypes[type];
63
+ services[type] = apiForProto({
64
+ credentials,
65
+ includes,
66
+ params,
67
+ service,
68
+ path: join(protosPath, protoFiles[service]),
69
+ socket: args.socket || defaultSocket,
70
+ type: packageTypes[service],
71
+ });
72
+ return services;
73
+ }, {}),
74
+ };
75
+ };
76
+ //# sourceMappingURL=authenticated_tapd_grpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authenticated_tapd_grpc.js","sourceRoot":"","sources":["../../src/tapd_grpc/authenticated_tapd_grpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAKpD,MAAM,iBAAiB,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7E,MAAM,EAAC,sBAAsB,EAAC,GAAG,OAAO,CAAC,GAAG,CAAC;AAC7C,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BE;AACF,eAAe,CAAC,IAAwB,EAA6B,EAAE;IACrE,MAAM,EAAC,WAAW,EAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,IAAI,iBAAiB,CAAC;IAElD,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,sBAAsB,KAAK,mBAAmB,EAAE,CAAC;QAClE,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,mBAAmB,CAAC;IAC3D,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IAE/D,MAAM,MAAM,GAAG;QACb,wBAAwB,EAAE,eAAe;QACzC,2BAA2B,EAAE,kBAAkB;QAC/C,iCAAiC,EAAE,CAAC,CAAC;QACrC,8BAA8B,EAAE,CAAC,CAAC;KACnC,CAAC;IAEF,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAsB,CAAC;IAEtD,qDAAqD;IACrD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE;YACpC,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;YAEnC,QAAQ,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;gBAC3B,WAAW;gBACX,QAAQ;gBACR,MAAM;gBACN,OAAO;gBACP,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC3C,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,aAAa;gBACpC,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC;aAC5B,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC,EAAE,EAAuB,CAAC;KAC5B,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ export default _default;
2
+ /** Get decoded Base64 or Hex encoded data
3
+
4
+ {
5
+ [serialized]: <Serialized Data String>
6
+ }
7
+
8
+ @returns
9
+ {
10
+ [decoded]: <Deserialized Data Buffer>
11
+ }
12
+ */
13
+ declare function _default({ serialized }: {
14
+ serialized?: string;
15
+ }): {
16
+ decoded?: Buffer;
17
+ };
18
+ //# sourceMappingURL=decode_serialized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode_serialized.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/decode_serialized.ts"],"names":[],"mappings":";AAGA;;;;;;;;;;EAUE;0BACc,EAAC,UAAU,EAAC,EAAE;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC"}
@@ -0,0 +1,23 @@
1
+ const { from } = Buffer;
2
+ const isHex = (n) => !(n.length % 2) && /^[0-9A-F]*$/i.test(n);
3
+ /** Get decoded Base64 or Hex encoded data
4
+
5
+ {
6
+ [serialized]: <Serialized Data String>
7
+ }
8
+
9
+ @returns
10
+ {
11
+ [decoded]: <Deserialized Data Buffer>
12
+ }
13
+ */
14
+ export default ({ serialized }) => {
15
+ if (!!serialized && !isHex(serialized)) {
16
+ return { decoded: from(serialized, 'base64') };
17
+ }
18
+ if (!!serialized && isHex(serialized)) {
19
+ return { decoded: from(serialized, 'hex') };
20
+ }
21
+ return {};
22
+ };
23
+ //# sourceMappingURL=decode_serialized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode_serialized.js","sourceRoot":"","sources":["../../src/tapd_grpc/decode_serialized.ts"],"names":[],"mappings":"AAAA,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,CAAC;AACtB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;EAUE;AACF,eAAe,CAAC,EAAC,UAAU,EAAwB,EAAsB,EAAE;IACzE,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,OAAO,EAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAC,CAAC;IAC/C,CAAC;IAED,IAAI,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,OAAO,EAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,EAAC,CAAC;IAC5C,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}