@aeternity/aepp-sdk 11.0.1 → 12.0.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.
- package/LICENSE +1 -1
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +12 -19
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +37 -0
- package/es/AeSdk.mjs +81 -0
- package/es/AeSdk.mjs.map +1 -0
- package/es/AeSdkAepp.d.ts +69 -0
- package/es/AeSdkAepp.mjs +175 -0
- package/es/AeSdkAepp.mjs.map +1 -0
- package/es/AeSdkBase.d.ts +212 -0
- package/es/AeSdkBase.mjs +310 -0
- package/es/AeSdkBase.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +103 -0
- package/es/AeSdkWallet.mjs +322 -0
- package/es/AeSdkWallet.mjs.map +1 -0
- package/es/Node.d.ts +44 -0
- package/es/Node.mjs +141 -0
- package/es/Node.mjs.map +1 -0
- package/es/account/Base.d.ts +65 -0
- package/es/account/Base.mjs +123 -0
- package/es/account/Base.mjs.map +1 -0
- package/es/account/Memory.d.ts +25 -0
- package/es/account/Memory.mjs +81 -0
- package/es/account/Memory.mjs.map +1 -0
- package/es/account/Rpc.d.ts +27 -0
- package/es/account/Rpc.mjs +79 -0
- package/es/account/Rpc.mjs.map +1 -0
- package/es/aens.d.ts +209 -0
- package/es/aens.mjs +332 -0
- package/es/aens.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
- package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
- package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
- package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
- package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +90 -46
- package/es/aepp-wallet-communication/schema.mjs +214 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/apis/compiler/compiler.d.ts +92 -0
- package/es/apis/compiler/compiler.mjs +576 -0
- package/es/apis/compiler/compiler.mjs.map +1 -0
- package/es/apis/compiler/index.d.ts +2 -0
- package/es/apis/compiler/index.mjs +3 -0
- package/es/apis/compiler/index.mjs.map +1 -0
- package/es/apis/compiler/models/index.d.ts +248 -0
- package/es/apis/compiler/models/index.mjs +48 -0
- package/es/apis/compiler/models/index.mjs.map +1 -0
- package/es/apis/compiler/models/mappers.d.ts +23 -0
- package/es/apis/compiler/models/mappers.mjs +585 -0
- package/es/apis/compiler/models/mappers.mjs.map +1 -0
- package/es/apis/compiler/models/parameters.d.ts +13 -0
- package/es/apis/compiler/models/parameters.mjs +71 -0
- package/es/apis/compiler/models/parameters.mjs.map +1 -0
- package/es/apis/node/index.d.ts +2 -0
- package/es/apis/node/index.mjs +3 -0
- package/es/apis/node/index.mjs.map +1 -0
- package/es/apis/node/models/index.d.ts +1061 -0
- package/es/apis/node/models/index.mjs +2 -0
- package/es/apis/node/models/index.mjs.map +1 -0
- package/es/apis/node/models/mappers.d.ts +95 -0
- package/es/apis/node/models/mappers.mjs +4164 -0
- package/es/apis/node/models/mappers.mjs.map +1 -0
- package/es/apis/node/models/parameters.d.ts +17 -0
- package/es/apis/node/models/parameters.mjs +165 -0
- package/es/apis/node/models/parameters.mjs.map +1 -0
- package/es/apis/node/node.d.ts +215 -0
- package/es/apis/node/node.mjs +1165 -0
- package/es/apis/node/node.mjs.map +1 -0
- package/es/chain.d.ts +220 -0
- package/es/chain.mjs +524 -0
- package/es/chain.mjs.map +1 -0
- package/es/channel/handlers.d.ts +34 -0
- package/es/channel/handlers.mjs +147 -112
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/index.d.ts +634 -0
- package/es/channel/index.mjs +898 -900
- package/es/channel/index.mjs.map +1 -1
- package/es/channel/internal.d.ts +100 -0
- package/es/channel/internal.mjs +97 -51
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Compiler.d.ts +17 -0
- package/es/contract/Compiler.mjs +67 -0
- package/es/contract/Compiler.mjs.map +1 -0
- package/es/contract/aci.d.ts +125 -0
- package/es/contract/aci.mjs +199 -180
- package/es/contract/aci.mjs.map +1 -1
- package/es/contract/ga.d.ts +68 -0
- package/es/contract/ga.mjs +190 -0
- package/es/contract/ga.mjs.map +1 -0
- package/es/contract/methods.d.ts +68 -0
- package/es/contract/methods.mjs +101 -0
- package/es/contract/methods.mjs.map +1 -0
- package/es/index.d.ts +32 -0
- package/es/index.mjs +32 -40
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +154 -0
- package/es/oracle.mjs +288 -0
- package/es/oracle.mjs.map +1 -0
- package/es/spend.d.ts +61 -0
- package/es/spend.mjs +122 -0
- package/es/spend.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +41 -0
- package/es/tx/builder/constants.mjs +11 -19
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types.d.ts +62 -0
- package/es/tx/builder/field-types.mjs +62 -10
- package/es/tx/builder/field-types.mjs.map +1 -1
- package/es/tx/builder/helpers.d.ts +131 -0
- package/es/tx/builder/helpers.mjs +71 -169
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +75 -0
- package/es/tx/builder/index.mjs +141 -323
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +350 -0
- package/es/tx/builder/schema.mjs +173 -510
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +63 -0
- package/es/tx/index.mjs +171 -265
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/min-fee.d.ts +20 -0
- package/es/tx/min-fee.mjs +148 -0
- package/es/tx/min-fee.mjs.map +1 -0
- package/es/tx/validator.d.ts +19 -0
- package/es/tx/validator.mjs +64 -71
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
- package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
- package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
- package/es/typings/bip32-path/index.d.mjs +2 -0
- package/es/typings/bip32-path/index.d.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs.map +1 -1
- package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
- package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
- package/es/utils/amount-formatter.d.ts +42 -0
- package/es/utils/amount-formatter.mjs +28 -41
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +6 -0
- package/es/utils/autorest.mjs +97 -0
- package/es/utils/autorest.mjs.map +1 -0
- package/es/utils/bignumber.d.ts +13 -0
- package/es/utils/bignumber.mjs +10 -8
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
- package/es/utils/bytes.mjs +10 -14
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +103 -0
- package/es/utils/crypto.mjs +60 -68
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder.d.ts +26 -0
- package/es/utils/encoder.mjs +47 -51
- package/es/utils/encoder.mjs.map +1 -1
- package/es/{errors.d.ts → utils/errors.d.ts} +254 -57
- package/es/utils/errors.mjs +318 -125
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +34 -0
- package/es/utils/hd-wallet.mjs +27 -16
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.d.ts +5 -0
- package/es/utils/json-big.mjs +10 -14
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.d.ts +51 -0
- package/es/utils/keystore.mjs +98 -193
- package/es/utils/keystore.mjs.map +1 -1
- package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
- package/es/utils/mptree.mjs +13 -14
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +14 -0
- package/es/utils/other.mjs +21 -36
- package/es/utils/other.mjs.map +1 -1
- package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.d.ts +24 -0
- package/es/utils/string.mjs +8 -10
- package/es/utils/string.mjs.map +1 -1
- package/package.json +49 -39
- package/src/AeSdk.ts +65 -0
- package/src/AeSdkAepp.ts +167 -0
- package/src/AeSdkBase.ts +320 -0
- package/src/AeSdkWallet.ts +332 -0
- package/src/Node.ts +167 -0
- package/src/account/Base.ts +114 -0
- package/src/account/Memory.ts +83 -0
- package/src/account/Rpc.ts +67 -0
- package/src/aens.ts +391 -0
- package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
- package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +16 -17
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
- package/src/aepp-wallet-communication/rpc/types.ts +66 -0
- package/src/aepp-wallet-communication/schema.ts +181 -0
- package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
- package/src/apis/compiler/code-model-v4.yaml +2649 -0
- package/src/apis/compiler/compiler.ts +585 -0
- package/src/apis/compiler/index.ts +2 -0
- package/src/apis/compiler/models/index.ts +301 -0
- package/src/apis/compiler/models/mappers.ts +583 -0
- package/src/apis/compiler/models/parameters.ts +93 -0
- package/src/apis/node/code-model-v4.yaml +10046 -0
- package/src/apis/node/index.ts +2 -0
- package/src/apis/node/models/index.ts +1253 -0
- package/src/apis/node/models/mappers.ts +4278 -0
- package/src/apis/node/models/parameters.ts +188 -0
- package/src/apis/node/node.ts +1299 -0
- package/src/chain.ts +444 -0
- package/src/channel/{handlers.js → handlers.ts} +220 -128
- package/src/channel/index.ts +991 -0
- package/src/channel/internal.ts +345 -0
- package/src/contract/Compiler.ts +66 -0
- package/src/contract/aci.ts +529 -0
- package/src/contract/ga.ts +178 -0
- package/src/contract/methods.ts +118 -0
- package/src/index.ts +51 -0
- package/src/oracle.ts +342 -0
- package/src/spend.ts +152 -0
- package/src/tx/builder/{constants.js → constants.ts} +12 -16
- package/src/tx/builder/field-types.ts +111 -0
- package/src/tx/builder/helpers.ts +253 -0
- package/src/tx/builder/index.ts +394 -0
- package/src/tx/builder/schema.ts +771 -0
- package/src/tx/index.ts +199 -0
- package/src/tx/min-fee.ts +136 -0
- package/src/tx/validator.ts +226 -0
- package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
- package/src/typings/@aeternity__uuid/index.d.ts +3 -0
- package/src/typings/bip32-path/index.d.ts +33 -0
- package/src/typings/tweetnacl-auth/index.d.ts +14 -0
- package/src/utils/amount-formatter.ts +29 -42
- package/src/utils/autorest.ts +90 -0
- package/src/utils/bignumber.ts +9 -11
- package/src/utils/bytes.ts +12 -14
- package/src/utils/crypto.ts +217 -0
- package/src/utils/encoder.ts +52 -55
- package/src/utils/errors.ts +268 -134
- package/src/utils/hd-wallet.ts +134 -0
- package/src/utils/json-big.ts +26 -0
- package/src/utils/keystore.ts +179 -0
- package/src/utils/mptree.ts +14 -14
- package/src/utils/other.ts +28 -43
- package/src/utils/string.ts +8 -10
- package/es/account/base.mjs +0 -179
- package/es/account/base.mjs.map +0 -1
- package/es/account/memory.mjs +0 -99
- package/es/account/memory.mjs.map +0 -1
- package/es/account/multiple.mjs +0 -179
- package/es/account/multiple.mjs.map +0 -1
- package/es/ae/aens.mjs +0 -404
- package/es/ae/aens.mjs.map +0 -1
- package/es/ae/aepp.mjs +0 -45
- package/es/ae/aepp.mjs.map +0 -1
- package/es/ae/contract.mjs +0 -159
- package/es/ae/contract.mjs.map +0 -1
- package/es/ae/index.mjs +0 -207
- package/es/ae/index.mjs.map +0 -1
- package/es/ae/oracle.mjs +0 -339
- package/es/ae/oracle.mjs.map +0 -1
- package/es/ae/universal.mjs +0 -45
- package/es/ae/universal.mjs.map +0 -1
- package/es/ae/wallet.mjs +0 -50
- package/es/ae/wallet.mjs.map +0 -1
- package/es/amount-formatter.d.ts +0 -58
- package/es/bignumber.d.ts +0 -18
- package/es/chain/index.mjs +0 -272
- package/es/chain/index.mjs.map +0 -1
- package/es/chain/node.mjs +0 -442
- package/es/chain/node.mjs.map +0 -1
- package/es/contract/compiler.mjs +0 -115
- package/es/contract/compiler.mjs.map +0 -1
- package/es/contract/ga/helpers.mjs +0 -30
- package/es/contract/ga/helpers.mjs.map +0 -1
- package/es/contract/ga/index.mjs +0 -178
- package/es/contract/ga/index.mjs.map +0 -1
- package/es/crypto-ts.d.ts +0 -9
- package/es/encoder.d.ts +0 -26
- package/es/node-pool/index.mjs +0 -188
- package/es/node-pool/index.mjs.map +0 -1
- package/es/node.mjs +0 -133
- package/es/node.mjs.map +0 -1
- package/es/other.d.ts +0 -31
- package/es/string.d.ts +0 -26
- package/es/tx/tx-object.mjs +0 -283
- package/es/tx/tx-object.mjs.map +0 -1
- package/es/tx/tx.mjs +0 -938
- package/es/tx/tx.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
- package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
- package/es/utils/async-init.mjs +0 -64
- package/es/utils/async-init.mjs.map +0 -1
- package/es/utils/crypto-ts.mjs.map +0 -1
- package/es/utils/swagger.mjs +0 -164
- package/es/utils/swagger.mjs.map +0 -1
- package/src/account/base.js +0 -153
- package/src/account/memory.js +0 -83
- package/src/account/multiple.js +0 -162
- package/src/ae/aens.js +0 -361
- package/src/ae/aepp.js +0 -45
- package/src/ae/contract.js +0 -148
- package/src/ae/index.js +0 -168
- package/src/ae/oracle.js +0 -311
- package/src/ae/universal.js +0 -47
- package/src/ae/wallet.js +0 -50
- package/src/chain/index.js +0 -269
- package/src/chain/node.js +0 -320
- package/src/channel/index.js +0 -903
- package/src/channel/internal.js +0 -236
- package/src/contract/aci.js +0 -376
- package/src/contract/compiler.js +0 -100
- package/src/contract/ga/helpers.js +0 -19
- package/src/contract/ga/index.js +0 -150
- package/src/index.js +0 -89
- package/src/node-pool/index.js +0 -172
- package/src/node.js +0 -116
- package/src/tx/builder/field-types.js +0 -61
- package/src/tx/builder/helpers.js +0 -334
- package/src/tx/builder/index.js +0 -465
- package/src/tx/builder/schema.js +0 -1100
- package/src/tx/index.js +0 -301
- package/src/tx/tx-object.js +0 -187
- package/src/tx/tx.js +0 -631
- package/src/tx/validator.js +0 -181
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
- package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
- package/src/utils/aepp-wallet-communication/helpers.js +0 -60
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
- package/src/utils/aepp-wallet-communication/schema.ts +0 -80
- package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
- package/src/utils/async-init.js +0 -45
- package/src/utils/crypto.js +0 -219
- package/src/utils/hd-wallet.js +0 -100
- package/src/utils/json-big.js +0 -26
- package/src/utils/keystore.js +0 -219
- package/src/utils/swagger.js +0 -156
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
|
|
2
|
+
import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
|
|
3
|
+
|
|
4
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
5
|
+
|
|
6
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* ISC License (ISC)
|
|
10
|
+
* Copyright (c) 2022 aeternity developers
|
|
11
|
+
*
|
|
12
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
13
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
14
|
+
* copyright notice and this permission notice appear in all copies.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
* PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import BrowserConnection from "./Browser.mjs";
|
|
25
|
+
import { MESSAGE_DIRECTION } from "../schema.mjs";
|
|
26
|
+
import { InternalError, RpcConnectionError } from "../../utils/errors.mjs";
|
|
27
|
+
|
|
28
|
+
var _onDisconnect = /*#__PURE__*/new WeakMap();
|
|
29
|
+
|
|
30
|
+
var _target = /*#__PURE__*/new WeakMap();
|
|
31
|
+
|
|
32
|
+
var _self = /*#__PURE__*/new WeakMap();
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Browser window Post Message connector module
|
|
36
|
+
*/
|
|
37
|
+
export default class BrowserWindowMessageConnection extends BrowserConnection {
|
|
38
|
+
/**
|
|
39
|
+
* @param options - Options
|
|
40
|
+
* @param options.target Target window for message
|
|
41
|
+
* @param options.self Host window for message
|
|
42
|
+
* @param options.origin Origin of receiver
|
|
43
|
+
* @param options.sendDirection Wrapping messages into additional struct
|
|
44
|
+
* `({ type: 'to_aepp' || 'to_waellet', data })`
|
|
45
|
+
* Used for handling messages between content script and page
|
|
46
|
+
* @param options.receiveDirection Unwrapping messages from additional struct
|
|
47
|
+
*/
|
|
48
|
+
constructor() {
|
|
49
|
+
let {
|
|
50
|
+
target,
|
|
51
|
+
self = window,
|
|
52
|
+
origin,
|
|
53
|
+
sendDirection,
|
|
54
|
+
receiveDirection = MESSAGE_DIRECTION.to_aepp,
|
|
55
|
+
...options
|
|
56
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
57
|
+
super(options);
|
|
58
|
+
|
|
59
|
+
_classPrivateFieldInitSpec(this, _onDisconnect, {
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
_classPrivateFieldInitSpec(this, _target, {
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
_classPrivateFieldInitSpec(this, _self, {
|
|
70
|
+
writable: true,
|
|
71
|
+
value: void 0
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
_classPrivateFieldSet(this, _target, target);
|
|
75
|
+
|
|
76
|
+
_classPrivateFieldSet(this, _self, self);
|
|
77
|
+
|
|
78
|
+
this.origin = origin;
|
|
79
|
+
this.sendDirection = sendDirection;
|
|
80
|
+
this.receiveDirection = receiveDirection;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
isConnected() {
|
|
84
|
+
return this.listener != null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
connect(onMessage, onDisconnect) {
|
|
88
|
+
super.connect(onMessage, onDisconnect);
|
|
89
|
+
|
|
90
|
+
this.listener = message => {
|
|
91
|
+
if (typeof message.data !== 'object') return;
|
|
92
|
+
if (this.origin != null && this.origin !== message.origin) return;
|
|
93
|
+
if (_classPrivateFieldGet(this, _target) != null && _classPrivateFieldGet(this, _target) !== message.source) return;
|
|
94
|
+
this.receiveMessage(message);
|
|
95
|
+
let {
|
|
96
|
+
data
|
|
97
|
+
} = message;
|
|
98
|
+
|
|
99
|
+
if (data.type != null) {
|
|
100
|
+
if (message.data.type !== this.receiveDirection) return;
|
|
101
|
+
data = data.data;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
onMessage(data, message.origin, message.source);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
_classPrivateFieldGet(this, _self).addEventListener('message', this.listener);
|
|
108
|
+
|
|
109
|
+
_classPrivateFieldSet(this, _onDisconnect, onDisconnect);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
disconnect() {
|
|
113
|
+
super.disconnect();
|
|
114
|
+
|
|
115
|
+
if (this.listener == null || _classPrivateFieldGet(this, _onDisconnect) == null) {
|
|
116
|
+
throw new InternalError('Expected to not happen, required for TS');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_classPrivateFieldGet(this, _self).removeEventListener('message', this.listener);
|
|
120
|
+
|
|
121
|
+
delete this.listener;
|
|
122
|
+
|
|
123
|
+
_classPrivateFieldGet(this, _onDisconnect).call(this);
|
|
124
|
+
|
|
125
|
+
_classPrivateFieldSet(this, _onDisconnect, undefined);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
sendMessage(msg) {
|
|
129
|
+
var _this$origin;
|
|
130
|
+
|
|
131
|
+
if (_classPrivateFieldGet(this, _target) == null) throw new RpcConnectionError('Can\'t send messages without target');
|
|
132
|
+
const message = this.sendDirection != null ? {
|
|
133
|
+
type: this.sendDirection,
|
|
134
|
+
data: msg
|
|
135
|
+
} : msg;
|
|
136
|
+
super.sendMessage(message);
|
|
137
|
+
|
|
138
|
+
_classPrivateFieldGet(this, _target).postMessage(message, (_this$origin = this.origin) !== null && _this$origin !== void 0 ? _this$origin : '*');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=BrowserWindowMessage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserWindowMessage.mjs","names":["BrowserConnection","MESSAGE_DIRECTION","InternalError","RpcConnectionError","BrowserWindowMessageConnection","constructor","target","self","window","origin","sendDirection","receiveDirection","to_aepp","options","isConnected","listener","connect","onMessage","onDisconnect","message","data","source","receiveMessage","type","addEventListener","disconnect","removeEventListener","undefined","sendMessage","msg","postMessage"],"sources":["../../../src/aepp-wallet-communication/connection/BrowserWindowMessage.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport BrowserConnection from './Browser'\nimport { MESSAGE_DIRECTION } from '../schema'\nimport { InternalError, RpcConnectionError } from '../../utils/errors'\n\nexport type ImplPostMessage = Pick<Window, 'addEventListener' | 'removeEventListener' | 'postMessage'>\n\n/**\n * Browser window Post Message connector module\n */\nexport default class BrowserWindowMessageConnection extends BrowserConnection {\n origin?: string\n sendDirection?: MESSAGE_DIRECTION\n receiveDirection: MESSAGE_DIRECTION\n listener?: (this: Window, ev: MessageEvent<any>) => void\n #onDisconnect?: () => void\n #target?: ImplPostMessage\n #self: ImplPostMessage\n\n /**\n * @param options - Options\n * @param options.target Target window for message\n * @param options.self Host window for message\n * @param options.origin Origin of receiver\n * @param options.sendDirection Wrapping messages into additional struct\n * `({ type: 'to_aepp' || 'to_waellet', data })`\n * Used for handling messages between content script and page\n * @param options.receiveDirection Unwrapping messages from additional struct\n */\n constructor ({\n target,\n self = window,\n origin,\n sendDirection,\n receiveDirection = MESSAGE_DIRECTION.to_aepp,\n ...options\n }: {\n target?: ImplPostMessage\n self?: ImplPostMessage\n origin?: string\n sendDirection?: MESSAGE_DIRECTION\n receiveDirection?: MESSAGE_DIRECTION\n debug?: boolean\n } = {}) {\n super(options)\n this.#target = target\n this.#self = self\n this.origin = origin\n this.sendDirection = sendDirection\n this.receiveDirection = receiveDirection\n }\n\n isConnected (): boolean {\n return this.listener != null\n }\n\n connect (\n onMessage: (message: any, origin: string, source: MessageEventSource | null) => void,\n onDisconnect: () => void\n ): void {\n super.connect(onMessage, onDisconnect)\n this.listener = (message: MessageEvent<any>) => {\n if (typeof message.data !== 'object') return\n if (this.origin != null && this.origin !== message.origin) return\n if (this.#target != null && this.#target !== message.source) return\n this.receiveMessage(message)\n let { data } = message\n if (data.type != null) {\n if (message.data.type !== this.receiveDirection) return\n data = data.data\n }\n onMessage(data, message.origin, message.source)\n }\n this.#self.addEventListener('message', this.listener)\n this.#onDisconnect = onDisconnect\n }\n\n disconnect (): void {\n super.disconnect()\n if (this.listener == null || this.#onDisconnect == null) {\n throw new InternalError('Expected to not happen, required for TS')\n }\n this.#self.removeEventListener('message', this.listener)\n delete this.listener\n this.#onDisconnect()\n this.#onDisconnect = undefined\n }\n\n sendMessage (msg: any): void {\n if (this.#target == null) throw new RpcConnectionError('Can\\'t send messages without target')\n const message = this.sendDirection != null ? { type: this.sendDirection, data: msg } : msg\n super.sendMessage(message)\n this.#target.postMessage(message, this.origin ?? '*')\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;OAEOA,iB;SACEC,iB;SACAC,a,EAAeC,kB;;;;;;;;AAIxB;AACA;AACA;AACA,eAAe,MAAMC,8BAAN,SAA6CJ,iBAA7C,CAA+D;EAS5E;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,WAAW,GAcH;IAAA,IAdK;MACXC,MADW;MAEXC,IAAI,GAAGC,MAFI;MAGXC,MAHW;MAIXC,aAJW;MAKXC,gBAAgB,GAAGV,iBAAiB,CAACW,OAL1B;MAMX,GAAGC;IANQ,CAcL,uEAAJ,EAAI;IACN,MAAMA,OAAN;;IADM;MAAA;MAAA;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAEN,qCAAeP,MAAf;;IACA,mCAAaC,IAAb;;IACA,KAAKE,MAAL,GAAcA,MAAd;IACA,KAAKC,aAAL,GAAqBA,aAArB;IACA,KAAKC,gBAAL,GAAwBA,gBAAxB;EACD;;EAEDG,WAAW,GAAa;IACtB,OAAO,KAAKC,QAAL,IAAiB,IAAxB;EACD;;EAEDC,OAAO,CACLC,SADK,EAELC,YAFK,EAGC;IACN,MAAMF,OAAN,CAAcC,SAAd,EAAyBC,YAAzB;;IACA,KAAKH,QAAL,GAAiBI,OAAD,IAAgC;MAC9C,IAAI,OAAOA,OAAO,CAACC,IAAf,KAAwB,QAA5B,EAAsC;MACtC,IAAI,KAAKX,MAAL,IAAe,IAAf,IAAuB,KAAKA,MAAL,KAAgBU,OAAO,CAACV,MAAnD,EAA2D;MAC3D,IAAI,wCAAgB,IAAhB,IAAwB,yCAAiBU,OAAO,CAACE,MAArD,EAA6D;MAC7D,KAAKC,cAAL,CAAoBH,OAApB;MACA,IAAI;QAAEC;MAAF,IAAWD,OAAf;;MACA,IAAIC,IAAI,CAACG,IAAL,IAAa,IAAjB,EAAuB;QACrB,IAAIJ,OAAO,CAACC,IAAR,CAAaG,IAAb,KAAsB,KAAKZ,gBAA/B,EAAiD;QACjDS,IAAI,GAAGA,IAAI,CAACA,IAAZ;MACD;;MACDH,SAAS,CAACG,IAAD,EAAOD,OAAO,CAACV,MAAf,EAAuBU,OAAO,CAACE,MAA/B,CAAT;IACD,CAXD;;IAYA,mCAAWG,gBAAX,CAA4B,SAA5B,EAAuC,KAAKT,QAA5C;;IACA,2CAAqBG,YAArB;EACD;;EAEDO,UAAU,GAAU;IAClB,MAAMA,UAAN;;IACA,IAAI,KAAKV,QAAL,IAAiB,IAAjB,IAAyB,8CAAsB,IAAnD,EAAyD;MACvD,MAAM,IAAIb,aAAJ,CAAkB,yCAAlB,CAAN;IACD;;IACD,mCAAWwB,mBAAX,CAA+B,SAA/B,EAA0C,KAAKX,QAA/C;;IACA,OAAO,KAAKA,QAAZ;;IACA;;IACA,2CAAqBY,SAArB;EACD;;EAEDC,WAAW,CAAEC,GAAF,EAAkB;IAAA;;IAC3B,IAAI,wCAAgB,IAApB,EAA0B,MAAM,IAAI1B,kBAAJ,CAAuB,qCAAvB,CAAN;IAC1B,MAAMgB,OAAO,GAAG,KAAKT,aAAL,IAAsB,IAAtB,GAA6B;MAAEa,IAAI,EAAE,KAAKb,aAAb;MAA4BU,IAAI,EAAES;IAAlC,CAA7B,GAAuEA,GAAvF;IACA,MAAMD,WAAN,CAAkBT,OAAlB;;IACA,qCAAaW,WAAb,CAAyBX,OAAzB,kBAAkC,KAAKV,MAAvC,uDAAiD,GAAjD;EACD;;AAnF2E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import BrowserConnection from './connection/Browser';
|
|
2
|
+
/**
|
|
3
|
+
* Browser connection proxy
|
|
4
|
+
* Provide functionality to easily forward messages from one connection to another and back
|
|
5
|
+
* @param con1 - first connection
|
|
6
|
+
* @param con2 - second connection
|
|
7
|
+
* @returns a function to stop proxying
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: (con1: BrowserConnection, con2: BrowserConnection) => () => void;
|
|
10
|
+
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* ISC License (ISC)
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright (c) 2022 aeternity developers
|
|
4
4
|
*
|
|
5
5
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
6
|
* purpose with or without fee is hereby granted, provided that the above
|
|
@@ -15,15 +15,19 @@
|
|
|
15
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { blake2b } from '@aeternity/blakejs'
|
|
19
|
-
import type { Data } from 'blakejs'
|
|
20
|
-
|
|
21
18
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param
|
|
25
|
-
* @
|
|
19
|
+
* Browser connection proxy
|
|
20
|
+
* Provide functionality to easily forward messages from one connection to another and back
|
|
21
|
+
* @param con1 - first connection
|
|
22
|
+
* @param con2 - second connection
|
|
23
|
+
* @returns a function to stop proxying
|
|
26
24
|
*/
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
export default ((con1, con2) => {
|
|
26
|
+
con1.connect(msg => con2.sendMessage(msg), () => con2.disconnect());
|
|
27
|
+
con2.connect(msg => con1.sendMessage(msg), () => con1.disconnect());
|
|
28
|
+
return () => {
|
|
29
|
+
con1.disconnect();
|
|
30
|
+
con2.disconnect();
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=connection-proxy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-proxy.mjs","names":["con1","con2","connect","msg","sendMessage","disconnect"],"sources":["../../src/aepp-wallet-communication/connection-proxy.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport BrowserConnection from './connection/Browser'\n\n/**\n * Browser connection proxy\n * Provide functionality to easily forward messages from one connection to another and back\n * @param con1 - first connection\n * @param con2 - second connection\n * @returns a function to stop proxying\n */\nexport default (con1: BrowserConnection, con2: BrowserConnection): () => void => {\n con1.connect((msg: any) => con2.sendMessage(msg), () => con2.disconnect())\n con2.connect((msg: any) => con1.sendMessage(msg), () => con1.disconnect())\n\n return () => {\n con1.disconnect()\n con2.disconnect()\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,CAACA,IAAD,EAA0BC,IAA1B,KAAkE;EAC/ED,IAAI,CAACE,OAAL,CAAcC,GAAD,IAAcF,IAAI,CAACG,WAAL,CAAiBD,GAAjB,CAA3B,EAAkD,MAAMF,IAAI,CAACI,UAAL,EAAxD;EACAJ,IAAI,CAACC,OAAL,CAAcC,GAAD,IAAcH,IAAI,CAACI,WAAL,CAAiBD,GAAjB,CAA3B,EAAkD,MAAMH,IAAI,CAACK,UAAL,EAAxD;EAEA,OAAO,MAAM;IACXL,IAAI,CAACK,UAAL;IACAJ,IAAI,CAACI,UAAL;EACD,CAHD;AAID,CARD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BrowserConnection from '../connection/Browser';
|
|
2
|
+
declare type RpcApiHandler = (p?: any) => any | undefined;
|
|
3
|
+
declare type RpcApi<Api> = {
|
|
4
|
+
[k in keyof Api]: RpcApiHandler;
|
|
5
|
+
};
|
|
6
|
+
declare type WithOrigin<Api extends RpcApi<Api>> = {
|
|
7
|
+
[k in keyof Api]: (p: Parameters<Api[k]>[0], origin: string) => ReturnType<Api[k]>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Contain functionality for using RPC conection
|
|
11
|
+
* @param connection - Connection object
|
|
12
|
+
* @param onDisconnect - Disconnect callback
|
|
13
|
+
* @param methods - Object containing handlers for each request by name
|
|
14
|
+
*/
|
|
15
|
+
export default class RpcClient<RemoteApi extends RpcApi<RemoteApi>, LocalApi extends RpcApi<LocalApi>> {
|
|
16
|
+
#private;
|
|
17
|
+
connection: BrowserConnection;
|
|
18
|
+
constructor(connection: BrowserConnection, onDisconnect: () => void, methods: WithOrigin<LocalApi>);
|
|
19
|
+
/**
|
|
20
|
+
* Make a request
|
|
21
|
+
* @param name - Method name
|
|
22
|
+
* @param params - Method params
|
|
23
|
+
* @returns Promise which will be resolved after receiving response message
|
|
24
|
+
*/
|
|
25
|
+
request<Name extends keyof RemoteApi>(name: Name, params: Parameters<RemoteApi[Name]>[0]): Promise<ReturnType<RemoteApi[Name]>>;
|
|
26
|
+
/**
|
|
27
|
+
* Make a notification
|
|
28
|
+
* @param name - Method name
|
|
29
|
+
* @param params - Method params
|
|
30
|
+
*/
|
|
31
|
+
notify<Name extends keyof RemoteApi>(name: Name, params: Parameters<RemoteApi[Name]>[0]): void;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
|
|
2
|
+
import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
|
|
3
|
+
|
|
4
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
11
|
+
|
|
12
|
+
import { RpcError, RpcInternalError, RpcMethodNotFoundError } from "../schema.mjs";
|
|
13
|
+
import { InvalidRpcMessageError, MissingCallbackError } from "../../utils/errors.mjs";
|
|
14
|
+
|
|
15
|
+
var _callbacks = /*#__PURE__*/new WeakMap();
|
|
16
|
+
|
|
17
|
+
var _messageId = /*#__PURE__*/new WeakMap();
|
|
18
|
+
|
|
19
|
+
var _methods = /*#__PURE__*/new WeakMap();
|
|
20
|
+
|
|
21
|
+
var _handleMessage = /*#__PURE__*/new WeakSet();
|
|
22
|
+
|
|
23
|
+
var _sendRequest = /*#__PURE__*/new WeakSet();
|
|
24
|
+
|
|
25
|
+
var _sendResponse = /*#__PURE__*/new WeakSet();
|
|
26
|
+
|
|
27
|
+
var _processResponse = /*#__PURE__*/new WeakSet();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Contain functionality for using RPC conection
|
|
31
|
+
* @param connection - Connection object
|
|
32
|
+
* @param onDisconnect - Disconnect callback
|
|
33
|
+
* @param methods - Object containing handlers for each request by name
|
|
34
|
+
*/
|
|
35
|
+
export default class RpcClient {
|
|
36
|
+
constructor(connection, onDisconnect, methods) {
|
|
37
|
+
_classPrivateMethodInitSpec(this, _processResponse);
|
|
38
|
+
|
|
39
|
+
_classPrivateMethodInitSpec(this, _sendResponse);
|
|
40
|
+
|
|
41
|
+
_classPrivateMethodInitSpec(this, _sendRequest);
|
|
42
|
+
|
|
43
|
+
_classPrivateMethodInitSpec(this, _handleMessage);
|
|
44
|
+
|
|
45
|
+
_classPrivateFieldInitSpec(this, _callbacks, {
|
|
46
|
+
writable: true,
|
|
47
|
+
value: new Map()
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
_classPrivateFieldInitSpec(this, _messageId, {
|
|
51
|
+
writable: true,
|
|
52
|
+
value: 0
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
_classPrivateFieldInitSpec(this, _methods, {
|
|
56
|
+
writable: true,
|
|
57
|
+
value: void 0
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
this.connection = connection;
|
|
61
|
+
|
|
62
|
+
_classPrivateFieldSet(this, _methods, methods);
|
|
63
|
+
|
|
64
|
+
connection.connect(_classPrivateMethodGet(this, _handleMessage, _handleMessage2).bind(this), onDisconnect);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Make a request
|
|
69
|
+
* @param name - Method name
|
|
70
|
+
* @param params - Method params
|
|
71
|
+
* @returns Promise which will be resolved after receiving response message
|
|
72
|
+
*/
|
|
73
|
+
async request(name, params) {
|
|
74
|
+
var _this$messageId;
|
|
75
|
+
|
|
76
|
+
_classPrivateMethodGet(this, _sendRequest, _sendRequest2).call(this, _classPrivateFieldSet(this, _messageId, (_this$messageId = _classPrivateFieldGet(this, _messageId), ++_this$messageId)), name, params);
|
|
77
|
+
|
|
78
|
+
return await new Promise((resolve, reject) => {
|
|
79
|
+
_classPrivateFieldGet(this, _callbacks).set(_classPrivateFieldGet(this, _messageId), {
|
|
80
|
+
resolve,
|
|
81
|
+
reject
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Make a notification
|
|
87
|
+
* @param name - Method name
|
|
88
|
+
* @param params - Method params
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
notify(name, params) {
|
|
93
|
+
_classPrivateMethodGet(this, _sendRequest, _sendRequest2).call(this, undefined, name, params);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Process response message
|
|
97
|
+
* @param msg - Message object
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function _handleMessage2(msg, origin) {
|
|
104
|
+
if ((msg === null || msg === void 0 ? void 0 : msg.jsonrpc) !== '2.0') throw new InvalidRpcMessageError(JSON.stringify(msg));
|
|
105
|
+
|
|
106
|
+
if ('result' in msg || 'error' in msg) {
|
|
107
|
+
_classPrivateMethodGet(this, _processResponse, _processResponse2).call(this, msg);
|
|
108
|
+
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const request = msg;
|
|
113
|
+
let result, error;
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
if (!(request.method in _classPrivateFieldGet(this, _methods))) throw new RpcMethodNotFoundError();
|
|
117
|
+
const methodName = request.method;
|
|
118
|
+
result = await _classPrivateFieldGet(this, _methods)[methodName](request.params, origin);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
error = e instanceof RpcError ? e : new RpcInternalError();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (request.id != null) {
|
|
124
|
+
_classPrivateMethodGet(this, _sendResponse, _sendResponse2).call(this, request.id, request.method, result, error);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function _sendRequest2(id, method, params) {
|
|
129
|
+
this.connection.sendMessage({
|
|
130
|
+
jsonrpc: '2.0',
|
|
131
|
+
...(id != null ? {
|
|
132
|
+
id
|
|
133
|
+
} : {}),
|
|
134
|
+
method,
|
|
135
|
+
...(params != null ? {
|
|
136
|
+
params
|
|
137
|
+
} : {})
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function _sendResponse2(id, method, // TODO: remove as far it is not required in JSON RPC
|
|
142
|
+
result, error) {
|
|
143
|
+
this.connection.sendMessage({
|
|
144
|
+
jsonrpc: '2.0',
|
|
145
|
+
id,
|
|
146
|
+
method,
|
|
147
|
+
...(error != null ? {
|
|
148
|
+
error
|
|
149
|
+
} : {
|
|
150
|
+
result
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function _processResponse2(_ref) {
|
|
156
|
+
let {
|
|
157
|
+
id,
|
|
158
|
+
error,
|
|
159
|
+
result
|
|
160
|
+
} = _ref;
|
|
161
|
+
|
|
162
|
+
const callbacks = _classPrivateFieldGet(this, _callbacks).get(id);
|
|
163
|
+
|
|
164
|
+
if (callbacks == null) throw new MissingCallbackError(id);
|
|
165
|
+
if (error != null) callbacks.reject(RpcError.deserialize(error));else callbacks.resolve(result);
|
|
166
|
+
|
|
167
|
+
_classPrivateFieldGet(this, _callbacks).delete(id);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=RpcClient.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RpcClient.mjs","names":["RpcError","RpcInternalError","RpcMethodNotFoundError","InvalidRpcMessageError","MissingCallbackError","RpcClient","constructor","connection","onDisconnect","methods","Map","connect","bind","request","name","params","Promise","resolve","reject","set","notify","undefined","msg","origin","jsonrpc","JSON","stringify","result","error","method","methodName","e","id","sendMessage","callbacks","get","deserialize","delete"],"sources":["../../../src/aepp-wallet-communication/rpc/RpcClient.ts"],"sourcesContent":["import { RpcError, RpcInternalError, RpcMethodNotFoundError } from '../schema'\nimport BrowserConnection from '../connection/Browser'\nimport { InvalidRpcMessageError, MissingCallbackError } from '../../utils/errors'\n\ninterface JsonRpcRequest {\n jsonrpc: '2.0'\n id: number\n method: string\n params?: any\n}\n\ninterface JsonRpcResponse {\n jsonrpc: '2.0'\n id: number\n method: string\n result?: any\n error?: {\n code: number\n message: string\n data?: any\n }\n}\n\ntype RpcApiHandler = (p?: any) => any | undefined\ntype RpcApi<Api> = { [k in keyof Api]: RpcApiHandler }\ntype WithOrigin<Api extends RpcApi<Api>> = {\n [k in keyof Api]: (p: Parameters<Api[k]>[0], origin: string) => ReturnType<Api[k]>\n}\n\n/**\n * Contain functionality for using RPC conection\n * @param connection - Connection object\n * @param onDisconnect - Disconnect callback\n * @param methods - Object containing handlers for each request by name\n */\nexport default class RpcClient <\n RemoteApi extends RpcApi<RemoteApi>, LocalApi extends RpcApi<LocalApi>\n> {\n connection: BrowserConnection\n #callbacks = new Map<number, { resolve: (v: any) => void, reject: (e: Error) => void }>()\n #messageId = 0\n #methods: WithOrigin<LocalApi>\n\n constructor (\n connection: BrowserConnection,\n onDisconnect: () => void,\n methods: WithOrigin<LocalApi>\n ) {\n this.connection = connection\n this.#methods = methods\n connection.connect(this.#handleMessage.bind(this), onDisconnect)\n }\n\n async #handleMessage (msg: JsonRpcRequest | JsonRpcResponse, origin: string): Promise<void> {\n if (msg?.jsonrpc !== '2.0') throw new InvalidRpcMessageError(JSON.stringify(msg))\n if ('result' in msg || 'error' in msg) {\n this.#processResponse(msg)\n return\n }\n\n const request = msg as JsonRpcRequest\n let result, error\n try {\n if (!(request.method in this.#methods)) throw new RpcMethodNotFoundError()\n const methodName = request.method as keyof LocalApi\n result = await this.#methods[methodName](request.params, origin)\n } catch (e) {\n error = e instanceof RpcError ? e : new RpcInternalError()\n }\n if (request.id != null) {\n this.#sendResponse(request.id, request.method as keyof LocalApi, result, error)\n }\n }\n\n #sendRequest (\n id: number | undefined,\n method: keyof RemoteApi | keyof LocalApi,\n params?: any\n ): void {\n this.connection.sendMessage({\n jsonrpc: '2.0',\n ...id != null ? { id } : {},\n method,\n ...params != null ? { params } : {}\n })\n }\n\n #sendResponse (\n id: number,\n method: keyof RemoteApi | keyof LocalApi, // TODO: remove as far it is not required in JSON RPC\n result?: any,\n error?: any\n ): void {\n this.connection.sendMessage({\n jsonrpc: '2.0',\n id,\n method,\n ...error != null ? { error } : { result }\n })\n }\n\n /**\n * Make a request\n * @param name - Method name\n * @param params - Method params\n * @returns Promise which will be resolved after receiving response message\n */\n async request<Name extends keyof RemoteApi> (\n name: Name, params: Parameters<RemoteApi[Name]>[0]\n ): Promise<ReturnType<RemoteApi[Name]>> {\n this.#sendRequest(++this.#messageId, name, params)\n return await new Promise((resolve, reject) => {\n this.#callbacks.set(this.#messageId, { resolve, reject })\n })\n }\n\n /**\n * Make a notification\n * @param name - Method name\n * @param params - Method params\n */\n notify<Name extends keyof RemoteApi> (name: Name, params: Parameters<RemoteApi[Name]>[0]): void {\n this.#sendRequest(undefined, name, params)\n }\n\n /**\n * Process response message\n * @param msg - Message object\n */\n #processResponse ({ id, error, result }: { id: number, error?: any, result?: any }): void {\n const callbacks = this.#callbacks.get(id)\n if (callbacks == null) throw new MissingCallbackError(id)\n if (error != null) callbacks.reject(RpcError.deserialize(error))\n else callbacks.resolve(result)\n this.#callbacks.delete(id)\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { send } from '../../spend';
|
|
2
|
+
import { EncodedData } from '../../utils/encoder';
|
|
3
|
+
import { METHODS, SUBSCRIPTION_TYPES, WALLET_TYPE } from '../schema';
|
|
4
|
+
export interface WalletInfo {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
networkId: string;
|
|
8
|
+
origin: string;
|
|
9
|
+
type: WALLET_TYPE;
|
|
10
|
+
}
|
|
11
|
+
export interface Accounts {
|
|
12
|
+
connected: {
|
|
13
|
+
[pub: EncodedData<'ak'>]: {};
|
|
14
|
+
};
|
|
15
|
+
current: {
|
|
16
|
+
[pub: EncodedData<'ak'>]: {};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface Node {
|
|
20
|
+
name: string;
|
|
21
|
+
url: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Network {
|
|
24
|
+
networkId: string;
|
|
25
|
+
node?: Node;
|
|
26
|
+
}
|
|
27
|
+
declare type Icons = Array<{
|
|
28
|
+
src: string;
|
|
29
|
+
sizes?: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
purpose?: string;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const RPC_VERSION = 1;
|
|
34
|
+
export interface WalletApi {
|
|
35
|
+
[METHODS.connect]: (p: {
|
|
36
|
+
name: string;
|
|
37
|
+
icons?: Icons;
|
|
38
|
+
version: typeof RPC_VERSION;
|
|
39
|
+
connectNode: boolean;
|
|
40
|
+
}) => Promise<WalletInfo & {
|
|
41
|
+
node?: Node;
|
|
42
|
+
}>;
|
|
43
|
+
[METHODS.closeConnection]: (p: any) => void;
|
|
44
|
+
[METHODS.subscribeAddress]: (p: {
|
|
45
|
+
type: SUBSCRIPTION_TYPES;
|
|
46
|
+
value: 'connected' | 'current';
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
subscription: Array<'connected' | 'current'>;
|
|
49
|
+
address: Accounts;
|
|
50
|
+
}>;
|
|
51
|
+
[METHODS.address]: () => Promise<Array<EncodedData<'ak'>>>;
|
|
52
|
+
[METHODS.sign]: ((p: {
|
|
53
|
+
tx: EncodedData<'tx'>;
|
|
54
|
+
onAccount: EncodedData<'ak'>;
|
|
55
|
+
returnSigned: boolean;
|
|
56
|
+
}) => Promise<{
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated this is not a hash at all, will be removed later at the same time
|
|
59
|
+
* as dropping ability to broadcast transaction by wallet
|
|
60
|
+
*/
|
|
61
|
+
transactionHash?: Awaited<ReturnType<typeof send>>;
|
|
62
|
+
signedTransaction?: EncodedData<'tx'>;
|
|
63
|
+
}>);
|
|
64
|
+
[METHODS.signMessage]: (p: {
|
|
65
|
+
message: string;
|
|
66
|
+
onAccount: EncodedData<'ak'>;
|
|
67
|
+
}) => Promise<{
|
|
68
|
+
signature: string;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
export interface AeppApi {
|
|
72
|
+
[METHODS.updateAddress]: (a: Accounts) => void;
|
|
73
|
+
[METHODS.updateNetwork]: (a: Network) => void;
|
|
74
|
+
[METHODS.readyToConnect]: (w: WalletInfo) => void;
|
|
75
|
+
[METHODS.closeConnection]: (p: any) => void;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","names":["METHODS","RPC_VERSION"],"sources":["../../../src/aepp-wallet-communication/rpc/types.ts"],"sourcesContent":["import { send } from '../../spend'\nimport { EncodedData } from '../../utils/encoder'\nimport { METHODS, SUBSCRIPTION_TYPES, WALLET_TYPE } from '../schema'\n\nexport interface WalletInfo {\n id: string\n name: string\n networkId: string\n origin: string\n type: WALLET_TYPE\n}\n\nexport interface Accounts {\n connected: { [pub: EncodedData<'ak'>]: {} }\n current: { [pub: EncodedData<'ak'>]: {} }\n}\n\nexport interface Node {\n name: string\n url: string\n}\n\nexport interface Network {\n networkId: string\n node?: Node\n}\n\ntype Icons = Array<{ src: string, sizes?: string, type?: string, purpose?: string }>\n\nexport const RPC_VERSION = 1\n\nexport interface WalletApi {\n [METHODS.connect]: (\n p: { name: string, icons?: Icons, version: typeof RPC_VERSION, connectNode: boolean }\n ) => Promise<WalletInfo & { node?: Node }>\n\n [METHODS.closeConnection]: (p: any) => void\n\n [METHODS.subscribeAddress]: (\n p: { type: SUBSCRIPTION_TYPES, value: 'connected' | 'current' }\n ) => Promise<{ subscription: Array<'connected' | 'current'>, address: Accounts }>\n\n [METHODS.address]: () => Promise<Array<EncodedData<'ak'>>>\n\n [METHODS.sign]: ((\n p: { tx: EncodedData<'tx'>, onAccount: EncodedData<'ak'>, returnSigned: boolean }\n ) => Promise<{\n /**\n * @deprecated this is not a hash at all, will be removed later at the same time\n * as dropping ability to broadcast transaction by wallet\n */\n transactionHash?: Awaited<ReturnType<typeof send>>\n signedTransaction?: EncodedData<'tx'>\n }>)\n\n [METHODS.signMessage]: (\n p: { message: string, onAccount: EncodedData<'ak'> }\n ) => Promise<{ signature: string }>\n}\n\nexport interface AeppApi {\n [METHODS.updateAddress]: (a: Accounts) => void\n [METHODS.updateNetwork]: (a: Network) => void\n [METHODS.readyToConnect]: (w: WalletInfo) => void\n [METHODS.closeConnection]: (p: any) => void\n}\n"],"mappings":"SAESA,O;AA2BT,OAAO,MAAMC,WAAW,GAAG,CAApB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { EncodedData } from '../utils/encoder';
|
|
2
|
+
import { BaseError } from '../utils/errors';
|
|
2
3
|
export declare const enum MESSAGE_DIRECTION {
|
|
3
4
|
to_waellet = "to_waellet",
|
|
4
5
|
to_aepp = "to_aepp"
|
|
@@ -24,51 +25,94 @@ export declare const enum METHODS {
|
|
|
24
25
|
}
|
|
25
26
|
export declare const enum RPC_STATUS {
|
|
26
27
|
CONNECTED = "CONNECTED",
|
|
27
|
-
NODE_BINDED = "NODE_BINDED",
|
|
28
28
|
DISCONNECTED = "DISCONNECTED",
|
|
29
|
-
CONNECTION_REJECTED = "CONNECTION_REJECTED",
|
|
30
|
-
WAITING_FOR_CONNECTION_APPROVE = "WAITING_FOR_CONNECTION_APPROVE",
|
|
31
29
|
WAITING_FOR_CONNECTION_REQUEST = "WAITING_FOR_CONNECTION_REQUEST"
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
31
|
+
interface RpcErrorAsJson {
|
|
32
|
+
code: number;
|
|
33
|
+
message: string;
|
|
34
|
+
data?: any;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @category exception
|
|
38
|
+
*/
|
|
39
|
+
export declare abstract class RpcError extends BaseError {
|
|
40
|
+
static code: number;
|
|
41
|
+
code: number;
|
|
42
|
+
data?: any;
|
|
43
|
+
toJSON(): RpcErrorAsJson;
|
|
44
|
+
static deserialize(json: RpcErrorAsJson): RpcError;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @category exception
|
|
48
|
+
*/
|
|
49
|
+
export declare class RpcInvalidTransactionError extends RpcError {
|
|
50
|
+
static code: number;
|
|
51
|
+
code: number;
|
|
52
|
+
constructor(data?: any);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @category exception
|
|
56
|
+
*/
|
|
57
|
+
export declare class RpcBroadcastError extends RpcError {
|
|
58
|
+
static code: number;
|
|
59
|
+
code: number;
|
|
60
|
+
constructor(data?: any);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @category exception
|
|
64
|
+
*/
|
|
65
|
+
export declare class RpcRejectedByUserError extends RpcError {
|
|
66
|
+
static code: number;
|
|
67
|
+
code: number;
|
|
68
|
+
constructor(data?: any);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @category exception
|
|
72
|
+
*/
|
|
73
|
+
export declare class RpcUnsupportedProtocolError extends RpcError {
|
|
74
|
+
static code: number;
|
|
75
|
+
code: number;
|
|
76
|
+
constructor();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @category exception
|
|
80
|
+
*/
|
|
81
|
+
export declare class RpcConnectionDenyError extends RpcError {
|
|
82
|
+
static code: number;
|
|
83
|
+
code: number;
|
|
84
|
+
constructor(data?: any);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @category exception
|
|
88
|
+
*/
|
|
89
|
+
export declare class RpcNotAuthorizeError extends RpcError {
|
|
90
|
+
static code: number;
|
|
91
|
+
code: number;
|
|
92
|
+
constructor();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @category exception
|
|
96
|
+
*/
|
|
97
|
+
export declare class RpcPermissionDenyError extends RpcError {
|
|
98
|
+
static code: number;
|
|
99
|
+
code: number;
|
|
100
|
+
constructor(address: EncodedData<'ak'>);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @category exception
|
|
104
|
+
*/
|
|
105
|
+
export declare class RpcInternalError extends RpcError {
|
|
106
|
+
static code: number;
|
|
107
|
+
code: number;
|
|
108
|
+
constructor();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @category exception
|
|
112
|
+
*/
|
|
113
|
+
export declare class RpcMethodNotFoundError extends RpcError {
|
|
114
|
+
static code: number;
|
|
115
|
+
code: number;
|
|
116
|
+
constructor();
|
|
117
|
+
}
|
|
118
|
+
export {};
|