ic-mops 0.29.0 → 0.30.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.ts +3 -2
- package/commands/import-identity.ts +22 -14
- package/dist/cli.js +3 -2
- package/dist/commands/import-identity.d.ts +5 -1
- package/dist/commands/import-identity.js +17 -14
- package/dist/mops.js +1 -1
- package/dist/package.json +1 -1
- package/mops.ts +1 -1
- package/package.json +1 -1
package/cli.ts
CHANGED
|
@@ -135,8 +135,9 @@ program
|
|
|
135
135
|
program
|
|
136
136
|
.command('import-identity <data>')
|
|
137
137
|
.description('Import .pem file data to use as identity')
|
|
138
|
-
.
|
|
139
|
-
|
|
138
|
+
.addOption(new Option('--no-encrypt', 'Do not ask for a password to encrypt identity'))
|
|
139
|
+
.action(async (data, options) => {
|
|
140
|
+
await importPem(data, options);
|
|
140
141
|
await whoami();
|
|
141
142
|
});
|
|
142
143
|
|
|
@@ -6,28 +6,36 @@ import {deleteSync} from 'del';
|
|
|
6
6
|
import {globalConfigDir} from '../mops.js';
|
|
7
7
|
import {encrypt} from '../pem.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
type ImportIdentityOptions = {
|
|
10
|
+
encrypt: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export async function importPem(data: string, options: ImportIdentityOptions = {encrypt: true}) {
|
|
10
14
|
try {
|
|
11
15
|
if (!fs.existsSync(globalConfigDir)) {
|
|
12
16
|
fs.mkdirSync(globalConfigDir);
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
let
|
|
16
|
-
type: 'password',
|
|
17
|
-
name: 'password',
|
|
18
|
-
message: 'Enter password to encrypt identity.pem',
|
|
19
|
-
});
|
|
20
|
-
let password = res.password;
|
|
19
|
+
let password = '';
|
|
21
20
|
|
|
22
|
-
if (
|
|
21
|
+
if (options.encrypt) {
|
|
23
22
|
let res = await prompts({
|
|
24
|
-
type: '
|
|
25
|
-
name: '
|
|
26
|
-
message: '
|
|
23
|
+
type: 'invisible',
|
|
24
|
+
name: 'password',
|
|
25
|
+
message: 'Enter password to encrypt identity.pem',
|
|
27
26
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
password = res.password;
|
|
28
|
+
|
|
29
|
+
if (!password) {
|
|
30
|
+
let res = await prompts({
|
|
31
|
+
type: 'confirm',
|
|
32
|
+
name: 'ok',
|
|
33
|
+
message: 'Are you sure you don\'t want to protect your identity.pem with a password?',
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
console.log('aborted');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
|
package/dist/cli.js
CHANGED
|
@@ -121,8 +121,9 @@ program
|
|
|
121
121
|
program
|
|
122
122
|
.command('import-identity <data>')
|
|
123
123
|
.description('Import .pem file data to use as identity')
|
|
124
|
-
.
|
|
125
|
-
|
|
124
|
+
.addOption(new Option('--no-encrypt', 'Do not ask for a password to encrypt identity'))
|
|
125
|
+
.action(async (data, options) => {
|
|
126
|
+
await importPem(data, options);
|
|
126
127
|
await whoami();
|
|
127
128
|
});
|
|
128
129
|
// sources
|
|
@@ -5,26 +5,29 @@ import prompts from 'prompts';
|
|
|
5
5
|
import { deleteSync } from 'del';
|
|
6
6
|
import { globalConfigDir } from '../mops.js';
|
|
7
7
|
import { encrypt } from '../pem.js';
|
|
8
|
-
export async function importPem(data) {
|
|
8
|
+
export async function importPem(data, options = { encrypt: true }) {
|
|
9
9
|
try {
|
|
10
10
|
if (!fs.existsSync(globalConfigDir)) {
|
|
11
11
|
fs.mkdirSync(globalConfigDir);
|
|
12
12
|
}
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
name: 'password',
|
|
16
|
-
message: 'Enter password to encrypt identity.pem',
|
|
17
|
-
});
|
|
18
|
-
let password = res.password;
|
|
19
|
-
if (!password) {
|
|
13
|
+
let password = '';
|
|
14
|
+
if (options.encrypt) {
|
|
20
15
|
let res = await prompts({
|
|
21
|
-
type: '
|
|
22
|
-
name: '
|
|
23
|
-
message: '
|
|
16
|
+
type: 'invisible',
|
|
17
|
+
name: 'password',
|
|
18
|
+
message: 'Enter password to encrypt identity.pem',
|
|
24
19
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
password = res.password;
|
|
21
|
+
if (!password) {
|
|
22
|
+
let res = await prompts({
|
|
23
|
+
type: 'confirm',
|
|
24
|
+
name: 'ok',
|
|
25
|
+
message: 'Are you sure you don\'t want to protect your identity.pem with a password?',
|
|
26
|
+
});
|
|
27
|
+
if (!res.ok) {
|
|
28
|
+
console.log('aborted');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
let identityPem = path.resolve(globalConfigDir, 'identity.pem');
|
package/dist/mops.js
CHANGED
|
@@ -104,7 +104,7 @@ export let getIdentity = async () => {
|
|
|
104
104
|
let identityPemEncrypted = path.resolve(globalConfigDir, 'identity.pem.encrypted');
|
|
105
105
|
if (fs.existsSync(identityPemEncrypted)) {
|
|
106
106
|
let res = await prompts({
|
|
107
|
-
type: '
|
|
107
|
+
type: 'invisible',
|
|
108
108
|
name: 'value',
|
|
109
109
|
message: 'Enter password:'
|
|
110
110
|
});
|
package/dist/package.json
CHANGED
package/mops.ts
CHANGED
|
@@ -121,7 +121,7 @@ export let getIdentity = async (): Promise<Identity | undefined> => {
|
|
|
121
121
|
let identityPemEncrypted = path.resolve(globalConfigDir, 'identity.pem.encrypted');
|
|
122
122
|
if (fs.existsSync(identityPemEncrypted)) {
|
|
123
123
|
let res = await prompts({
|
|
124
|
-
type: '
|
|
124
|
+
type: 'invisible',
|
|
125
125
|
name: 'value',
|
|
126
126
|
message: 'Enter password:'
|
|
127
127
|
});
|