@beclab/olaresid 0.1.4 → 0.1.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/dist/business/index.d.ts +3 -3
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business/index.js +49 -64
- package/dist/business/index.js.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/crypto-utils.d.ts +32 -4
- package/dist/utils/crypto-utils.d.ts.map +1 -1
- package/dist/utils/crypto-utils.js +93 -31
- package/dist/utils/crypto-utils.js.map +1 -1
- package/examples/crypto-utilities.ts +3 -3
- package/examples/ed25519-jwk.ts +1 -1
- package/examples/encoding-utils.ts +96 -0
- package/examples/generate-mnemonic.ts +3 -3
- package/examples/register-subdomain.ts +4 -3
- package/examples/transfer-domain.ts +1 -1
- package/examples/wallet-management.ts +8 -8
- package/package.json +1 -3
- package/src/business/index.ts +46 -58
- package/src/cli.ts +3 -3
- package/src/index.ts +6 -1
- package/src/utils/crypto-utils.ts +110 -33
|
@@ -40,6 +40,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
};
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.base64ToUint8Array = base64ToUint8Array;
|
|
44
|
+
exports.uint8ArrayToHex = uint8ArrayToHex;
|
|
45
|
+
exports.hexToUint8Array = hexToUint8Array;
|
|
46
|
+
exports.uint8ArrayToBase64 = uint8ArrayToBase64;
|
|
43
47
|
exports.generateMnemonic = generateMnemonic;
|
|
44
48
|
exports.getEthereumAddressFromMnemonic = getEthereumAddressFromMnemonic;
|
|
45
49
|
exports.getEVMPrivateKeyFromMnemonic = getEVMPrivateKeyFromMnemonic;
|
|
@@ -48,11 +52,60 @@ exports.getEd25519JwkFromMnemonic = getEd25519JwkFromMnemonic;
|
|
|
48
52
|
exports.deriveDIDFromMnemonic = deriveDIDFromMnemonic;
|
|
49
53
|
exports.generateDIDKeyData = generateDIDKeyData;
|
|
50
54
|
exports.createRsaKeyPair = createRsaKeyPair;
|
|
51
|
-
const bip39 = __importStar(require("bip39"));
|
|
52
55
|
const varint = __importStar(require("varint"));
|
|
53
56
|
const base58_1 = require("multiformats/bases/base58");
|
|
54
57
|
const base64_1 = require("multiformats/bases/base64");
|
|
55
58
|
// ============================================================================
|
|
59
|
+
// Cross-platform encoding utilities (Browser + Node.js compatible)
|
|
60
|
+
// ============================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Convert base64 string to Uint8Array (cross-platform)
|
|
63
|
+
* Works in both browser and Node.js environments
|
|
64
|
+
* @param base64 base64 encoded string
|
|
65
|
+
* @returns Uint8Array
|
|
66
|
+
*/
|
|
67
|
+
function base64ToUint8Array(base64) {
|
|
68
|
+
const binaryString = atob(base64);
|
|
69
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
70
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
71
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
72
|
+
}
|
|
73
|
+
return bytes;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Convert Uint8Array to hex string (cross-platform)
|
|
77
|
+
* @param bytes Uint8Array to convert
|
|
78
|
+
* @returns hex string without '0x' prefix
|
|
79
|
+
*/
|
|
80
|
+
function uint8ArrayToHex(bytes) {
|
|
81
|
+
return Array.from(bytes)
|
|
82
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
83
|
+
.join('');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Convert hex string to Uint8Array (cross-platform)
|
|
87
|
+
* @param hex hex string (with or without '0x' prefix)
|
|
88
|
+
* @returns Uint8Array
|
|
89
|
+
*/
|
|
90
|
+
function hexToUint8Array(hex) {
|
|
91
|
+
const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
92
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
93
|
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
94
|
+
bytes[i / 2] = parseInt(cleanHex.slice(i, i + 2), 16);
|
|
95
|
+
}
|
|
96
|
+
return bytes;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Convert Uint8Array to base64 string (cross-platform)
|
|
100
|
+
* Works in both browser and Node.js environments
|
|
101
|
+
* @param bytes Uint8Array to convert
|
|
102
|
+
* @returns base64 encoded string
|
|
103
|
+
*/
|
|
104
|
+
function uint8ArrayToBase64(bytes) {
|
|
105
|
+
const binaryString = String.fromCharCode(...bytes);
|
|
106
|
+
return btoa(binaryString);
|
|
107
|
+
}
|
|
108
|
+
// ============================================================================
|
|
56
109
|
// Trust Wallet Core Management
|
|
57
110
|
// ============================================================================
|
|
58
111
|
let walletCore = null;
|
|
@@ -74,18 +127,9 @@ async function loadWalletCore() {
|
|
|
74
127
|
// Start loading
|
|
75
128
|
loadingPromise = (async () => {
|
|
76
129
|
try {
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// Browser environment with ES modules
|
|
81
|
-
const { initWasm } = await Promise.resolve().then(() => __importStar(require('@trustwallet/wallet-core')));
|
|
82
|
-
walletCore = await initWasm();
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
// Node.js environment
|
|
86
|
-
const { initWasm } = require('@trustwallet/wallet-core');
|
|
87
|
-
walletCore = await initWasm();
|
|
88
|
-
}
|
|
130
|
+
// Dynamic import works in both Node.js ESM and browser ESM
|
|
131
|
+
const { initWasm } = await Promise.resolve().then(() => __importStar(require('@trustwallet/wallet-core')));
|
|
132
|
+
walletCore = await initWasm();
|
|
89
133
|
walletCoreLoaded = true;
|
|
90
134
|
return walletCore;
|
|
91
135
|
}
|
|
@@ -98,22 +142,34 @@ async function loadWalletCore() {
|
|
|
98
142
|
}
|
|
99
143
|
// multicodec code for Ed25519 keys (0xed)
|
|
100
144
|
const ED25519_CODEC_ID = varint.encode(parseInt('0xed', 16));
|
|
145
|
+
/**
|
|
146
|
+
* Simple mnemonic validation (checks word count)
|
|
147
|
+
* @param mnemonic BIP39 mnemonic phrase
|
|
148
|
+
* @returns true if mnemonic has valid word count (12, 15, 18, 21, or 24 words)
|
|
149
|
+
*/
|
|
150
|
+
function validateMnemonic(mnemonic) {
|
|
151
|
+
const words = mnemonic.trim().split(/\s+/);
|
|
152
|
+
const validWordCounts = [12, 15, 18, 21, 24];
|
|
153
|
+
return validWordCounts.includes(words.length);
|
|
154
|
+
}
|
|
101
155
|
// ============================================================================
|
|
102
156
|
// Mnemonic and Key Derivation Functions
|
|
103
157
|
// ============================================================================
|
|
104
158
|
/**
|
|
105
|
-
* Generate a random BIP39 mnemonic phrase
|
|
159
|
+
* Generate a random BIP39 mnemonic phrase using Trust Wallet Core
|
|
160
|
+
* Works in both Node.js and browser environments
|
|
161
|
+
*
|
|
106
162
|
* @param wordCount Number of words (12, 15, 18, 21, or 24), default is 12
|
|
107
|
-
* @returns A mnemonic phrase string
|
|
163
|
+
* @returns A promise that resolves to a mnemonic phrase string
|
|
108
164
|
*
|
|
109
165
|
* @example
|
|
110
166
|
* ```typescript
|
|
111
|
-
* const mnemonic = generateMnemonic(12);
|
|
167
|
+
* const mnemonic = await generateMnemonic(12);
|
|
112
168
|
* console.log(mnemonic);
|
|
113
169
|
* // Output: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
|
|
114
170
|
* ```
|
|
115
171
|
*/
|
|
116
|
-
function generateMnemonic(wordCount = 12) {
|
|
172
|
+
async function generateMnemonic(wordCount = 12) {
|
|
117
173
|
// Convert word count to entropy bits
|
|
118
174
|
// 12 words = 128 bits, 15 words = 160 bits, etc.
|
|
119
175
|
const strengthMap = {
|
|
@@ -127,7 +183,12 @@ function generateMnemonic(wordCount = 12) {
|
|
|
127
183
|
if (!strength) {
|
|
128
184
|
throw new Error('Invalid word count. Must be one of: 12, 15, 18, 21, 24');
|
|
129
185
|
}
|
|
130
|
-
|
|
186
|
+
// Ensure Wallet Core is loaded
|
|
187
|
+
const core = await loadWalletCore();
|
|
188
|
+
const { HDWallet } = core;
|
|
189
|
+
const wallet = HDWallet.create(strength, '');
|
|
190
|
+
const mnemonic = wallet.mnemonic();
|
|
191
|
+
return mnemonic;
|
|
131
192
|
}
|
|
132
193
|
/**
|
|
133
194
|
* Derive Ethereum address from mnemonic using Trust Wallet Core
|
|
@@ -144,8 +205,8 @@ function generateMnemonic(wordCount = 12) {
|
|
|
144
205
|
*/
|
|
145
206
|
async function getEthereumAddressFromMnemonic(mnemonic) {
|
|
146
207
|
// Validate mnemonic
|
|
147
|
-
if (!
|
|
148
|
-
throw new Error('Invalid mnemonic phrase');
|
|
208
|
+
if (!validateMnemonic(mnemonic)) {
|
|
209
|
+
throw new Error('Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words');
|
|
149
210
|
}
|
|
150
211
|
const core = await loadWalletCore();
|
|
151
212
|
const { HDWallet, CoinType } = core;
|
|
@@ -168,16 +229,17 @@ async function getEthereumAddressFromMnemonic(mnemonic) {
|
|
|
168
229
|
*/
|
|
169
230
|
async function getEVMPrivateKeyFromMnemonic(mnemonic) {
|
|
170
231
|
// Validate mnemonic
|
|
171
|
-
if (!
|
|
172
|
-
throw new Error('Invalid mnemonic phrase');
|
|
232
|
+
if (!validateMnemonic(mnemonic)) {
|
|
233
|
+
throw new Error('Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words');
|
|
173
234
|
}
|
|
174
235
|
const core = await loadWalletCore();
|
|
175
236
|
const { HDWallet, CoinType } = core;
|
|
176
237
|
const wallet = HDWallet.createWithMnemonic(mnemonic, '');
|
|
177
238
|
// Get private key for Ethereum
|
|
178
239
|
const privateKeyData = wallet.getKeyForCoin(CoinType.ethereum);
|
|
179
|
-
// Convert to hex string with 0x prefix
|
|
180
|
-
const
|
|
240
|
+
// Convert to hex string with 0x prefix (cross-platform)
|
|
241
|
+
const privateKeyBytes = new Uint8Array(privateKeyData.data());
|
|
242
|
+
const privateKeyHex = '0x' + uint8ArrayToHex(privateKeyBytes);
|
|
181
243
|
return privateKeyHex;
|
|
182
244
|
}
|
|
183
245
|
/**
|
|
@@ -218,8 +280,8 @@ async function getID(mnemonic) {
|
|
|
218
280
|
*/
|
|
219
281
|
async function getDIDFromMnemonic(mnemonic) {
|
|
220
282
|
// Validate mnemonic
|
|
221
|
-
if (!
|
|
222
|
-
throw new Error('Invalid mnemonic phrase');
|
|
283
|
+
if (!validateMnemonic(mnemonic)) {
|
|
284
|
+
throw new Error('Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words');
|
|
223
285
|
}
|
|
224
286
|
const id = await getID(mnemonic);
|
|
225
287
|
return `did:key:${id}`;
|
|
@@ -261,8 +323,8 @@ async function getDIDFromMnemonic(mnemonic) {
|
|
|
261
323
|
*/
|
|
262
324
|
async function getEd25519JwkFromMnemonic(mnemonic) {
|
|
263
325
|
// Validate mnemonic
|
|
264
|
-
if (!
|
|
265
|
-
throw new Error('Invalid mnemonic phrase');
|
|
326
|
+
if (!validateMnemonic(mnemonic)) {
|
|
327
|
+
throw new Error('Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words');
|
|
266
328
|
}
|
|
267
329
|
const core = await loadWalletCore();
|
|
268
330
|
const { HDWallet, Curve } = core;
|
|
@@ -312,8 +374,8 @@ async function getEd25519JwkFromMnemonic(mnemonic) {
|
|
|
312
374
|
*/
|
|
313
375
|
async function deriveDIDFromMnemonic(mnemonic) {
|
|
314
376
|
// Validate mnemonic once upfront
|
|
315
|
-
if (!
|
|
316
|
-
throw new Error('Invalid mnemonic phrase');
|
|
377
|
+
if (!validateMnemonic(mnemonic)) {
|
|
378
|
+
throw new Error('Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words');
|
|
317
379
|
}
|
|
318
380
|
// Derive both in parallel for better performance
|
|
319
381
|
const [owner, did] = await Promise.all([
|
|
@@ -337,7 +399,7 @@ async function deriveDIDFromMnemonic(mnemonic) {
|
|
|
337
399
|
* ```
|
|
338
400
|
*/
|
|
339
401
|
async function generateDIDKeyData(wordCount = 12) {
|
|
340
|
-
const mnemonic = generateMnemonic(wordCount);
|
|
402
|
+
const mnemonic = await generateMnemonic(wordCount);
|
|
341
403
|
const { owner, did } = await deriveDIDFromMnemonic(mnemonic);
|
|
342
404
|
return {
|
|
343
405
|
mnemonic,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-utils.js","sourceRoot":"","sources":["../../src/utils/crypto-utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"crypto-utils.js","sourceRoot":"","sources":["../../src/utils/crypto-utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCH,gDAOC;AAOD,0CAIC;AAOD,0CAOC;AAQD,gDAGC;AA+ED,4CA4BC;AAeD,wEAeC;AAgBD,oEAuBC;AA4CD,gDAUC;AAqCD,8DAoDC;AAeD,sDAkBC;AAgBD,gDAWC;AAkHD,4CAkBC;AAxkBD,+CAAiC;AACjC,sDAAsD;AACtD,sDAAsD;AAkBtD,+EAA+E;AAC/E,mEAAmE;AACnE,+EAA+E;AAE/E;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAChD,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,KAAK,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,KAAK,CAAC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AC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,gBAAgB,CAC/B,SAAiB,IAAI;IAErB,sBAAsB;IACtB,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,MAAM,EAAE,EAAE,CAAC;QACd,4EAA4E;QAC5E,OAAO,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACP,yDAAyD;QACzD,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;AACF,CAAC"}
|
|
@@ -29,10 +29,10 @@ async function main() {
|
|
|
29
29
|
console.log('\n📝 Example 1: Generate Mnemonic Phrases');
|
|
30
30
|
console.log('-'.repeat(60));
|
|
31
31
|
|
|
32
|
-
const mnemonic12 = generateMnemonic(12);
|
|
32
|
+
const mnemonic12 = await generateMnemonic(12);
|
|
33
33
|
console.log('12-word mnemonic:', mnemonic12);
|
|
34
34
|
|
|
35
|
-
const mnemonic24 = generateMnemonic(24);
|
|
35
|
+
const mnemonic24 = await generateMnemonic(24);
|
|
36
36
|
console.log('24-word mnemonic:', mnemonic24);
|
|
37
37
|
|
|
38
38
|
// =========================================================================
|
|
@@ -105,7 +105,7 @@ async function main() {
|
|
|
105
105
|
console.log('\n✅ Example 7: Verify Consistency');
|
|
106
106
|
console.log('-'.repeat(60));
|
|
107
107
|
|
|
108
|
-
const verifyMnemonic = generateMnemonic(12);
|
|
108
|
+
const verifyMnemonic = await generateMnemonic(12);
|
|
109
109
|
console.log('Testing mnemonic:', verifyMnemonic);
|
|
110
110
|
|
|
111
111
|
const addr1 = await getEthereumAddressFromMnemonic(verifyMnemonic);
|
package/examples/ed25519-jwk.ts
CHANGED
|
@@ -20,7 +20,7 @@ async function example_generateEd25519JWK() {
|
|
|
20
20
|
try {
|
|
21
21
|
// Step 1: Generate a new mnemonic phrase
|
|
22
22
|
console.log('\n🔑 Step 1: Generating BIP39 mnemonic...');
|
|
23
|
-
const mnemonic = generateMnemonic(12);
|
|
23
|
+
const mnemonic = await generateMnemonic(12);
|
|
24
24
|
console.log(`Mnemonic: ${mnemonic}`);
|
|
25
25
|
|
|
26
26
|
// Step 2: Derive Ed25519 key pair and DID from mnemonic
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test encoding utilities exported from olaresid
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
base64ToUint8Array,
|
|
7
|
+
uint8ArrayToHex,
|
|
8
|
+
hexToUint8Array,
|
|
9
|
+
uint8ArrayToBase64
|
|
10
|
+
} from '../src/index';
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
console.log('============================================================');
|
|
14
|
+
console.log('Testing Cross-platform Encoding Utilities');
|
|
15
|
+
console.log(
|
|
16
|
+
'============================================================\n'
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// Test data
|
|
20
|
+
const testString = 'Hello, Olares!';
|
|
21
|
+
const testBytes = new TextEncoder().encode(testString);
|
|
22
|
+
|
|
23
|
+
console.log('📝 Original text:', testString);
|
|
24
|
+
console.log('📦 Original bytes:', testBytes);
|
|
25
|
+
console.log('');
|
|
26
|
+
|
|
27
|
+
// Test 1: Uint8Array to Hex
|
|
28
|
+
console.log('🔄 Test 1: uint8ArrayToHex()');
|
|
29
|
+
console.log('------------------------------------------------------------');
|
|
30
|
+
const hexString = uint8ArrayToHex(testBytes);
|
|
31
|
+
console.log('✅ Hex string:', hexString);
|
|
32
|
+
console.log('');
|
|
33
|
+
|
|
34
|
+
// Test 2: Hex to Uint8Array
|
|
35
|
+
console.log('🔄 Test 2: hexToUint8Array()');
|
|
36
|
+
console.log('------------------------------------------------------------');
|
|
37
|
+
const bytesFromHex = hexToUint8Array(hexString);
|
|
38
|
+
console.log('✅ Bytes from hex:', bytesFromHex);
|
|
39
|
+
console.log(
|
|
40
|
+
'✅ Matches original:',
|
|
41
|
+
JSON.stringify(bytesFromHex) === JSON.stringify(testBytes)
|
|
42
|
+
);
|
|
43
|
+
console.log('');
|
|
44
|
+
|
|
45
|
+
// Test 3: Uint8Array to Base64
|
|
46
|
+
console.log('🔄 Test 3: uint8ArrayToBase64()');
|
|
47
|
+
console.log('------------------------------------------------------------');
|
|
48
|
+
const base64String = uint8ArrayToBase64(testBytes);
|
|
49
|
+
console.log('✅ Base64 string:', base64String);
|
|
50
|
+
console.log('');
|
|
51
|
+
|
|
52
|
+
// Test 4: Base64 to Uint8Array
|
|
53
|
+
console.log('🔄 Test 4: base64ToUint8Array()');
|
|
54
|
+
console.log('------------------------------------------------------------');
|
|
55
|
+
const bytesFromBase64 = base64ToUint8Array(base64String);
|
|
56
|
+
console.log('✅ Bytes from base64:', bytesFromBase64);
|
|
57
|
+
console.log(
|
|
58
|
+
'✅ Matches original:',
|
|
59
|
+
JSON.stringify(bytesFromBase64) === JSON.stringify(testBytes)
|
|
60
|
+
);
|
|
61
|
+
console.log('');
|
|
62
|
+
|
|
63
|
+
// Test 5: Round-trip conversion
|
|
64
|
+
console.log('🔄 Test 5: Round-trip conversion (hex)');
|
|
65
|
+
console.log('------------------------------------------------------------');
|
|
66
|
+
const hex1 = uint8ArrayToHex(testBytes);
|
|
67
|
+
const bytes1 = hexToUint8Array(hex1);
|
|
68
|
+
const hex2 = uint8ArrayToHex(bytes1);
|
|
69
|
+
console.log('✅ Round-trip hex successful:', hex1 === hex2);
|
|
70
|
+
console.log('');
|
|
71
|
+
|
|
72
|
+
console.log('🔄 Test 6: Round-trip conversion (base64)');
|
|
73
|
+
console.log('------------------------------------------------------------');
|
|
74
|
+
const b64_1 = uint8ArrayToBase64(testBytes);
|
|
75
|
+
const bytes2 = base64ToUint8Array(b64_1);
|
|
76
|
+
const b64_2 = uint8ArrayToBase64(bytes2);
|
|
77
|
+
console.log('✅ Round-trip base64 successful:', b64_1 === b64_2);
|
|
78
|
+
console.log('');
|
|
79
|
+
|
|
80
|
+
// Test 7: Hex with 0x prefix
|
|
81
|
+
console.log('🔄 Test 7: Hex with 0x prefix');
|
|
82
|
+
console.log('------------------------------------------------------------');
|
|
83
|
+
const hexWithPrefix = '0x' + hexString;
|
|
84
|
+
const bytesFromPrefixedHex = hexToUint8Array(hexWithPrefix);
|
|
85
|
+
console.log(
|
|
86
|
+
'✅ Can handle 0x prefix:',
|
|
87
|
+
JSON.stringify(bytesFromPrefixedHex) === JSON.stringify(testBytes)
|
|
88
|
+
);
|
|
89
|
+
console.log('');
|
|
90
|
+
|
|
91
|
+
console.log('============================================================');
|
|
92
|
+
console.log('✅ All encoding utility tests passed!');
|
|
93
|
+
console.log('============================================================');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
main().catch(console.error);
|
|
@@ -21,7 +21,7 @@ async function example1_generateNew() {
|
|
|
21
21
|
|
|
22
22
|
// Generate a 12-word mnemonic
|
|
23
23
|
console.log('\n🔑 Generating 12-word mnemonic...');
|
|
24
|
-
const mnemonic12 = generateMnemonic(12);
|
|
24
|
+
const mnemonic12 = await generateMnemonic(12);
|
|
25
25
|
console.log(`Mnemonic: ${mnemonic12}`);
|
|
26
26
|
|
|
27
27
|
console.log('\n⏳ Deriving keys using Trust Wallet Core...');
|
|
@@ -35,7 +35,7 @@ async function example1_generateNew() {
|
|
|
35
35
|
// Generate a 24-word mnemonic
|
|
36
36
|
console.log('\n' + '-'.repeat(60));
|
|
37
37
|
console.log('\n🔑 Generating 24-word mnemonic...');
|
|
38
|
-
const mnemonic24 = generateMnemonic(24);
|
|
38
|
+
const mnemonic24 = await generateMnemonic(24);
|
|
39
39
|
console.log(`Mnemonic: ${mnemonic24}`);
|
|
40
40
|
|
|
41
41
|
console.log('\n⏳ Deriving keys...');
|
|
@@ -95,7 +95,7 @@ async function example4_parallelDerivation() {
|
|
|
95
95
|
console.log('Example 4: Parallel Key Derivation (Performance Test)');
|
|
96
96
|
console.log('='.repeat(60));
|
|
97
97
|
|
|
98
|
-
const mnemonic = generateMnemonic(12);
|
|
98
|
+
const mnemonic = await generateMnemonic(12);
|
|
99
99
|
console.log(`\n📝 Mnemonic: ${mnemonic}`);
|
|
100
100
|
|
|
101
101
|
console.log('\n⏳ Deriving owner and DID in parallel...');
|
|
@@ -53,7 +53,7 @@ async function main() {
|
|
|
53
53
|
console.log('-'.repeat(60));
|
|
54
54
|
|
|
55
55
|
// Replace with your actual parent domain
|
|
56
|
-
const PARENT_DOMAIN = process.env.PARENT_DOMAIN || '
|
|
56
|
+
const PARENT_DOMAIN = process.env.PARENT_DOMAIN || '1.com';
|
|
57
57
|
const parentDomain = olaresId.domain(PARENT_DOMAIN);
|
|
58
58
|
|
|
59
59
|
console.log(`📋 Parent domain: ${PARENT_DOMAIN}`);
|
|
@@ -79,7 +79,7 @@ async function main() {
|
|
|
79
79
|
console.log('\n📝 Step 4: Generate Mnemonic for Subdomain');
|
|
80
80
|
console.log('-'.repeat(60));
|
|
81
81
|
|
|
82
|
-
const mnemonic = generateMnemonic(12);
|
|
82
|
+
const mnemonic = await generateMnemonic(12);
|
|
83
83
|
console.log('✅ Generated 12-word mnemonic:');
|
|
84
84
|
console.log(` ${mnemonic}`);
|
|
85
85
|
console.log(
|
|
@@ -92,7 +92,8 @@ async function main() {
|
|
|
92
92
|
console.log('\n📝 Step 5: Register Subdomain');
|
|
93
93
|
console.log('-'.repeat(60));
|
|
94
94
|
|
|
95
|
-
const SUBDOMAIN_LABEL =
|
|
95
|
+
const SUBDOMAIN_LABEL =
|
|
96
|
+
process.env.SUBDOMAIN || `example-child-${Date.now()}`;
|
|
96
97
|
console.log(`📋 Subdomain label: ${SUBDOMAIN_LABEL}`);
|
|
97
98
|
console.log(`📋 Full domain will be: ${SUBDOMAIN_LABEL}.${PARENT_DOMAIN}`);
|
|
98
99
|
|
|
@@ -98,7 +98,7 @@ async function main() {
|
|
|
98
98
|
mnemonic = process.env.NEW_OWNER_MNEMONIC;
|
|
99
99
|
console.log('📝 Using provided mnemonic');
|
|
100
100
|
} else {
|
|
101
|
-
mnemonic = generateMnemonic(12);
|
|
101
|
+
mnemonic = await generateMnemonic(12);
|
|
102
102
|
console.log('🔑 Generated 12-word mnemonic:');
|
|
103
103
|
console.log(` ${mnemonic}`);
|
|
104
104
|
console.log(
|
|
@@ -56,10 +56,10 @@ async function main() {
|
|
|
56
56
|
console.log('');
|
|
57
57
|
|
|
58
58
|
// 2. Add a new EVM wallet (optional - only if you have an EVM private key)
|
|
59
|
-
if (process.env.
|
|
59
|
+
if (process.env.EVM_PRIVATE_KEY) {
|
|
60
60
|
console.log('2️⃣ Adding a new EVM wallet...');
|
|
61
61
|
const addResult = await domain.addEVMWallet(
|
|
62
|
-
process.env.
|
|
62
|
+
process.env.EVM_PRIVATE_KEY
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
if (addResult.success) {
|
|
@@ -87,10 +87,10 @@ async function main() {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// 4. Remove an EVM wallet (optional)
|
|
90
|
-
if (process.env.
|
|
90
|
+
if (process.env.EVM_PRIVATE_KEY) {
|
|
91
91
|
console.log('4️⃣ Removing an EVM wallet...');
|
|
92
92
|
const removeResult = await domain.removeEVMWallet(
|
|
93
|
-
process.env.
|
|
93
|
+
process.env.EVM_PRIVATE_KEY
|
|
94
94
|
);
|
|
95
95
|
|
|
96
96
|
if (removeResult.success) {
|
|
@@ -127,10 +127,10 @@ async function main() {
|
|
|
127
127
|
console.log('');
|
|
128
128
|
|
|
129
129
|
// 6. Add a new Solana wallet (optional - only if you have a Solana private key)
|
|
130
|
-
if (process.env.
|
|
130
|
+
if (process.env.SOLANA_PRIVATE_KEY) {
|
|
131
131
|
console.log('6️⃣ Adding a new Solana wallet...');
|
|
132
132
|
const addResult = await domain.addSolanaWallet(
|
|
133
|
-
process.env.
|
|
133
|
+
process.env.SOLANA_PRIVATE_KEY
|
|
134
134
|
);
|
|
135
135
|
|
|
136
136
|
if (addResult.success) {
|
|
@@ -162,10 +162,10 @@ async function main() {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
// 8. Remove a Solana wallet (optional)
|
|
165
|
-
if (process.env.
|
|
165
|
+
if (process.env.SOLANA_PRIVATE_KEY) {
|
|
166
166
|
console.log('8️⃣ Removing a Solana wallet...');
|
|
167
167
|
const removeResult = await domain.removeSolanaWallet(
|
|
168
|
-
process.env.
|
|
168
|
+
process.env.SOLANA_PRIVATE_KEY
|
|
169
169
|
);
|
|
170
170
|
|
|
171
171
|
if (removeResult.success) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beclab/olaresid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "DID Contract SDK with CLI tool",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,8 +39,6 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@solana/web3.js": "^1.87.6",
|
|
41
41
|
"@trustwallet/wallet-core": "^3.2.9",
|
|
42
|
-
"bip39": "^3.1.0",
|
|
43
|
-
"bs58": "^5.0.0",
|
|
44
42
|
"ethers": "^6.9.1",
|
|
45
43
|
"multiformats": "9.6.4",
|
|
46
44
|
"tweetnacl": "^1.0.3",
|