@beclab/olaresid 0.1.5 → 0.1.7

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.
Files changed (51) hide show
  1. package/README.md +10 -0
  2. package/dist/business/index.d.ts +3 -3
  3. package/dist/business/index.d.ts.map +1 -1
  4. package/dist/business/index.js +31 -37
  5. package/dist/business/index.js.map +1 -1
  6. package/dist/cli.js +3 -4
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -6
  11. package/dist/index.js.map +1 -1
  12. package/dist/utils/crypto-utils.d.ts +4 -32
  13. package/dist/utils/crypto-utils.d.ts.map +1 -1
  14. package/dist/utils/crypto-utils.js +32 -95
  15. package/dist/utils/crypto-utils.js.map +1 -1
  16. package/examples/crypto-utilities.ts +3 -3
  17. package/examples/ed25519-jwk.ts +1 -1
  18. package/examples/frontend-demo/index.html +13 -0
  19. package/examples/frontend-demo/package-lock.json +5370 -0
  20. package/examples/frontend-demo/package.json +33 -0
  21. package/examples/frontend-demo/src/App.vue +1211 -0
  22. package/examples/frontend-demo/src/main.ts +8 -0
  23. package/examples/frontend-demo/src/style.css +341 -0
  24. package/examples/frontend-demo/tsconfig.json +24 -0
  25. package/examples/frontend-demo/webpack.config.js +87 -0
  26. package/examples/generate-mnemonic.ts +3 -3
  27. package/examples/register-subdomain.ts +1 -1
  28. package/examples/transfer-domain.ts +1 -1
  29. package/package.json +2 -1
  30. package/src/business/index.ts +23 -34
  31. package/src/cli.ts +3 -4
  32. package/src/index.ts +1 -6
  33. package/src/utils/crypto-utils.ts +34 -112
  34. package/examples/encoding-utils.ts +0 -96
  35. package/examples/quasar-demo/.eslintrc.js +0 -23
  36. package/examples/quasar-demo/.quasar/app.js +0 -43
  37. package/examples/quasar-demo/.quasar/client-entry.js +0 -38
  38. package/examples/quasar-demo/.quasar/client-prefetch.js +0 -130
  39. package/examples/quasar-demo/.quasar/quasar-user-options.js +0 -16
  40. package/examples/quasar-demo/README.md +0 -49
  41. package/examples/quasar-demo/index.html +0 -11
  42. package/examples/quasar-demo/package-lock.json +0 -6407
  43. package/examples/quasar-demo/package.json +0 -36
  44. package/examples/quasar-demo/quasar.config.js +0 -73
  45. package/examples/quasar-demo/src/App.vue +0 -13
  46. package/examples/quasar-demo/src/css/app.scss +0 -1
  47. package/examples/quasar-demo/src/layouts/MainLayout.vue +0 -21
  48. package/examples/quasar-demo/src/pages/IndexPage.vue +0 -905
  49. package/examples/quasar-demo/src/router/index.ts +0 -25
  50. package/examples/quasar-demo/src/router/routes.ts +0 -11
  51. package/examples/quasar-demo/tsconfig.json +0 -28
@@ -0,0 +1,8 @@
1
+ import { createApp } from 'vue';
2
+ import App from './App.vue';
3
+ import './style.css';
4
+
5
+ import { Buffer } from 'buffer';
6
+ (window as any).Buffer = Buffer;
7
+
8
+ createApp(App).mount('#app');
@@ -0,0 +1,341 @@
1
+ /* Reset and base styles */
2
+ * {
3
+ margin: 0;
4
+ padding: 0;
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ body {
9
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
10
+ 'Helvetica Neue', Arial, sans-serif;
11
+ line-height: 1.6;
12
+ color: #333;
13
+ background: #f5f5f5;
14
+ overflow-x: hidden;
15
+ }
16
+
17
+ /* App layout */
18
+ .app {
19
+ max-width: 900px;
20
+ width: 100%;
21
+ margin: 0 auto;
22
+ padding: 20px;
23
+ min-height: 100vh;
24
+ display: flex;
25
+ flex-direction: column;
26
+ }
27
+
28
+ /* Header */
29
+ header {
30
+ text-align: center;
31
+ margin-bottom: 30px;
32
+ padding: 20px;
33
+ background: white;
34
+ border-radius: 8px;
35
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
36
+ }
37
+
38
+ header h1 {
39
+ font-size: 2rem;
40
+ margin-bottom: 15px;
41
+ color: #2c3e50;
42
+ }
43
+
44
+ nav {
45
+ display: flex;
46
+ gap: 10px;
47
+ justify-content: center;
48
+ flex-wrap: wrap;
49
+ }
50
+
51
+ /* Buttons */
52
+ button {
53
+ padding: 10px 20px;
54
+ border: 2px solid #3498db;
55
+ background: white;
56
+ color: #3498db;
57
+ font-size: 1rem;
58
+ cursor: pointer;
59
+ border-radius: 6px;
60
+ transition: all 0.3s ease;
61
+ font-weight: 500;
62
+ }
63
+
64
+ button:hover {
65
+ background: #3498db;
66
+ color: white;
67
+ }
68
+
69
+ button.active {
70
+ background: #3498db;
71
+ color: white;
72
+ }
73
+
74
+ button:disabled {
75
+ opacity: 0.5;
76
+ cursor: not-allowed;
77
+ background: #ddd;
78
+ border-color: #ddd;
79
+ color: #999;
80
+ }
81
+
82
+ .btn-primary {
83
+ background: #3498db;
84
+ color: white;
85
+ border-color: #3498db;
86
+ }
87
+
88
+ .btn-primary:hover:not(:disabled) {
89
+ background: #2980b9;
90
+ border-color: #2980b9;
91
+ }
92
+
93
+ .btn-secondary {
94
+ background: #95a5a6;
95
+ color: white;
96
+ border-color: #95a5a6;
97
+ margin-top: 15px;
98
+ }
99
+
100
+ .btn-secondary:hover:not(:disabled) {
101
+ background: #7f8c8d;
102
+ border-color: #7f8c8d;
103
+ }
104
+
105
+ .btn-copy {
106
+ padding: 5px 10px;
107
+ font-size: 0.9rem;
108
+ background: #ecf0f1;
109
+ border: 1px solid #bdc3c7;
110
+ color: #2c3e50;
111
+ }
112
+
113
+ .btn-copy:hover {
114
+ background: #bdc3c7;
115
+ color: #2c3e50;
116
+ }
117
+
118
+ /* Main content */
119
+ main {
120
+ flex: 1;
121
+ width: 100%;
122
+ overflow-x: hidden;
123
+ }
124
+
125
+ .section {
126
+ background: white;
127
+ padding: 30px;
128
+ border-radius: 8px;
129
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
130
+ width: 100%;
131
+ overflow: hidden;
132
+ }
133
+
134
+ .section h2 {
135
+ font-size: 1.5rem;
136
+ margin-bottom: 10px;
137
+ color: #2c3e50;
138
+ }
139
+
140
+ .subtitle {
141
+ color: #7f8c8d;
142
+ margin-bottom: 20px;
143
+ font-size: 0.95rem;
144
+ }
145
+
146
+ /* Input group */
147
+ .input-group {
148
+ display: flex;
149
+ gap: 10px;
150
+ margin-bottom: 20px;
151
+ }
152
+
153
+ input {
154
+ flex: 1;
155
+ padding: 12px;
156
+ border: 2px solid #ddd;
157
+ border-radius: 6px;
158
+ font-size: 1rem;
159
+ transition: border-color 0.3s ease;
160
+ }
161
+
162
+ input:focus {
163
+ outline: none;
164
+ border-color: #3498db;
165
+ }
166
+
167
+ input:disabled {
168
+ background: #f5f5f5;
169
+ cursor: not-allowed;
170
+ }
171
+
172
+ /* Result display */
173
+ .result {
174
+ margin-top: 25px;
175
+ padding: 20px;
176
+ background: #f8f9fa;
177
+ border-radius: 6px;
178
+ border-left: 4px solid #3498db;
179
+ width: 100%;
180
+ overflow: hidden;
181
+ word-wrap: break-word;
182
+ }
183
+
184
+ .result h3 {
185
+ margin-bottom: 15px;
186
+ color: #27ae60;
187
+ font-size: 1.2rem;
188
+ }
189
+
190
+ .result-header {
191
+ display: flex;
192
+ justify-content: space-between;
193
+ align-items: center;
194
+ margin-bottom: 15px;
195
+ }
196
+
197
+ .field {
198
+ margin-bottom: 15px;
199
+ }
200
+
201
+ .field:last-child {
202
+ margin-bottom: 0;
203
+ }
204
+
205
+ .field label {
206
+ display: block;
207
+ font-weight: 600;
208
+ margin-bottom: 5px;
209
+ color: #555;
210
+ font-size: 0.9rem;
211
+ }
212
+
213
+ .field.warning {
214
+ background: #fff3cd;
215
+ padding: 15px;
216
+ border-radius: 6px;
217
+ border-left: 4px solid #f39c12;
218
+ }
219
+
220
+ .field.warning label {
221
+ color: #856404;
222
+ }
223
+
224
+ .value-row {
225
+ display: flex;
226
+ gap: 10px;
227
+ align-items: center;
228
+ width: 100%;
229
+ min-width: 0;
230
+ }
231
+
232
+ code {
233
+ flex: 1;
234
+ display: block;
235
+ padding: 10px;
236
+ background: white;
237
+ border: 1px solid #ddd;
238
+ border-radius: 4px;
239
+ font-family: 'Monaco', 'Courier New', monospace;
240
+ font-size: 0.85rem;
241
+ word-break: break-all;
242
+ overflow-wrap: break-word;
243
+ color: #333;
244
+ max-width: 100%;
245
+ overflow-x: auto;
246
+ }
247
+
248
+ pre {
249
+ background: white;
250
+ padding: 15px;
251
+ border-radius: 6px;
252
+ overflow-x: auto;
253
+ font-family: 'Monaco', 'Courier New', monospace;
254
+ font-size: 0.85rem;
255
+ line-height: 1.5;
256
+ max-height: 500px;
257
+ overflow-y: auto;
258
+ border: 1px solid #ddd;
259
+ word-break: break-all;
260
+ overflow-wrap: break-word;
261
+ white-space: pre-wrap;
262
+ max-width: 100%;
263
+ }
264
+
265
+ /* Error display */
266
+ .error {
267
+ margin-top: 20px;
268
+ padding: 15px;
269
+ background: #f8d7da;
270
+ color: #721c24;
271
+ border-radius: 6px;
272
+ border-left: 4px solid #dc3545;
273
+ }
274
+
275
+ /* Toast notification */
276
+ .toast {
277
+ position: fixed;
278
+ bottom: 30px;
279
+ right: 30px;
280
+ background: #27ae60;
281
+ color: white;
282
+ padding: 15px 25px;
283
+ border-radius: 6px;
284
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
285
+ animation: slideIn 0.3s ease;
286
+ z-index: 1000;
287
+ }
288
+
289
+ @keyframes slideIn {
290
+ from {
291
+ transform: translateY(100px);
292
+ opacity: 0;
293
+ }
294
+ to {
295
+ transform: translateY(0);
296
+ opacity: 1;
297
+ }
298
+ }
299
+
300
+ /* Footer */
301
+ footer {
302
+ text-align: center;
303
+ padding: 20px;
304
+ color: #7f8c8d;
305
+ font-size: 0.9rem;
306
+ margin-top: 30px;
307
+ }
308
+
309
+ /* Responsive */
310
+ @media (max-width: 768px) {
311
+ .app {
312
+ padding: 10px;
313
+ }
314
+
315
+ header h1 {
316
+ font-size: 1.5rem;
317
+ }
318
+
319
+ .section {
320
+ padding: 20px;
321
+ }
322
+
323
+ .input-group {
324
+ flex-direction: column;
325
+ }
326
+
327
+ .toast {
328
+ right: 10px;
329
+ left: 10px;
330
+ bottom: 10px;
331
+ }
332
+
333
+ nav {
334
+ gap: 5px;
335
+ }
336
+
337
+ button {
338
+ padding: 8px 16px;
339
+ font-size: 0.9rem;
340
+ }
341
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
+ "skipLibCheck": true,
8
+
9
+ /* Webpack mode */
10
+ "moduleResolution": "node",
11
+ "isolatedModules": true,
12
+ "moduleDetection": "force",
13
+ "jsx": "preserve",
14
+
15
+ /* Linting */
16
+ "strict": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noFallthroughCasesInSwitch": true,
20
+ "esModuleInterop": true,
21
+ "allowSyntheticDefaultImports": true
22
+ },
23
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
24
+ }
@@ -0,0 +1,87 @@
1
+ const path = require('path');
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
3
+ const { VueLoaderPlugin } = require('vue-loader');
4
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
5
+
6
+ module.exports = (env, argv) => {
7
+ const isDevelopment = argv.mode === 'development';
8
+
9
+ return {
10
+ mode: isDevelopment ? 'development' : 'production',
11
+ entry: './src/main.ts',
12
+ output: {
13
+ path: path.resolve(__dirname, 'dist'),
14
+ filename: isDevelopment ? '[name].js' : '[name].[contenthash].js',
15
+ clean: true
16
+ },
17
+ resolve: {
18
+ extensions: ['.ts', '.js', '.vue', '.json', '.wasm'],
19
+ alias: {
20
+ '@': path.resolve(__dirname, 'src')
21
+ },
22
+ fallback: {
23
+ buffer: require.resolve('buffer/'),
24
+ crypto: false,
25
+ fs: false,
26
+ path: false,
27
+ 'fs/promises': false
28
+ }
29
+ },
30
+ module: {
31
+ rules: [
32
+ {
33
+ test: /\.vue$/,
34
+ loader: 'vue-loader'
35
+ },
36
+ {
37
+ test: /\.ts$/,
38
+ loader: 'ts-loader',
39
+ options: {
40
+ appendTsSuffixTo: [/\.vue$/],
41
+ transpileOnly: true
42
+ },
43
+ exclude: /node_modules/
44
+ },
45
+ {
46
+ test: /\.css$/,
47
+ use: ['style-loader', 'css-loader']
48
+ },
49
+ {
50
+ test: /\.wasm$/,
51
+ type: 'webassembly/async'
52
+ }
53
+ ]
54
+ },
55
+ plugins: [
56
+ new VueLoaderPlugin(),
57
+ new HtmlWebpackPlugin({
58
+ template: './index.html',
59
+ inject: true
60
+ }),
61
+ new CopyWebpackPlugin({
62
+ patterns: [
63
+ {
64
+ from: path.resolve(
65
+ __dirname,
66
+ '../../node_modules/@trustwallet/wallet-core/dist/lib/wallet-core.wasm'
67
+ ),
68
+ to: 'wallet-core.wasm'
69
+ }
70
+ ]
71
+ })
72
+ ],
73
+ experiments: {
74
+ asyncWebAssembly: true,
75
+ topLevelAwait: true
76
+ },
77
+ devServer: {
78
+ port: 9000,
79
+ hot: true,
80
+ open: true
81
+ },
82
+ devtool: isDevelopment ? 'eval-source-map' : false,
83
+ performance: {
84
+ hints: false
85
+ }
86
+ };
87
+ };
@@ -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 = await generateMnemonic(12);
24
+ const mnemonic12 = 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 = await generateMnemonic(24);
38
+ const mnemonic24 = 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 = await generateMnemonic(12);
98
+ const mnemonic = generateMnemonic(12);
99
99
  console.log(`\n📝 Mnemonic: ${mnemonic}`);
100
100
 
101
101
  console.log('\n⏳ Deriving owner and DID in parallel...');
@@ -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 = await generateMnemonic(12);
82
+ const mnemonic = generateMnemonic(12);
83
83
  console.log('✅ Generated 12-word mnemonic:');
84
84
  console.log(` ${mnemonic}`);
85
85
  console.log(
@@ -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 = await generateMnemonic(12);
101
+ mnemonic = generateMnemonic(12);
102
102
  console.log('🔑 Generated 12-word mnemonic:');
103
103
  console.log(` ${mnemonic}`);
104
104
  console.log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beclab/olaresid",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "DID Contract SDK with CLI tool",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,6 +39,7 @@
39
39
  "dependencies": {
40
40
  "@solana/web3.js": "^1.87.6",
41
41
  "@trustwallet/wallet-core": "^3.2.9",
42
+ "bip39": "^3.1.0",
42
43
  "ethers": "^6.9.1",
43
44
  "multiformats": "9.6.4",
44
45
  "tweetnacl": "^1.0.3",
@@ -4,12 +4,6 @@ import { parseContractError } from '../utils/error-parser';
4
4
  import { TagContext } from './tag-context';
5
5
  import { TagTypeBuilder } from '../utils/tag-type-builder';
6
6
  import { normalizeToDomain } from '../utils/olares-id';
7
- import {
8
- base64ToUint8Array,
9
- uint8ArrayToHex,
10
- hexToUint8Array,
11
- uint8ArrayToBase64
12
- } from '../utils/crypto-utils';
13
7
 
14
8
  export interface TransactionResult<T = any> {
15
9
  // Basic transaction information
@@ -54,11 +48,7 @@ export {
54
48
  getDIDFromMnemonic,
55
49
  generateDIDKeyData,
56
50
  deriveDIDFromMnemonic,
57
- getEd25519JwkFromMnemonic,
58
- base64ToUint8Array,
59
- uint8ArrayToHex,
60
- hexToUint8Array,
61
- uint8ArrayToBase64
51
+ getEd25519JwkFromMnemonic
62
52
  } from '../utils/crypto-utils';
63
53
  export type { RSAPublicKeyData, DIDKeyData } from '../utils/crypto-utils';
64
54
 
@@ -190,7 +180,7 @@ export class DomainContext {
190
180
  * ```typescript
191
181
  * // For parent domain "parent.com", register subdomain "child"
192
182
  * const parentDomain = olaresId.domain('parent.com');
193
- * const mnemonic = await generateMnemonic(12);
183
+ * const mnemonic = generateMnemonic(12);
194
184
  *
195
185
  * const result = await parentDomain.registerSubdomain('child', mnemonic);
196
186
  * // This will register "child.parent.com"
@@ -276,7 +266,7 @@ export class DomainContext {
276
266
  *
277
267
  * @example
278
268
  * ```typescript
279
- * const mnemonic = await generateMnemonic(12);
269
+ * const mnemonic = generateMnemonic(12);
280
270
  * const result = await domain.transfer(mnemonic);
281
271
  * if (result.success) {
282
272
  * console.log('Domain transferred!');
@@ -871,7 +861,7 @@ export class DomainContext {
871
861
  } catch {
872
862
  // Try base64
873
863
  try {
874
- const secretKey = base64ToUint8Array(solanaPrivateKey);
864
+ const secretKey = Buffer.from(solanaPrivateKey, 'base64');
875
865
  solanaWallet = Keypair.fromSecretKey(secretKey);
876
866
  } catch {
877
867
  // Try as JSON array
@@ -882,9 +872,9 @@ export class DomainContext {
882
872
  }
883
873
  }
884
874
 
885
- // Get Solana address as bytes32 (cross-platform)
875
+ // Get Solana address as bytes32
886
876
  const solanaAddressBytes =
887
- '0x' + uint8ArrayToHex(solanaWallet.publicKey.toBytes());
877
+ '0x' + solanaWallet.publicKey.toBuffer().toString('hex');
888
878
 
889
879
  // Get current timestamp
890
880
  const signAt = Math.floor(Date.now() / 1000) - 30 * 60; // 30 minutes ago
@@ -944,8 +934,8 @@ export class DomainContext {
944
934
  decodeUTF8(solanaMsg),
945
935
  solanaWallet.secretKey
946
936
  );
947
- // Convert signature to hex (cross-platform)
948
- const sigFromAuthAddrHex = '0x' + uint8ArrayToHex(sigFromAuthAddr);
937
+ const sigFromAuthAddrHex =
938
+ '0x' + Buffer.from(sigFromAuthAddr).toString('hex');
949
939
 
950
940
  // Call contract
951
941
  const tx = await rootTagger.updateSolanaWallet(
@@ -1008,7 +998,7 @@ export class DomainContext {
1008
998
  } catch {
1009
999
  // Try base64
1010
1000
  try {
1011
- const secretKey = base64ToUint8Array(solanaPrivateKey);
1001
+ const secretKey = Buffer.from(solanaPrivateKey, 'base64');
1012
1002
  solanaWallet = Keypair.fromSecretKey(secretKey);
1013
1003
  } catch {
1014
1004
  // Try as JSON array
@@ -1019,9 +1009,9 @@ export class DomainContext {
1019
1009
  }
1020
1010
  }
1021
1011
 
1022
- // Get Solana address as bytes32 (cross-platform)
1012
+ // Get Solana address as bytes32
1023
1013
  const solanaAddressBytes =
1024
- '0x' + uint8ArrayToHex(solanaWallet.publicKey.toBytes());
1014
+ '0x' + solanaWallet.publicKey.toBuffer().toString('hex');
1025
1015
 
1026
1016
  // Get current timestamp
1027
1017
  const signAt = Math.floor(Date.now() / 1000) - 30 * 60; // 30 minutes ago
@@ -1122,8 +1112,11 @@ export class DomainContext {
1122
1112
  // Extract addresses from the result and convert to base58
1123
1113
  // Result is array of { algorithm, addr } where addr is bytes32
1124
1114
  return result.map((item: any) => {
1125
- // Convert hex to Uint8Array (cross-platform)
1126
- const buffer = hexToUint8Array(item.addr);
1115
+ // Remove 0x prefix and convert hex to buffer
1116
+ const hexStr = item.addr.startsWith('0x')
1117
+ ? item.addr.slice(2)
1118
+ : item.addr;
1119
+ const buffer = Buffer.from(hexStr, 'hex');
1127
1120
  // Convert to Solana public key and then to base58
1128
1121
  return new PublicKey(buffer).toBase58();
1129
1122
  });
@@ -1438,16 +1431,13 @@ export function bytes4ToIpv4(bytes4Hex: string): string {
1438
1431
  */
1439
1432
  export function pemToDer(pem: string): string {
1440
1433
  // Remove PEM headers, footers, and whitespace
1441
- const base64Str = pem
1434
+ const base64 = pem
1442
1435
  .replace(/-----BEGIN.*?-----/g, '')
1443
1436
  .replace(/-----END.*?-----/g, '')
1444
1437
  .replace(/\s/g, '');
1445
1438
 
1446
- // Convert base64 to Uint8Array using cross-platform method
1447
- const derBuffer = base64ToUint8Array(base64Str);
1448
-
1449
- // Convert to hex string
1450
- const hexString = uint8ArrayToHex(derBuffer);
1439
+ const derBuffer = Buffer.from(base64, 'base64');
1440
+ const hexString = derBuffer.toString('hex');
1451
1441
 
1452
1442
  // Convert to hex string with 0x prefix
1453
1443
  return '0x' + hexString;
@@ -1462,14 +1452,13 @@ export function derToPem(derHex: string): string {
1462
1452
  // Remove '0x' prefix if present
1463
1453
  const hexString = derHex.startsWith('0x') ? derHex.slice(2) : derHex;
1464
1454
 
1465
- // Convert hex to base64 using cross-platform methods
1466
- const bytes = hexToUint8Array(hexString);
1467
- const base64Str = uint8ArrayToBase64(bytes);
1455
+ const derBuffer = Buffer.from(hexString, 'hex');
1456
+ const base64 = derBuffer.toString('base64');
1468
1457
 
1469
1458
  // Split base64 into 64-character lines for PEM format
1470
1459
  const lines: string[] = [];
1471
- for (let i = 0; i < base64Str.length; i += 64) {
1472
- lines.push(base64Str.slice(i, i + 64));
1460
+ for (let i = 0; i < base64.length; i += 64) {
1461
+ lines.push(base64.slice(i, i + 64));
1473
1462
  }
1474
1463
 
1475
1464
  // Construct PEM format with headers and footers
package/src/cli.ts CHANGED
@@ -1014,7 +1014,7 @@ async function registerSubdomain(
1014
1014
  );
1015
1015
  process.exit(1);
1016
1016
  }
1017
- mnemonic = await generateMnemonic(wordCount);
1017
+ mnemonic = generateMnemonic(wordCount);
1018
1018
 
1019
1019
  // Save mnemonic to file
1020
1020
  const mnemonicFile = './subdomain-mnemonic.txt';
@@ -1141,7 +1141,7 @@ async function transferDomain(
1141
1141
  );
1142
1142
  process.exit(1);
1143
1143
  }
1144
- mnemonic = await generateMnemonic(wordCount);
1144
+ mnemonic = generateMnemonic(wordCount);
1145
1145
 
1146
1146
  // Save mnemonic to file
1147
1147
  const mnemonicFile = './transfer-new-owner-mnemonic.txt';
@@ -1228,7 +1228,7 @@ async function cryptoGenerate(options: CliOptions): Promise<void> {
1228
1228
  process.exit(1);
1229
1229
  }
1230
1230
 
1231
- const mnemonic = await generateMnemonic(wordCount);
1231
+ const mnemonic = generateMnemonic(wordCount);
1232
1232
 
1233
1233
  // Save mnemonic to file
1234
1234
  const outputFile = options.output || './mnemonic.txt';
@@ -2953,7 +2953,6 @@ async function main(): Promise<void> {
2953
2953
  }
2954
2954
  }
2955
2955
 
2956
- // 运行主函数
2957
2956
  main().catch((error) => {
2958
2957
  console.error(
2959
2958
  '❌ Unexpected error:',