@koralabs/kora-labs-common 6.9.4 → 6.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aws/jwtSigner.d.ts +0 -2
- package/aws/kmsEnvironment.d.ts +0 -8
- package/aws/kmsEnvironment.js +4 -4
- package/aws/objectStore.d.ts +0 -8
- package/chain/cache/ShortTermCache.d.ts +17 -0
- package/chain/cache/ShortTermCache.js +46 -0
- package/chain/config.d.ts +9 -0
- package/chain/config.js +40 -0
- package/chain/datum/imageDatum.d.ts +14 -0
- package/chain/datum/imageDatum.js +87 -0
- package/chain/failover/ChainProviderFailover.d.ts +50 -0
- package/chain/failover/ChainProviderFailover.js +91 -0
- package/chain/failover/interfaces.d.ts +62 -0
- package/chain/failover/interfaces.js +2 -0
- package/chain/index.d.ts +9 -0
- package/chain/index.js +28 -0
- package/chain/providerConfig.d.ts +22 -0
- package/chain/providerConfig.js +13 -0
- package/chain/providers/Blockfrost.d.ts +59 -0
- package/chain/providers/Blockfrost.js +142 -0
- package/chain/providers/Koios.d.ts +68 -0
- package/chain/providers/Koios.js +214 -0
- package/chain/transport/fetchProviderJson.d.ts +26 -0
- package/chain/transport/fetchProviderJson.js +165 -0
- package/environment/index.js +4 -4
- package/fn/index.d.ts +0 -2
- package/fn/index.js +1 -1
- package/handles/api.js +0 -1
- package/handles/constants.js +1 -1
- package/handles/interfaces/ScriptDetails.js +1 -1
- package/handles/interfaces/api.js +3 -3
- package/handles/interfaces/index.d.ts +4 -4
- package/handles/interfaces/index.js +5 -5
- package/handles/policies.js +1 -1
- package/handles/utils.d.ts +1 -1
- package/logger/index.js +1 -1
- package/mpt/index.js +17 -7
- package/mpt/labelSet.d.ts +0 -2
- package/package.json +7 -7
- package/types/index.js +4 -4
- package/types/profile-header.js +2 -2
- package/utils/cbor/index.d.ts +4 -6
- package/utils/cbor/index.js +18 -8
- package/utils/crypto/index.d.ts +2 -4
- package/utils/crypto/index.js +23 -13
- package/utils/index.d.ts +5 -5
package/handles/api.js
CHANGED
package/handles/constants.js
CHANGED
|
@@ -31,7 +31,7 @@ var ERROR_TEXT;
|
|
|
31
31
|
ERROR_TEXT["HANDLE_PAGE_INVALID"] = "'page' must be a number";
|
|
32
32
|
ERROR_TEXT["HANDLE_SLOT_NUMBER_INVALID"] = "'slot_number' must be a number";
|
|
33
33
|
ERROR_TEXT["HANDLE_PAGE_AND_SLOT_NUMBER_INVALID"] = "'page' and 'slot_number' can't be used together";
|
|
34
|
-
})(ERROR_TEXT
|
|
34
|
+
})(ERROR_TEXT || (exports.ERROR_TEXT = ERROR_TEXT = {}));
|
|
35
35
|
exports.HANDLES_PER_PAGE_MAX = 1000;
|
|
36
36
|
exports.EMPTY = '|empty|';
|
|
37
37
|
exports.TWELVE_HOURS_IN_SLOTS = 43200; // value comes from the securityParam here: https://cips.cardano.org/cips/cip9/#nonupdatableparameters then converted to slots
|
|
@@ -19,4 +19,4 @@ var ScriptType;
|
|
|
19
19
|
ScriptType["HAL_REF_SPEND_PROXY"] = "halrefprx";
|
|
20
20
|
ScriptType["HAL_REF_SPEND"] = "halref";
|
|
21
21
|
ScriptType["HAL_ROYALTY_SPEND"] = "halroy";
|
|
22
|
-
})(ScriptType
|
|
22
|
+
})(ScriptType || (exports.ScriptType = ScriptType = {}));
|
|
@@ -6,7 +6,7 @@ var UTxOFunctionName;
|
|
|
6
6
|
UTxOFunctionName["ADD_UTXO"] = "addUtxo";
|
|
7
7
|
UTxOFunctionName["UPDATE_HOLDER_INDEX"] = "updateHolderIndex";
|
|
8
8
|
UTxOFunctionName["UPDATE_HANDLE_INDEXES"] = "updateHandleIndexes";
|
|
9
|
-
})(UTxOFunctionName
|
|
9
|
+
})(UTxOFunctionName || (exports.UTxOFunctionName = UTxOFunctionName = {}));
|
|
10
10
|
var LockedLambdaReason;
|
|
11
11
|
(function (LockedLambdaReason) {
|
|
12
12
|
LockedLambdaReason["REINDEX"] = "REINDEX";
|
|
@@ -16,7 +16,7 @@ var LockedLambdaReason;
|
|
|
16
16
|
LockedLambdaReason["ROLLBACK_20"] = "ROLLBACK_20";
|
|
17
17
|
LockedLambdaReason["UTXO_IMPORT"] = "UTXO_IMPORT";
|
|
18
18
|
LockedLambdaReason["UNLOCKED"] = "";
|
|
19
|
-
})(LockedLambdaReason
|
|
19
|
+
})(LockedLambdaReason || (exports.LockedLambdaReason = LockedLambdaReason = {}));
|
|
20
20
|
var IndexNames;
|
|
21
21
|
(function (IndexNames) {
|
|
22
22
|
IndexNames["ADDRESS"] = "address";
|
|
@@ -39,4 +39,4 @@ var IndexNames;
|
|
|
39
39
|
IndexNames["SUBHANDLE"] = "subhandle";
|
|
40
40
|
IndexNames["UTXO"] = "utxo";
|
|
41
41
|
IndexNames["UTXO_SLOT"] = "utxo_slot";
|
|
42
|
-
})(IndexNames
|
|
42
|
+
})(IndexNames || (exports.IndexNames = IndexNames = {}));
|
|
@@ -2,10 +2,10 @@ import { BoolInt, FeaturedItemType, HexString, HexStringOrEmpty } from '../../ty
|
|
|
2
2
|
import type { ScriptDetails } from './ScriptDetails';
|
|
3
3
|
import { UTxOWithTxInfo } from '../UTxO';
|
|
4
4
|
export declare enum Rarity {
|
|
5
|
-
basic = "basic"
|
|
6
|
-
common = "common"
|
|
7
|
-
rare = "rare"
|
|
8
|
-
ultra_rare = "ultra_rare"
|
|
5
|
+
basic = "basic",// - 8-15 characters
|
|
6
|
+
common = "common",// - 4-7 characters
|
|
7
|
+
rare = "rare",// - 3 characters
|
|
8
|
+
ultra_rare = "ultra_rare",// - 2 characters
|
|
9
9
|
legendary = "legendary"
|
|
10
10
|
}
|
|
11
11
|
export interface SocialItem {
|
|
@@ -22,18 +22,18 @@ var Rarity;
|
|
|
22
22
|
Rarity["rare"] = "rare";
|
|
23
23
|
Rarity["ultra_rare"] = "ultra_rare";
|
|
24
24
|
Rarity["legendary"] = "legendary"; // - 1 character
|
|
25
|
-
})(Rarity
|
|
25
|
+
})(Rarity || (exports.Rarity = Rarity = {}));
|
|
26
26
|
var HandleType;
|
|
27
27
|
(function (HandleType) {
|
|
28
28
|
HandleType["VIRTUAL_SUBHANDLE"] = "virtual_subhandle";
|
|
29
29
|
HandleType["NFT_SUBHANDLE"] = "nft_subhandle";
|
|
30
30
|
HandleType["HANDLE"] = "handle";
|
|
31
|
-
})(HandleType
|
|
31
|
+
})(HandleType || (exports.HandleType = HandleType = {}));
|
|
32
32
|
var SubHandleType;
|
|
33
33
|
(function (SubHandleType) {
|
|
34
34
|
SubHandleType["VIRTUAL"] = "virtual";
|
|
35
35
|
SubHandleType["NFT"] = "nft";
|
|
36
|
-
})(SubHandleType
|
|
36
|
+
})(SubHandleType || (exports.SubHandleType = SubHandleType = {}));
|
|
37
37
|
var OAuthSocial;
|
|
38
38
|
(function (OAuthSocial) {
|
|
39
39
|
OAuthSocial[OAuthSocial["twitter"] = 0] = "twitter";
|
|
@@ -55,7 +55,7 @@ var OAuthSocial;
|
|
|
55
55
|
OAuthSocial[OAuthSocial["spotify"] = 16] = "spotify";
|
|
56
56
|
OAuthSocial[OAuthSocial["soundcloud"] = 17] = "soundcloud";
|
|
57
57
|
OAuthSocial[OAuthSocial["paypal"] = 18] = "paypal";
|
|
58
|
-
})(OAuthSocial
|
|
58
|
+
})(OAuthSocial || (exports.OAuthSocial = OAuthSocial = {}));
|
|
59
59
|
var AvailabilityResponseCode;
|
|
60
60
|
(function (AvailabilityResponseCode) {
|
|
61
61
|
AvailabilityResponseCode[AvailabilityResponseCode["AVAILABLE"] = 200] = "AVAILABLE";
|
|
@@ -63,5 +63,5 @@ var AvailabilityResponseCode;
|
|
|
63
63
|
AvailabilityResponseCode[AvailabilityResponseCode["NOT_AVAILABLE_FOR_LEGAL_REASONS"] = 451] = "NOT_AVAILABLE_FOR_LEGAL_REASONS";
|
|
64
64
|
AvailabilityResponseCode[AvailabilityResponseCode["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
65
65
|
AvailabilityResponseCode[AvailabilityResponseCode["LOCKED"] = 423] = "LOCKED";
|
|
66
|
-
})(AvailabilityResponseCode
|
|
66
|
+
})(AvailabilityResponseCode || (exports.AvailabilityResponseCode = AvailabilityResponseCode = {}));
|
|
67
67
|
__exportStar(require("./WalletHandle"), exports);
|
package/handles/policies.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.HANDLE_POLICIES = {
|
|
|
18
18
|
getActivePolicy(network, isDeMi = false, atSlot) {
|
|
19
19
|
var _a;
|
|
20
20
|
const theSlot = atSlot ? atSlot : (0, utils_1.getSlotNumberFromDate)(new Date(Date.now()));
|
|
21
|
-
return (_a = Object.entries(this[network]).find(([, value]) => { var _a; return value.firstMintingSlot <= theSlot && ((_a = value.lastMintingSlot) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY) >= theSlot && value.isDeMi == isDeMi; })) === null || _a === void 0 ? void 0 : _a[0];
|
|
21
|
+
return (_a = Object.entries(this[network]).find(([, value]) => { var _a, _b; return value.firstMintingSlot <= theSlot && ((_a = value.lastMintingSlot) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY) >= theSlot && ((_b = value.isDeMi) !== null && _b !== void 0 ? _b : false) == isDeMi; })) === null || _a === void 0 ? void 0 : _a[0];
|
|
22
22
|
},
|
|
23
23
|
contains(network, policyId) {
|
|
24
24
|
return Object.keys(this[network]).includes(policyId);
|
package/handles/utils.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const buildMetadata: ({ handleName, handleType, cid, ogNumber }:
|
|
|
7
7
|
handleName: string;
|
|
8
8
|
handleType: HandleType;
|
|
9
9
|
cid: string;
|
|
10
|
-
ogNumber?: number
|
|
10
|
+
ogNumber?: number;
|
|
11
11
|
}) => IHandleMetadata;
|
|
12
12
|
export declare const checkHandlePattern: (handle: string, root?: string) => {
|
|
13
13
|
valid: boolean;
|
package/logger/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var LogCategory;
|
|
|
26
26
|
LogCategory["FATAL"] = "FATAL";
|
|
27
27
|
LogCategory["NOTIFY"] = "NOTIFY";
|
|
28
28
|
LogCategory["USER_ISSUE"] = "USER_ISSUE";
|
|
29
|
-
})(LogCategory
|
|
29
|
+
})(LogCategory || (exports.LogCategory = LogCategory = {}));
|
|
30
30
|
const ANSI_RESET = '\x1b[0m';
|
|
31
31
|
const ANSI_BLUE = '\x1b[34m';
|
|
32
32
|
const ANSI_GREEN = '\x1b[32m';
|
package/mpt/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.computeMintingDataRoot = exports.buildMintingDataTrie = exports.Trie = exports.labelSet = void 0;
|
|
27
37
|
// Server-only (Node) MPT module. Pulls @aiken-lang/merkle-patricia-forestry (native `level`/`blake2b`)
|
package/mpt/labelSet.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
/** Does the canonical label set contain `label`? */
|
|
4
2
|
export declare const contains: (set: string, label: string) => boolean;
|
|
5
3
|
/** Insert `label`, keeping the set sorted ascending. Throws if already present. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koralabs/kora-labs-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.11.0",
|
|
4
4
|
"description": "Kora Labs Common Utilities",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"@types/jest": "^30.0.0",
|
|
44
44
|
"@types/node": "^22.15.17",
|
|
45
45
|
"@types/pluralize": "^0.0.29",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
47
|
-
"@typescript-eslint/parser": "^
|
|
48
|
-
"eslint": "^8.57.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
|
47
|
+
"@typescript-eslint/parser": "^8.67.0",
|
|
48
|
+
"eslint": "^8.57.1",
|
|
49
49
|
"jest": "^30.4.2",
|
|
50
50
|
"ts-jest": "^29.4.11",
|
|
51
|
-
"typescript": "^
|
|
51
|
+
"typescript": "^5.9.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@aws-sdk/client-kms": "^3.1003.0",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"pluralize-esm": "^9.0.5"
|
|
64
64
|
},
|
|
65
65
|
"overrides": {
|
|
66
|
-
"js-yaml": "4.3.
|
|
67
|
-
"brace-expansion": "5.0.
|
|
66
|
+
"js-yaml": "4.3.1",
|
|
67
|
+
"brace-expansion": "5.0.9"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@aiken-lang/merkle-patricia-forestry": "^1.2.0"
|
package/types/index.js
CHANGED
|
@@ -32,14 +32,14 @@ var AssetNameLabel;
|
|
|
32
32
|
AssetNameLabel["LBL_100"] = "000643b0";
|
|
33
33
|
AssetNameLabel["LBL_222"] = "000de140";
|
|
34
34
|
AssetNameLabel["LBL_444"] = "001bc280";
|
|
35
|
-
})(AssetNameLabel
|
|
35
|
+
})(AssetNameLabel || (exports.AssetNameLabel = AssetNameLabel = {}));
|
|
36
36
|
var CardanoNetwork;
|
|
37
37
|
(function (CardanoNetwork) {
|
|
38
38
|
CardanoNetwork["MAINNET"] = "MAINNET";
|
|
39
39
|
CardanoNetwork["PREPROD"] = "PREPROD";
|
|
40
40
|
CardanoNetwork["PREVIEW"] = "PREVIEW";
|
|
41
41
|
CardanoNetwork["UNSET"] = "UNSET";
|
|
42
|
-
})(CardanoNetwork
|
|
42
|
+
})(CardanoNetwork || (exports.CardanoNetwork = CardanoNetwork = {}));
|
|
43
43
|
var AddressType;
|
|
44
44
|
(function (AddressType) {
|
|
45
45
|
AddressType["Wallet"] = "wallet";
|
|
@@ -48,9 +48,9 @@ var AddressType;
|
|
|
48
48
|
AddressType["Reward"] = "reward";
|
|
49
49
|
AddressType["Other"] = "other";
|
|
50
50
|
AddressType["Drep"] = "drep";
|
|
51
|
-
})(AddressType
|
|
51
|
+
})(AddressType || (exports.AddressType = AddressType = {}));
|
|
52
52
|
var StakeAddressType;
|
|
53
53
|
(function (StakeAddressType) {
|
|
54
54
|
StakeAddressType["Script"] = "f";
|
|
55
55
|
StakeAddressType["Key"] = "e";
|
|
56
|
-
})(StakeAddressType
|
|
56
|
+
})(StakeAddressType || (exports.StakeAddressType = StakeAddressType = {}));
|
package/types/profile-header.js
CHANGED
|
@@ -7,11 +7,11 @@ var ProfileHeaderBannerImageTypes;
|
|
|
7
7
|
ProfileHeaderBannerImageTypes["circuit_board"] = "circuit_board";
|
|
8
8
|
ProfileHeaderBannerImageTypes["hidden"] = "hidden";
|
|
9
9
|
ProfileHeaderBannerImageTypes["asset"] = "asset";
|
|
10
|
-
})(ProfileHeaderBannerImageTypes
|
|
10
|
+
})(ProfileHeaderBannerImageTypes || (exports.ProfileHeaderBannerImageTypes = ProfileHeaderBannerImageTypes = {}));
|
|
11
11
|
var ProfileHeaderPFPImageTypes;
|
|
12
12
|
(function (ProfileHeaderPFPImageTypes) {
|
|
13
13
|
ProfileHeaderPFPImageTypes["personalized_handle"] = "personalized_handle";
|
|
14
14
|
ProfileHeaderPFPImageTypes["pfp"] = "pfp";
|
|
15
15
|
ProfileHeaderPFPImageTypes["hidden"] = "hidden";
|
|
16
16
|
ProfileHeaderPFPImageTypes["asset"] = "asset";
|
|
17
|
-
})(ProfileHeaderPFPImageTypes
|
|
17
|
+
})(ProfileHeaderPFPImageTypes || (exports.ProfileHeaderPFPImageTypes = ProfileHeaderPFPImageTypes = {}));
|
package/utils/cbor/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
export { designerSchema } from './schema/designer';
|
|
4
2
|
export { handleDatumSchema } from './schema/handleData';
|
|
5
3
|
export { marketplaceDatumSchema } from './schema/marketplaceDatum';
|
|
@@ -44,8 +42,8 @@ declare class JsonToDatumObject {
|
|
|
44
42
|
json: any;
|
|
45
43
|
options: EncodeOptions;
|
|
46
44
|
constructor(json: any, options?: EncodeOptions);
|
|
47
|
-
getFormattedKey: (key: string) => string | number | Buffer
|
|
48
|
-
getHexOrString: (str: string) => string | Buffer
|
|
45
|
+
getFormattedKey: (key: string) => string | number | Buffer<ArrayBuffer>;
|
|
46
|
+
getHexOrString: (str: string) => string | Buffer<ArrayBuffer>;
|
|
49
47
|
encodeCBOR: (encoder: any) => any;
|
|
50
48
|
keyIsNumeric: (key: any) => boolean | undefined;
|
|
51
49
|
}
|
|
@@ -57,6 +55,6 @@ export declare const encodeJsonToDatum: (json: any, options?: EncodeOptions) =>
|
|
|
57
55
|
export declare const decodeCborToJson: ({ cborString, schema, defaultKeyType, forJson }: {
|
|
58
56
|
cborString: string;
|
|
59
57
|
schema?: any;
|
|
60
|
-
defaultKeyType?: DefaultTextFormat
|
|
61
|
-
forJson?: boolean
|
|
58
|
+
defaultKeyType?: DefaultTextFormat;
|
|
59
|
+
forJson?: boolean;
|
|
62
60
|
}) => any;
|
package/utils/cbor/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.decodeCborToJson = exports.encodeJsonToDatum = exports.DupeKey = exports.DefaultTextFormat = exports.subHandleSettingsDatumSchema = exports.socialsSchema = exports.portalSchema = exports.marketplaceDatumSchema = exports.handleDatumSchema = exports.designerSchema = void 0;
|
|
27
37
|
const boolean_1 = require("boolean");
|
|
@@ -53,7 +63,7 @@ var DefaultTextFormat;
|
|
|
53
63
|
(function (DefaultTextFormat) {
|
|
54
64
|
DefaultTextFormat["UTF8"] = "utf8";
|
|
55
65
|
DefaultTextFormat["HEX"] = "hex";
|
|
56
|
-
})(DefaultTextFormat
|
|
66
|
+
})(DefaultTextFormat || (exports.DefaultTextFormat = DefaultTextFormat = {}));
|
|
57
67
|
class JsonToDatumObject {
|
|
58
68
|
constructor(json, options) {
|
|
59
69
|
var _a, _b;
|
package/utils/crypto/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { AddressDetails, AddressType, AssetNameLabel } from '../../types';
|
|
4
2
|
export declare const getNativeCrypto: () => Promise<any>;
|
|
5
3
|
export declare function dec2hex(dec: number): string;
|
|
@@ -18,8 +16,8 @@ export declare const getPaymentAddressType: (headerByte: number) => AddressType;
|
|
|
18
16
|
export declare const buildPaymentAddressType: (address: string) => AddressType;
|
|
19
17
|
export declare const buildStakeKey: (address: string) => string | null;
|
|
20
18
|
export declare const getPaymentKeyHash: (address: string) => string | null;
|
|
21
|
-
export declare const bech32FromHex: (hex: string, isTestnet?: boolean, type?:
|
|
22
|
-
export declare const bech32AddressFromHashes: (paymentHash: string, paymentHashType?:
|
|
19
|
+
export declare const bech32FromHex: (hex: string, isTestnet?: boolean, type?: "addr" | "stake" | "pool" | "drep" | "cc_hot" | "cc_cold") => string;
|
|
20
|
+
export declare const bech32AddressFromHashes: (paymentHash: string, paymentHashType?: "key" | "script", stakeHash?: string, stakeHashType?: "key" | "script", type?: "addr" | "stake", isTestnet?: boolean) => string;
|
|
23
21
|
export declare const buildHolderInfo: (addr: string) => AddressDetails;
|
|
24
22
|
export declare const getDateStringFromSlot: (currentSlot: number) => Date;
|
|
25
23
|
export declare const getSlotNumberFromDate: (date: Date) => number;
|
package/utils/crypto/index.js
CHANGED
|
@@ -15,18 +15,32 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.blake2b = exports.addressHexToBech32 = exports.getSlotNumberFromDate = exports.getDateStringFromSlot = exports.buildHolderInfo = exports.bech32AddressFromHashes = exports.bech32FromHex = exports.getPaymentKeyHash = exports.buildStakeKey = exports.buildPaymentAddressType = exports.getPaymentAddressType = exports.checkNameLabel = exports.parseAssetNameLabel = exports.decodeAddress = exports.
|
|
39
|
+
exports.blake2b = exports.addressHexToBech32 = exports.getSlotNumberFromDate = exports.getDateStringFromSlot = exports.buildHolderInfo = exports.bech32AddressFromHashes = exports.bech32FromHex = exports.getPaymentKeyHash = exports.buildStakeKey = exports.buildPaymentAddressType = exports.getPaymentAddressType = exports.checkNameLabel = exports.parseAssetNameLabel = exports.decodeAddress = exports.sha256 = exports.getNativeCrypto = void 0;
|
|
40
|
+
exports.dec2hex = dec2hex;
|
|
41
|
+
exports.getRandomCodeVerifier = getRandomCodeVerifier;
|
|
42
|
+
exports.base64urlencode = base64urlencode;
|
|
43
|
+
exports.getChallengeFromVerifier = getChallengeFromVerifier;
|
|
30
44
|
const bech32_1 = require("bech32");
|
|
31
45
|
const blakejs_1 = require("blakejs");
|
|
32
46
|
const bs58_1 = __importDefault(require("bs58"));
|
|
@@ -48,14 +62,12 @@ exports.getNativeCrypto = getNativeCrypto;
|
|
|
48
62
|
function dec2hex(dec) {
|
|
49
63
|
return ('0' + dec.toString(16)).slice(-2);
|
|
50
64
|
}
|
|
51
|
-
exports.dec2hex = dec2hex;
|
|
52
65
|
async function getRandomCodeVerifier(length) {
|
|
53
66
|
const crypto = await (0, exports.getNativeCrypto)();
|
|
54
67
|
const array = new Uint32Array(length / 2);
|
|
55
68
|
crypto.getRandomValues(array);
|
|
56
69
|
return Array.from(array, dec2hex).join('');
|
|
57
70
|
}
|
|
58
|
-
exports.getRandomCodeVerifier = getRandomCodeVerifier;
|
|
59
71
|
const sha256 = async (plain) => {
|
|
60
72
|
const crypto = await (0, exports.getNativeCrypto)();
|
|
61
73
|
const encoder = new TextEncoder();
|
|
@@ -75,20 +87,18 @@ function base64urlencode(a) {
|
|
|
75
87
|
.replace(/\//g, '_')
|
|
76
88
|
.replace(/=+$/, '');
|
|
77
89
|
}
|
|
78
|
-
exports.base64urlencode = base64urlencode;
|
|
79
90
|
async function getChallengeFromVerifier(verifier) {
|
|
80
91
|
const hashed = await (0, exports.sha256)(verifier);
|
|
81
92
|
const base64encoded = base64urlencode(hashed);
|
|
82
93
|
return base64encoded;
|
|
83
94
|
}
|
|
84
|
-
exports.getChallengeFromVerifier = getChallengeFromVerifier;
|
|
85
95
|
const decodeAddress = (address) => {
|
|
86
96
|
try {
|
|
87
97
|
const addressWords = bech32_1.bech32.decode(address, address.length);
|
|
88
98
|
const payload = bech32_1.bech32.fromWords(addressWords.words);
|
|
89
99
|
return `${Buffer.from(payload).toString('hex')}`;
|
|
90
100
|
}
|
|
91
|
-
catch (
|
|
101
|
+
catch (_a) {
|
|
92
102
|
return null;
|
|
93
103
|
}
|
|
94
104
|
};
|
package/utils/index.d.ts
CHANGED
|
@@ -13,18 +13,18 @@ export declare const getElapsedTime: (milliseconds: number) => string;
|
|
|
13
13
|
export declare const objectHasKeys: (o: any) => boolean;
|
|
14
14
|
export declare const isEmpty: (obj: any) => boolean;
|
|
15
15
|
export declare const isObject: (o: any) => boolean;
|
|
16
|
-
export declare const hasOwnProperty: (o: any, v: PropertyKey) => boolean;
|
|
17
|
-
export declare const isDate: (d: any) =>
|
|
16
|
+
export declare const hasOwnProperty: (o: any, ...args: [v: PropertyKey]) => boolean;
|
|
17
|
+
export declare const isDate: (d: any) => d is Date;
|
|
18
18
|
export declare const isEmptyObject: (o: any) => boolean;
|
|
19
19
|
export declare const makeObjectWithoutPrototype: () => any;
|
|
20
|
-
export declare const ExcludesFalse: <T>(n?: T |
|
|
20
|
+
export declare const ExcludesFalse: <T>(n?: T | undefined | null) => n is T;
|
|
21
21
|
export declare const diff: (lhs: any, rhs: any) => any;
|
|
22
22
|
export declare const mapStringifyReplacer: (_key: any, value: any) => any;
|
|
23
23
|
export declare const mapNoKeysStringifyReplacer: (_key: any, value: any) => any;
|
|
24
24
|
export declare const USER_ISSUE_TRACKING_ID_REGEX: RegExp;
|
|
25
25
|
export declare const createUserIssueTrackingId: ({ timestamp, random }?: {
|
|
26
|
-
timestamp?: number
|
|
27
|
-
random?: (
|
|
26
|
+
timestamp?: number;
|
|
27
|
+
random?: () => number;
|
|
28
28
|
}) => string;
|
|
29
29
|
export declare const isUserIssueTrackingId: (value: unknown) => value is string;
|
|
30
30
|
export declare const normalizeUserIssueEventSegment: (value: string) => string;
|