@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.
- package/README.md +10 -0
- package/dist/business/index.d.ts +3 -3
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business/index.js +31 -37
- package/dist/business/index.js.map +1 -1
- package/dist/cli.js +3 -4
- 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 +1 -6
- package/dist/index.js.map +1 -1
- package/dist/utils/crypto-utils.d.ts +4 -32
- package/dist/utils/crypto-utils.d.ts.map +1 -1
- package/dist/utils/crypto-utils.js +32 -95
- 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/frontend-demo/index.html +13 -0
- package/examples/frontend-demo/package-lock.json +5370 -0
- package/examples/frontend-demo/package.json +33 -0
- package/examples/frontend-demo/src/App.vue +1211 -0
- package/examples/frontend-demo/src/main.ts +8 -0
- package/examples/frontend-demo/src/style.css +341 -0
- package/examples/frontend-demo/tsconfig.json +24 -0
- package/examples/frontend-demo/webpack.config.js +87 -0
- package/examples/generate-mnemonic.ts +3 -3
- package/examples/register-subdomain.ts +1 -1
- package/examples/transfer-domain.ts +1 -1
- package/package.json +2 -1
- package/src/business/index.ts +23 -34
- package/src/cli.ts +3 -4
- package/src/index.ts +1 -6
- package/src/utils/crypto-utils.ts +34 -112
- package/examples/encoding-utils.ts +0 -96
- package/examples/quasar-demo/.eslintrc.js +0 -23
- package/examples/quasar-demo/.quasar/app.js +0 -43
- package/examples/quasar-demo/.quasar/client-entry.js +0 -38
- package/examples/quasar-demo/.quasar/client-prefetch.js +0 -130
- package/examples/quasar-demo/.quasar/quasar-user-options.js +0 -16
- package/examples/quasar-demo/README.md +0 -49
- package/examples/quasar-demo/index.html +0 -11
- package/examples/quasar-demo/package-lock.json +0 -6407
- package/examples/quasar-demo/package.json +0 -36
- package/examples/quasar-demo/quasar.config.js +0 -73
- package/examples/quasar-demo/src/App.vue +0 -13
- package/examples/quasar-demo/src/css/app.scss +0 -1
- package/examples/quasar-demo/src/layouts/MainLayout.vue +0 -21
- package/examples/quasar-demo/src/pages/IndexPage.vue +0 -905
- package/examples/quasar-demo/src/router/index.ts +0 -25
- package/examples/quasar-demo/src/router/routes.ts +0 -11
- package/examples/quasar-demo/tsconfig.json +0 -28
package/src/index.ts
CHANGED
|
@@ -38,12 +38,7 @@ export {
|
|
|
38
38
|
getDIDFromMnemonic,
|
|
39
39
|
generateDIDKeyData,
|
|
40
40
|
deriveDIDFromMnemonic,
|
|
41
|
-
getEd25519JwkFromMnemonic
|
|
42
|
-
// Cross-platform encoding utilities
|
|
43
|
-
base64ToUint8Array,
|
|
44
|
-
uint8ArrayToHex,
|
|
45
|
-
hexToUint8Array,
|
|
46
|
-
uint8ArrayToBase64
|
|
41
|
+
getEd25519JwkFromMnemonic
|
|
47
42
|
} from './business';
|
|
48
43
|
|
|
49
44
|
type Domain = PackageDomain.Domain;
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* compatibility across the entire Olares ecosystem.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import * as bip39 from 'bip39';
|
|
9
10
|
import * as varint from 'varint';
|
|
10
11
|
import { base58btc } from 'multiformats/bases/base58';
|
|
11
12
|
import { base64url } from 'multiformats/bases/base64';
|
|
12
13
|
|
|
13
14
|
// Browser globals type declaration
|
|
14
15
|
declare const window: any;
|
|
15
|
-
declare const atob: (input: string) => string;
|
|
16
16
|
declare const btoa: (input: string) => string;
|
|
17
17
|
|
|
18
18
|
export interface RSAPublicKeyData {
|
|
@@ -26,61 +26,6 @@ export interface DIDKeyData {
|
|
|
26
26
|
mnemonic: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// ============================================================================
|
|
30
|
-
// Cross-platform encoding utilities (Browser + Node.js compatible)
|
|
31
|
-
// ============================================================================
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Convert base64 string to Uint8Array (cross-platform)
|
|
35
|
-
* Works in both browser and Node.js environments
|
|
36
|
-
* @param base64 base64 encoded string
|
|
37
|
-
* @returns Uint8Array
|
|
38
|
-
*/
|
|
39
|
-
export function base64ToUint8Array(base64: string): Uint8Array {
|
|
40
|
-
const binaryString = atob(base64);
|
|
41
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
42
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
43
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
44
|
-
}
|
|
45
|
-
return bytes;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Convert Uint8Array to hex string (cross-platform)
|
|
50
|
-
* @param bytes Uint8Array to convert
|
|
51
|
-
* @returns hex string without '0x' prefix
|
|
52
|
-
*/
|
|
53
|
-
export function uint8ArrayToHex(bytes: Uint8Array): string {
|
|
54
|
-
return Array.from(bytes)
|
|
55
|
-
.map((b) => b.toString(16).padStart(2, '0'))
|
|
56
|
-
.join('');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Convert hex string to Uint8Array (cross-platform)
|
|
61
|
-
* @param hex hex string (with or without '0x' prefix)
|
|
62
|
-
* @returns Uint8Array
|
|
63
|
-
*/
|
|
64
|
-
export function hexToUint8Array(hex: string): Uint8Array {
|
|
65
|
-
const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
66
|
-
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
67
|
-
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
68
|
-
bytes[i / 2] = parseInt(cleanHex.slice(i, i + 2), 16);
|
|
69
|
-
}
|
|
70
|
-
return bytes;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Convert Uint8Array to base64 string (cross-platform)
|
|
75
|
-
* Works in both browser and Node.js environments
|
|
76
|
-
* @param bytes Uint8Array to convert
|
|
77
|
-
* @returns base64 encoded string
|
|
78
|
-
*/
|
|
79
|
-
export function uint8ArrayToBase64(bytes: Uint8Array): string {
|
|
80
|
-
const binaryString = String.fromCharCode(...bytes);
|
|
81
|
-
return btoa(binaryString);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
29
|
// ============================================================================
|
|
85
30
|
// Trust Wallet Core Management
|
|
86
31
|
// ============================================================================
|
|
@@ -107,9 +52,19 @@ async function loadWalletCore(): Promise<any> {
|
|
|
107
52
|
// Start loading
|
|
108
53
|
loadingPromise = (async () => {
|
|
109
54
|
try {
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
55
|
+
// Check if running in browser or Node.js
|
|
56
|
+
if (
|
|
57
|
+
typeof window !== 'undefined' &&
|
|
58
|
+
typeof require === 'undefined'
|
|
59
|
+
) {
|
|
60
|
+
// Browser environment with ES modules
|
|
61
|
+
const { initWasm } = await import('@trustwallet/wallet-core');
|
|
62
|
+
walletCore = await initWasm();
|
|
63
|
+
} else {
|
|
64
|
+
// Node.js environment
|
|
65
|
+
const { initWasm } = require('@trustwallet/wallet-core');
|
|
66
|
+
walletCore = await initWasm();
|
|
67
|
+
}
|
|
113
68
|
|
|
114
69
|
walletCoreLoaded = true;
|
|
115
70
|
return walletCore;
|
|
@@ -129,38 +84,23 @@ async function loadWalletCore(): Promise<any> {
|
|
|
129
84
|
// multicodec code for Ed25519 keys (0xed)
|
|
130
85
|
const ED25519_CODEC_ID = varint.encode(parseInt('0xed', 16));
|
|
131
86
|
|
|
132
|
-
/**
|
|
133
|
-
* Simple mnemonic validation (checks word count)
|
|
134
|
-
* @param mnemonic BIP39 mnemonic phrase
|
|
135
|
-
* @returns true if mnemonic has valid word count (12, 15, 18, 21, or 24 words)
|
|
136
|
-
*/
|
|
137
|
-
function validateMnemonic(mnemonic: string): boolean {
|
|
138
|
-
const words = mnemonic.trim().split(/\s+/);
|
|
139
|
-
const validWordCounts = [12, 15, 18, 21, 24];
|
|
140
|
-
return validWordCounts.includes(words.length);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
87
|
// ============================================================================
|
|
144
88
|
// Mnemonic and Key Derivation Functions
|
|
145
89
|
// ============================================================================
|
|
146
90
|
|
|
147
91
|
/**
|
|
148
|
-
* Generate a random BIP39 mnemonic phrase
|
|
149
|
-
* Works in both Node.js and browser environments
|
|
150
|
-
*
|
|
92
|
+
* Generate a random BIP39 mnemonic phrase
|
|
151
93
|
* @param wordCount Number of words (12, 15, 18, 21, or 24), default is 12
|
|
152
|
-
* @returns A
|
|
94
|
+
* @returns A mnemonic phrase string
|
|
153
95
|
*
|
|
154
96
|
* @example
|
|
155
97
|
* ```typescript
|
|
156
|
-
* const mnemonic =
|
|
98
|
+
* const mnemonic = generateMnemonic(12);
|
|
157
99
|
* console.log(mnemonic);
|
|
158
100
|
* // Output: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
|
|
159
101
|
* ```
|
|
160
102
|
*/
|
|
161
|
-
export
|
|
162
|
-
wordCount: number = 12
|
|
163
|
-
): Promise<string> {
|
|
103
|
+
export function generateMnemonic(wordCount: number = 12): string {
|
|
164
104
|
// Convert word count to entropy bits
|
|
165
105
|
// 12 words = 128 bits, 15 words = 160 bits, etc.
|
|
166
106
|
const strengthMap: Record<number, number> = {
|
|
@@ -178,14 +118,7 @@ export async function generateMnemonic(
|
|
|
178
118
|
);
|
|
179
119
|
}
|
|
180
120
|
|
|
181
|
-
|
|
182
|
-
const core = await loadWalletCore();
|
|
183
|
-
const { HDWallet } = core;
|
|
184
|
-
|
|
185
|
-
const wallet = HDWallet.create(strength, '');
|
|
186
|
-
const mnemonic = wallet.mnemonic();
|
|
187
|
-
|
|
188
|
-
return mnemonic;
|
|
121
|
+
return bip39.generateMnemonic(strength);
|
|
189
122
|
}
|
|
190
123
|
|
|
191
124
|
/**
|
|
@@ -205,10 +138,8 @@ export async function getEthereumAddressFromMnemonic(
|
|
|
205
138
|
mnemonic: string
|
|
206
139
|
): Promise<string> {
|
|
207
140
|
// Validate mnemonic
|
|
208
|
-
if (!validateMnemonic(mnemonic)) {
|
|
209
|
-
throw new Error(
|
|
210
|
-
'Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words'
|
|
211
|
-
);
|
|
141
|
+
if (!bip39.validateMnemonic(mnemonic)) {
|
|
142
|
+
throw new Error('Invalid mnemonic phrase');
|
|
212
143
|
}
|
|
213
144
|
|
|
214
145
|
const core = await loadWalletCore();
|
|
@@ -236,10 +167,8 @@ export async function getEVMPrivateKeyFromMnemonic(
|
|
|
236
167
|
mnemonic: string
|
|
237
168
|
): Promise<string> {
|
|
238
169
|
// Validate mnemonic
|
|
239
|
-
if (!validateMnemonic(mnemonic)) {
|
|
240
|
-
throw new Error(
|
|
241
|
-
'Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words'
|
|
242
|
-
);
|
|
170
|
+
if (!bip39.validateMnemonic(mnemonic)) {
|
|
171
|
+
throw new Error('Invalid mnemonic phrase');
|
|
243
172
|
}
|
|
244
173
|
|
|
245
174
|
const core = await loadWalletCore();
|
|
@@ -250,9 +179,9 @@ export async function getEVMPrivateKeyFromMnemonic(
|
|
|
250
179
|
// Get private key for Ethereum
|
|
251
180
|
const privateKeyData = wallet.getKeyForCoin(CoinType.ethereum);
|
|
252
181
|
|
|
253
|
-
// Convert to hex string with 0x prefix
|
|
254
|
-
const
|
|
255
|
-
|
|
182
|
+
// Convert to hex string with 0x prefix
|
|
183
|
+
const privateKeyHex =
|
|
184
|
+
'0x' + Buffer.from(privateKeyData.data()).toString('hex');
|
|
256
185
|
|
|
257
186
|
return privateKeyHex;
|
|
258
187
|
}
|
|
@@ -301,10 +230,8 @@ async function getID(mnemonic: string): Promise<string> {
|
|
|
301
230
|
*/
|
|
302
231
|
export async function getDIDFromMnemonic(mnemonic: string): Promise<string> {
|
|
303
232
|
// Validate mnemonic
|
|
304
|
-
if (!validateMnemonic(mnemonic)) {
|
|
305
|
-
throw new Error(
|
|
306
|
-
'Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words'
|
|
307
|
-
);
|
|
233
|
+
if (!bip39.validateMnemonic(mnemonic)) {
|
|
234
|
+
throw new Error('Invalid mnemonic phrase');
|
|
308
235
|
}
|
|
309
236
|
|
|
310
237
|
const id = await getID(mnemonic);
|
|
@@ -351,10 +278,8 @@ export async function getEd25519JwkFromMnemonic(mnemonic: string): Promise<{
|
|
|
351
278
|
privateJwk: any;
|
|
352
279
|
}> {
|
|
353
280
|
// Validate mnemonic
|
|
354
|
-
if (!validateMnemonic(mnemonic)) {
|
|
355
|
-
throw new Error(
|
|
356
|
-
'Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words'
|
|
357
|
-
);
|
|
281
|
+
if (!bip39.validateMnemonic(mnemonic)) {
|
|
282
|
+
throw new Error('Invalid mnemonic phrase');
|
|
358
283
|
}
|
|
359
284
|
|
|
360
285
|
const core = await loadWalletCore();
|
|
@@ -375,7 +300,6 @@ export async function getEd25519JwkFromMnemonic(mnemonic: string): Promise<{
|
|
|
375
300
|
idBytes.set(publicKeyBytes, ED25519_CODEC_ID.length);
|
|
376
301
|
const id = base58btc.encode(idBytes);
|
|
377
302
|
const did = `did:key:${id}`;
|
|
378
|
-
const keyId = `${did}#${id}`;
|
|
379
303
|
|
|
380
304
|
// Base64url encode the keys
|
|
381
305
|
const x = base64url.baseEncode(publicKeyBytes);
|
|
@@ -387,7 +311,7 @@ export async function getEd25519JwkFromMnemonic(mnemonic: string): Promise<{
|
|
|
387
311
|
crv: 'Ed25519', // Curve: Ed25519
|
|
388
312
|
alg: 'EdDSA', // Algorithm: EdDSA
|
|
389
313
|
use: 'sig', // Use: signature
|
|
390
|
-
kid:
|
|
314
|
+
kid: did, // DID
|
|
391
315
|
x: x // Public key parameter
|
|
392
316
|
};
|
|
393
317
|
|
|
@@ -418,10 +342,8 @@ export async function deriveDIDFromMnemonic(mnemonic: string): Promise<{
|
|
|
418
342
|
did: string;
|
|
419
343
|
}> {
|
|
420
344
|
// Validate mnemonic once upfront
|
|
421
|
-
if (!validateMnemonic(mnemonic)) {
|
|
422
|
-
throw new Error(
|
|
423
|
-
'Invalid mnemonic phrase: must have 12, 15, 18, 21, or 24 words'
|
|
424
|
-
);
|
|
345
|
+
if (!bip39.validateMnemonic(mnemonic)) {
|
|
346
|
+
throw new Error('Invalid mnemonic phrase');
|
|
425
347
|
}
|
|
426
348
|
|
|
427
349
|
// Derive both in parallel for better performance
|
|
@@ -450,7 +372,7 @@ export async function deriveDIDFromMnemonic(mnemonic: string): Promise<{
|
|
|
450
372
|
export async function generateDIDKeyData(
|
|
451
373
|
wordCount: number = 12
|
|
452
374
|
): Promise<DIDKeyData> {
|
|
453
|
-
const mnemonic =
|
|
375
|
+
const mnemonic = generateMnemonic(wordCount);
|
|
454
376
|
const { owner, did } = await deriveDIDFromMnemonic(mnemonic);
|
|
455
377
|
|
|
456
378
|
return {
|
|
@@ -1,96 +0,0 @@
|
|
|
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);
|
|
@@ -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);
|
|
@@ -1,130 +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 App from 'app/src/App.vue';
|
|
15
|
-
let appPrefetch =
|
|
16
|
-
typeof App.preFetch === 'function'
|
|
17
|
-
? App.preFetch
|
|
18
|
-
: // Class components return the component options (and the preFetch hook) inside __c property
|
|
19
|
-
App.__c !== void 0 && typeof App.__c.preFetch === 'function'
|
|
20
|
-
? App.__c.preFetch
|
|
21
|
-
: false;
|
|
22
|
-
|
|
23
|
-
function getMatchedComponents(to, router) {
|
|
24
|
-
const route = to
|
|
25
|
-
? to.matched
|
|
26
|
-
? to
|
|
27
|
-
: router.resolve(to).route
|
|
28
|
-
: router.currentRoute.value;
|
|
29
|
-
|
|
30
|
-
if (!route) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const matched = route.matched.filter((m) => m.components !== void 0);
|
|
35
|
-
|
|
36
|
-
if (matched.length === 0) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return Array.prototype.concat.apply(
|
|
41
|
-
[],
|
|
42
|
-
matched.map((m) => {
|
|
43
|
-
return Object.keys(m.components).map((key) => {
|
|
44
|
-
const comp = m.components[key];
|
|
45
|
-
return {
|
|
46
|
-
path: m.path,
|
|
47
|
-
c: comp
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function addPreFetchHooks({ router, publicPath }) {
|
|
55
|
-
// Add router hook for handling preFetch.
|
|
56
|
-
// Doing it after initial route is resolved so that we don't double-fetch
|
|
57
|
-
// the data that we already have. Using router.beforeResolve() so that all
|
|
58
|
-
// async components are resolved.
|
|
59
|
-
router.beforeResolve((to, from, next) => {
|
|
60
|
-
const urlPath = window.location.href.replace(
|
|
61
|
-
window.location.origin,
|
|
62
|
-
''
|
|
63
|
-
),
|
|
64
|
-
matched = getMatchedComponents(to, router),
|
|
65
|
-
prevMatched = getMatchedComponents(from, router);
|
|
66
|
-
|
|
67
|
-
let diffed = false;
|
|
68
|
-
const preFetchList = matched
|
|
69
|
-
.filter((m, i) => {
|
|
70
|
-
return (
|
|
71
|
-
diffed ||
|
|
72
|
-
(diffed =
|
|
73
|
-
!prevMatched[i] ||
|
|
74
|
-
prevMatched[i].c !== m.c ||
|
|
75
|
-
m.path.indexOf('/:') > -1) // does it has params?
|
|
76
|
-
);
|
|
77
|
-
})
|
|
78
|
-
.filter(
|
|
79
|
-
(m) =>
|
|
80
|
-
m.c !== void 0 &&
|
|
81
|
-
(typeof m.c.preFetch === 'function' ||
|
|
82
|
-
// Class components return the component options (and the preFetch hook) inside __c property
|
|
83
|
-
(m.c.__c !== void 0 &&
|
|
84
|
-
typeof m.c.__c.preFetch === 'function'))
|
|
85
|
-
)
|
|
86
|
-
.map((m) => (m.c.__c !== void 0 ? m.c.__c.preFetch : m.c.preFetch));
|
|
87
|
-
|
|
88
|
-
if (appPrefetch !== false) {
|
|
89
|
-
preFetchList.unshift(appPrefetch);
|
|
90
|
-
appPrefetch = false;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (preFetchList.length === 0) {
|
|
94
|
-
return next();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let hasRedirected = false;
|
|
98
|
-
const redirect = (url) => {
|
|
99
|
-
hasRedirected = true;
|
|
100
|
-
next(url);
|
|
101
|
-
};
|
|
102
|
-
const proceed = () => {
|
|
103
|
-
if (hasRedirected === false) {
|
|
104
|
-
next();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
preFetchList
|
|
109
|
-
.reduce(
|
|
110
|
-
(promise, preFetch) =>
|
|
111
|
-
promise.then(
|
|
112
|
-
() =>
|
|
113
|
-
hasRedirected === false &&
|
|
114
|
-
preFetch({
|
|
115
|
-
currentRoute: to,
|
|
116
|
-
previousRoute: from,
|
|
117
|
-
redirect,
|
|
118
|
-
urlPath,
|
|
119
|
-
publicPath
|
|
120
|
-
})
|
|
121
|
-
),
|
|
122
|
-
Promise.resolve()
|
|
123
|
-
)
|
|
124
|
-
.then(proceed)
|
|
125
|
-
.catch((e) => {
|
|
126
|
-
console.error(e);
|
|
127
|
-
proceed();
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}
|
|
@@ -1,16 +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 { Notify } from 'quasar';
|
|
15
|
-
|
|
16
|
-
export default { config: { notify: {} }, plugins: { Notify } };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# OlaresID Quasar Demo
|
|
2
|
-
|
|
3
|
-
最简化的 Quasar 演示项目,展示如何在 Quasar 应用中使用 `@beclab/olaresid` 库。
|
|
4
|
-
|
|
5
|
-
## 安装
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# 进入项目目录
|
|
9
|
-
cd did-system/packages/olaresid/examples/quasar-demo
|
|
10
|
-
|
|
11
|
-
# 安装依赖
|
|
12
|
-
npm install
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 运行
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# 开发模式
|
|
19
|
-
npm run dev
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
项目将在 `http://localhost:9001` 运行。
|
|
23
|
-
|
|
24
|
-
## 项目结构
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
quasar-demo/
|
|
28
|
-
├── src/
|
|
29
|
-
│ ├── layouts/
|
|
30
|
-
│ │ └── MainLayout.vue # 主布局
|
|
31
|
-
│ ├── pages/
|
|
32
|
-
│ │ └── IndexPage.vue # 首页(演示 OlaresID)
|
|
33
|
-
│ ├── router/
|
|
34
|
-
│ │ ├── index.ts # 路由配置
|
|
35
|
-
│ │ └── routes.ts # 路由定义
|
|
36
|
-
│ ├── css/
|
|
37
|
-
│ │ └── app.scss # 全局样式
|
|
38
|
-
│ └── App.vue # 根组件
|
|
39
|
-
├── index.html # HTML 模板
|
|
40
|
-
├── package.json # 依赖配置
|
|
41
|
-
├── quasar.config.js # Quasar 配置
|
|
42
|
-
└── tsconfig.json # TypeScript 配置
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## 功能
|
|
46
|
-
|
|
47
|
-
- 显示 OlaresID 实例信息
|
|
48
|
-
- 测试域名查询功能
|
|
49
|
-
- 示例域名:`tw7613781.olares.com`
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>OlaresID Demo</title>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<!-- quasar:entry-point -->
|
|
10
|
-
</body>
|
|
11
|
-
</html>
|