@owlmeans/did 0.1.18-rc.8 → 0.1.18
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 +2 -2
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/did/SKILL.md +113 -16
- package/build/consts.local.d.ts +2 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +2 -0
- package/build/consts.local.js.map +1 -0
- package/build/i18n/fr.json +8 -0
- package/build/i18n/wallet-fr.json +99 -0
- package/build/i18n.js +19 -15
- package/build/i18n.js.map +1 -1
- package/build/model.d.ts.map +1 -1
- package/build/model.js +4 -4
- package/build/model.js.map +1 -1
- package/build/plugins/ed25519owl.js +5 -5
- package/build/plugins/ed25519owl.js.map +1 -1
- package/build/utils/index.d.ts +2 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/key.d.ts.map +1 -1
- package/build/utils/key.js +2 -2
- package/build/utils/key.js.map +1 -1
- package/build/utils/mnemonic/types.d.ts +13 -0
- package/build/utils/mnemonic/types.d.ts.map +1 -0
- package/build/utils/mnemonic/types.js +2 -0
- package/build/utils/mnemonic/types.js.map +1 -0
- package/build/utils/mnemonic.d.ts +3 -5
- package/build/utils/mnemonic.d.ts.map +1 -1
- package/build/utils/mnemonic.js +15 -11
- package/build/utils/mnemonic.js.map +1 -1
- package/build/utils/types.d.ts +11 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/build/utils.d.ts +3 -4
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +25 -21
- package/build/utils.js.map +1 -1
- package/build/wallet.d.ts.map +1 -1
- package/build/wallet.js +15 -15
- package/build/wallet.js.map +1 -1
- package/package.json +12 -11
- package/src/consts.local.ts +1 -0
- package/src/i18n/fr.json +8 -0
- package/src/i18n/wallet-fr.json +99 -0
- package/src/i18n.ts +20 -15
- package/src/model.ts +4 -4
- package/src/plugins/ed25519owl.ts +5 -5
- package/src/utils/index.ts +2 -0
- package/src/utils/key.ts +3 -3
- package/src/utils/mnemonic/types.ts +13 -0
- package/src/utils/mnemonic.ts +21 -14
- package/src/utils/types.ts +11 -0
- package/src/utils.ts +32 -26
- package/src/wallet.ts +19 -18
- package/tests/mnemonic.spec.ts +31 -0
- package/tsconfig.json +1 -1
- package/build/.gitkeep +0 -0
package/build/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const matchMeta: (haystack: KeyMeta, needle: Partial<KeyMeta>) => boolean;
|
|
1
|
+
import type { KeyPathUtils } from './utils/types.js';
|
|
2
|
+
export declare const createKeyPathUtils: () => KeyPathUtils;
|
|
3
|
+
export declare const keyPathUtils: KeyPathUtils;
|
|
5
4
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,eAAO,MAAM,kBAAkB,QAAO,YAgCrC,CAAA;AAED,eAAO,MAAM,YAAY,cAAuB,CAAA"}
|
package/build/utils.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { ENTITY_PREFIX, KP_SEP, PREFIX_SEP, PROFILE_PREFIX, SERVICE_PREFIX } from './consts.js';
|
|
2
|
-
|
|
3
|
-
export const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
items
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { skipFields } from './consts.local.js';
|
|
3
|
+
export const createKeyPathUtils = () => {
|
|
4
|
+
const toPath = (...args) => args.map(arg => Array.isArray(arg) ? arg.join(PREFIX_SEP) : arg).join(KP_SEP);
|
|
5
|
+
const mataToPath = (meta) => {
|
|
6
|
+
const { scopes, id, entityId } = meta;
|
|
7
|
+
const items = [];
|
|
8
|
+
if (scopes != null && scopes.length === 1) {
|
|
9
|
+
items.push([SERVICE_PREFIX, scopes[0]]);
|
|
10
|
+
}
|
|
11
|
+
if (entityId != null) {
|
|
12
|
+
items.push([ENTITY_PREFIX, entityId]);
|
|
13
|
+
}
|
|
14
|
+
if (id != null) {
|
|
15
|
+
items.push([PROFILE_PREFIX, id]);
|
|
16
|
+
}
|
|
17
|
+
return toPath(...items);
|
|
18
|
+
};
|
|
19
|
+
const matchMeta = (haystack, needle) => Object.entries(needle).every(([key, value]) => skipFields.includes(key)
|
|
20
|
+
|| (haystack[key] != null
|
|
21
|
+
&& (Array.isArray(value)
|
|
22
|
+
? Array.isArray(haystack[key])
|
|
23
|
+
&& value.every(value => haystack[key].includes(value))
|
|
24
|
+
: haystack[key] === value)));
|
|
25
|
+
return { toPath, mataToPath, matchMeta };
|
|
16
26
|
};
|
|
17
|
-
const
|
|
18
|
-
export const matchMeta = (haystack, needle) => Object.entries(needle).every(([key, value]) => skipFields.includes(key)
|
|
19
|
-
|| (haystack[key] != null
|
|
20
|
-
&& (Array.isArray(value)
|
|
21
|
-
? Array.isArray(haystack[key])
|
|
22
|
-
&& value.every(value => haystack[key].includes(value))
|
|
23
|
-
: haystack[key] === value)));
|
|
27
|
+
export const keyPathUtils = createKeyPathUtils();
|
|
24
28
|
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE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C,CAAA;IAED,MAAM,SAAS,GAAG,CAAC,QAAiB,EAAE,MAAwB,EAAW,EAAE,CACzE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAC5C,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;WACrB,CAAC,QAAQ,CAAC,GAA4B,CAAC,IAAI,IAAI;eAC7C,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACtB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAA4B,CAAC,CAAC;uBACpD,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,QAAQ,CAAC,GAA4B,CAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC9F,CAAC,CAAC,QAAQ,CAAC,GAA4B,CAAC,KAAK,KAAK,CAAC,CACtD,CAAC,CAAA;IAEN,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA;AAC1C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAA"}
|
package/build/wallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,QAAQ,EAAE,SAAS,EAAyC,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAS/H,eAAO,MAAM,UAAU,UAAiB,QAAQ,SAAS,oBAAoB,KAAG,OAAO,CAAC,SAAS,CA4KhG,CAAA"}
|
package/build/wallet.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DIDInitializationError, DIDKeyError, DIDWalletError } from './errors.js';
|
|
2
|
-
import { generateMnemonic, toEntropy, toMnemonic, toSeed } from './utils/mnemonic.js';
|
|
3
2
|
import { KEY_OWL, MASTER } from './consts.js';
|
|
4
3
|
import { plugins } from './plugins/index.js';
|
|
5
4
|
import { ed25519owlPluginBuilder } from './plugins/ed25519owl.js';
|
|
6
5
|
import { produceKey } from './utils/key.js';
|
|
7
6
|
import { makeDidKeyModel } from './model.js';
|
|
8
|
-
import {
|
|
7
|
+
import { keyPathUtils } from './utils.js';
|
|
8
|
+
import { mnemonicHelper } from './utils/mnemonic.js';
|
|
9
9
|
export const makeWallet = async (store, opts) => {
|
|
10
10
|
if (await store.master.load(MASTER) == null) {
|
|
11
11
|
if (!opts?.force && !opts?.allowEmpty) {
|
|
@@ -21,10 +21,10 @@ export const makeWallet = async (store, opts) => {
|
|
|
21
21
|
const wallet = {
|
|
22
22
|
store,
|
|
23
23
|
generate: async (opts) => {
|
|
24
|
-
const mnemonic = generateMnemonic(opts);
|
|
24
|
+
const mnemonic = mnemonicHelper.generateMnemonic(opts);
|
|
25
25
|
const seed = {
|
|
26
|
-
entropy: toEntropy(mnemonic),
|
|
27
|
-
seed: toSeed(mnemonic)
|
|
26
|
+
entropy: mnemonicHelper.toEntropy(mnemonic),
|
|
27
|
+
seed: mnemonicHelper.toSeed(mnemonic)
|
|
28
28
|
};
|
|
29
29
|
const master = produceKey(seed.seed, type);
|
|
30
30
|
await store.master.save({ id: MASTER, ...master, ...seed });
|
|
@@ -37,7 +37,7 @@ export const makeWallet = async (store, opts) => {
|
|
|
37
37
|
}
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
|
-
return toMnemonic(master.seed);
|
|
40
|
+
return mnemonicHelper.toMnemonic(master.seed);
|
|
41
41
|
},
|
|
42
42
|
master: async () => makeDidKeyModel(await store.master.get(MASTER)),
|
|
43
43
|
add: async (key, meta) => {
|
|
@@ -76,15 +76,16 @@ export const makeWallet = async (store, opts) => {
|
|
|
76
76
|
return makeDidKeyModel(await store.keys.get(did));
|
|
77
77
|
},
|
|
78
78
|
find: async (meta) => {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
79
|
+
const where = Object.fromEntries(Object.entries(meta).filter(([_, v]) => typeof v !== 'boolean'));
|
|
80
|
+
const result = await store.meta.list(where);
|
|
81
|
+
const keys = await Promise.all(result.items.filter(item => keyPathUtils.matchMeta(item, meta))
|
|
81
82
|
.map(async (meta) => store.keys.get(meta.id)));
|
|
82
83
|
return keys.map(key => makeDidKeyModel(key));
|
|
83
84
|
},
|
|
84
85
|
provide: async (meta) => {
|
|
85
86
|
const found = await wallet.find(meta);
|
|
86
87
|
if (found.length === 0) {
|
|
87
|
-
const path = mataToPath(meta);
|
|
88
|
+
const path = keyPathUtils.mataToPath(meta);
|
|
88
89
|
const master = await wallet.master();
|
|
89
90
|
const key = master.derive(path);
|
|
90
91
|
if (meta.name == null) {
|
|
@@ -116,7 +117,7 @@ export const makeWallet = async (store, opts) => {
|
|
|
116
117
|
if (key == null) {
|
|
117
118
|
throw new DIDWalletError('no:key');
|
|
118
119
|
}
|
|
119
|
-
await store.keys.delete(
|
|
120
|
+
await store.keys.delete(did);
|
|
120
121
|
const model = makeDidKeyModel(key);
|
|
121
122
|
await store.meta.delete(model.exportAddress());
|
|
122
123
|
return model;
|
|
@@ -125,9 +126,9 @@ export const makeWallet = async (store, opts) => {
|
|
|
125
126
|
const result = [];
|
|
126
127
|
let more = false;
|
|
127
128
|
do {
|
|
128
|
-
const found = await store.keys.list(
|
|
129
|
+
const found = await store.keys.list(undefined, { page: Math.floor(result.length / 100), size: 100 });
|
|
129
130
|
result.push(...found.items);
|
|
130
|
-
more = found.
|
|
131
|
+
more = found.items.length > 0 && found.total > result.length;
|
|
131
132
|
} while (more);
|
|
132
133
|
return result.map(key => makeDidKeyModel(key));
|
|
133
134
|
},
|
|
@@ -135,10 +136,9 @@ export const makeWallet = async (store, opts) => {
|
|
|
135
136
|
const result = [];
|
|
136
137
|
let more = false;
|
|
137
138
|
do {
|
|
138
|
-
|
|
139
|
-
const found = await store.meta.list({ pager: { page: Math.floor(result.length / 100), size: 100 } });
|
|
139
|
+
const found = await store.meta.list(undefined, { page: Math.floor(result.length / 100), size: 100 });
|
|
140
140
|
result.push(...found.items);
|
|
141
|
-
more = found.
|
|
141
|
+
more = found.items.length > 0 && found.total > result.length;
|
|
142
142
|
} while (more);
|
|
143
143
|
return result;
|
|
144
144
|
}
|
package/build/wallet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,KAAe,EAAE,IAA2B,EAAsB,EAAE;IACnG,IAAI,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;YACtC,MAAM,IAAI,sBAAsB,CAAC,QAAQ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,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/did",
|
|
3
|
-
"version": "0.1.18
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc -b",
|
|
8
|
+
"test": "bun test ./tests",
|
|
8
9
|
"dev": "sleep 153 && nodemon -e ts,tsx,json --watch src --exec \"tsc -p ./tsconfig.json\"",
|
|
9
10
|
"watch": "tsc -b -w --preserveWatchOutput --pretty"
|
|
10
11
|
},
|
|
@@ -21,18 +22,18 @@
|
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@noble/curves": "^
|
|
25
|
-
"@noble/hashes": "^
|
|
26
|
-
"@owlmeans/auth": "^0.1.18
|
|
27
|
-
"@owlmeans/basic-keys": "^0.1.18
|
|
28
|
-
"@owlmeans/error": "^0.1.18
|
|
29
|
-
"@owlmeans/i18n": "^0.1.18
|
|
30
|
-
"@owlmeans/resource": "^0.1.18
|
|
31
|
-
"@scure/base": "^2.
|
|
32
|
-
"@scure/bip39": "^
|
|
25
|
+
"@noble/curves": "^2.4.0",
|
|
26
|
+
"@noble/hashes": "^2.4.0",
|
|
27
|
+
"@owlmeans/auth": "^0.1.18",
|
|
28
|
+
"@owlmeans/basic-keys": "^0.1.18",
|
|
29
|
+
"@owlmeans/error": "^0.1.18",
|
|
30
|
+
"@owlmeans/i18n": "^0.1.18",
|
|
31
|
+
"@owlmeans/resource": "^0.1.18",
|
|
32
|
+
"@scure/base": "^2.4.0",
|
|
33
|
+
"@scure/bip39": "^2.4.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@owlmeans/dep-config": "
|
|
36
|
+
"@owlmeans/dep-config": "^0.1.18",
|
|
36
37
|
"nodemon": "^3.1.14",
|
|
37
38
|
"typescript": "^7.0.2"
|
|
38
39
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const skipFields = ['name']
|
package/src/i18n/fr.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"createKey": {
|
|
3
|
+
"title": "Créer une clé",
|
|
4
|
+
"description": "Une organisation ou un service vous demande de créer une nouvelle clé cryptographique",
|
|
5
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi la création de cette clé vous est demandée.",
|
|
6
|
+
"proceed": {
|
|
7
|
+
"label": "Confirmer"
|
|
8
|
+
},
|
|
9
|
+
"cancel": {
|
|
10
|
+
"label": "Annuler"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"getEntityKey": {
|
|
14
|
+
"title": "Obtenir la clé publique d’une organisation",
|
|
15
|
+
"description": "Un service vous demande de fournir une clé publique et des données associées pour un profil d’organisation",
|
|
16
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi cette clé vous est demandée.",
|
|
17
|
+
"proceed": {
|
|
18
|
+
"label": "Confirmer"
|
|
19
|
+
},
|
|
20
|
+
"cancel": {
|
|
21
|
+
"label": "Annuler"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"sign": {
|
|
25
|
+
"title": "Signer avec la clé",
|
|
26
|
+
"description": "Un service vous demande de signer un document avec votre clé",
|
|
27
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi cette signature vous est demandée.",
|
|
28
|
+
"proceed": {
|
|
29
|
+
"label": "Confirmer"
|
|
30
|
+
},
|
|
31
|
+
"cancel": {
|
|
32
|
+
"label": "Annuler"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"masterSign": {
|
|
36
|
+
"title": "Signer avec la clé principale",
|
|
37
|
+
"description": "Un service vous demande de signer un document avec votre clé principale, qui devrait vraisemblablement être utilisée seulement avec les services OwlMeans",
|
|
38
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi cette signature vous est demandée.",
|
|
39
|
+
"proceed": {
|
|
40
|
+
"label": "Confirmer"
|
|
41
|
+
},
|
|
42
|
+
"cancel": {
|
|
43
|
+
"label": "Annuler"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"getMasterDid": {
|
|
47
|
+
"title": "Obtenir votre DID principal",
|
|
48
|
+
"description": "Un service vous demande votre adresse décentralisée principale, qui devrait vraisemblablement être partagée seulement avec les services OwlMeans",
|
|
49
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi le partage de votre DID principal vous est demandé.",
|
|
50
|
+
"proceed": {
|
|
51
|
+
"label": "Confirmer"
|
|
52
|
+
},
|
|
53
|
+
"cancel": {
|
|
54
|
+
"label": "Annuler"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"selectKey": {
|
|
58
|
+
"title": "Choisir une clé",
|
|
59
|
+
"description": "Un service vous demande de choisir une clé pour obtenir ses informations publiques",
|
|
60
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi les informations publiques d’une de vos clés vous sont demandées.",
|
|
61
|
+
"proceed": {
|
|
62
|
+
"label": "Confirmer"
|
|
63
|
+
},
|
|
64
|
+
"cancel": {
|
|
65
|
+
"label": "Annuler"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"getPublicDetails": {
|
|
69
|
+
"title": "Obtenir la clé publique",
|
|
70
|
+
"description": "Un service vous demande une clé publique liée au profil de votre organisation",
|
|
71
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi le partage de votre clé publique vous est demandé.",
|
|
72
|
+
"proceed": {
|
|
73
|
+
"label": "Confirmer"
|
|
74
|
+
},
|
|
75
|
+
"cancel": {
|
|
76
|
+
"label": "Annuler"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"requestPermissions": {
|
|
80
|
+
"title": "Autorisations demandées",
|
|
81
|
+
"description": "Un service demande à effectuer une suite d’actions avec votre portefeuille",
|
|
82
|
+
"unknown-reason": "Soyez prudent : nous ne savons pas pourquoi ces actions vous sont demandées.",
|
|
83
|
+
"proceed": {
|
|
84
|
+
"label": "Confirmer"
|
|
85
|
+
},
|
|
86
|
+
"cancel": {
|
|
87
|
+
"label": "Annuler"
|
|
88
|
+
},
|
|
89
|
+
"method": {
|
|
90
|
+
"createKey": "Créer une clé cryptographique",
|
|
91
|
+
"getEntityKey": "Obtenir la clé publique d’une organisation",
|
|
92
|
+
"sign": "Signer des données avec votre clé",
|
|
93
|
+
"masterSign": "Signer des données avec votre clé principale",
|
|
94
|
+
"getMasterDid": "Obtenir votre identifiant principal",
|
|
95
|
+
"selectKey": "Obtenir une de vos clés publiques",
|
|
96
|
+
"getPublicDetails": "Obtenir votre clé publique"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
package/src/i18n.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
|
|
3
3
|
import en from './i18n/en.json' with { type: 'json' }
|
|
4
4
|
import pl from './i18n/pl.json' with { type: 'json' }
|
|
@@ -7,6 +7,7 @@ import be from './i18n/be.json' with { type: 'json' }
|
|
|
7
7
|
import uk from './i18n/uk.json' with { type: 'json' }
|
|
8
8
|
import es from './i18n/es.json' with { type: 'json' }
|
|
9
9
|
import de from './i18n/de.json' with { type: 'json' }
|
|
10
|
+
import fr from './i18n/fr.json' with { type: 'json' }
|
|
10
11
|
|
|
11
12
|
import walletEn from './i18n/wallet-en.json' with { type: 'json' }
|
|
12
13
|
import walletPl from './i18n/wallet-pl.json' with { type: 'json' }
|
|
@@ -15,19 +16,23 @@ import walletBe from './i18n/wallet-be.json' with { type: 'json' }
|
|
|
15
16
|
import walletUk from './i18n/wallet-uk.json' with { type: 'json' }
|
|
16
17
|
import walletEs from './i18n/wallet-es.json' with { type: 'json' }
|
|
17
18
|
import walletDe from './i18n/wallet-de.json' with { type: 'json' }
|
|
19
|
+
import walletFr from './i18n/wallet-fr.json' with { type: 'json' }
|
|
20
|
+
import { i18nHelper } from '@owlmeans/i18n'
|
|
18
21
|
|
|
19
|
-
addI18nLib('en', 'keys', en, { ns: 'did' })
|
|
20
|
-
addI18nLib('pl', 'keys', pl, { ns: 'did' })
|
|
21
|
-
addI18nLib('ru', 'keys', ru, { ns: 'did' })
|
|
22
|
-
addI18nLib('be', 'keys', be, { ns: 'did' })
|
|
23
|
-
addI18nLib('uk', 'keys', uk, { ns: 'did' })
|
|
24
|
-
addI18nLib('es', 'keys', es, { ns: 'did' })
|
|
25
|
-
addI18nLib('de', 'keys', de, { ns: 'did' })
|
|
22
|
+
i18nHelper.addI18nLib('en', 'keys', en, { ns: 'did' })
|
|
23
|
+
i18nHelper.addI18nLib('pl', 'keys', pl, { ns: 'did' })
|
|
24
|
+
i18nHelper.addI18nLib('ru', 'keys', ru, { ns: 'did' })
|
|
25
|
+
i18nHelper.addI18nLib('be', 'keys', be, { ns: 'did' })
|
|
26
|
+
i18nHelper.addI18nLib('uk', 'keys', uk, { ns: 'did' })
|
|
27
|
+
i18nHelper.addI18nLib('es', 'keys', es, { ns: 'did' })
|
|
28
|
+
i18nHelper.addI18nLib('de', 'keys', de, { ns: 'did' })
|
|
29
|
+
i18nHelper.addI18nLib('fr', 'keys', fr, { ns: 'did' })
|
|
26
30
|
|
|
27
|
-
addI18nLib('en', 'wallet', walletEn, { ns: 'did' })
|
|
28
|
-
addI18nLib('pl', 'wallet', walletPl, { ns: 'did' })
|
|
29
|
-
addI18nLib('ru', 'wallet', walletRu, { ns: 'did' })
|
|
30
|
-
addI18nLib('be', 'wallet', walletBe, { ns: 'did' })
|
|
31
|
-
addI18nLib('uk', 'wallet', walletUk, { ns: 'did' })
|
|
32
|
-
addI18nLib('es', 'wallet', walletEs, { ns: 'did' })
|
|
33
|
-
addI18nLib('de', 'wallet', walletDe, { ns: 'did' })
|
|
31
|
+
i18nHelper.addI18nLib('en', 'wallet', walletEn, { ns: 'did' })
|
|
32
|
+
i18nHelper.addI18nLib('pl', 'wallet', walletPl, { ns: 'did' })
|
|
33
|
+
i18nHelper.addI18nLib('ru', 'wallet', walletRu, { ns: 'did' })
|
|
34
|
+
i18nHelper.addI18nLib('be', 'wallet', walletBe, { ns: 'did' })
|
|
35
|
+
i18nHelper.addI18nLib('uk', 'wallet', walletUk, { ns: 'did' })
|
|
36
|
+
i18nHelper.addI18nLib('es', 'wallet', walletEs, { ns: 'did' })
|
|
37
|
+
i18nHelper.addI18nLib('de', 'wallet', walletDe, { ns: 'did' })
|
|
38
|
+
i18nHelper.addI18nLib('fr', 'wallet', walletFr, { ns: 'did' })
|
package/src/model.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { makeKeyPairModel, plugins, type KeyPair } from '@owlmeans/basic-keys'
|
|
2
2
|
import type { DIDKeyModel } from './types.js'
|
|
3
3
|
import { DIDKeyError } from './errors.js'
|
|
4
|
-
import {
|
|
4
|
+
import { keyUtils } from '@owlmeans/basic-keys/utils'
|
|
5
5
|
import { base64 } from '@scure/base'
|
|
6
6
|
import { KP_SEP, MAX_DEPTH } from './consts.js'
|
|
7
7
|
|
|
8
|
-
export const makeDidKeyModel
|
|
8
|
+
export const makeDidKeyModel = (input?: KeyPair | string): DIDKeyModel => {
|
|
9
9
|
if (typeof input == 'string') {
|
|
10
10
|
const plugin = plugins[input]
|
|
11
11
|
if (plugin != null && (plugin.fromSeed == null || plugin.derive == null)) {
|
|
@@ -18,7 +18,7 @@ export const makeDidKeyModel: (input?: KeyPair | string) => DIDKeyModel = input
|
|
|
18
18
|
if (model.keyPair == null) {
|
|
19
19
|
throw new DIDKeyError('no:keypair')
|
|
20
20
|
}
|
|
21
|
-
assertType(model.keyPair?.type)
|
|
21
|
+
keyUtils.assertType(model.keyPair?.type)
|
|
22
22
|
if (model.keyPair.privateKey == null) {
|
|
23
23
|
throw new DIDKeyError('no:pk')
|
|
24
24
|
}
|
|
@@ -35,7 +35,7 @@ export const makeDidKeyModel: (input?: KeyPair | string) => DIDKeyModel = input
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const newKey = [model.keyPair.type, base64.encode(
|
|
38
|
-
plugins[model.keyPair.type].derive!(prepareKey(model.keyPair.privateKey), item)
|
|
38
|
+
plugins[model.keyPair.type].derive!(keyUtils.prepareKey(model.keyPair.privateKey), item)
|
|
39
39
|
)].join(':')
|
|
40
40
|
|
|
41
41
|
const derived = makeDidKeyModel(newKey)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ed25519 } from '@noble/curves/ed25519'
|
|
1
|
+
import { ed25519 } from '@noble/curves/ed25519.js'
|
|
2
2
|
import type { KeyPlugin } from '@owlmeans/basic-keys/plugins'
|
|
3
3
|
import { KEY_OWL } from '../consts.js'
|
|
4
4
|
import { base58, utf8 } from '@scure/base'
|
|
5
|
-
import { concatBytes, randomBytes } from '@noble/hashes/utils'
|
|
6
|
-
import { hmac } from '@noble/hashes/hmac'
|
|
7
|
-
import { sha512 } from '@noble/hashes/
|
|
8
|
-
import { keccak_256 } from '@noble/hashes/sha3'
|
|
5
|
+
import { concatBytes, randomBytes } from '@noble/hashes/utils.js'
|
|
6
|
+
import { hmac } from '@noble/hashes/hmac.js'
|
|
7
|
+
import { sha512 } from '@noble/hashes/sha2.js'
|
|
8
|
+
import { keccak_256 } from '@noble/hashes/sha3.js'
|
|
9
9
|
|
|
10
10
|
export const ed25519owlPluginBuilder = (type: string = KEY_OWL): KeyPlugin => {
|
|
11
11
|
const key: KeyPlugin = {
|
package/src/utils/index.ts
CHANGED
package/src/utils/key.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { keyUtils } from '@owlmeans/basic-keys/utils'
|
|
3
3
|
import { KEY_OWL } from '../consts.js'
|
|
4
4
|
import { base64 } from '@scure/base'
|
|
5
5
|
import { plugins } from '../plugins/index.js'
|
|
6
6
|
import { DIDKeyError } from '../errors.js'
|
|
7
7
|
import type { DIDKeyPair } from '../types.js'
|
|
8
8
|
|
|
9
|
-
export const produceKey = (seed: string | Uint8Array, type: string = KEY_OWL) => {
|
|
9
|
+
export const produceKey = (seed: string | Uint8Array, type: string = KEY_OWL): DIDKeyPair => {
|
|
10
10
|
if (typeof seed === 'string') {
|
|
11
11
|
seed = base64.decode(seed)
|
|
12
12
|
}
|
|
13
|
-
assertType(type)
|
|
13
|
+
keyUtils.assertType(type)
|
|
14
14
|
|
|
15
15
|
if (plugins[type].fromSeed == null) {
|
|
16
16
|
throw new DIDKeyError(`non-derivable:${type}`)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MnemonicOptions } from '../../types.js'
|
|
2
|
+
|
|
3
|
+
/** BIP-39 mnemonics: generation and the seed and entropy derived from them. */
|
|
4
|
+
export interface MnemonicHelper {
|
|
5
|
+
/** A new mnemonic of `opts.size` words (12–24, default 18). @throws {SyntaxError} outside that range */
|
|
6
|
+
generateMnemonic: (opts?: MnemonicOptions) => string
|
|
7
|
+
/** The BIP-39 seed of a mnemonic, base64. */
|
|
8
|
+
toSeed: (mnemonic: string) => string
|
|
9
|
+
/** The BIP-39 seed of a mnemonic, hex. */
|
|
10
|
+
toEntropy: (mnemonic: string) => string
|
|
11
|
+
/** The mnemonic of hex entropy. */
|
|
12
|
+
toMnemonic: (seed: string) => string
|
|
13
|
+
}
|
package/src/utils/mnemonic.ts
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import type { MnemonicOptions } from '../types.js'
|
|
2
2
|
import { generateMnemonic as generate, mnemonicToSeedSync, entropyToMnemonic } from '@scure/bip39'
|
|
3
3
|
import { hex, base64 } from '@scure/base'
|
|
4
|
-
import { wordlist } from '@scure/bip39/wordlists/english'
|
|
4
|
+
import { wordlist } from '@scure/bip39/wordlists/english.js'
|
|
5
|
+
import type { MnemonicHelper } from './mnemonic/types.js'
|
|
5
6
|
|
|
6
|
-
export const
|
|
7
|
-
const
|
|
7
|
+
export const createMnemonicHelper = (): MnemonicHelper => {
|
|
8
|
+
const generateMnemonic = (opts?: MnemonicOptions): string => {
|
|
9
|
+
const size = opts?.size ?? 18
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
if (size < 12 || size > 24) {
|
|
12
|
+
throw new SyntaxError('Mnemonic size should be between 12 and 24')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const strength = Math.round(256 * size / 24)
|
|
16
|
+
return generate(wordlist as any, strength + (32 - strength % 32))
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
}
|
|
19
|
+
const toSeed = (mnemonic: string): string =>
|
|
20
|
+
base64.encode(mnemonicToSeedSync(mnemonic))
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
const toEntropy = (mnemonic: string): string =>
|
|
23
|
+
hex.encode(mnemonicToSeedSync(mnemonic))
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
const toMnemonic = (seed: string): string =>
|
|
26
|
+
entropyToMnemonic(hex.decode(seed), wordlist as any)
|
|
27
|
+
|
|
28
|
+
return { generateMnemonic, toSeed, toEntropy, toMnemonic }
|
|
29
|
+
}
|
|
22
30
|
|
|
23
|
-
export const
|
|
24
|
-
entropyToMnemonic(hex.decode(seed), wordlist as any)
|
|
31
|
+
export const mnemonicHelper = createMnemonicHelper()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KeyMeta } from '../types.js'
|
|
2
|
+
|
|
3
|
+
/** Wallet key paths composed from key metadata. */
|
|
4
|
+
export interface KeyPathUtils {
|
|
5
|
+
/** Join path items with the key-path separator; an array item is joined with the prefix one. */
|
|
6
|
+
toPath: (...args: (string | string[])[]) => string
|
|
7
|
+
/** The derivation path of a key described by its metadata: service, entity, profile. */
|
|
8
|
+
mataToPath: (meta: Partial<KeyMeta>) => string
|
|
9
|
+
/** Whether a key's metadata carries every field the needle asks for (`name` is ignored). */
|
|
10
|
+
matchMeta: (haystack: KeyMeta, needle: Partial<KeyMeta>) => boolean
|
|
11
|
+
}
|