@locuschain/lib 0.1.33 → 0.1.35
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/dist/index.umd.d.mts +15 -0
- package/dist/umd/index.umd.js +26296 -0
- package/dist/utils/index.cjs.cjs +34 -5
- package/dist/utils/index.esm.js +34 -5
- package/dist/utils/tx-validator.d.mts +2 -0
- package/package.json +4 -4
- package/dist/accounts/index.amd.js +0 -306
- package/dist/autogen/index.amd.js +0 -151
- package/dist/chunks/account-BSrvZ7S8.js +0 -77
- package/dist/chunks/address-class-Dp7aNQb2.js +0 -18
- package/dist/chunks/base-B_kRRfsf.js +0 -27
- package/dist/chunks/debugWalletActions-BDz-h2tl.js +0 -993
- package/dist/chunks/keystore-BexHKV9z.js +0 -143
- package/dist/chunks/lclib-BfTIyj-E.js +0 -3838
- package/dist/chunks/rpc-C4n7t9y0.js +0 -25
- package/dist/chunks/transport-BBAz1kmP.js +0 -30
- package/dist/chunks/tslib.es6-D29rxPkW.js +0 -37
- package/dist/chunks/tx-type-CS4wIUJ8.js +0 -68
- package/dist/chunks/wasm-3Ghi_Hxd.js +0 -213
- package/dist/clients/index.amd.js +0 -97
- package/dist/constant/index.amd.js +0 -458
- package/dist/contracts/index.amd.js +0 -19640
- package/dist/errors/index.amd.js +0 -17
- package/dist/index.amd.js +0 -43
- package/dist/transports/index.amd.js +0 -98
- package/dist/utils/index.amd.js +0 -323
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
define(['exports', './wasm-3Ghi_Hxd', './base-B_kRRfsf', './account-BSrvZ7S8'], (function (exports, wasm, base, account) { 'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 새 dual-key keystore 를 만들고 결과 JSON array 를 master / normal 두
|
|
5
|
-
* 반쪽으로 분리한다. 각 반쪽은 독립적으로 영속화한 뒤 unlockMasterKeystore
|
|
6
|
-
* / unlockNormalKeystore 로 다시 unlock 할 수 있다.
|
|
7
|
-
*
|
|
8
|
-
* WASM 의 `createAccountAndKeystore` 에 대한 얇은 래퍼다. `utils/index.mts`
|
|
9
|
-
* 가 raw WASM export 도 함께 re-export 하므로 충돌을 피하려고 이름을
|
|
10
|
-
* 새로 붙였다.
|
|
11
|
-
*/
|
|
12
|
-
function createKeystoreBundle(args) {
|
|
13
|
-
var _a, _b;
|
|
14
|
-
const raw = wasm.createAccountAndKeystore({
|
|
15
|
-
passwordMaster: args.passwordMaster,
|
|
16
|
-
passwordNormal: args.passwordNormal,
|
|
17
|
-
algoMaster: (_a = args.algoMaster) !== null && _a !== void 0 ? _a : '',
|
|
18
|
-
algoNormal: (_b = args.algoNormal) !== null && _b !== void 0 ? _b : '',
|
|
19
|
-
});
|
|
20
|
-
const { masterKsJson, normalKsJson } = splitKeystoreBundle(raw);
|
|
21
|
-
return { raw, masterKsJson, normalKsJson };
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* WASM `createAccountAndKeystore` 헬퍼가 반환한 `[master, normal]` keystore
|
|
25
|
-
* 배열을 두 JSON 문자열로 분리한다.
|
|
26
|
-
*/
|
|
27
|
-
function splitKeystoreBundle(bundleJson) {
|
|
28
|
-
let parsed;
|
|
29
|
-
try {
|
|
30
|
-
parsed = JSON.parse(bundleJson);
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
throw new base.BaseError('splitKeystoreBundle: bundle is not valid JSON', { cause: err });
|
|
34
|
-
}
|
|
35
|
-
if (!Array.isArray(parsed) || parsed.length !== 2) {
|
|
36
|
-
throw new base.BaseError(`splitKeystoreBundle: expected a JSON array of length 2, got length ${Array.isArray(parsed) ? parsed.length : 'n/a'}`);
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
masterKsJson: JSON.stringify(parsed[0]),
|
|
40
|
-
normalKsJson: JSON.stringify(parsed[1]),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* master keystore JSON 을 password 로 복호화한다.
|
|
45
|
-
*
|
|
46
|
-
* WASM 헬퍼가 emit 하는 lowercase-camelCase 필드 (`address`, `mkeyAlgorithm`,
|
|
47
|
-
* `msecretKey`, `mpublicKey`) 를 그대로 반환한다.
|
|
48
|
-
*/
|
|
49
|
-
function unlockMasterKeystore(args) {
|
|
50
|
-
const raw = wasm.loadMasterKeystore({
|
|
51
|
-
passStr: args.password,
|
|
52
|
-
ksJson: args.ksJson,
|
|
53
|
-
});
|
|
54
|
-
let parsed;
|
|
55
|
-
try {
|
|
56
|
-
parsed = JSON.parse(raw);
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
throw new base.BaseError('unlockMasterKeystore: WASM returned non-JSON', { cause: err });
|
|
60
|
-
}
|
|
61
|
-
assertField(parsed, 'address', 'unlockMasterKeystore');
|
|
62
|
-
assertField(parsed, 'msecretKey', 'unlockMasterKeystore');
|
|
63
|
-
assertField(parsed, 'mpublicKey', 'unlockMasterKeystore');
|
|
64
|
-
return parsed;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* normal keystore JSON 을 password 로 복호화한다.
|
|
68
|
-
*
|
|
69
|
-
* WASM 헬퍼가 emit 하는 lowercase-camelCase 필드 (`address`, `nkeyAlgorithm`,
|
|
70
|
-
* `nsecretKey`, `npublicKey`, `keyBind`) 를 그대로 반환한다.
|
|
71
|
-
*/
|
|
72
|
-
function unlockNormalKeystore(args) {
|
|
73
|
-
const raw = wasm.loadNormalKeystore({
|
|
74
|
-
passStr: args.password,
|
|
75
|
-
ksJson: args.ksJson,
|
|
76
|
-
});
|
|
77
|
-
let parsed;
|
|
78
|
-
try {
|
|
79
|
-
parsed = JSON.parse(raw);
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
throw new base.BaseError('unlockNormalKeystore: WASM returned non-JSON', { cause: err });
|
|
83
|
-
}
|
|
84
|
-
assertField(parsed, 'address', 'unlockNormalKeystore');
|
|
85
|
-
assertField(parsed, 'nsecretKey', 'unlockNormalKeystore');
|
|
86
|
-
assertField(parsed, 'npublicKey', 'unlockNormalKeystore');
|
|
87
|
-
return parsed;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* one-shot 헬퍼: 전체 `[master, normal]` keystore JSON 과 두 password 를
|
|
91
|
-
* 받아 `keysToAccount` 가 소비하는 평탄한 (address, msk, mpk, nsk, npk)
|
|
92
|
-
* tuple 을 반환한다.
|
|
93
|
-
*/
|
|
94
|
-
function unlockKeystoreBundle(args) {
|
|
95
|
-
const halves = typeof args.ksJsonBundle === 'string'
|
|
96
|
-
? splitKeystoreBundle(args.ksJsonBundle)
|
|
97
|
-
: {
|
|
98
|
-
masterKsJson: args.ksJsonBundle.masterKsJson,
|
|
99
|
-
normalKsJson: args.ksJsonBundle.normalKsJson,
|
|
100
|
-
};
|
|
101
|
-
const master = unlockMasterKeystore({
|
|
102
|
-
ksJson: halves.masterKsJson,
|
|
103
|
-
password: args.passwordMaster,
|
|
104
|
-
});
|
|
105
|
-
const normal = unlockNormalKeystore({
|
|
106
|
-
ksJson: halves.normalKsJson,
|
|
107
|
-
password: args.passwordNormal,
|
|
108
|
-
});
|
|
109
|
-
if (master.address !== normal.address) {
|
|
110
|
-
throw new base.BaseError(`unlockKeystoreBundle: keystore address mismatch (master=${master.address} normal=${normal.address})`);
|
|
111
|
-
}
|
|
112
|
-
if (master.mpublicKey === normal.npublicKey) {
|
|
113
|
-
throw new account.DegenerateKeyError({
|
|
114
|
-
source: 'unlockKeystoreBundle',
|
|
115
|
-
algoMaster: master.mkeyAlgorithm,
|
|
116
|
-
algoNormal: normal.nkeyAlgorithm,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
address: master.address,
|
|
121
|
-
msk: master.msecretKey,
|
|
122
|
-
mpk: master.mpublicKey,
|
|
123
|
-
nsk: normal.nsecretKey,
|
|
124
|
-
npk: normal.npublicKey,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function assertField(obj, key, fn) {
|
|
128
|
-
if (!obj || typeof obj !== 'object') {
|
|
129
|
-
throw new base.BaseError(`${fn}: WASM result is not an object`);
|
|
130
|
-
}
|
|
131
|
-
const v = obj[key];
|
|
132
|
-
if (typeof v !== 'string' || v.length === 0) {
|
|
133
|
-
throw new base.BaseError(`${fn}: WASM result missing '${key}'`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
exports.createKeystoreBundle = createKeystoreBundle;
|
|
138
|
-
exports.splitKeystoreBundle = splitKeystoreBundle;
|
|
139
|
-
exports.unlockKeystoreBundle = unlockKeystoreBundle;
|
|
140
|
-
exports.unlockMasterKeystore = unlockMasterKeystore;
|
|
141
|
-
exports.unlockNormalKeystore = unlockNormalKeystore;
|
|
142
|
-
|
|
143
|
-
}));
|