@beclab/olaresid 0.1.12 ā 0.2.0
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/CLI-TREE.md +107 -0
- package/CLI.md +122 -1329
- package/README.md +30 -12
- package/SDK-TREE.md +151 -0
- package/TAG.md +95 -41
- package/config.json +6 -4
- package/dist/abi/TerminusDIDQueryABI.d.ts +397 -0
- package/dist/abi/TerminusDIDQueryABI.d.ts.map +1 -0
- package/dist/abi/TerminusDIDQueryABI.js +519 -0
- package/dist/abi/TerminusDIDQueryABI.js.map +1 -0
- package/dist/business/index.d.ts +1 -1
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business/index.js +11 -24
- package/dist/business/index.js.map +1 -1
- package/dist/business/tag-context.d.ts +1 -0
- package/dist/business/tag-context.d.ts.map +1 -1
- package/dist/business/tag-context.js +13 -7
- package/dist/business/tag-context.js.map +1 -1
- package/dist/cli.js +238 -107
- package/dist/cli.js.map +1 -1
- package/dist/config/index.d.ts +16 -4
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +28 -14
- package/dist/config/index.js.map +1 -1
- package/dist/domain/core.d.ts +65 -0
- package/dist/domain/core.d.ts.map +1 -0
- package/dist/domain/core.js +317 -0
- package/dist/domain/core.js.map +1 -0
- package/dist/domain/index.d.ts +104 -57
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +188 -428
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/types.d.ts +56 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/domain/types.js +3 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/index.d.ts +81 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -143
- package/dist/index.js.map +1 -1
- package/dist/utils/crypto-utils.d.ts +124 -0
- package/dist/utils/crypto-utils.d.ts.map +1 -1
- package/dist/utils/crypto-utils.js +156 -8
- package/dist/utils/crypto-utils.js.map +1 -1
- package/dist/utils/error-parser.d.ts.map +1 -1
- package/dist/utils/error-parser.js +2 -1
- package/dist/utils/error-parser.js.map +1 -1
- package/dist/utils/event-parser.d.ts +161 -0
- package/dist/utils/event-parser.d.ts.map +1 -0
- package/dist/utils/event-parser.js +140 -0
- package/dist/utils/event-parser.js.map +1 -0
- package/dist/utils/tag-type-builder.d.ts +43 -0
- package/dist/utils/tag-type-builder.d.ts.map +1 -1
- package/dist/utils/tag-type-builder.js +122 -0
- package/dist/utils/tag-type-builder.js.map +1 -1
- package/dist/utils/tag-type-parser.d.ts +70 -0
- package/dist/utils/tag-type-parser.d.ts.map +1 -0
- package/dist/utils/tag-type-parser.js +190 -0
- package/dist/utils/tag-type-parser.js.map +1 -0
- package/examples/create-with-rpc-demo.ts +142 -0
- package/examples/fetch-all-flat-demo.ts +159 -0
- package/examples/fetch-by-indices-demo.ts +235 -0
- package/examples/fetch-domain-demo.ts +137 -0
- package/examples/fetch-domains-demo.ts +221 -0
- package/examples/frontend-demo/index.html +2 -2
- package/examples/frontend-demo/package-lock.json +4 -1
- package/examples/index.ts +3 -5
- package/jest.config.js +25 -0
- package/package.json +6 -2
- package/src/abi/TerminusDIDQueryABI.ts +516 -0
- package/src/business/index.ts +10 -33
- package/src/business/tag-context.ts +35 -7
- package/src/cli.ts +344 -121
- package/src/config/index.ts +34 -19
- package/src/domain/core.ts +382 -0
- package/src/domain/index.ts +271 -641
- package/src/domain/types.ts +59 -0
- package/src/index.ts +222 -207
- package/src/utils/crypto-utils.ts +239 -2
- package/src/utils/error-parser.ts +2 -1
- package/src/utils/event-parser.ts +353 -0
- package/src/utils/tag-type-builder.ts +138 -0
- package/src/utils/tag-type-parser.ts +246 -0
- package/tests/unit/crypto-utils.test.ts +338 -0
- package/tests/unit/ed25519-jwk.test.ts +201 -0
- package/tests/unit/event-parser.test.ts +690 -0
- package/tests/unit/generate-mnemonic.test.ts +268 -0
- package/tests/unit/olares-id-format.test.ts +321 -0
- package/tests/unit/tag-type-parser.test.ts +802 -0
- package/tests/unit/tag-types.test.ts +821 -0
- package/tsconfig.json +3 -2
- package/dist/abi/ABITypeABI.d.ts +0 -88
- package/dist/abi/ABITypeABI.d.ts.map +0 -1
- package/dist/abi/ABITypeABI.js +0 -382
- package/dist/abi/ABITypeABI.js.map +0 -1
- package/dist/abi/RegistryABI.d.ts +0 -77
- package/dist/abi/RegistryABI.d.ts.map +0 -1
- package/dist/abi/RegistryABI.js +0 -462
- package/dist/abi/RegistryABI.js.map +0 -1
- package/dist/tag/address.d.ts +0 -11
- package/dist/tag/address.d.ts.map +0 -1
- package/dist/tag/address.js +0 -44
- package/dist/tag/address.js.map +0 -1
- package/dist/tag/array.d.ts +0 -14
- package/dist/tag/array.d.ts.map +0 -1
- package/dist/tag/array.js +0 -72
- package/dist/tag/array.js.map +0 -1
- package/dist/tag/bool.d.ts +0 -11
- package/dist/tag/bool.d.ts.map +0 -1
- package/dist/tag/bool.js +0 -43
- package/dist/tag/bool.js.map +0 -1
- package/dist/tag/bytes.d.ts +0 -11
- package/dist/tag/bytes.d.ts.map +0 -1
- package/dist/tag/bytes.js +0 -37
- package/dist/tag/bytes.js.map +0 -1
- package/dist/tag/flarray.d.ts +0 -15
- package/dist/tag/flarray.d.ts.map +0 -1
- package/dist/tag/flarray.js +0 -81
- package/dist/tag/flarray.js.map +0 -1
- package/dist/tag/flbytes.d.ts +0 -11
- package/dist/tag/flbytes.d.ts.map +0 -1
- package/dist/tag/flbytes.js +0 -47
- package/dist/tag/flbytes.js.map +0 -1
- package/dist/tag/index.d.ts +0 -32
- package/dist/tag/index.d.ts.map +0 -1
- package/dist/tag/index.js +0 -121
- package/dist/tag/index.js.map +0 -1
- package/dist/tag/int.d.ts +0 -12
- package/dist/tag/int.d.ts.map +0 -1
- package/dist/tag/int.js +0 -49
- package/dist/tag/int.js.map +0 -1
- package/dist/tag/string.d.ts +0 -11
- package/dist/tag/string.d.ts.map +0 -1
- package/dist/tag/string.js +0 -37
- package/dist/tag/string.js.map +0 -1
- package/dist/tag/tag.d.ts +0 -67
- package/dist/tag/tag.d.ts.map +0 -1
- package/dist/tag/tag.js +0 -157
- package/dist/tag/tag.js.map +0 -1
- package/dist/tag/tuple.d.ts +0 -17
- package/dist/tag/tuple.d.ts.map +0 -1
- package/dist/tag/tuple.js +0 -162
- package/dist/tag/tuple.js.map +0 -1
- package/dist/tag/uint.d.ts +0 -12
- package/dist/tag/uint.d.ts.map +0 -1
- package/dist/tag/uint.js +0 -49
- package/dist/tag/uint.js.map +0 -1
- package/dist/test/did.d.ts +0 -2
- package/dist/test/did.d.ts.map +0 -1
- package/dist/test/did.js +0 -177
- package/dist/test/did.js.map +0 -1
- package/dist/utils/tag-abi-codec.d.ts +0 -69
- package/dist/utils/tag-abi-codec.d.ts.map +0 -1
- package/dist/utils/tag-abi-codec.js +0 -144
- package/dist/utils/tag-abi-codec.js.map +0 -1
- package/examples/crypto-utilities.ts +0 -140
- package/examples/ed25519-jwk.ts +0 -73
- package/examples/generate-mnemonic.ts +0 -149
- package/examples/legacy.ts +0 -33
- package/examples/olares-id-format.ts +0 -197
- package/examples/tag-builder.ts +0 -235
- package/examples/tag-nested-tuple.ts +0 -190
- package/examples/tag-simple.ts +0 -149
- package/examples/tag-tagger.ts +0 -217
- package/examples/test-nested-tuple-conversion.ts +0 -143
- package/examples/test-type-bytes-parser.ts +0 -70
- package/src/abi/ABITypeABI.ts +0 -379
- package/src/abi/RegistryABI.ts +0 -459
- package/src/tag/address.ts +0 -48
- package/src/tag/array.ts +0 -80
- package/src/tag/bool.ts +0 -43
- package/src/tag/bytes.ts +0 -38
- package/src/tag/flarray.ts +0 -99
- package/src/tag/flbytes.ts +0 -48
- package/src/tag/index.ts +0 -170
- package/src/tag/int.ts +0 -51
- package/src/tag/string.ts +0 -38
- package/src/tag/tag.ts +0 -229
- package/src/tag/tuple.ts +0 -193
- package/src/tag/uint.ts +0 -51
- package/src/test/did.ts +0 -346
- package/src/utils/tag-abi-codec.ts +0 -158
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tag ABI Codec
|
|
3
|
-
* Unified encoding/decoding utility for Tag values
|
|
4
|
-
*
|
|
5
|
-
* Key Principle: ALL values use abi.encode()
|
|
6
|
-
* - Simple values: abi.encode("value")
|
|
7
|
-
* - Arrays: abi.encode(["a", "b", "c"])
|
|
8
|
-
* - Tuples: abi.encode(struct)
|
|
9
|
-
* - Elements for push: abi.encode(singleElement)
|
|
10
|
-
*/
|
|
11
|
-
export declare class TagAbiCodec {
|
|
12
|
-
private static abiCoder;
|
|
13
|
-
/**
|
|
14
|
-
* Parse tuple field types from ABI type string
|
|
15
|
-
* @param abiType e.g., "tuple(string,uint8,tuple(bool,address))"
|
|
16
|
-
* @returns Array of field types: ["string", "uint8", "tuple(bool,address)"]
|
|
17
|
-
*/
|
|
18
|
-
private static parseTupleFields;
|
|
19
|
-
/**
|
|
20
|
-
* Convert object to array based on ABI type structure
|
|
21
|
-
* Supports nested tuples recursively
|
|
22
|
-
*
|
|
23
|
-
* @param abiType ABI type string
|
|
24
|
-
* @param value Value (can be object or array)
|
|
25
|
-
* @returns Array value
|
|
26
|
-
*/
|
|
27
|
-
private static convertObjectToArray;
|
|
28
|
-
/**
|
|
29
|
-
* Encode a value with given ABI type
|
|
30
|
-
*
|
|
31
|
-
* @param abiType ABI type string (e.g., "string", "uint256", "tuple(string,uint8)")
|
|
32
|
-
* @param value Value to encode (objects are automatically converted to arrays)
|
|
33
|
-
* @returns Encoded bytes (with 0x prefix)
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* // Simple value
|
|
37
|
-
* TagAbiCodec.encode("string", "hello");
|
|
38
|
-
*
|
|
39
|
-
* // Array value
|
|
40
|
-
* TagAbiCodec.encode("string[]", ["a", "b", "c"]);
|
|
41
|
-
*
|
|
42
|
-
* // Tuple with object input
|
|
43
|
-
* TagAbiCodec.encode("tuple(string,uint8)", {name: "Alice", age: 30});
|
|
44
|
-
*
|
|
45
|
-
* // Nested tuple with object input
|
|
46
|
-
* TagAbiCodec.encode(
|
|
47
|
-
* "tuple(string,tuple(uint8,bool))",
|
|
48
|
-
* {name: "Alice", profile: {age: 30, verified: true}}
|
|
49
|
-
* );
|
|
50
|
-
*
|
|
51
|
-
* // Tuple with array input (still supported)
|
|
52
|
-
* TagAbiCodec.encode("tuple(string,uint8)", ["Alice", 30]);
|
|
53
|
-
*/
|
|
54
|
-
static encode(abiType: string, value: any): string;
|
|
55
|
-
/**
|
|
56
|
-
* Decode bytes with given ABI type
|
|
57
|
-
*
|
|
58
|
-
* @param abiType ABI type string
|
|
59
|
-
* @param encodedData Encoded bytes (with or without 0x prefix)
|
|
60
|
-
* @returns Decoded value
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* TagAbiCodec.decode("string", encodedBytes); // ā "hello"
|
|
64
|
-
* TagAbiCodec.decode("uint256", encodedBytes); // ā 123n (BigInt)
|
|
65
|
-
* TagAbiCodec.decode("tuple(string,uint8)", encodedBytes); // ā ["Alice", 30n]
|
|
66
|
-
*/
|
|
67
|
-
static decode(abiType: string, encodedData: string): any;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=tag-abi-codec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tag-abi-codec.d.ts","sourceRoot":"","sources":["../../src/utils/tag-abi-codec.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkB;IAEzC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAkC/B;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IA6CnC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM;IAQlD;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,GAAG;CAIxD"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TagAbiCodec = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
|
-
/**
|
|
6
|
-
* Tag ABI Codec
|
|
7
|
-
* Unified encoding/decoding utility for Tag values
|
|
8
|
-
*
|
|
9
|
-
* Key Principle: ALL values use abi.encode()
|
|
10
|
-
* - Simple values: abi.encode("value")
|
|
11
|
-
* - Arrays: abi.encode(["a", "b", "c"])
|
|
12
|
-
* - Tuples: abi.encode(struct)
|
|
13
|
-
* - Elements for push: abi.encode(singleElement)
|
|
14
|
-
*/
|
|
15
|
-
class TagAbiCodec {
|
|
16
|
-
/**
|
|
17
|
-
* Parse tuple field types from ABI type string
|
|
18
|
-
* @param abiType e.g., "tuple(string,uint8,tuple(bool,address))"
|
|
19
|
-
* @returns Array of field types: ["string", "uint8", "tuple(bool,address)"]
|
|
20
|
-
*/
|
|
21
|
-
static parseTupleFields(abiType) {
|
|
22
|
-
if (!abiType.startsWith('tuple(')) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
const innerTypes = abiType.slice(6, -1); // Remove "tuple(" and ")"
|
|
26
|
-
const fields = [];
|
|
27
|
-
let depth = 0;
|
|
28
|
-
let currentField = '';
|
|
29
|
-
for (let i = 0; i < innerTypes.length; i++) {
|
|
30
|
-
const char = innerTypes[i];
|
|
31
|
-
if (char === '(') {
|
|
32
|
-
depth++;
|
|
33
|
-
currentField += char;
|
|
34
|
-
}
|
|
35
|
-
else if (char === ')') {
|
|
36
|
-
depth--;
|
|
37
|
-
currentField += char;
|
|
38
|
-
}
|
|
39
|
-
else if (char === ',' && depth === 0) {
|
|
40
|
-
fields.push(currentField.trim());
|
|
41
|
-
currentField = '';
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
currentField += char;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (currentField) {
|
|
48
|
-
fields.push(currentField.trim());
|
|
49
|
-
}
|
|
50
|
-
return fields;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Convert object to array based on ABI type structure
|
|
54
|
-
* Supports nested tuples recursively
|
|
55
|
-
*
|
|
56
|
-
* @param abiType ABI type string
|
|
57
|
-
* @param value Value (can be object or array)
|
|
58
|
-
* @returns Array value
|
|
59
|
-
*/
|
|
60
|
-
static convertObjectToArray(abiType, value) {
|
|
61
|
-
// If already an array or not an object, return as-is
|
|
62
|
-
if (Array.isArray(value) ||
|
|
63
|
-
typeof value !== 'object' ||
|
|
64
|
-
value === null) {
|
|
65
|
-
return value;
|
|
66
|
-
}
|
|
67
|
-
// If not a tuple type, return as-is
|
|
68
|
-
if (!abiType.startsWith('tuple(')) {
|
|
69
|
-
return value;
|
|
70
|
-
}
|
|
71
|
-
// Parse tuple field types
|
|
72
|
-
const fieldTypes = this.parseTupleFields(abiType);
|
|
73
|
-
const fieldNames = Object.keys(value);
|
|
74
|
-
if (fieldNames.length !== fieldTypes.length) {
|
|
75
|
-
throw new Error(`Tuple field count mismatch: expected ${fieldTypes.length} fields, got ${fieldNames.length} (${fieldNames.join(', ')})`);
|
|
76
|
-
}
|
|
77
|
-
// Convert object to array, recursively handling nested tuples
|
|
78
|
-
const result = [];
|
|
79
|
-
for (let i = 0; i < fieldNames.length; i++) {
|
|
80
|
-
const fieldName = fieldNames[i];
|
|
81
|
-
const fieldType = fieldTypes[i];
|
|
82
|
-
const fieldValue = value[fieldName];
|
|
83
|
-
// Recursively convert nested tuples
|
|
84
|
-
if (fieldType.startsWith('tuple(')) {
|
|
85
|
-
result.push(this.convertObjectToArray(fieldType, fieldValue));
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
result.push(fieldValue);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Encode a value with given ABI type
|
|
95
|
-
*
|
|
96
|
-
* @param abiType ABI type string (e.g., "string", "uint256", "tuple(string,uint8)")
|
|
97
|
-
* @param value Value to encode (objects are automatically converted to arrays)
|
|
98
|
-
* @returns Encoded bytes (with 0x prefix)
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* // Simple value
|
|
102
|
-
* TagAbiCodec.encode("string", "hello");
|
|
103
|
-
*
|
|
104
|
-
* // Array value
|
|
105
|
-
* TagAbiCodec.encode("string[]", ["a", "b", "c"]);
|
|
106
|
-
*
|
|
107
|
-
* // Tuple with object input
|
|
108
|
-
* TagAbiCodec.encode("tuple(string,uint8)", {name: "Alice", age: 30});
|
|
109
|
-
*
|
|
110
|
-
* // Nested tuple with object input
|
|
111
|
-
* TagAbiCodec.encode(
|
|
112
|
-
* "tuple(string,tuple(uint8,bool))",
|
|
113
|
-
* {name: "Alice", profile: {age: 30, verified: true}}
|
|
114
|
-
* );
|
|
115
|
-
*
|
|
116
|
-
* // Tuple with array input (still supported)
|
|
117
|
-
* TagAbiCodec.encode("tuple(string,uint8)", ["Alice", 30]);
|
|
118
|
-
*/
|
|
119
|
-
static encode(abiType, value) {
|
|
120
|
-
// Convert object to array if needed (handles nested tuples recursively)
|
|
121
|
-
const convertedValue = this.convertObjectToArray(abiType, value);
|
|
122
|
-
// Use ethers AbiCoder to encode
|
|
123
|
-
return this.abiCoder.encode([abiType], [convertedValue]);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Decode bytes with given ABI type
|
|
127
|
-
*
|
|
128
|
-
* @param abiType ABI type string
|
|
129
|
-
* @param encodedData Encoded bytes (with or without 0x prefix)
|
|
130
|
-
* @returns Decoded value
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* TagAbiCodec.decode("string", encodedBytes); // ā "hello"
|
|
134
|
-
* TagAbiCodec.decode("uint256", encodedBytes); // ā 123n (BigInt)
|
|
135
|
-
* TagAbiCodec.decode("tuple(string,uint8)", encodedBytes); // ā ["Alice", 30n]
|
|
136
|
-
*/
|
|
137
|
-
static decode(abiType, encodedData) {
|
|
138
|
-
const decoded = this.abiCoder.decode([abiType], encodedData);
|
|
139
|
-
return decoded[0];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.TagAbiCodec = TagAbiCodec;
|
|
143
|
-
TagAbiCodec.abiCoder = new ethers_1.AbiCoder();
|
|
144
|
-
//# sourceMappingURL=tag-abi-codec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tag-abi-codec.js","sourceRoot":"","sources":["../../src/utils/tag-abi-codec.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Crypto Utilities
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates all crypto utility functions:
|
|
5
|
-
* - Generate mnemonic phrases
|
|
6
|
-
* - Derive Ethereum addresses from mnemonics
|
|
7
|
-
* - Derive DIDs from mnemonics
|
|
8
|
-
* - Derive EVM private keys from mnemonics
|
|
9
|
-
* - Complete key derivation (all at once)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
generateMnemonic,
|
|
14
|
-
getEthereumAddressFromMnemonic,
|
|
15
|
-
getDIDFromMnemonic,
|
|
16
|
-
getEVMPrivateKeyFromMnemonic,
|
|
17
|
-
deriveDIDFromMnemonic,
|
|
18
|
-
generateDIDKeyData
|
|
19
|
-
} from '../src/utils/crypto-utils';
|
|
20
|
-
|
|
21
|
-
async function main() {
|
|
22
|
-
console.log('='.repeat(60));
|
|
23
|
-
console.log('Crypto Utilities Examples');
|
|
24
|
-
console.log('='.repeat(60));
|
|
25
|
-
|
|
26
|
-
// =========================================================================
|
|
27
|
-
// 1. Generate Mnemonic
|
|
28
|
-
// =========================================================================
|
|
29
|
-
console.log('\nš Example 1: Generate Mnemonic Phrases');
|
|
30
|
-
console.log('-'.repeat(60));
|
|
31
|
-
|
|
32
|
-
const mnemonic12 = generateMnemonic(12);
|
|
33
|
-
console.log('12-word mnemonic:', mnemonic12);
|
|
34
|
-
|
|
35
|
-
const mnemonic24 = generateMnemonic(24);
|
|
36
|
-
console.log('24-word mnemonic:', mnemonic24);
|
|
37
|
-
|
|
38
|
-
// =========================================================================
|
|
39
|
-
// 2. Derive Ethereum Address
|
|
40
|
-
// =========================================================================
|
|
41
|
-
console.log('\nš Example 2: Get Ethereum Address from Mnemonic');
|
|
42
|
-
console.log('-'.repeat(60));
|
|
43
|
-
|
|
44
|
-
const testMnemonic =
|
|
45
|
-
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
|
|
46
|
-
const address = await getEthereumAddressFromMnemonic(testMnemonic);
|
|
47
|
-
console.log('Mnemonic:', testMnemonic);
|
|
48
|
-
console.log('Address:', address);
|
|
49
|
-
|
|
50
|
-
// =========================================================================
|
|
51
|
-
// 3. Derive DID
|
|
52
|
-
// =========================================================================
|
|
53
|
-
console.log('\nš Example 3: Get DID from Mnemonic');
|
|
54
|
-
console.log('-'.repeat(60));
|
|
55
|
-
|
|
56
|
-
const did = await getDIDFromMnemonic(testMnemonic);
|
|
57
|
-
console.log('Mnemonic:', testMnemonic);
|
|
58
|
-
console.log('DID:', did);
|
|
59
|
-
|
|
60
|
-
// =========================================================================
|
|
61
|
-
// 4. Derive EVM Private Key
|
|
62
|
-
// =========================================================================
|
|
63
|
-
console.log('\nš Example 4: Get EVM Private Key from Mnemonic');
|
|
64
|
-
console.log('-'.repeat(60));
|
|
65
|
-
|
|
66
|
-
const privateKey = await getEVMPrivateKeyFromMnemonic(testMnemonic);
|
|
67
|
-
console.log('Mnemonic:', testMnemonic);
|
|
68
|
-
console.log('Private Key:', privateKey);
|
|
69
|
-
console.log('\nā ļø Never share your private key!');
|
|
70
|
-
|
|
71
|
-
// =========================================================================
|
|
72
|
-
// 5. Derive Owner and DID Together
|
|
73
|
-
// =========================================================================
|
|
74
|
-
console.log('\nš Example 5: Derive Owner and DID from Mnemonic');
|
|
75
|
-
console.log('-'.repeat(60));
|
|
76
|
-
|
|
77
|
-
const { owner, did: derivedDid } = await deriveDIDFromMnemonic(
|
|
78
|
-
testMnemonic
|
|
79
|
-
);
|
|
80
|
-
console.log('Mnemonic:', testMnemonic);
|
|
81
|
-
console.log('Owner (Address):', owner);
|
|
82
|
-
console.log('DID:', derivedDid);
|
|
83
|
-
|
|
84
|
-
// =========================================================================
|
|
85
|
-
// 6. Generate Complete Key Data (All at Once)
|
|
86
|
-
// =========================================================================
|
|
87
|
-
console.log('\nš² Example 6: Generate Complete Key Data');
|
|
88
|
-
console.log('-'.repeat(60));
|
|
89
|
-
|
|
90
|
-
const keyData12 = await generateDIDKeyData(12);
|
|
91
|
-
console.log('Generated 12-word key set:');
|
|
92
|
-
console.log(' Mnemonic:', keyData12.mnemonic);
|
|
93
|
-
console.log(' Owner:', keyData12.owner);
|
|
94
|
-
console.log(' DID:', keyData12.did);
|
|
95
|
-
|
|
96
|
-
const keyData24 = await generateDIDKeyData(24);
|
|
97
|
-
console.log('\nGenerated 24-word key set:');
|
|
98
|
-
console.log(' Mnemonic:', keyData24.mnemonic);
|
|
99
|
-
console.log(' Owner:', keyData24.owner);
|
|
100
|
-
console.log(' DID:', keyData24.did);
|
|
101
|
-
|
|
102
|
-
// =========================================================================
|
|
103
|
-
// 7. Verify Consistency
|
|
104
|
-
// =========================================================================
|
|
105
|
-
console.log('\nā
Example 7: Verify Consistency');
|
|
106
|
-
console.log('-'.repeat(60));
|
|
107
|
-
|
|
108
|
-
const verifyMnemonic = generateMnemonic(12);
|
|
109
|
-
console.log('Testing mnemonic:', verifyMnemonic);
|
|
110
|
-
|
|
111
|
-
const addr1 = await getEthereumAddressFromMnemonic(verifyMnemonic);
|
|
112
|
-
const { owner: addr2 } = await deriveDIDFromMnemonic(verifyMnemonic);
|
|
113
|
-
const { owner: addr3 } = await generateDIDKeyData(12); // Different mnemonic
|
|
114
|
-
|
|
115
|
-
console.log('\nAddresses derived from same mnemonic:');
|
|
116
|
-
console.log(' Method 1 (getEthereumAddressFromMnemonic):', addr1);
|
|
117
|
-
console.log(' Method 2 (deriveDIDFromMnemonic):', addr2);
|
|
118
|
-
console.log(' Consistent?', addr1 === addr2 ? 'ā
Yes' : 'ā No');
|
|
119
|
-
|
|
120
|
-
console.log('\nAddresses from different mnemonics:');
|
|
121
|
-
console.log(' Address 1:', addr1);
|
|
122
|
-
console.log(' Address 2:', addr3);
|
|
123
|
-
console.log(' Different?', addr1 !== addr3 ? 'ā
Yes' : 'ā No');
|
|
124
|
-
|
|
125
|
-
// =========================================================================
|
|
126
|
-
// Summary
|
|
127
|
-
// =========================================================================
|
|
128
|
-
console.log('\n' + '='.repeat(60));
|
|
129
|
-
console.log('Summary of Crypto Utilities:');
|
|
130
|
-
console.log('='.repeat(60));
|
|
131
|
-
console.log('1. generateMnemonic(words) - Generate new mnemonic');
|
|
132
|
-
console.log('2. getEthereumAddressFromMnemonic - Get Ethereum address');
|
|
133
|
-
console.log('3. getDIDFromMnemonic - Get DID');
|
|
134
|
-
console.log('4. getEVMPrivateKeyFromMnemonic - Get private key');
|
|
135
|
-
console.log('5. deriveDIDFromMnemonic - Get owner + DID');
|
|
136
|
-
console.log('6. generateDIDKeyData - Generate all at once');
|
|
137
|
-
console.log('='.repeat(60));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
main().catch(console.error);
|
package/examples/ed25519-jwk.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Generate Ed25519 JWK using mnemonic and key pair derivation
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates how to:
|
|
5
|
-
* 1. Generate a BIP39 mnemonic phrase
|
|
6
|
-
* 2. Derive Ed25519 key pair from the mnemonic
|
|
7
|
-
* 3. Convert the key pair to JSON Web Key (JWK) format
|
|
8
|
-
*
|
|
9
|
-
* The JWK format is commonly used for cryptographic keys in web applications
|
|
10
|
-
* and follows the RFC 7517 specification.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { generateMnemonic, getEd25519JwkFromMnemonic } from '../src/index';
|
|
14
|
-
|
|
15
|
-
async function example_generateEd25519JWK() {
|
|
16
|
-
console.log('='.repeat(70));
|
|
17
|
-
console.log('Example: Generate Ed25519 JWK from Mnemonic');
|
|
18
|
-
console.log('='.repeat(70));
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
// Step 1: Generate a new mnemonic phrase
|
|
22
|
-
console.log('\nš Step 1: Generating BIP39 mnemonic...');
|
|
23
|
-
const mnemonic = generateMnemonic(12);
|
|
24
|
-
console.log(`Mnemonic: ${mnemonic}`);
|
|
25
|
-
|
|
26
|
-
// Step 2: Derive Ed25519 key pair and DID from mnemonic
|
|
27
|
-
console.log('\nš Step 2: Deriving Ed25519 key pair from mnemonic...');
|
|
28
|
-
const { publicJwk, privateJwk } = await getEd25519JwkFromMnemonic(
|
|
29
|
-
mnemonic
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
console.log(`Public JWK: ${JSON.stringify(publicJwk, null, 2)}`);
|
|
33
|
-
console.log(`Private JWK: ${JSON.stringify(privateJwk, null, 2)}`);
|
|
34
|
-
} catch (error: any) {
|
|
35
|
-
console.error('\nā Error:', error.message);
|
|
36
|
-
if (error.stack) {
|
|
37
|
-
console.error('\nStack trace:');
|
|
38
|
-
console.error(error.stack);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function main() {
|
|
44
|
-
console.log('š Ed25519 JWK Generation Example\n');
|
|
45
|
-
console.log(
|
|
46
|
-
'This example shows how to generate Ed25519 keys in JWK format'
|
|
47
|
-
);
|
|
48
|
-
console.log("using olaresid's cryptographic utilities.\n");
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
await example_generateEd25519JWK();
|
|
52
|
-
|
|
53
|
-
console.log('\n\n' + '='.repeat(70));
|
|
54
|
-
console.log('ā
All examples completed successfully!');
|
|
55
|
-
console.log('='.repeat(70));
|
|
56
|
-
console.log('\nā ļø SECURITY WARNING:');
|
|
57
|
-
console.log(' - Never share your mnemonic phrase or private JWK!');
|
|
58
|
-
console.log(
|
|
59
|
-
' - Store private keys securely (encrypted, hardware security modules)'
|
|
60
|
-
);
|
|
61
|
-
console.log(' - Use public JWKs for verification purposes only\n');
|
|
62
|
-
} catch (error: any) {
|
|
63
|
-
console.error('\nā Error:', error.message || error);
|
|
64
|
-
if (error.stack) {
|
|
65
|
-
console.error('\nStack trace:');
|
|
66
|
-
console.error(error.stack);
|
|
67
|
-
}
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Run the examples
|
|
73
|
-
main();
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Generate mnemonic and derive keys using Trust Wallet Core
|
|
3
|
-
*
|
|
4
|
-
* This implementation is compatible with TermiPass and the entire Olares ecosystem.
|
|
5
|
-
* It uses Trust Wallet Core for key derivation, ensuring consistency across all projects.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
generateMnemonic,
|
|
10
|
-
getEthereumAddressFromMnemonic,
|
|
11
|
-
getDIDFromMnemonic,
|
|
12
|
-
generateDIDKeyData,
|
|
13
|
-
deriveDIDFromMnemonic
|
|
14
|
-
} from '../src/index';
|
|
15
|
-
|
|
16
|
-
async function example1_generateNew() {
|
|
17
|
-
console.log('='.repeat(60));
|
|
18
|
-
console.log('Example 1: Generate New Mnemonic and Keys');
|
|
19
|
-
console.log('Using Trust Wallet Core (Same as TermiPass)');
|
|
20
|
-
console.log('='.repeat(60));
|
|
21
|
-
|
|
22
|
-
// Generate a 12-word mnemonic
|
|
23
|
-
console.log('\nš Generating 12-word mnemonic...');
|
|
24
|
-
const mnemonic12 = generateMnemonic(12);
|
|
25
|
-
console.log(`Mnemonic: ${mnemonic12}`);
|
|
26
|
-
|
|
27
|
-
console.log('\nā³ Deriving keys using Trust Wallet Core...');
|
|
28
|
-
const owner12 = await getEthereumAddressFromMnemonic(mnemonic12);
|
|
29
|
-
const did12 = await getDIDFromMnemonic(mnemonic12);
|
|
30
|
-
|
|
31
|
-
console.log('\nā
Derived keys:');
|
|
32
|
-
console.log(` Ethereum Address: ${owner12}`);
|
|
33
|
-
console.log(` DID: ${did12}`);
|
|
34
|
-
|
|
35
|
-
// Generate a 24-word mnemonic
|
|
36
|
-
console.log('\n' + '-'.repeat(60));
|
|
37
|
-
console.log('\nš Generating 24-word mnemonic...');
|
|
38
|
-
const mnemonic24 = generateMnemonic(24);
|
|
39
|
-
console.log(`Mnemonic: ${mnemonic24}`);
|
|
40
|
-
|
|
41
|
-
console.log('\nā³ Deriving keys...');
|
|
42
|
-
const owner24 = await getEthereumAddressFromMnemonic(mnemonic24);
|
|
43
|
-
const did24 = await getDIDFromMnemonic(mnemonic24);
|
|
44
|
-
|
|
45
|
-
console.log('\nā
Derived keys:');
|
|
46
|
-
console.log(` Ethereum Address: ${owner24}`);
|
|
47
|
-
console.log(` DID: ${did24}`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async function example2_useGenerateDIDKeyData() {
|
|
51
|
-
console.log('\n\n' + '='.repeat(60));
|
|
52
|
-
console.log('Example 2: Generate Everything at Once');
|
|
53
|
-
console.log('='.repeat(60));
|
|
54
|
-
|
|
55
|
-
console.log('\nā³ Generating mnemonic and deriving keys...');
|
|
56
|
-
const keyData = await generateDIDKeyData(12);
|
|
57
|
-
|
|
58
|
-
console.log('\nā
Generated DID Key Data:');
|
|
59
|
-
console.log(` Mnemonic: ${keyData.mnemonic}`);
|
|
60
|
-
console.log(` Owner (Ethereum): ${keyData.owner}`);
|
|
61
|
-
console.log(` DID: ${keyData.did}`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async function example3_testCompatibility() {
|
|
65
|
-
console.log('\n\n' + '='.repeat(60));
|
|
66
|
-
console.log('Example 3: Verify Compatibility with TermiPass');
|
|
67
|
-
console.log('='.repeat(60));
|
|
68
|
-
|
|
69
|
-
// Use the same test mnemonic as in TermiPass
|
|
70
|
-
const testMnemonic =
|
|
71
|
-
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
|
|
72
|
-
|
|
73
|
-
console.log(`\nš Input mnemonic (standard test mnemonic):`);
|
|
74
|
-
console.log(testMnemonic);
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
console.log('\nā³ Deriving keys using Trust Wallet Core...');
|
|
78
|
-
const { owner, did } = await deriveDIDFromMnemonic(testMnemonic);
|
|
79
|
-
|
|
80
|
-
console.log('\nā
Derived keys:');
|
|
81
|
-
console.log(` Ethereum Address: ${owner}`);
|
|
82
|
-
console.log(` DID: ${did}`);
|
|
83
|
-
|
|
84
|
-
console.log('\nš” Note: These keys should match with TermiPass output');
|
|
85
|
-
console.log(
|
|
86
|
-
' You can verify this by running the same mnemonic in TermiPass'
|
|
87
|
-
);
|
|
88
|
-
} catch (error: any) {
|
|
89
|
-
console.error(`\nā Error: ${error.message}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function example4_parallelDerivation() {
|
|
94
|
-
console.log('\n\n' + '='.repeat(60));
|
|
95
|
-
console.log('Example 4: Parallel Key Derivation (Performance Test)');
|
|
96
|
-
console.log('='.repeat(60));
|
|
97
|
-
|
|
98
|
-
const mnemonic = generateMnemonic(12);
|
|
99
|
-
console.log(`\nš Mnemonic: ${mnemonic}`);
|
|
100
|
-
|
|
101
|
-
console.log('\nā³ Deriving owner and DID in parallel...');
|
|
102
|
-
const startTime = Date.now();
|
|
103
|
-
|
|
104
|
-
const { owner, did } = await deriveDIDFromMnemonic(mnemonic);
|
|
105
|
-
|
|
106
|
-
const endTime = Date.now();
|
|
107
|
-
const duration = endTime - startTime;
|
|
108
|
-
|
|
109
|
-
console.log('\nā
Results:');
|
|
110
|
-
console.log(` Owner: ${owner}`);
|
|
111
|
-
console.log(` DID: ${did}`);
|
|
112
|
-
console.log(` Time taken: ${duration}ms`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function main() {
|
|
116
|
-
console.log('š Trust Wallet Core Integration - Key Generation Examples\n');
|
|
117
|
-
console.log('This implementation ensures compatibility with TermiPass');
|
|
118
|
-
console.log('and the entire Olares ecosystem.\n');
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
await example1_generateNew();
|
|
122
|
-
await example2_useGenerateDIDKeyData();
|
|
123
|
-
await example3_testCompatibility();
|
|
124
|
-
await example4_parallelDerivation();
|
|
125
|
-
|
|
126
|
-
console.log('\n\n' + '='.repeat(60));
|
|
127
|
-
console.log('ā
All examples completed successfully!');
|
|
128
|
-
console.log('='.repeat(60));
|
|
129
|
-
console.log(
|
|
130
|
-
'\nā ļø SECURITY WARNING: Never share your mnemonic phrase!'
|
|
131
|
-
);
|
|
132
|
-
console.log(
|
|
133
|
-
' Store it securely and never commit it to version control.'
|
|
134
|
-
);
|
|
135
|
-
console.log(
|
|
136
|
-
'\nš” These keys are compatible with TermiPass and other Olares tools.\n'
|
|
137
|
-
);
|
|
138
|
-
} catch (error: any) {
|
|
139
|
-
console.error('\nā Error:', error.message || error);
|
|
140
|
-
if (error.stack) {
|
|
141
|
-
console.error('\nStack trace:');
|
|
142
|
-
console.error(error.stack);
|
|
143
|
-
}
|
|
144
|
-
process.exit(1);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Run the examples
|
|
149
|
-
main();
|
package/examples/legacy.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import DID from '../src/index';
|
|
2
|
-
|
|
3
|
-
// op sepolia testnet environment
|
|
4
|
-
const RPC = 'https://sepolia.optimism.io';
|
|
5
|
-
const CONTRACT_DID = '0xe2D7c3a9013960E04d4E9F5F9B63fff37eEd97A8'; // DID contract address
|
|
6
|
-
const CONTRACT_ROOT_RESOLVER = '0xcB045D9133A4F5ffCe2C98b2C47e951e8c9A0655'; // RootResolver contract address
|
|
7
|
-
const CONTRACT_ABI_TYPE = '0x7386fCBae6Ad4CCE1499d9153D99bc950B589718'; // ABIType contract address
|
|
8
|
-
|
|
9
|
-
// // op mainnet environment
|
|
10
|
-
// const RPC = 'https://optimism-rpc.publicnode.com';
|
|
11
|
-
// const CONTRACT_DID = '0x5DA4Fa8E567d86e52Ef8Da860de1be8f54cae97D'; // DID contract address
|
|
12
|
-
// const CONTRACT_ROOT_RESOLVER = '0x0223be5559961f9D393b28EFD1dBEdcB2dD67523'; // RootResolver contract address
|
|
13
|
-
// const CONTRACT_ABI_TYPE = '0x9ae3F16bD99294Af1784beB1a0A5C84bf2636365'; // ABIType contract address
|
|
14
|
-
|
|
15
|
-
async function main() {
|
|
16
|
-
const did = DID.createConsole(
|
|
17
|
-
RPC,
|
|
18
|
-
CONTRACT_DID,
|
|
19
|
-
CONTRACT_ROOT_RESOLVER,
|
|
20
|
-
CONTRACT_ABI_TYPE
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// Get specific domain data
|
|
24
|
-
const domain = await did.fetchDomain('tw7613781.olares.com');
|
|
25
|
-
console.log('Domain Data:', domain);
|
|
26
|
-
|
|
27
|
-
// Get all domain data (the mainnet has a large amount of data, the testnet has a small amount of data, for testing it is recommended to experience this function in the testnet environment)
|
|
28
|
-
await did.fetchAll();
|
|
29
|
-
console.log('All Domains:', did.allDomainCache);
|
|
30
|
-
console.log('Domain Tree Cache:', did.treesCache);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
main().catch(console.error);
|