@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,117 +1,34 @@
|
|
|
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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
4
|
};
|
|
56
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
6
|
exports.HttpRemoteData = void 0;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function HttpRemoteData() {
|
|
65
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
66
|
-
}
|
|
67
|
-
HttpRemoteData.from = function (uri) {
|
|
7
|
+
const index_1 = __importDefault(require("../../dependencies/src/axios-0.19.0/index"));
|
|
8
|
+
const RemoteData_1 = require("./RemoteData");
|
|
9
|
+
const HTTP_SCHEME = 'http';
|
|
10
|
+
const HTTPS_SCHEME = 'https';
|
|
11
|
+
class HttpRemoteData extends RemoteData_1.RemoteData {
|
|
12
|
+
static from(uri) {
|
|
68
13
|
return HttpRemoteData.validate(uri) ? new HttpRemoteData(uri) : undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
14
|
+
}
|
|
15
|
+
static validate(uri) {
|
|
71
16
|
return uri.startsWith(HTTP_SCHEME) || uri.startsWith(HTTPS_SCHEME);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var response;
|
|
89
|
-
return __generator(this, function (_a) {
|
|
90
|
-
switch (_a.label) {
|
|
91
|
-
case 0: return [4 /*yield*/, this.getData('arraybuffer')];
|
|
92
|
-
case 1:
|
|
93
|
-
response = _a.sent();
|
|
94
|
-
return [2 /*return*/, response ? { bytes: Buffer.from(response.data), contentType: response.headers['content-type'] } : undefined];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
HttpRemoteData.prototype.getData = function (responseType) {
|
|
100
|
-
if (responseType === void 0) { responseType = 'json'; }
|
|
101
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
return __generator(this, function (_a) {
|
|
103
|
-
switch (_a.label) {
|
|
104
|
-
case 0:
|
|
105
|
-
if (!HttpRemoteData.validate(this.uri)) {
|
|
106
|
-
return [2 /*return*/, undefined];
|
|
107
|
-
}
|
|
108
|
-
return [4 /*yield*/, index_1.default.get(this.uri, { responseType: responseType })];
|
|
109
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
return HttpRemoteData;
|
|
115
|
-
}(RemoteData_1.RemoteData));
|
|
17
|
+
}
|
|
18
|
+
async get() {
|
|
19
|
+
const response = await this.getData();
|
|
20
|
+
return response?.data;
|
|
21
|
+
}
|
|
22
|
+
async getRaw() {
|
|
23
|
+
const response = await this.getData('arraybuffer');
|
|
24
|
+
return response ? { bytes: Buffer.from(response.data), contentType: response.headers['content-type'] } : undefined;
|
|
25
|
+
}
|
|
26
|
+
async getData(responseType = 'json') {
|
|
27
|
+
if (!HttpRemoteData.validate(this.uri)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return await index_1.default.get(this.uri, { responseType });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
116
33
|
exports.HttpRemoteData = HttpRemoteData;
|
|
117
34
|
//# sourceMappingURL=HttpRemoteData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpRemoteData.js","sourceRoot":"","sources":["../../../src/utils/remote-data/HttpRemoteData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpRemoteData.js","sourceRoot":"","sources":["../../../src/utils/remote-data/HttpRemoteData.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA8F;AAE9F,6CAAkD;AAElD,MAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,MAAM,YAAY,GAAG,OAAO,CAAA;AAE5B,MAAa,cAAkB,SAAQ,uBAAa;IAC3C,MAAM,CAAC,IAAI,CAAI,GAAW;QAC/B,OAAO,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC3E,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,GAAW;QAChC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IACpE,CAAC;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,QAAQ,GAAiC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;QACnE,OAAO,QAAQ,EAAE,IAAI,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,MAAM,QAAQ,GAA2C,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAC1F,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IACpH,CAAC;IAEO,KAAK,CAAC,OAAO,CAAI,eAA6B,MAAM;QAC1D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,MAAM,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,CAAC,CAAA;IACpD,CAAC;CACF;AA1BD,wCA0BC"}
|
|
@@ -1,67 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// https://github.com/ipfs/in-web-browsers/blob/master/ADDRESSING.md
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
19
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
20
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
21
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
22
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
23
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
24
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
28
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
29
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
30
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
31
|
-
function step(op) {
|
|
32
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
33
|
-
while (_) try {
|
|
34
|
-
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;
|
|
35
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
36
|
-
switch (op[0]) {
|
|
37
|
-
case 0: case 1: t = op; break;
|
|
38
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
39
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
40
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
41
|
-
default:
|
|
42
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
43
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
44
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
45
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
46
|
-
if (t[2]) _.ops.pop();
|
|
47
|
-
_.trys.pop(); continue;
|
|
48
|
-
}
|
|
49
|
-
op = body.call(thisArg, _);
|
|
50
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
51
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
55
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
56
5
|
};
|
|
57
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
7
|
exports.IpfsRemoteData = void 0;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
8
|
+
const index_1 = __importDefault(require("../../dependencies/src/axios-0.19.0/index"));
|
|
9
|
+
const RemoteData_1 = require("./RemoteData");
|
|
10
|
+
const IPFS_SCHEME = 'ipfs';
|
|
11
|
+
const IPFS_HTTP_GATEWAY = 'https://dweb.link/ipfs';
|
|
12
|
+
const IPNS_SCHEME = 'ipns';
|
|
13
|
+
const IPNS_HTTP_GATEWAY = 'https://dweb.link/ipns';
|
|
65
14
|
function http(uri) {
|
|
66
15
|
if (uri.startsWith(IPFS_SCHEME)) {
|
|
67
16
|
return ipfs(uri);
|
|
@@ -74,69 +23,36 @@ function http(uri) {
|
|
|
74
23
|
}
|
|
75
24
|
}
|
|
76
25
|
function ipfs(uri) {
|
|
77
|
-
return
|
|
26
|
+
return `${IPFS_HTTP_GATEWAY}/${uri.replace(`${IPFS_SCHEME}://`, '')}`;
|
|
78
27
|
}
|
|
79
28
|
function ipns(uri) {
|
|
80
|
-
return
|
|
29
|
+
return `${IPNS_HTTP_GATEWAY}/${uri.replace(`${IPNS_SCHEME}://`, '')}`;
|
|
81
30
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
function IpfsRemoteData() {
|
|
85
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
86
|
-
}
|
|
87
|
-
IpfsRemoteData.from = function (uri) {
|
|
31
|
+
class IpfsRemoteData extends RemoteData_1.RemoteData {
|
|
32
|
+
static from(uri) {
|
|
88
33
|
return IpfsRemoteData.validate(uri) ? new IpfsRemoteData(uri) : undefined;
|
|
89
|
-
}
|
|
90
|
-
|
|
34
|
+
}
|
|
35
|
+
static validate(uri) {
|
|
91
36
|
return uri.startsWith(IPFS_SCHEME) || uri.startsWith(IPNS_SCHEME);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
case 1:
|
|
113
|
-
response = _a.sent();
|
|
114
|
-
return [2 /*return*/, response ? { bytes: Buffer.from(response.data), contentType: response.headers['content-type'] } : undefined];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
IpfsRemoteData.prototype.getData = function (responseType) {
|
|
120
|
-
if (responseType === void 0) { responseType = 'json'; }
|
|
121
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var uri;
|
|
123
|
-
return __generator(this, function (_a) {
|
|
124
|
-
switch (_a.label) {
|
|
125
|
-
case 0:
|
|
126
|
-
if (!IpfsRemoteData.validate(this.uri)) {
|
|
127
|
-
return [2 /*return*/, undefined];
|
|
128
|
-
}
|
|
129
|
-
uri = http(this.uri);
|
|
130
|
-
if (!uri) {
|
|
131
|
-
return [2 /*return*/, undefined];
|
|
132
|
-
}
|
|
133
|
-
return [4 /*yield*/, index_1.default.get(uri, { responseType: responseType })];
|
|
134
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
return IpfsRemoteData;
|
|
140
|
-
}(RemoteData_1.RemoteData));
|
|
37
|
+
}
|
|
38
|
+
async get() {
|
|
39
|
+
const response = await this.getData();
|
|
40
|
+
return response?.data;
|
|
41
|
+
}
|
|
42
|
+
async getRaw() {
|
|
43
|
+
const response = await this.getData('arraybuffer');
|
|
44
|
+
return response ? { bytes: Buffer.from(response.data), contentType: response.headers['content-type'] } : undefined;
|
|
45
|
+
}
|
|
46
|
+
async getData(responseType = 'json') {
|
|
47
|
+
if (!IpfsRemoteData.validate(this.uri)) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const uri = http(this.uri);
|
|
51
|
+
if (!uri) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return await index_1.default.get(uri, { responseType });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
141
57
|
exports.IpfsRemoteData = IpfsRemoteData;
|
|
142
58
|
//# sourceMappingURL=IpfsRemoteData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IpfsRemoteData.js","sourceRoot":"","sources":["../../../src/utils/remote-data/IpfsRemoteData.ts"],"names":[],"mappings":";AAAA,oEAAoE
|
|
1
|
+
{"version":3,"file":"IpfsRemoteData.js","sourceRoot":"","sources":["../../../src/utils/remote-data/IpfsRemoteData.ts"],"names":[],"mappings":";AAAA,oEAAoE;;;;;;AAEpE,sFAA8F;AAE9F,6CAAkD;AAElD,MAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAElD,MAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAElD,SAAS,IAAI,CAAC,GAAW;IACvB,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;IAClB,CAAC;SAAM,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,OAAO,GAAG,iBAAiB,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,KAAK,EAAE,EAAE,CAAC,EAAE,CAAA;AACvE,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,OAAO,GAAG,iBAAiB,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,KAAK,EAAE,EAAE,CAAC,EAAE,CAAA;AACvE,CAAC;AAED,MAAa,cAAkB,SAAQ,uBAAa;IAC3C,MAAM,CAAC,IAAI,CAAI,GAAW;QAC/B,OAAO,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC3E,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,GAAW;QAChC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;IACnE,CAAC;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,QAAQ,GAAiC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;QACnE,OAAO,QAAQ,EAAE,IAAI,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,MAAM,QAAQ,GAA2C,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAC1F,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IACpH,CAAC;IAEO,KAAK,CAAC,OAAO,CAAI,eAA6B,MAAM;QAC1D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC1B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,CAAC,CAAA;IAC/C,CAAC;CACF;AA/BD,wCA+BC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoteData = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class RemoteData {
|
|
5
|
+
constructor(uri) {
|
|
6
6
|
this.uri = uri;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
}());
|
|
8
|
+
}
|
|
10
9
|
exports.RemoteData = RemoteData;
|
|
11
10
|
//# sourceMappingURL=RemoteData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteData.js","sourceRoot":"","sources":["../../../src/utils/remote-data/RemoteData.ts"],"names":[],"mappings":";;;AAKA;
|
|
1
|
+
{"version":3,"file":"RemoteData.js","sourceRoot":"","sources":["../../../src/utils/remote-data/RemoteData.ts"],"names":[],"mappings":";;;AAKA,MAAsB,UAAU;IAC9B,YAAsC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;CAItD;AALD,gCAKC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RemoteData } from './RemoteData';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Validator = (uri: string) => boolean;
|
|
3
|
+
type Factory<T> = <S>(uri: string, extra: T) => RemoteData<S> | undefined;
|
|
4
4
|
export interface RemoteDataFactoryExtra {
|
|
5
5
|
}
|
|
6
6
|
export declare class RemoteDataFactory<T extends RemoteDataFactoryExtra = any> {
|
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoteDataFactory = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _a;
|
|
10
|
-
if (extraFactoriesWithValidators === void 0) { extraFactoriesWithValidators = []; }
|
|
4
|
+
const HttpRemoteData_1 = require("./HttpRemoteData");
|
|
5
|
+
const IpfsRemoteData_1 = require("./IpfsRemoteData");
|
|
6
|
+
const Sha256RemoteData_1 = require("./Sha256RemoteData");
|
|
7
|
+
class RemoteDataFactory {
|
|
8
|
+
constructor(extraFactoriesWithValidators = []) {
|
|
11
9
|
this.factoriesWithValidators = [
|
|
12
|
-
[HttpRemoteData_1.HttpRemoteData.validate,
|
|
13
|
-
[IpfsRemoteData_1.IpfsRemoteData.validate,
|
|
14
|
-
[Sha256RemoteData_1.Sha256RemoteData.validate,
|
|
10
|
+
[HttpRemoteData_1.HttpRemoteData.validate, (uri, _extra) => HttpRemoteData_1.HttpRemoteData.from(uri)],
|
|
11
|
+
[IpfsRemoteData_1.IpfsRemoteData.validate, (uri, _extra) => IpfsRemoteData_1.IpfsRemoteData.from(uri)],
|
|
12
|
+
[Sha256RemoteData_1.Sha256RemoteData.validate, (uri, _extra) => Sha256RemoteData_1.Sha256RemoteData.from(uri)]
|
|
15
13
|
];
|
|
16
|
-
|
|
14
|
+
this.factoriesWithValidators.push(...extraFactoriesWithValidators);
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _b = (_a = this.factoriesWithValidators.find(function (_a) {
|
|
21
|
-
var validator = _a[0], _ = _a[1];
|
|
22
|
-
return validator(uri);
|
|
23
|
-
})) !== null && _a !== void 0 ? _a : [undefined, undefined], factory = _b[1];
|
|
16
|
+
create(uri, extra) {
|
|
17
|
+
const [, factory] = this.factoriesWithValidators.find(([validator, _]) => validator(uri)) ?? [undefined, undefined];
|
|
24
18
|
return factory ? factory(uri, extra) : undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
28
21
|
exports.RemoteDataFactory = RemoteDataFactory;
|
|
29
22
|
//# sourceMappingURL=RemoteDataFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteDataFactory.js","sourceRoot":"","sources":["../../../src/utils/remote-data/RemoteDataFactory.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"RemoteDataFactory.js","sourceRoot":"","sources":["../../../src/utils/remote-data/RemoteDataFactory.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AACjD,qDAAiD;AAEjD,yDAAqD;AAOrD,MAAa,iBAAiB;IAO5B,YAAmB,+BAA0D,EAAE;QAN5D,4BAAuB,GAA8B;YACtE,CAAC,+BAAc,CAAC,QAAQ,EAAE,CAAC,GAAW,EAAE,MAAS,EAAE,EAAE,CAAC,+BAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC/E,CAAC,+BAAc,CAAC,QAAQ,EAAE,CAAC,GAAW,EAAE,MAAS,EAAE,EAAE,CAAC,+BAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC/E,CAAC,mCAAgB,CAAC,QAAQ,EAAE,CAAC,GAAW,EAAE,MAAS,EAAE,EAAE,CAAC,mCAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACpF,CAAA;QAGC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,4BAA4B,CAAC,CAAA;IACpE,CAAC;IAEM,MAAM,CAAI,GAAW,EAAE,KAAQ;QACpC,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAEnH,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAClD,CAAC;CACF;AAhBD,8CAgBC"}
|
|
@@ -1,139 +1,66 @@
|
|
|
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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
4
|
};
|
|
56
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
6
|
exports.Sha256RemoteData = void 0;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
7
|
+
const index_1 = __importDefault(require("../../dependencies/src/axios-0.19.0/index"));
|
|
8
|
+
const sha = require("../../dependencies/src/sha.js-2.4.11/index");
|
|
9
|
+
const hex_1 = require("../hex");
|
|
10
|
+
const RemoteData_1 = require("./RemoteData");
|
|
11
|
+
const SHA256_SCHEME = 'sha256';
|
|
63
12
|
function parseUri(uri) {
|
|
64
|
-
|
|
65
|
-
return { hash
|
|
13
|
+
const [hash, path] = uri.replace(`${SHA256_SCHEME}://`, '').split(/\/(.+)/, 2);
|
|
14
|
+
return { hash, path };
|
|
66
15
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
_this.path = path;
|
|
73
|
-
return _this;
|
|
16
|
+
class Sha256RemoteData extends RemoteData_1.RemoteData {
|
|
17
|
+
constructor(uri, hash, path) {
|
|
18
|
+
super(uri);
|
|
19
|
+
this.hash = hash;
|
|
20
|
+
this.path = path;
|
|
74
21
|
}
|
|
75
|
-
|
|
22
|
+
static from(uri) {
|
|
76
23
|
if (!Sha256RemoteData.validate(uri)) {
|
|
77
24
|
return undefined;
|
|
78
25
|
}
|
|
79
|
-
|
|
26
|
+
const { hash, path } = parseUri(uri);
|
|
80
27
|
if (!hash || !path) {
|
|
81
28
|
return undefined;
|
|
82
29
|
}
|
|
83
30
|
return new Sha256RemoteData(uri, Buffer.from((0, hex_1.stripHexPrefix)(hash), 'hex'), decodeURIComponent(path));
|
|
84
|
-
}
|
|
85
|
-
|
|
31
|
+
}
|
|
32
|
+
static validate(uri) {
|
|
86
33
|
if (!uri.startsWith(SHA256_SCHEME)) {
|
|
87
34
|
return false;
|
|
88
35
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
36
|
+
const { hash, path } = parseUri(uri);
|
|
37
|
+
const validHash = !!hash && hash.startsWith('0x');
|
|
38
|
+
const validPath = !!path;
|
|
92
39
|
return validHash && validPath;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return [2 /*return*/, undefined];
|
|
119
|
-
}
|
|
120
|
-
return [4 /*yield*/, index_1.default.get(this.path, { responseType: 'arraybuffer' })];
|
|
121
|
-
case 1:
|
|
122
|
-
response = _a.sent();
|
|
123
|
-
data = response.data;
|
|
124
|
-
hash = sha('sha256').update(data).digest();
|
|
125
|
-
if (!this.hash.equals(hash)) {
|
|
126
|
-
return [2 /*return*/, undefined];
|
|
127
|
-
}
|
|
128
|
-
return [2 /*return*/, {
|
|
129
|
-
bytes: Buffer.from(data),
|
|
130
|
-
contentType: response.headers['content-type']
|
|
131
|
-
}];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
return Sha256RemoteData;
|
|
137
|
-
}(RemoteData_1.RemoteData));
|
|
40
|
+
}
|
|
41
|
+
async get() {
|
|
42
|
+
const data = await this.getRaw();
|
|
43
|
+
if (data === undefined) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const decoder = new TextDecoder();
|
|
47
|
+
return JSON.parse(decoder.decode(data.bytes.buffer));
|
|
48
|
+
}
|
|
49
|
+
async getRaw() {
|
|
50
|
+
if (!Sha256RemoteData.validate(this.uri)) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const response = await index_1.default.get(this.path, { responseType: 'arraybuffer' });
|
|
54
|
+
const data = response.data;
|
|
55
|
+
const hash = sha('sha256').update(data).digest();
|
|
56
|
+
if (!this.hash.equals(hash)) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
bytes: Buffer.from(data),
|
|
61
|
+
contentType: response.headers['content-type']
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
138
65
|
exports.Sha256RemoteData = Sha256RemoteData;
|
|
139
66
|
//# sourceMappingURL=Sha256RemoteData.js.map
|