@affinidi/cli 2.14.4 → 2.15.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/dist/helpers/token.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { generateKeyPairSync } from 'node:crypto';
|
|
2
|
+
import { SupportedAlgorithms } from '../common/constants.js';
|
|
2
3
|
import { policiesDataSchema } from '../common/validators.js';
|
|
3
4
|
import { iamService } from '../services/affinidi/iam/service.js';
|
|
4
5
|
export function generateKeyPair(keyId, algorithm, passphrase) {
|
|
5
|
-
const
|
|
6
|
+
const isEc = algorithm === SupportedAlgorithms.ES256 || algorithm === SupportedAlgorithms.ES512;
|
|
7
|
+
const namedCurve = algorithm === SupportedAlgorithms.ES256 ? 'P-256' : 'P-521';
|
|
8
|
+
const { publicKey, privateKey } = isEc
|
|
9
|
+
? generateKeyPairSync('ec', { namedCurve })
|
|
10
|
+
: generateKeyPairSync('rsa', { modulusLength: 4096 });
|
|
6
11
|
const publicKeyPem = publicKey.export({ format: 'pem', type: 'spki' });
|
|
7
12
|
const exportOptions = {
|
|
8
13
|
format: 'pem',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/helpers/token.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/helpers/token.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAA;AAEhE,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,SAAiB,EAAE,UAAmB;IACnF,MAAM,IAAI,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AAA;IACnF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import
|
|
3
|
+
import { Entry } from '@napi-rs/keyring';
|
|
4
4
|
import Conf from 'conf';
|
|
5
5
|
import z from 'zod';
|
|
6
6
|
import { config } from './env-config.js';
|
|
@@ -10,19 +10,25 @@ const credentialsSchema = z.object({
|
|
|
10
10
|
});
|
|
11
11
|
const account = 'Affinidi';
|
|
12
12
|
const service = 'sessionID (@affinidi/cli)';
|
|
13
|
-
// NOTE: `
|
|
13
|
+
// NOTE: `@napi-rs/keyring` manages credentials in the system's keychain.
|
|
14
14
|
// On macOS the passwords are managed by the Keychain,
|
|
15
15
|
// on Linux they are managed by the Secret Service API/libsecret,
|
|
16
|
-
// and on Windows they are managed by Credential Vault.
|
|
17
|
-
// NOTE: `
|
|
18
|
-
//
|
|
16
|
+
// and on Windows they are managed by the Credential Vault.
|
|
17
|
+
// NOTE: The `service`/`account` pair is kept identical to the one previously
|
|
18
|
+
// used with `keytar`, so credentials already stored in the keychain
|
|
19
|
+
// remain readable after the migration.
|
|
20
|
+
// NOTE: If the keychain backend is unavailable (e.g. `libsecret` is not
|
|
21
|
+
// installed on Linux), CLI falls back to saving sessionId into a file.
|
|
22
|
+
function getKeychainEntry() {
|
|
23
|
+
return new Entry(service, account);
|
|
24
|
+
}
|
|
19
25
|
class CredentialsVault {
|
|
20
26
|
constructor(store) {
|
|
21
27
|
this.store = store;
|
|
22
28
|
}
|
|
23
29
|
async clear() {
|
|
24
30
|
try {
|
|
25
|
-
|
|
31
|
+
getKeychainEntry().deletePassword();
|
|
26
32
|
}
|
|
27
33
|
catch (error) {
|
|
28
34
|
this.store.clear();
|
|
@@ -30,7 +36,7 @@ class CredentialsVault {
|
|
|
30
36
|
}
|
|
31
37
|
async getSessionId() {
|
|
32
38
|
try {
|
|
33
|
-
return
|
|
39
|
+
return getKeychainEntry().getPassword();
|
|
34
40
|
}
|
|
35
41
|
catch (error) {
|
|
36
42
|
return this.store.get('sessionId');
|
|
@@ -38,7 +44,7 @@ class CredentialsVault {
|
|
|
38
44
|
}
|
|
39
45
|
async setSessionId(value) {
|
|
40
46
|
try {
|
|
41
|
-
|
|
47
|
+
getKeychainEntry().setPassword(value);
|
|
42
48
|
}
|
|
43
49
|
catch (error) {
|
|
44
50
|
this.store.set('sessionId', value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials-vault.js","sourceRoot":"","sources":["../../src/services/credentials-vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"credentials-vault.js","sourceRoot":"","sources":["../../src/services/credentials-vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAA;AAClC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,SAAS,EAAE,eAAe;CAC3B,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,UAAU,CAAA;AAC1B,MAAM,OAAO,GAAG,2BAA2B,CAAA;AAE3C,yEAAyE;AACzE,4DAA4D;AAC5D,uEAAuE;AACvE,iEAAiE;AACjE,6EAA6E;AAC7E,0EAA0E;AAC1E,6CAA6C;AAC7C,wEAAwE;AACxE,6EAA6E;AAC7E,SAAS,gBAAgB;IACvB,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,gBAAgB;IACpB,YAA6B,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;IAEzD,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,gBAAgB,EAAE,CAAC,cAAc,EAAE,CAAA;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC;YACH,OAAO,gBAAgB,EAAE,CAAC,WAAW,EAAE,CAAA;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAa;QAC9B,IAAI,CAAC;YACH,gBAAgB,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;CACF;AAED,MAAM,cAAc,GAAG,IAAI,IAAI,CAAc;IAC3C,UAAU,EAAE,MAAM,CAAC,mBAAmB;IACtC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC;CAC1C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,cAAc,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@affinidi/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "Affinidi CLI",
|
|
5
5
|
"author": "affinidi.com",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"typings": "dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"affinidi": "
|
|
9
|
+
"affinidi": "bin/run.js"
|
|
10
10
|
},
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"type": "module",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@oclif/plugin-not-found": "^3.2.42",
|
|
56
56
|
"@oclif/plugin-search": "^1.2.5",
|
|
57
57
|
"@oclif/plugin-warn-if-update-available": "^3.1.11",
|
|
58
|
-
"@
|
|
58
|
+
"@napi-rs/keyring": "^1.3.0",
|
|
59
59
|
"axios": "^1.8.3",
|
|
60
60
|
"chalk": "^5.3.0",
|
|
61
61
|
"conf": "^13.0.1",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"jose": "^5.6.3",
|
|
68
68
|
"open": "^10.1.0",
|
|
69
69
|
"tcp-port-used": "^1.0.2",
|
|
70
|
-
"uuid": "^
|
|
70
|
+
"uuid": "^11.1.1",
|
|
71
71
|
"zod": "^3.23.8",
|
|
72
72
|
"zod-validation-error": "^3.3.0"
|
|
73
73
|
},
|
|
@@ -81,7 +81,6 @@
|
|
|
81
81
|
"@types/mocha": "10.0.7",
|
|
82
82
|
"@types/node": "^18.19.39",
|
|
83
83
|
"@types/tcp-port-used": "^1.0.4",
|
|
84
|
-
"@types/uuid": "^10.0.0",
|
|
85
84
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
86
85
|
"@typescript-eslint/parser": "^5.59.9",
|
|
87
86
|
"chai": "4.4.1",
|
|
@@ -103,8 +102,10 @@
|
|
|
103
102
|
"typescript": "^5.5.3"
|
|
104
103
|
},
|
|
105
104
|
"overrides": {
|
|
106
|
-
"brace-expansion": "2.0.
|
|
105
|
+
"brace-expansion": "^2.0.3",
|
|
107
106
|
"cookie": "^0.7.0",
|
|
107
|
+
"diff": "^8.0.3",
|
|
108
|
+
"serialize-javascript": "^7.0.5",
|
|
108
109
|
"tar-fs": "2.1.4"
|
|
109
110
|
},
|
|
110
111
|
"oclif": {
|