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 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
- .action(async (data) => {
139
- await importPem(data);
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
- export async function importPem(data: string) {
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 res = await prompts({
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 (!password) {
21
+ if (options.encrypt) {
23
22
  let res = await prompts({
24
- type: 'confirm',
25
- name: 'ok',
26
- message: 'Are you sure you don\'t want to protect your identity.pem with a password?',
23
+ type: 'invisible',
24
+ name: 'password',
25
+ message: 'Enter password to encrypt identity.pem',
27
26
  });
28
- if (!res.ok) {
29
- console.log('aborted');
30
- return;
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
- .action(async (data) => {
125
- await importPem(data);
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
@@ -1 +1,5 @@
1
- export declare function importPem(data: string): Promise<void>;
1
+ type ImportIdentityOptions = {
2
+ encrypt: boolean;
3
+ };
4
+ export declare function importPem(data: string, options?: ImportIdentityOptions): Promise<void>;
5
+ export {};
@@ -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 res = await prompts({
14
- type: 'password',
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: 'confirm',
22
- name: 'ok',
23
- message: 'Are you sure you don\'t want to protect your identity.pem with a password?',
16
+ type: 'invisible',
17
+ name: 'password',
18
+ message: 'Enter password to encrypt identity.pem',
24
19
  });
25
- if (!res.ok) {
26
- console.log('aborted');
27
- return;
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: 'password',
107
+ type: 'invisible',
108
108
  name: 'value',
109
109
  message: 'Enter password:'
110
110
  });
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/cli.js"
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: 'password',
124
+ type: 'invisible',
125
125
  name: 'value',
126
126
  message: 'Enter password:'
127
127
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/cli.js"