@beclab/olaresid 0.1.5 → 0.1.6

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 (31) hide show
  1. package/dist/utils/crypto-utils.d.ts.map +1 -1
  2. package/dist/utils/crypto-utils.js +29 -4
  3. package/dist/utils/crypto-utils.js.map +1 -1
  4. package/examples/frontend-demo/.dockerignore +40 -0
  5. package/examples/frontend-demo/index.html +13 -0
  6. package/examples/frontend-demo/package-lock.json +5304 -0
  7. package/examples/frontend-demo/package.json +32 -0
  8. package/examples/frontend-demo/src/App.vue +1156 -0
  9. package/examples/frontend-demo/src/main.ts +5 -0
  10. package/examples/frontend-demo/src/style.css +323 -0
  11. package/examples/frontend-demo/tsconfig.json +24 -0
  12. package/examples/frontend-demo/webpack.config.js +86 -0
  13. package/package.json +1 -1
  14. package/src/utils/crypto-utils.ts +29 -4
  15. package/examples/quasar-demo/.eslintrc.js +0 -23
  16. package/examples/quasar-demo/.quasar/app.js +0 -43
  17. package/examples/quasar-demo/.quasar/client-entry.js +0 -38
  18. package/examples/quasar-demo/.quasar/client-prefetch.js +0 -130
  19. package/examples/quasar-demo/.quasar/quasar-user-options.js +0 -16
  20. package/examples/quasar-demo/README.md +0 -49
  21. package/examples/quasar-demo/index.html +0 -11
  22. package/examples/quasar-demo/package-lock.json +0 -6407
  23. package/examples/quasar-demo/package.json +0 -36
  24. package/examples/quasar-demo/quasar.config.js +0 -73
  25. package/examples/quasar-demo/src/App.vue +0 -13
  26. package/examples/quasar-demo/src/css/app.scss +0 -1
  27. package/examples/quasar-demo/src/layouts/MainLayout.vue +0 -21
  28. package/examples/quasar-demo/src/pages/IndexPage.vue +0 -905
  29. package/examples/quasar-demo/src/router/index.ts +0 -25
  30. package/examples/quasar-demo/src/router/routes.ts +0 -11
  31. package/examples/quasar-demo/tsconfig.json +0 -28
@@ -0,0 +1,5 @@
1
+ import { createApp } from 'vue';
2
+ import App from './App.vue';
3
+ import './style.css';
4
+
5
+ createApp(App).mount('#app');
@@ -0,0 +1,323 @@
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
+ }
15
+
16
+ /* App layout */
17
+ .app {
18
+ max-width: 900px;
19
+ margin: 0 auto;
20
+ padding: 20px;
21
+ min-height: 100vh;
22
+ display: flex;
23
+ flex-direction: column;
24
+ }
25
+
26
+ /* Header */
27
+ header {
28
+ text-align: center;
29
+ margin-bottom: 30px;
30
+ padding: 20px;
31
+ background: white;
32
+ border-radius: 8px;
33
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
34
+ }
35
+
36
+ header h1 {
37
+ font-size: 2rem;
38
+ margin-bottom: 15px;
39
+ color: #2c3e50;
40
+ }
41
+
42
+ nav {
43
+ display: flex;
44
+ gap: 10px;
45
+ justify-content: center;
46
+ flex-wrap: wrap;
47
+ }
48
+
49
+ /* Buttons */
50
+ button {
51
+ padding: 10px 20px;
52
+ border: 2px solid #3498db;
53
+ background: white;
54
+ color: #3498db;
55
+ font-size: 1rem;
56
+ cursor: pointer;
57
+ border-radius: 6px;
58
+ transition: all 0.3s ease;
59
+ font-weight: 500;
60
+ }
61
+
62
+ button:hover {
63
+ background: #3498db;
64
+ color: white;
65
+ }
66
+
67
+ button.active {
68
+ background: #3498db;
69
+ color: white;
70
+ }
71
+
72
+ button:disabled {
73
+ opacity: 0.5;
74
+ cursor: not-allowed;
75
+ background: #ddd;
76
+ border-color: #ddd;
77
+ color: #999;
78
+ }
79
+
80
+ .btn-primary {
81
+ background: #3498db;
82
+ color: white;
83
+ border-color: #3498db;
84
+ }
85
+
86
+ .btn-primary:hover:not(:disabled) {
87
+ background: #2980b9;
88
+ border-color: #2980b9;
89
+ }
90
+
91
+ .btn-secondary {
92
+ background: #95a5a6;
93
+ color: white;
94
+ border-color: #95a5a6;
95
+ margin-top: 15px;
96
+ }
97
+
98
+ .btn-secondary:hover:not(:disabled) {
99
+ background: #7f8c8d;
100
+ border-color: #7f8c8d;
101
+ }
102
+
103
+ .btn-copy {
104
+ padding: 5px 10px;
105
+ font-size: 0.9rem;
106
+ background: #ecf0f1;
107
+ border: 1px solid #bdc3c7;
108
+ color: #2c3e50;
109
+ }
110
+
111
+ .btn-copy:hover {
112
+ background: #bdc3c7;
113
+ color: #2c3e50;
114
+ }
115
+
116
+ /* Main content */
117
+ main {
118
+ flex: 1;
119
+ }
120
+
121
+ .section {
122
+ background: white;
123
+ padding: 30px;
124
+ border-radius: 8px;
125
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
126
+ }
127
+
128
+ .section h2 {
129
+ font-size: 1.5rem;
130
+ margin-bottom: 10px;
131
+ color: #2c3e50;
132
+ }
133
+
134
+ .subtitle {
135
+ color: #7f8c8d;
136
+ margin-bottom: 20px;
137
+ font-size: 0.95rem;
138
+ }
139
+
140
+ /* Input group */
141
+ .input-group {
142
+ display: flex;
143
+ gap: 10px;
144
+ margin-bottom: 20px;
145
+ }
146
+
147
+ input {
148
+ flex: 1;
149
+ padding: 12px;
150
+ border: 2px solid #ddd;
151
+ border-radius: 6px;
152
+ font-size: 1rem;
153
+ transition: border-color 0.3s ease;
154
+ }
155
+
156
+ input:focus {
157
+ outline: none;
158
+ border-color: #3498db;
159
+ }
160
+
161
+ input:disabled {
162
+ background: #f5f5f5;
163
+ cursor: not-allowed;
164
+ }
165
+
166
+ /* Result display */
167
+ .result {
168
+ margin-top: 25px;
169
+ padding: 20px;
170
+ background: #f8f9fa;
171
+ border-radius: 6px;
172
+ border-left: 4px solid #3498db;
173
+ }
174
+
175
+ .result h3 {
176
+ margin-bottom: 15px;
177
+ color: #27ae60;
178
+ font-size: 1.2rem;
179
+ }
180
+
181
+ .result-header {
182
+ display: flex;
183
+ justify-content: space-between;
184
+ align-items: center;
185
+ margin-bottom: 15px;
186
+ }
187
+
188
+ .field {
189
+ margin-bottom: 15px;
190
+ }
191
+
192
+ .field:last-child {
193
+ margin-bottom: 0;
194
+ }
195
+
196
+ .field label {
197
+ display: block;
198
+ font-weight: 600;
199
+ margin-bottom: 5px;
200
+ color: #555;
201
+ font-size: 0.9rem;
202
+ }
203
+
204
+ .field.warning {
205
+ background: #fff3cd;
206
+ padding: 15px;
207
+ border-radius: 6px;
208
+ border-left: 4px solid #f39c12;
209
+ }
210
+
211
+ .field.warning label {
212
+ color: #856404;
213
+ }
214
+
215
+ .value-row {
216
+ display: flex;
217
+ gap: 10px;
218
+ align-items: center;
219
+ }
220
+
221
+ code {
222
+ flex: 1;
223
+ display: block;
224
+ padding: 10px;
225
+ background: white;
226
+ border: 1px solid #ddd;
227
+ border-radius: 4px;
228
+ font-family: 'Monaco', 'Courier New', monospace;
229
+ font-size: 0.85rem;
230
+ word-break: break-all;
231
+ color: #333;
232
+ }
233
+
234
+ pre {
235
+ background: white;
236
+ padding: 15px;
237
+ border-radius: 6px;
238
+ overflow-x: auto;
239
+ font-family: 'Monaco', 'Courier New', monospace;
240
+ font-size: 0.85rem;
241
+ line-height: 1.5;
242
+ max-height: 500px;
243
+ overflow-y: auto;
244
+ border: 1px solid #ddd;
245
+ }
246
+
247
+ /* Error display */
248
+ .error {
249
+ margin-top: 20px;
250
+ padding: 15px;
251
+ background: #f8d7da;
252
+ color: #721c24;
253
+ border-radius: 6px;
254
+ border-left: 4px solid #dc3545;
255
+ }
256
+
257
+ /* Toast notification */
258
+ .toast {
259
+ position: fixed;
260
+ bottom: 30px;
261
+ right: 30px;
262
+ background: #27ae60;
263
+ color: white;
264
+ padding: 15px 25px;
265
+ border-radius: 6px;
266
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
267
+ animation: slideIn 0.3s ease;
268
+ z-index: 1000;
269
+ }
270
+
271
+ @keyframes slideIn {
272
+ from {
273
+ transform: translateY(100px);
274
+ opacity: 0;
275
+ }
276
+ to {
277
+ transform: translateY(0);
278
+ opacity: 1;
279
+ }
280
+ }
281
+
282
+ /* Footer */
283
+ footer {
284
+ text-align: center;
285
+ padding: 20px;
286
+ color: #7f8c8d;
287
+ font-size: 0.9rem;
288
+ margin-top: 30px;
289
+ }
290
+
291
+ /* Responsive */
292
+ @media (max-width: 768px) {
293
+ .app {
294
+ padding: 10px;
295
+ }
296
+
297
+ header h1 {
298
+ font-size: 1.5rem;
299
+ }
300
+
301
+ .section {
302
+ padding: 20px;
303
+ }
304
+
305
+ .input-group {
306
+ flex-direction: column;
307
+ }
308
+
309
+ .toast {
310
+ right: 10px;
311
+ left: 10px;
312
+ bottom: 10px;
313
+ }
314
+
315
+ nav {
316
+ gap: 5px;
317
+ }
318
+
319
+ button {
320
+ padding: 8px 16px;
321
+ font-size: 0.9rem;
322
+ }
323
+ }
@@ -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,86 @@
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
+ crypto: false,
24
+ fs: false,
25
+ path: false,
26
+ 'fs/promises': false
27
+ }
28
+ },
29
+ module: {
30
+ rules: [
31
+ {
32
+ test: /\.vue$/,
33
+ loader: 'vue-loader'
34
+ },
35
+ {
36
+ test: /\.ts$/,
37
+ loader: 'ts-loader',
38
+ options: {
39
+ appendTsSuffixTo: [/\.vue$/],
40
+ transpileOnly: true
41
+ },
42
+ exclude: /node_modules/
43
+ },
44
+ {
45
+ test: /\.css$/,
46
+ use: ['style-loader', 'css-loader']
47
+ },
48
+ {
49
+ test: /\.wasm$/,
50
+ type: 'webassembly/async'
51
+ }
52
+ ]
53
+ },
54
+ plugins: [
55
+ new VueLoaderPlugin(),
56
+ new HtmlWebpackPlugin({
57
+ template: './index.html',
58
+ inject: true
59
+ }),
60
+ new CopyWebpackPlugin({
61
+ patterns: [
62
+ {
63
+ from: path.resolve(
64
+ __dirname,
65
+ '../../node_modules/@trustwallet/wallet-core/dist/lib/wallet-core.wasm'
66
+ ),
67
+ to: 'wallet-core.wasm'
68
+ }
69
+ ]
70
+ })
71
+ ],
72
+ experiments: {
73
+ asyncWebAssembly: true,
74
+ topLevelAwait: true
75
+ },
76
+ devServer: {
77
+ port: 9000,
78
+ hot: true,
79
+ open: true
80
+ },
81
+ devtool: isDevelopment ? 'eval-source-map' : false,
82
+ performance: {
83
+ hints: false
84
+ }
85
+ };
86
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beclab/olaresid",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "DID Contract SDK with CLI tool",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -92,6 +92,7 @@ let loadingPromise: Promise<any> | null = null;
92
92
  /**
93
93
  * Load Trust Wallet Core (lazy loading)
94
94
  * Works in both Node.js and browser environments
95
+ * Handles different module export formats (CommonJS vs ESM)
95
96
  */
96
97
  async function loadWalletCore(): Promise<any> {
97
98
  // Return cached instance if already loaded
@@ -108,8 +109,33 @@ async function loadWalletCore(): Promise<any> {
108
109
  loadingPromise = (async () => {
109
110
  try {
110
111
  // Dynamic import works in both Node.js ESM and browser ESM
111
- const { initWasm } = await import('@trustwallet/wallet-core');
112
- walletCore = await initWasm();
112
+ const WalletCoreModule = await import('@trustwallet/wallet-core');
113
+
114
+ // Handle different export formats (CommonJS vs ESM)
115
+ let initWasmFunc: any;
116
+ if (WalletCoreModule.initWasm) {
117
+ // ESM named export
118
+ initWasmFunc = WalletCoreModule.initWasm;
119
+ } else if (
120
+ WalletCoreModule.default &&
121
+ (WalletCoreModule.default as any).initWasm
122
+ ) {
123
+ // ESM default export with initWasm
124
+ initWasmFunc = (WalletCoreModule.default as any).initWasm;
125
+ } else if (WalletCoreModule.default) {
126
+ // Default export is the function itself
127
+ initWasmFunc = WalletCoreModule.default;
128
+ } else {
129
+ // Module itself is the function
130
+ initWasmFunc = WalletCoreModule as any;
131
+ }
132
+
133
+ // Call the init function
134
+ if (typeof initWasmFunc === 'function') {
135
+ walletCore = await initWasmFunc();
136
+ } else {
137
+ throw new Error('initWasm is not a function');
138
+ }
113
139
 
114
140
  walletCoreLoaded = true;
115
141
  return walletCore;
@@ -375,7 +401,6 @@ export async function getEd25519JwkFromMnemonic(mnemonic: string): Promise<{
375
401
  idBytes.set(publicKeyBytes, ED25519_CODEC_ID.length);
376
402
  const id = base58btc.encode(idBytes);
377
403
  const did = `did:key:${id}`;
378
- const keyId = `${did}#${id}`;
379
404
 
380
405
  // Base64url encode the keys
381
406
  const x = base64url.baseEncode(publicKeyBytes);
@@ -387,7 +412,7 @@ export async function getEd25519JwkFromMnemonic(mnemonic: string): Promise<{
387
412
  crv: 'Ed25519', // Curve: Ed25519
388
413
  alg: 'EdDSA', // Algorithm: EdDSA
389
414
  use: 'sig', // Use: signature
390
- kid: keyId, // Key ID
415
+ kid: did, // DID
391
416
  x: x // Public key parameter
392
417
  };
393
418
 
@@ -1,23 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parserOptions: {
4
- parser: '@typescript-eslint/parser',
5
- ecmaVersion: 2021
6
- },
7
- env: {
8
- browser: true,
9
- es2021: true,
10
- node: true
11
- },
12
- extends: [
13
- 'plugin:vue/vue3-essential',
14
- 'eslint:recommended',
15
- '@vue/typescript/recommended',
16
- 'prettier'
17
- ],
18
- plugins: ['vue', '@typescript-eslint'],
19
- rules: {
20
- '@typescript-eslint/no-explicit-any': 'off',
21
- '@typescript-eslint/no-unused-vars': 'warn'
22
- }
23
- };
@@ -1,43 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * THIS FILE IS GENERATED AUTOMATICALLY.
4
- * DO NOT EDIT.
5
- *
6
- * You are probably looking on adding startup/initialization code.
7
- * Use "quasar new boot <name>" and add it there.
8
- * One boot file per concern. Then reference the file(s) in quasar.config.js > boot:
9
- * boot: ['file', ...] // do not add ".js" extension to it.
10
- *
11
- * Boot files are your "main.js"
12
- **/
13
-
14
- import { Quasar } from 'quasar';
15
- import { markRaw } from 'vue';
16
- import RootComponent from 'app/src/App.vue';
17
-
18
- import createRouter from 'app/src/router/index';
19
-
20
- export default async function (createAppFn, quasarUserOptions) {
21
- // Create the app instance.
22
- // Here we inject into it the Quasar UI, the router & possibly the store.
23
- const app = createAppFn(RootComponent);
24
-
25
- app.config.performance = true;
26
-
27
- app.use(Quasar, quasarUserOptions);
28
-
29
- const router = markRaw(
30
- typeof createRouter === 'function'
31
- ? await createRouter({})
32
- : createRouter
33
- );
34
-
35
- // Expose the app, the router and the store.
36
- // Note that we are not mounting the app here, since bootstrapping will be
37
- // different depending on whether we are in a browser or on the server.
38
- return {
39
- app,
40
-
41
- router
42
- };
43
- }
@@ -1,38 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * THIS FILE IS GENERATED AUTOMATICALLY.
4
- * DO NOT EDIT.
5
- *
6
- * You are probably looking on adding startup/initialization code.
7
- * Use "quasar new boot <name>" and add it there.
8
- * One boot file per concern. Then reference the file(s) in quasar.config.js > boot:
9
- * boot: ['file', ...] // do not add ".js" extension to it.
10
- *
11
- * Boot files are your "main.js"
12
- **/
13
-
14
- import { createApp } from 'vue';
15
-
16
- import '@quasar/extras/roboto-font/roboto-font.css';
17
-
18
- import '@quasar/extras/material-icons/material-icons.css';
19
-
20
- // We load Quasar stylesheet file
21
- import 'quasar/dist/quasar.css';
22
-
23
- import 'src/css/app.scss';
24
-
25
- import createQuasarApp from './app.js';
26
- import quasarUserOptions from './quasar-user-options.js';
27
-
28
- console.info('[Quasar] Running SPA.');
29
-
30
- const publicPath = `/`;
31
-
32
- async function start({ app, router }) {
33
- app.use(router);
34
-
35
- app.mount('#q-app');
36
- }
37
-
38
- createQuasarApp(createApp, quasarUserOptions).then(start);