@airgap/coinlib-core 0.13.45-beta.3 → 0.13.45-beta.5
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 +83 -30
- package/actions/Action.js.map +1 -1
- package/actions/LinkedAction.js +82 -18
- package/actions/LinkedAction.js.map +1 -1
- package/actions/RepeatableAction.js +83 -20
- package/actions/RepeatableAction.js.map +1 -1
- package/actions/SimpleAction.js +74 -12
- package/actions/SimpleAction.js.map +1 -1
- package/actions/StateMachine.js +17 -16
- package/actions/StateMachine.js.map +1 -1
- package/data/KeyPair.d.ts +1 -0
- package/data/Lazy.js +64 -15
- package/data/Lazy.js.map +1 -1
- package/data/RPCBody.js +6 -3
- 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 +130 -88
- 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 +61 -57
- 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 +2 -1
- 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 +10 -8
- 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 +28 -22
- 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 +10 -9
- 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 +11 -10
- 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 +8 -7
- 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 +63 -61
- 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 +63 -61
- 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 +3 -2
- 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 +76 -47
- 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 +61 -46
- 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 +106 -61
- 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 +100 -95
- 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 +75 -46
- 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 +70 -45
- 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 +63 -58
- 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 +33 -30
- 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 +20 -18
- 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 +12 -5
- 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 +76 -75
- 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 +178 -115
- 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 +9 -6
- 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 +83 -78
- 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 +36 -27
- 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 +26 -25
- 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 +230 -14
- package/dependencies/src/cosmjs/index.js +480 -373
- package/dependencies/src/cosmjs/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.d.ts +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/index.js +19 -15
- 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 +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js +28 -37
- 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 +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js +30 -38
- 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 +1 -0
- package/dependencies/src/eciesjs-0.3.9/src/utils.js +24 -33
- package/dependencies/src/eciesjs-0.3.9/src/utils.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js +34 -42
- 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 +10 -6
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js.map +1 -1
- package/errors/coinlib-error.d.ts +2 -1
- package/errors/coinlib-error.js +38 -16
- package/errors/coinlib-error.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.js +148 -89
- 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 +54 -7
- package/protocols/BlockExplorerProtocol.js.map +1 -1
- package/protocols/CryptoClient.js +78 -19
- package/protocols/CryptoClient.js.map +1 -1
- package/protocols/Ed25519CryptoClient.js +98 -30
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinSubProtocol.js +1 -1
- package/protocols/ICoinSubProtocol.js.map +1 -1
- package/protocols/NonExtendedProtocol.js +29 -26
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.js +73 -9
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.js +76 -12
- package/protocols/Sr25519CryptoClient.js.map +1 -1
- package/utils/AES.js +132 -81
- package/utils/AES.js.map +1 -1
- package/utils/ErrorWithData.js +23 -5
- package/utils/ErrorWithData.js.map +1 -1
- package/utils/Network.js +1 -1
- package/utils/Network.js.map +1 -1
- package/utils/ProtocolBlockExplorer.js +4 -3
- package/utils/ProtocolBlockExplorer.js.map +1 -1
- package/utils/ProtocolNetwork.js +16 -11
- package/utils/ProtocolNetwork.js.map +1 -1
- package/utils/ProtocolSymbols.d.ts +3 -1
- package/utils/ProtocolSymbols.js +8 -6
- package/utils/ProtocolSymbols.js.map +1 -1
- package/utils/array.js +15 -14
- package/utils/array.js.map +1 -1
- package/utils/assert.js +12 -8
- package/utils/assert.js.map +1 -1
- package/utils/base64Check.d.ts +1 -0
- package/utils/base64Check.js +15 -15
- package/utils/base64Check.js.map +1 -1
- package/utils/blake2b.js +14 -11
- package/utils/blake2b.js.map +1 -1
- package/utils/buffer.d.ts +1 -0
- package/utils/buffer.js +1 -1
- package/utils/buffer.js.map +1 -1
- package/utils/cache.js +87 -38
- package/utils/cache.js.map +1 -1
- package/utils/error.js +3 -2
- package/utils/error.js.map +1 -1
- package/utils/hex.d.ts +2 -1
- package/utils/hex.js +38 -31
- package/utils/hex.js.map +1 -1
- package/utils/interfaces.js +4 -3
- package/utils/interfaces.js.map +1 -1
- package/utils/object.js +7 -5
- package/utils/object.js.map +1 -1
- package/utils/padStart.js +2 -1
- package/utils/padStart.js.map +1 -1
- package/utils/remote-data/HttpRemoteData.js +107 -24
- package/utils/remote-data/HttpRemoteData.js.map +1 -1
- package/utils/remote-data/IpfsRemoteData.js +116 -32
- package/utils/remote-data/IpfsRemoteData.js.map +1 -1
- package/utils/remote-data/RemoteData.d.ts +1 -0
- package/utils/remote-data/RemoteData.js +4 -3
- package/utils/remote-data/RemoteData.js.map +1 -1
- package/utils/remote-data/RemoteDataFactory.d.ts +2 -2
- package/utils/remote-data/RemoteDataFactory.js +20 -13
- package/utils/remote-data/RemoteDataFactory.js.map +1 -1
- package/utils/remote-data/Sha256RemoteData.d.ts +1 -0
- package/utils/remote-data/Sha256RemoteData.js +117 -44
- package/utils/remote-data/Sha256RemoteData.js.map +1 -1
- package/utils/string.js +9 -8
- package/utils/string.js.map +1 -1
- package/utils/type.js +4 -3
- package/utils/type.js.map +1 -1
- package/utils/xxhash.d.ts +1 -0
- package/utils/xxhash.js +11 -9
- package/utils/xxhash.js.map +1 -1
- package/wallet/AirGapCoinWallet.js +183 -64
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +201 -88
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.js +165 -48
- package/wallet/AirGapNFTWallet.js.map +1 -1
- package/wallet/AirGapWallet.js +145 -58
- package/wallet/AirGapWallet.js.map +1 -1
|
@@ -1,34 +1,117 @@
|
|
|
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
|
+
};
|
|
2
53
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
54
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
55
|
};
|
|
5
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
57
|
exports.HttpRemoteData = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
58
|
+
var index_1 = __importDefault(require("../../dependencies/src/axios-0.19.0/index"));
|
|
59
|
+
var RemoteData_1 = require("./RemoteData");
|
|
60
|
+
var HTTP_SCHEME = 'http';
|
|
61
|
+
var HTTPS_SCHEME = 'https';
|
|
62
|
+
var HttpRemoteData = /** @class */ (function (_super) {
|
|
63
|
+
__extends(HttpRemoteData, _super);
|
|
64
|
+
function HttpRemoteData() {
|
|
65
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
66
|
}
|
|
15
|
-
|
|
67
|
+
HttpRemoteData.from = function (uri) {
|
|
68
|
+
return HttpRemoteData.validate(uri) ? new HttpRemoteData(uri) : undefined;
|
|
69
|
+
};
|
|
70
|
+
HttpRemoteData.validate = function (uri) {
|
|
16
71
|
return uri.startsWith(HTTP_SCHEME) || uri.startsWith(HTTPS_SCHEME);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
72
|
+
};
|
|
73
|
+
HttpRemoteData.prototype.get = function () {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var response;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0: return [4 /*yield*/, this.getData()];
|
|
79
|
+
case 1:
|
|
80
|
+
response = _a.sent();
|
|
81
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
HttpRemoteData.prototype.getRaw = function () {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
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));
|
|
33
116
|
exports.HttpRemoteData = HttpRemoteData;
|
|
34
117
|
//# 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,oFAA8F;AAE9F,2CAAkD;AAElD,IAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,IAAM,YAAY,GAAG,OAAO,CAAA;AAE5B;IAAuC,kCAAa;IAApD;;IA0BA,CAAC;IAzBe,mBAAI,GAAlB,UAAsB,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;IAEa,uBAAQ,GAAtB,UAAuB,GAAW;QAChC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IACpE,CAAC;IAEY,4BAAG,GAAhB;;;;;4BACiD,qBAAM,IAAI,CAAC,OAAO,EAAE,EAAA;;wBAA7D,QAAQ,GAAiC,SAAoB;wBACnE,sBAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAA;;;;KACtB;IAEY,+BAAM,GAAnB;;;;;4BAC2D,qBAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAA;;wBAApF,QAAQ,GAA2C,SAAiC;wBAC1F,sBAAO,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,EAAA;;;;KACnH;IAEa,gCAAO,GAArB,UAAyB,YAAmC;QAAnC,6BAAA,EAAA,qBAAmC;;;;;wBAC1D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;4BACtC,sBAAO,SAAS,EAAA;yBACjB;wBAEM,qBAAM,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,YAAY,cAAA,EAAE,CAAC,EAAA;4BAAlD,sBAAO,SAA2C,EAAA;;;;KACnD;IACH,qBAAC;AAAD,CAAC,AA1BD,CAAuC,uBAAU,GA0BhD;AA1BY,wCAAc"}
|
|
@@ -1,16 +1,67 @@
|
|
|
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
|
+
};
|
|
3
54
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
55
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
56
|
};
|
|
6
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
58
|
exports.IpfsRemoteData = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
59
|
+
var index_1 = __importDefault(require("../../dependencies/src/axios-0.19.0/index"));
|
|
60
|
+
var RemoteData_1 = require("./RemoteData");
|
|
61
|
+
var IPFS_SCHEME = 'ipfs';
|
|
62
|
+
var IPFS_HTTP_GATEWAY = 'https://dweb.link/ipfs';
|
|
63
|
+
var IPNS_SCHEME = 'ipns';
|
|
64
|
+
var IPNS_HTTP_GATEWAY = 'https://dweb.link/ipns';
|
|
14
65
|
function http(uri) {
|
|
15
66
|
if (uri.startsWith(IPFS_SCHEME)) {
|
|
16
67
|
return ipfs(uri);
|
|
@@ -23,36 +74,69 @@ function http(uri) {
|
|
|
23
74
|
}
|
|
24
75
|
}
|
|
25
76
|
function ipfs(uri) {
|
|
26
|
-
return
|
|
77
|
+
return "".concat(IPFS_HTTP_GATEWAY, "/").concat(uri.replace("".concat(IPFS_SCHEME, "://"), ''));
|
|
27
78
|
}
|
|
28
79
|
function ipns(uri) {
|
|
29
|
-
return
|
|
80
|
+
return "".concat(IPNS_HTTP_GATEWAY, "/").concat(uri.replace("".concat(IPNS_SCHEME, "://"), ''));
|
|
30
81
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
82
|
+
var IpfsRemoteData = /** @class */ (function (_super) {
|
|
83
|
+
__extends(IpfsRemoteData, _super);
|
|
84
|
+
function IpfsRemoteData() {
|
|
85
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
34
86
|
}
|
|
35
|
-
|
|
87
|
+
IpfsRemoteData.from = function (uri) {
|
|
88
|
+
return IpfsRemoteData.validate(uri) ? new IpfsRemoteData(uri) : undefined;
|
|
89
|
+
};
|
|
90
|
+
IpfsRemoteData.validate = function (uri) {
|
|
36
91
|
return uri.startsWith(IPFS_SCHEME) || uri.startsWith(IPNS_SCHEME);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
92
|
+
};
|
|
93
|
+
IpfsRemoteData.prototype.get = function () {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
var response;
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0: return [4 /*yield*/, this.getData()];
|
|
99
|
+
case 1:
|
|
100
|
+
response = _a.sent();
|
|
101
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
IpfsRemoteData.prototype.getRaw = function () {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
var response;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0: return [4 /*yield*/, this.getData('arraybuffer')];
|
|
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));
|
|
57
141
|
exports.IpfsRemoteData = IpfsRemoteData;
|
|
58
142
|
//# 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,oFAA8F;AAE9F,2CAAkD;AAElD,IAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,IAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAElD,IAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,IAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAElD,SAAS,IAAI,CAAC,GAAW;IACvB,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;KACjB;SAAM,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;KACjB;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,OAAO,UAAG,iBAAiB,cAAI,GAAG,CAAC,OAAO,CAAC,UAAG,WAAW,QAAK,EAAE,EAAE,CAAC,CAAE,CAAA;AACvE,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,OAAO,UAAG,iBAAiB,cAAI,GAAG,CAAC,OAAO,CAAC,UAAG,WAAW,QAAK,EAAE,EAAE,CAAC,CAAE,CAAA;AACvE,CAAC;AAED;IAAuC,kCAAa;IAApD;;IA+BA,CAAC;IA9Be,mBAAI,GAAlB,UAAsB,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;IAEa,uBAAQ,GAAtB,UAAuB,GAAW;QAChC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;IACnE,CAAC;IAEY,4BAAG,GAAhB;;;;;4BACiD,qBAAM,IAAI,CAAC,OAAO,EAAE,EAAA;;wBAA7D,QAAQ,GAAiC,SAAoB;wBACnE,sBAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAA;;;;KACtB;IAEY,+BAAM,GAAnB;;;;;4BAC2D,qBAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAA;;wBAApF,QAAQ,GAA2C,SAAiC;wBAC1F,sBAAO,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,EAAA;;;;KACnH;IAEa,gCAAO,GAArB,UAAyB,YAAmC;QAAnC,6BAAA,EAAA,qBAAmC;;;;;;wBAC1D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;4BACtC,sBAAO,SAAS,EAAA;yBACjB;wBAEK,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;wBAC1B,IAAI,CAAC,GAAG,EAAE;4BACR,sBAAO,SAAS,EAAA;yBACjB;wBAEM,qBAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,YAAY,cAAA,EAAE,CAAC,EAAA;4BAA7C,sBAAO,SAAsC,EAAA;;;;KAC9C;IACH,qBAAC;AAAD,CAAC,AA/BD,CAAuC,uBAAU,GA+BhD;AA/BY,wCAAc"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoteData = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var RemoteData = /** @class */ (function () {
|
|
5
|
+
function RemoteData(uri) {
|
|
6
6
|
this.uri = uri;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
return RemoteData;
|
|
9
|
+
}());
|
|
9
10
|
exports.RemoteData = RemoteData;
|
|
10
11
|
//# 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;IACE,oBAAsC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAIvD,iBAAC;AAAD,CAAC,AALD,IAKC;AALqB,gCAAU"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RemoteData } from './RemoteData';
|
|
2
|
-
type Validator = (uri: string) => boolean;
|
|
3
|
-
type Factory<T> = <S>(uri: string, extra: T) => RemoteData<S> | undefined;
|
|
2
|
+
declare type Validator = (uri: string) => boolean;
|
|
3
|
+
declare 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,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoteDataFactory = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
var HttpRemoteData_1 = require("./HttpRemoteData");
|
|
5
|
+
var IpfsRemoteData_1 = require("./IpfsRemoteData");
|
|
6
|
+
var Sha256RemoteData_1 = require("./Sha256RemoteData");
|
|
7
|
+
var RemoteDataFactory = /** @class */ (function () {
|
|
8
|
+
function RemoteDataFactory(extraFactoriesWithValidators) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (extraFactoriesWithValidators === void 0) { extraFactoriesWithValidators = []; }
|
|
9
11
|
this.factoriesWithValidators = [
|
|
10
|
-
[HttpRemoteData_1.HttpRemoteData.validate, (uri, _extra)
|
|
11
|
-
[IpfsRemoteData_1.IpfsRemoteData.validate, (uri, _extra)
|
|
12
|
-
[Sha256RemoteData_1.Sha256RemoteData.validate, (uri, _extra)
|
|
12
|
+
[HttpRemoteData_1.HttpRemoteData.validate, function (uri, _extra) { return HttpRemoteData_1.HttpRemoteData.from(uri); }],
|
|
13
|
+
[IpfsRemoteData_1.IpfsRemoteData.validate, function (uri, _extra) { return IpfsRemoteData_1.IpfsRemoteData.from(uri); }],
|
|
14
|
+
[Sha256RemoteData_1.Sha256RemoteData.validate, function (uri, _extra) { return Sha256RemoteData_1.Sha256RemoteData.from(uri); }]
|
|
13
15
|
];
|
|
14
|
-
this.factoriesWithValidators.push(
|
|
16
|
+
(_a = this.factoriesWithValidators).push.apply(_a, extraFactoriesWithValidators);
|
|
15
17
|
}
|
|
16
|
-
create(uri, extra) {
|
|
17
|
-
|
|
18
|
+
RemoteDataFactory.prototype.create = function (uri, extra) {
|
|
19
|
+
var _a;
|
|
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];
|
|
18
24
|
return factory ? factory(uri, extra) : undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
25
|
+
};
|
|
26
|
+
return RemoteDataFactory;
|
|
27
|
+
}());
|
|
21
28
|
exports.RemoteDataFactory = RemoteDataFactory;
|
|
22
29
|
//# 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,mDAAiD;AACjD,mDAAiD;AAEjD,uDAAqD;AAOrD;IAOE,2BAAmB,4BAA4D;;QAA5D,6CAAA,EAAA,iCAA4D;QAN5D,4BAAuB,GAA8B;YACtE,CAAC,+BAAc,CAAC,QAAQ,EAAE,UAAC,GAAW,EAAE,MAAS,IAAK,OAAA,+BAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAxB,CAAwB,CAAC;YAC/E,CAAC,+BAAc,CAAC,QAAQ,EAAE,UAAC,GAAW,EAAE,MAAS,IAAK,OAAA,+BAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAxB,CAAwB,CAAC;YAC/E,CAAC,mCAAgB,CAAC,QAAQ,EAAE,UAAC,GAAW,EAAE,MAAS,IAAK,OAAA,mCAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAA1B,CAA0B,CAAC;SACpF,CAAA;QAGC,CAAA,KAAA,IAAI,CAAC,uBAAuB,CAAA,CAAC,IAAI,WAAI,4BAA4B,EAAC;IACpE,CAAC;IAEM,kCAAM,GAAb,UAAiB,GAAW,EAAE,KAAQ;;QAC9B,IAAA,KAAc,MAAA,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAC,EAAc;gBAAb,SAAS,QAAA,EAAE,CAAC,QAAA;YAAM,OAAA,SAAS,CAAC,GAAG,CAAC;QAAd,CAAc,CAAC,mCAAI,CAAC,SAAS,EAAE,SAAS,CAAC,EAA1G,OAAO,QAAmG,CAAA;QAEnH,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAClD,CAAC;IACH,wBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,8CAAiB"}
|
|
@@ -1,66 +1,139 @@
|
|
|
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
|
+
};
|
|
2
53
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
54
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
55
|
};
|
|
5
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
57
|
exports.Sha256RemoteData = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
58
|
+
var index_1 = __importDefault(require("../../dependencies/src/axios-0.19.0/index"));
|
|
59
|
+
var sha = require("../../dependencies/src/sha.js-2.4.11/index");
|
|
60
|
+
var hex_1 = require("../hex");
|
|
61
|
+
var RemoteData_1 = require("./RemoteData");
|
|
62
|
+
var SHA256_SCHEME = 'sha256';
|
|
12
63
|
function parseUri(uri) {
|
|
13
|
-
|
|
14
|
-
return { hash, path };
|
|
64
|
+
var _a = uri.replace("".concat(SHA256_SCHEME, "://"), '').split(/\/(.+)/, 2), hash = _a[0], path = _a[1];
|
|
65
|
+
return { hash: hash, path: path };
|
|
15
66
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
67
|
+
var Sha256RemoteData = /** @class */ (function (_super) {
|
|
68
|
+
__extends(Sha256RemoteData, _super);
|
|
69
|
+
function Sha256RemoteData(uri, hash, path) {
|
|
70
|
+
var _this = _super.call(this, uri) || this;
|
|
71
|
+
_this.hash = hash;
|
|
72
|
+
_this.path = path;
|
|
73
|
+
return _this;
|
|
21
74
|
}
|
|
22
|
-
|
|
75
|
+
Sha256RemoteData.from = function (uri) {
|
|
23
76
|
if (!Sha256RemoteData.validate(uri)) {
|
|
24
77
|
return undefined;
|
|
25
78
|
}
|
|
26
|
-
|
|
79
|
+
var _a = parseUri(uri), hash = _a.hash, path = _a.path;
|
|
27
80
|
if (!hash || !path) {
|
|
28
81
|
return undefined;
|
|
29
82
|
}
|
|
30
83
|
return new Sha256RemoteData(uri, Buffer.from((0, hex_1.stripHexPrefix)(hash), 'hex'), decodeURIComponent(path));
|
|
31
|
-
}
|
|
32
|
-
|
|
84
|
+
};
|
|
85
|
+
Sha256RemoteData.validate = function (uri) {
|
|
33
86
|
if (!uri.startsWith(SHA256_SCHEME)) {
|
|
34
87
|
return false;
|
|
35
88
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
89
|
+
var _a = parseUri(uri), hash = _a.hash, path = _a.path;
|
|
90
|
+
var validHash = !!hash && hash.startsWith('0x');
|
|
91
|
+
var validPath = !!path;
|
|
39
92
|
return validHash && validPath;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
93
|
+
};
|
|
94
|
+
Sha256RemoteData.prototype.get = function () {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var data, decoder;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0: return [4 /*yield*/, this.getRaw()];
|
|
100
|
+
case 1:
|
|
101
|
+
data = _a.sent();
|
|
102
|
+
if (data === undefined) {
|
|
103
|
+
return [2 /*return*/, undefined];
|
|
104
|
+
}
|
|
105
|
+
decoder = new TextDecoder();
|
|
106
|
+
return [2 /*return*/, JSON.parse(decoder.decode(data.bytes.buffer))];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
Sha256RemoteData.prototype.getRaw = function () {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var response, data, hash;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
if (!Sha256RemoteData.validate(this.uri)) {
|
|
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));
|
|
65
138
|
exports.Sha256RemoteData = Sha256RemoteData;
|
|
66
139
|
//# sourceMappingURL=Sha256RemoteData.js.map
|