@airgap/coinlib-core 0.13.45-beta.2 → 0.13.45-beta.3
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/actions/Action.js +30 -83
- package/actions/Action.js.map +1 -1
- package/actions/LinkedAction.js +18 -82
- package/actions/LinkedAction.js.map +1 -1
- package/actions/RepeatableAction.js +20 -83
- package/actions/RepeatableAction.js.map +1 -1
- package/actions/SimpleAction.js +12 -74
- package/actions/SimpleAction.js.map +1 -1
- package/actions/StateMachine.js +16 -17
- package/actions/StateMachine.js.map +1 -1
- package/data/KeyPair.d.ts +0 -1
- package/data/Lazy.js +15 -64
- package/data/Lazy.js.map +1 -1
- package/data/RPCBody.js +3 -6
- package/data/RPCBody.js.map +1 -1
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.d.ts +12 -12
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js +88 -130
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js.map +1 -1
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.d.ts +3 -3
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js +57 -61
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js.map +1 -1
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js +96 -96
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js.map +1 -1
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js +1 -2
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js.map +1 -1
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js +8 -10
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js +22 -28
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js +9 -10
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js +10 -11
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js +7 -8
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js.map +1 -1
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.d.ts +3 -3
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js +61 -63
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js.map +1 -1
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.d.ts +4 -4
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js +61 -63
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js.map +1 -1
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.d.ts +1 -1
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js +2 -3
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js +111 -111
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js +15 -15
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js +47 -76
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js +46 -61
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js +61 -106
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/interface.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.d.ts +6 -6
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js +95 -100
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js +33 -33
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js +9 -9
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js +46 -75
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js +45 -70
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js +41 -41
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js +4 -4
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.d.ts +2 -2
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js +58 -63
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js +30 -33
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js +18 -20
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js +5 -12
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js +13 -13
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.d.ts +78 -78
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js +2 -2
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.d.ts +45 -45
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js +75 -76
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js +115 -178
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.d.ts +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js +6 -9
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js +78 -83
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js +27 -36
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.d.ts +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js +25 -26
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js.map +1 -1
- package/dependencies/src/cosmjs/index.d.ts +14 -230
- package/dependencies/src/cosmjs/index.js +373 -480
- package/dependencies/src/cosmjs/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.js +15 -19
- package/dependencies/src/eciesjs-0.3.9/src/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js +37 -28
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js +38 -30
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.js +33 -24
- package/dependencies/src/eciesjs-0.3.9/src/utils.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js +42 -34
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js +6 -10
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js.map +1 -1
- package/errors/coinlib-error.js +16 -37
- package/errors/coinlib-error.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.js +89 -148
- package/errors/index.js.map +1 -1
- package/index.js +19 -19
- package/index.js.map +1 -1
- package/interfaces/IAirGapSignedTransaction.d.ts +1 -1
- package/interfaces/IAirGapTransaction.js +3 -3
- package/interfaces/IAirGapTransaction.js.map +1 -1
- package/networks.js +9 -9
- package/networks.js.map +1 -1
- package/package.json +1 -1
- package/protocols/BlockExplorerProtocol.js +7 -54
- package/protocols/BlockExplorerProtocol.js.map +1 -1
- package/protocols/CryptoClient.js +19 -78
- package/protocols/CryptoClient.js.map +1 -1
- package/protocols/Ed25519CryptoClient.js +30 -98
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinSubProtocol.js +1 -1
- package/protocols/ICoinSubProtocol.js.map +1 -1
- package/protocols/NonExtendedProtocol.js +26 -29
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.js +9 -73
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.js +12 -76
- package/protocols/Sr25519CryptoClient.js.map +1 -1
- package/utils/AES.js +81 -132
- package/utils/AES.js.map +1 -1
- package/utils/ErrorWithData.js +5 -23
- package/utils/ErrorWithData.js.map +1 -1
- package/utils/Network.js +1 -1
- package/utils/Network.js.map +1 -1
- package/utils/ProtocolBlockExplorer.js +3 -4
- package/utils/ProtocolBlockExplorer.js.map +1 -1
- package/utils/ProtocolNetwork.js +11 -16
- package/utils/ProtocolNetwork.js.map +1 -1
- package/utils/ProtocolSymbols.d.ts +1 -1
- package/utils/ProtocolSymbols.js +6 -6
- package/utils/ProtocolSymbols.js.map +1 -1
- package/utils/array.js +14 -15
- package/utils/array.js.map +1 -1
- package/utils/assert.js +8 -12
- package/utils/assert.js.map +1 -1
- package/utils/base64Check.d.ts +0 -1
- package/utils/base64Check.js +15 -15
- package/utils/base64Check.js.map +1 -1
- package/utils/blake2b.js +11 -14
- package/utils/blake2b.js.map +1 -1
- package/utils/buffer.d.ts +0 -1
- package/utils/buffer.js +1 -1
- package/utils/buffer.js.map +1 -1
- package/utils/cache.js +38 -87
- package/utils/cache.js.map +1 -1
- package/utils/error.js +2 -3
- package/utils/error.js.map +1 -1
- package/utils/hex.d.ts +1 -2
- package/utils/hex.js +31 -38
- package/utils/hex.js.map +1 -1
- package/utils/interfaces.js +3 -4
- package/utils/interfaces.js.map +1 -1
- package/utils/object.js +5 -7
- package/utils/object.js.map +1 -1
- package/utils/padStart.js +1 -2
- package/utils/padStart.js.map +1 -1
- package/utils/remote-data/HttpRemoteData.js +24 -107
- package/utils/remote-data/HttpRemoteData.js.map +1 -1
- package/utils/remote-data/IpfsRemoteData.js +32 -116
- package/utils/remote-data/IpfsRemoteData.js.map +1 -1
- package/utils/remote-data/RemoteData.d.ts +0 -1
- package/utils/remote-data/RemoteData.js +3 -4
- package/utils/remote-data/RemoteData.js.map +1 -1
- package/utils/remote-data/RemoteDataFactory.d.ts +2 -2
- package/utils/remote-data/RemoteDataFactory.js +13 -20
- package/utils/remote-data/RemoteDataFactory.js.map +1 -1
- package/utils/remote-data/Sha256RemoteData.d.ts +0 -1
- package/utils/remote-data/Sha256RemoteData.js +44 -117
- package/utils/remote-data/Sha256RemoteData.js.map +1 -1
- package/utils/string.js +8 -9
- package/utils/string.js.map +1 -1
- package/utils/type.js +3 -4
- package/utils/type.js.map +1 -1
- package/utils/xxhash.d.ts +0 -1
- package/utils/xxhash.js +9 -11
- package/utils/xxhash.js.map +1 -1
- package/wallet/AirGapCoinWallet.js +64 -183
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +88 -201
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.js +48 -165
- package/wallet/AirGapNFTWallet.js.map +1 -1
- package/wallet/AirGapWallet.js +58 -145
- package/wallet/AirGapWallet.js.map +1 -1
|
@@ -1,107 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.Ed25519CryptoClient = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
const bytes_1 = require("@stablelib/bytes");
|
|
5
|
+
const blake2b_1 = require("@stablelib/blake2b");
|
|
6
|
+
const ed25519_1 = require("@stablelib/ed25519");
|
|
7
|
+
const nacl_1 = require("@stablelib/nacl");
|
|
8
|
+
const utf8_1 = require("@stablelib/utf8");
|
|
9
|
+
const hex_1 = require("../utils/hex");
|
|
10
|
+
const CryptoClient_1 = require("./CryptoClient");
|
|
62
11
|
function toHex(value) {
|
|
63
12
|
return Buffer.from(value).toString('hex');
|
|
64
13
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
14
|
+
class Ed25519CryptoClient extends CryptoClient_1.CryptoClient {
|
|
15
|
+
async encryptAsymmetric(payload, publicKey) {
|
|
16
|
+
const kxOtherPublicKey = (0, ed25519_1.convertPublicKeyToX25519)(Buffer.from(publicKey, 'hex'));
|
|
17
|
+
const keypair = (0, nacl_1.generateKeyPair)();
|
|
18
|
+
const state = new blake2b_1.BLAKE2b(24);
|
|
19
|
+
const nonce = state.update(keypair.publicKey, 32).update(kxOtherPublicKey, 32).digest();
|
|
20
|
+
const encryptedMessage = (0, nacl_1.box)(kxOtherPublicKey, keypair.secretKey, nonce, (0, hex_1.isHex)(payload) ? Buffer.from(payload, 'hex') : (0, utf8_1.encode)(payload));
|
|
21
|
+
return toHex((0, bytes_1.concat)(keypair.publicKey, encryptedMessage));
|
|
22
|
+
}
|
|
23
|
+
async decryptAsymmetric(encryptedPayload, keypair) {
|
|
24
|
+
const kxSelfPrivateKey = (0, ed25519_1.convertSecretKeyToX25519)(Buffer.from(keypair.privateKey, 'hex')); // Secret bytes to scalar bytes
|
|
25
|
+
const kxSelfPublicKey = (0, ed25519_1.convertPublicKeyToX25519)(Buffer.from(keypair.publicKey, 'hex')); // Secret bytes to scalar bytes
|
|
26
|
+
const encryptedPayloadBytes = Buffer.from(encryptedPayload, (0, hex_1.isHex)(encryptedPayload) ? 'hex' : 'utf-8');
|
|
27
|
+
const kxOtherPublicKey = encryptedPayloadBytes.slice(0, 32);
|
|
28
|
+
const ciphertext = encryptedPayloadBytes.slice(32);
|
|
29
|
+
const state = new blake2b_1.BLAKE2b(24);
|
|
30
|
+
const nonce = state.update(kxOtherPublicKey, 32).update(kxSelfPublicKey, 32).digest();
|
|
31
|
+
const decryptedMessage = (0, nacl_1.openBox)(kxOtherPublicKey, kxSelfPrivateKey, nonce, ciphertext);
|
|
32
|
+
if (decryptedMessage === null) {
|
|
33
|
+
throw new Error('Ed25519 decryption failed.');
|
|
34
|
+
}
|
|
35
|
+
return Buffer.from(decryptedMessage).toString();
|
|
69
36
|
}
|
|
70
|
-
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var kxOtherPublicKey, keypair, state, nonce, encryptedMessage;
|
|
73
|
-
return __generator(this, function (_a) {
|
|
74
|
-
kxOtherPublicKey = (0, ed25519_1.convertPublicKeyToX25519)(Buffer.from(publicKey, 'hex'));
|
|
75
|
-
keypair = (0, nacl_1.generateKeyPair)();
|
|
76
|
-
state = new blake2b_1.BLAKE2b(24);
|
|
77
|
-
nonce = state.update(keypair.publicKey, 32).update(kxOtherPublicKey, 32).digest();
|
|
78
|
-
encryptedMessage = (0, nacl_1.box)(kxOtherPublicKey, keypair.secretKey, nonce, (0, hex_1.isHex)(payload) ? Buffer.from(payload, 'hex') : (0, utf8_1.encode)(payload));
|
|
79
|
-
return [2 /*return*/, toHex((0, bytes_1.concat)(keypair.publicKey, encryptedMessage))];
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
Ed25519CryptoClient.prototype.decryptAsymmetric = function (encryptedPayload, keypair) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var kxSelfPrivateKey, kxSelfPublicKey, encryptedPayloadBytes, kxOtherPublicKey, ciphertext, state, nonce, decryptedMessage;
|
|
86
|
-
return __generator(this, function (_a) {
|
|
87
|
-
kxSelfPrivateKey = (0, ed25519_1.convertSecretKeyToX25519)(Buffer.from(keypair.privateKey, 'hex')) // Secret bytes to scalar bytes
|
|
88
|
-
;
|
|
89
|
-
kxSelfPublicKey = (0, ed25519_1.convertPublicKeyToX25519)(Buffer.from(keypair.publicKey, 'hex')) // Secret bytes to scalar bytes
|
|
90
|
-
;
|
|
91
|
-
encryptedPayloadBytes = Buffer.from(encryptedPayload, (0, hex_1.isHex)(encryptedPayload) ? 'hex' : 'utf-8');
|
|
92
|
-
kxOtherPublicKey = encryptedPayloadBytes.slice(0, 32);
|
|
93
|
-
ciphertext = encryptedPayloadBytes.slice(32);
|
|
94
|
-
state = new blake2b_1.BLAKE2b(24);
|
|
95
|
-
nonce = state.update(kxOtherPublicKey, 32).update(kxSelfPublicKey, 32).digest();
|
|
96
|
-
decryptedMessage = (0, nacl_1.openBox)(kxOtherPublicKey, kxSelfPrivateKey, nonce, ciphertext);
|
|
97
|
-
if (decryptedMessage === null) {
|
|
98
|
-
throw new Error('Ed25519 decryption failed.');
|
|
99
|
-
}
|
|
100
|
-
return [2 /*return*/, Buffer.from(decryptedMessage).toString()];
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
return Ed25519CryptoClient;
|
|
105
|
-
}(CryptoClient_1.CryptoClient));
|
|
37
|
+
}
|
|
106
38
|
exports.Ed25519CryptoClient = Ed25519CryptoClient;
|
|
107
39
|
//# sourceMappingURL=Ed25519CryptoClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ed25519CryptoClient.js","sourceRoot":"","sources":["../../src/protocols/Ed25519CryptoClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Ed25519CryptoClient.js","sourceRoot":"","sources":["../../src/protocols/Ed25519CryptoClient.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,gDAA4C;AAC5C,gDAAgG;AAChG,0CAA+D;AAC/D,0CAAwC;AAExC,sCAAoC;AAEpC,iDAA6C;AAE7C,SAAS,KAAK,CAAC,KAAU;IACvB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC3C,CAAC;AAED,MAAsB,mBAAoB,SAAQ,2BAAY;IACrD,KAAK,CAAC,iBAAiB,CAAC,OAAe,EAAE,SAAiB;QAC/D,MAAM,gBAAgB,GAAe,IAAA,kCAAwB,EAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA;QAE5F,MAAM,OAAO,GAAY,IAAA,sBAAe,GAAE,CAAA;QAC1C,MAAM,KAAK,GAAY,IAAI,iBAAO,CAAC,EAAE,CAAC,CAAA;QACtC,MAAM,KAAK,GAAe,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;QAEnG,MAAM,gBAAgB,GAAe,IAAA,UAAG,EACtC,gBAAgB,EAChB,OAAO,CAAC,SAAS,EACjB,KAAK,EACL,IAAA,WAAK,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,aAAM,EAAC,OAAO,CAAC,CAC/D,CAAA;QAED,OAAO,KAAK,CAAC,IAAA,cAAM,EAAC,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAA;IAC3D,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,gBAAwB,EAAE,OAAkD;QACzG,MAAM,gBAAgB,GAAe,IAAA,kCAAwB,EAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA,CAAC,+BAA+B;QACrI,MAAM,eAAe,GAAe,IAAA,kCAAwB,EAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA,CAAC,+BAA+B;QAEnI,MAAM,qBAAqB,GAAW,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAA,WAAK,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAC9G,MAAM,gBAAgB,GAAW,qBAAqB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACnE,MAAM,UAAU,GAAW,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAE1D,MAAM,KAAK,GAAY,IAAI,iBAAO,CAAC,EAAE,CAAC,CAAA;QACtC,MAAM,KAAK,GAAe,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;QAEjG,MAAM,gBAAgB,GAAsB,IAAA,cAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;QAE1G,IAAI,gBAAgB,KAAK,IAAI,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC/C,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAA;IACjD,CAAC;CACF;AArCD,kDAqCC"}
|
|
@@ -5,5 +5,5 @@ var SubProtocolType;
|
|
|
5
5
|
(function (SubProtocolType) {
|
|
6
6
|
SubProtocolType["ACCOUNT"] = "account";
|
|
7
7
|
SubProtocolType["TOKEN"] = "token";
|
|
8
|
-
})(SubProtocolType
|
|
8
|
+
})(SubProtocolType || (exports.SubProtocolType = SubProtocolType = {}));
|
|
9
9
|
//# sourceMappingURL=ICoinSubProtocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICoinSubProtocol.js","sourceRoot":"","sources":["../../src/protocols/ICoinSubProtocol.ts"],"names":[],"mappings":";;;AAEA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,
|
|
1
|
+
{"version":3,"file":"ICoinSubProtocol.js","sourceRoot":"","sources":["../../src/protocols/ICoinSubProtocol.ts"],"names":[],"mappings":";;;AAEA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B"}
|
|
@@ -1,49 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NonExtendedProtocol = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
NonExtendedProtocol.prototype.getExtendedPublicKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
4
|
+
class NonExtendedProtocol {
|
|
5
|
+
getExtendedPublicKeyFromMnemonic(mnemonic, derivationPath, password) {
|
|
8
6
|
throw Promise.reject('extended public key support not implemented');
|
|
9
|
-
}
|
|
10
|
-
|
|
7
|
+
}
|
|
8
|
+
getExtendedPublicKeyFromHexSecret(secret, derivationPath) {
|
|
11
9
|
throw Promise.reject('extended public key support not implemented');
|
|
12
|
-
}
|
|
13
|
-
|
|
10
|
+
}
|
|
11
|
+
getExtendedPrivateKeyFromMnemonic(mnemonic, derivationPath, password) {
|
|
14
12
|
throw Promise.reject('extended private key support not implemented');
|
|
15
|
-
}
|
|
16
|
-
|
|
13
|
+
}
|
|
14
|
+
getExtendedPrivateKeyFromHexSecret(secret, derivationPath) {
|
|
17
15
|
throw Promise.reject('extended private key support not implemented');
|
|
18
|
-
}
|
|
19
|
-
|
|
16
|
+
}
|
|
17
|
+
getBalanceOfExtendedPublicKey(extendedPublicKey, offset) {
|
|
20
18
|
return Promise.reject('extended public balance not implemented');
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
}
|
|
20
|
+
signWithExtendedPrivateKey(extendedPrivateKey, transaction, childDerivationPath) {
|
|
23
21
|
return Promise.reject('extended private key signing for not implemented');
|
|
24
|
-
}
|
|
25
|
-
|
|
22
|
+
}
|
|
23
|
+
getAddressFromExtendedPublicKey(extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex) {
|
|
26
24
|
return Promise.resolve({
|
|
27
25
|
address: '',
|
|
28
26
|
cursor: { hasNext: false }
|
|
29
27
|
});
|
|
30
|
-
}
|
|
31
|
-
|
|
28
|
+
}
|
|
29
|
+
getAddressesFromExtendedPublicKey(extendedPublicKey, visibilityDerivationIndex, addressCount, offset) {
|
|
32
30
|
return Promise.resolve([]);
|
|
33
|
-
}
|
|
34
|
-
|
|
31
|
+
}
|
|
32
|
+
estimateMaxTransactionValueFromExtendedPublicKey(extendedPublicKey, recipients, fee) {
|
|
35
33
|
return Promise.reject('estimating max value using extended public key not implemented');
|
|
36
|
-
}
|
|
37
|
-
|
|
34
|
+
}
|
|
35
|
+
estimateFeeDefaultsFromExtendedPublicKey(publicKey, recipients, values, data) {
|
|
38
36
|
return Promise.reject('estimating fee defaults using extended public key not implemented');
|
|
39
|
-
}
|
|
40
|
-
|
|
37
|
+
}
|
|
38
|
+
getTransactionsFromExtendedPublicKey(extendedPublicKey, limit, cursor) {
|
|
41
39
|
return Promise.reject('fetching txs using extended public key not implemented');
|
|
42
|
-
}
|
|
43
|
-
|
|
40
|
+
}
|
|
41
|
+
prepareTransactionFromExtendedPublicKey(extendedPublicKey, offset, recipients, values, fee) {
|
|
44
42
|
return Promise.reject('extended public key tx not implemented');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
48
45
|
exports.NonExtendedProtocol = NonExtendedProtocol;
|
|
49
46
|
//# sourceMappingURL=NonExtendedProtocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonExtendedProtocol.js","sourceRoot":"","sources":["../../src/protocols/NonExtendedProtocol.ts"],"names":[],"mappings":";;;AAKA
|
|
1
|
+
{"version":3,"file":"NonExtendedProtocol.js","sourceRoot":"","sources":["../../src/protocols/NonExtendedProtocol.ts"],"names":[],"mappings":";;;AAKA,MAAsB,mBAAmB;IAChC,gCAAgC,CAAC,QAAgB,EAAE,cAAsB,EAAE,QAAiB;QACjG,MAAM,OAAO,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAA;IACrE,CAAC;IAEM,iCAAiC,CAAC,MAAc,EAAE,cAAsB;QAC7E,MAAM,OAAO,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAA;IACrE,CAAC;IAEM,iCAAiC,CAAC,QAAgB,EAAE,cAAsB,EAAE,QAAiB;QAClG,MAAM,OAAO,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAA;IACtE,CAAC;IAEM,kCAAkC,CAAC,MAAc,EAAE,cAAsB;QAC9E,MAAM,OAAO,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAA;IACtE,CAAC;IAEM,6BAA6B,CAAC,iBAAyB,EAAE,MAAc;QAC5E,OAAO,OAAO,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAA;IAClE,CAAC;IAEM,0BAA0B,CAAC,kBAA0B,EAAE,WAAgB,EAAE,mBAA2B;QACzG,OAAO,OAAO,CAAC,MAAM,CAAC,kDAAkD,CAAC,CAAA;IAC3E,CAAC;IAEM,+BAA+B,CACpC,iBAAyB,EACzB,yBAAiC,EACjC,sBAA8B;QAE9B,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;SAC3B,CAAC,CAAA;IACJ,CAAC;IAEM,iCAAiC,CACtC,iBAAyB,EACzB,yBAAiC,EACjC,YAAoB,EACpB,MAAc;QAEd,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC;IAEM,gDAAgD,CAAC,iBAAyB,EAAE,UAAoB,EAAE,GAAW;QAClH,OAAO,OAAO,CAAC,MAAM,CAAC,gEAAgE,CAAC,CAAA;IACzF,CAAC;IAEM,wCAAwC,CAC7C,SAAiB,EACjB,UAAoB,EACpB,MAAgB,EAChB,IAAU;QAEV,OAAO,OAAO,CAAC,MAAM,CAAC,mEAAmE,CAAC,CAAA;IAC5F,CAAC;IAEM,oCAAoC,CACzC,iBAAyB,EACzB,KAAa,EACb,MAAkC;QAElC,OAAO,OAAO,CAAC,MAAM,CAAC,wDAAwD,CAAC,CAAA;IACjF,CAAC;IAEM,uCAAuC,CAC5C,iBAAyB,EACzB,MAAc,EACd,UAAoB,EACpB,MAAgB,EAChB,GAAW;QAEX,OAAO,OAAO,CAAC,MAAM,CAAC,wCAAwC,CAAC,CAAA;IACjE,CAAC;CACF;AA3ED,kDA2EC"}
|
|
@@ -1,79 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.Secp256k1CryptoClient = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
4
|
+
const index_1 = require("../dependencies/src/eciesjs-0.3.9/src/index");
|
|
5
|
+
const CryptoClient_1 = require("./CryptoClient");
|
|
6
|
+
class Secp256k1CryptoClient extends CryptoClient_1.CryptoClient {
|
|
7
|
+
async encryptAsymmetric(payload, publicKey) {
|
|
8
|
+
return (0, index_1.encrypt)(publicKey, Buffer.from(payload)).toString('hex');
|
|
9
|
+
}
|
|
10
|
+
async decryptAsymmetric(encryptedPayload, keypair) {
|
|
11
|
+
return (0, index_1.decrypt)(keypair.privateKey, Buffer.from(encryptedPayload, 'hex')).toString();
|
|
61
12
|
}
|
|
62
|
-
|
|
63
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
return [2 /*return*/, (0, index_1.encrypt)(publicKey, Buffer.from(payload)).toString('hex')];
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
Secp256k1CryptoClient.prototype.decryptAsymmetric = function (encryptedPayload, keypair) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
return [2 /*return*/, (0, index_1.decrypt)(keypair.privateKey, Buffer.from(encryptedPayload, 'hex')).toString()];
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
return Secp256k1CryptoClient;
|
|
77
|
-
}(CryptoClient_1.CryptoClient));
|
|
13
|
+
}
|
|
78
14
|
exports.Secp256k1CryptoClient = Secp256k1CryptoClient;
|
|
79
15
|
//# sourceMappingURL=Secp256k1CryptoClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Secp256k1CryptoClient.js","sourceRoot":"","sources":["../../src/protocols/Secp256k1CryptoClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Secp256k1CryptoClient.js","sourceRoot":"","sources":["../../src/protocols/Secp256k1CryptoClient.ts"],"names":[],"mappings":";;;AAAA,uEAA8E;AAE9E,iDAA6C;AAE7C,MAAsB,qBAAsB,SAAQ,2BAAY;IACvD,KAAK,CAAC,iBAAiB,CAAC,OAAe,EAAE,SAAiB;QAC/D,OAAO,IAAA,eAAO,EAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjE,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,gBAAwB,EAAE,OAAkD;QACzG,OAAO,IAAA,eAAO,EAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IACrF,CAAC;CACF;AARD,sDAQC"}
|
|
@@ -1,82 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.Sr25519CryptoClient = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
const coinlib_error_1 = require("../errors/coinlib-error");
|
|
6
|
+
const CryptoClient_1 = require("./CryptoClient");
|
|
7
|
+
class Sr25519CryptoClient extends CryptoClient_1.CryptoClient {
|
|
8
|
+
async encryptAsymmetric(payload, publicKey) {
|
|
9
|
+
// Currently not supported: https://github.com/polkadot-js/common/issues/633
|
|
10
|
+
throw new errors_1.NotImplementedError(coinlib_error_1.Domain.UTILS, `encryptAsymmetric() not implemented.`);
|
|
11
|
+
}
|
|
12
|
+
async decryptAsymmetric(encryptedPayload, keypair) {
|
|
13
|
+
// Currently not supported: https://github.com/polkadot-js/common/issues/633
|
|
14
|
+
throw new errors_1.NotImplementedError(coinlib_error_1.Domain.UTILS, `decryptAsymmetric() not implemented.`);
|
|
62
15
|
}
|
|
63
|
-
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
return __generator(this, function (_a) {
|
|
66
|
-
// Currently not supported: https://github.com/polkadot-js/common/issues/633
|
|
67
|
-
throw new errors_1.NotImplementedError(coinlib_error_1.Domain.UTILS, "encryptAsymmetric() not implemented.");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
Sr25519CryptoClient.prototype.decryptAsymmetric = function (encryptedPayload, keypair) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
return __generator(this, function (_a) {
|
|
74
|
-
// Currently not supported: https://github.com/polkadot-js/common/issues/633
|
|
75
|
-
throw new errors_1.NotImplementedError(coinlib_error_1.Domain.UTILS, "decryptAsymmetric() not implemented.");
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
return Sr25519CryptoClient;
|
|
80
|
-
}(CryptoClient_1.CryptoClient));
|
|
16
|
+
}
|
|
81
17
|
exports.Sr25519CryptoClient = Sr25519CryptoClient;
|
|
82
18
|
//# sourceMappingURL=Sr25519CryptoClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sr25519CryptoClient.js","sourceRoot":"","sources":["../../src/protocols/Sr25519CryptoClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sr25519CryptoClient.js","sourceRoot":"","sources":["../../src/protocols/Sr25519CryptoClient.ts"],"names":[],"mappings":";;;AAAA,sCAA+C;AAC/C,2DAAgD;AAChD,iDAA6C;AAE7C,MAAsB,mBAAoB,SAAQ,2BAAY;IACrD,KAAK,CAAC,iBAAiB,CAAC,OAAe,EAAE,SAAiB;QAC/D,4EAA4E;QAC5E,MAAM,IAAI,4BAAmB,CAAC,sBAAM,CAAC,KAAK,EAAE,sCAAsC,CAAC,CAAA;IACrF,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,gBAAwB,EAAE,OAAkD;QACzG,4EAA4E;QAC5E,MAAM,IAAI,4BAAmB,CAAC,sBAAM,CAAC,KAAK,EAAE,sCAAsC,CAAC,CAAA;IACrF,CAAC;CACF;AAVD,kDAUC"}
|