Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion npmDepsHash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sha256-D8wYv85LH0iSHUSfh7oUwaE6Xxn+yDhFHnhguf7ss5M=
sha256-GCy9PbuauZqmT3Bf4NR/Va2RAYnXWiUgS/+1mSQ6cZk=
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polykey-cli",
"version": "0.16.5",
"version": "0.16.6",
"homepage": "https://polykey.com",
"author": "Roger Qiu",
"contributors": [
Expand Down Expand Up @@ -153,7 +153,7 @@
"nexpect": "^0.6.0",
"node-gyp-build": "^4.4.0",
"nodemon": "^3.0.1",
"polykey": "^1.17.0",
"polykey": "^1.17.1",
"prettier": "^3.0.0",
"shelljs": "^0.8.5",
"shx": "^0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandAllow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CommandAllow extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(`type ${type} is not valid, expected node or identity`);
}
} finally {
if (pkClient! != null) await pkClient.stop();
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandAuthenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CommandAuthenticate extends CommandPolykey {
}),
);
} else {
never();
never(`either message request or response must be defined`);
}
}
}, auth);
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandDisallow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CommandDisallow extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(`type ${type} is not valid, expected node or identity`);
}
} finally {
if (pkClient! != null) await pkClient.stop();
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandDiscover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class CommandDiscover extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(`type ${type} is not valid, expected node or identity`);
}
await eventsP;
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CommandGet extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(`type ${type} is not valid, expected node or identity`);
}
const gestalt = res!.gestalt;
if (options.format === 'json') {
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CommandPermissions extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(`type ${type} is not valid, expected node or identity`);
}
if (options.format === 'json') {
process.stdout.write(
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandTrust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CommandTrust extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(`type ${type} is not valid, expected node or identity`);
}
} finally {
if (pkClient! != null) await pkClient.stop();
Expand Down
2 changes: 1 addition & 1 deletion src/identities/CommandUntrust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CommandUntrust extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(`type ${type} is not valid, expected node or identity`);
}
} finally {
if (pkClient! != null) await pkClient.stop();
Expand Down
6 changes: 1 addition & 5 deletions src/secrets/CommandCat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type PolykeyClient from 'polykey/dist/PolykeyClient';
import type { ContentOrErrorMessage } from 'polykey/dist/client/types';
import type { ReadableStream } from 'stream/web';
import CommandPolykey from '../CommandPolykey';
import * as binUtils from '../utils';
import * as binOptions from '../utils/options';
Expand Down Expand Up @@ -96,9 +94,7 @@ class CommandGet extends CommandPolykey {
await writer.close();
// Print out incoming data to standard out
let hasErrored = false;
// TypeScript cannot properly perform type narrowing on this type, so
// the `as` keyword is used to help it out.
for await (const result of response.readable as ReadableStream<ContentOrErrorMessage>) {
for await (const result of response.readable) {
if (result.type === 'error') {
hasErrored = true;
switch (result.code) {
Expand Down
4 changes: 2 additions & 2 deletions src/secrets/CommandEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ class CommandEdit extends CommandPolykey {
},
cause: e,
});
// If the secret didn't exist before and we can't read the file,
// If the secret didn't exist before, and we can't read the file,
// then the secret was never actually created or saved. The user
// doesn't want to make the secret anymore, so abort mision!
// doesn't want to make the secret anymore, so abort mission!
} else {
return;
}
Expand Down
12 changes: 9 additions & 3 deletions src/secrets/CommandEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ class CommandEnv extends CommandPolykey {
case 'ignore':
continue;
default:
utils.never();
utils.never(
`option ${envInvalid} is not valid, expected error, warn or ignore`,
);
}
}
newName = secretEnvName;
Expand All @@ -192,7 +194,9 @@ class CommandEnv extends CommandPolykey {
case 'overwrite':
break;
default:
utils.never();
utils.never(
`option ${envDuplicate} is not valid, expected error, keep, warn or overwrite`,
);
}
}

Expand Down Expand Up @@ -338,7 +342,9 @@ class CommandEnv extends CommandPolykey {
}
break;
default:
utils.never();
utils.never(
`format '${format}' is not valid, expected unix, cmd, powershell or json`,
);
}
}
} finally {
Expand Down
4 changes: 1 addition & 3 deletions src/secrets/CommandMkdir.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type PolykeyClient from 'polykey/dist/PolykeyClient';
import type { SuccessOrErrorMessage } from 'polykey/dist/client/types';
import type { ReadableStream } from 'stream/web';
import CommandPolykey from '../CommandPolykey';
import * as binUtils from '../utils';
import * as binOptions from '../utils/options';
Expand Down Expand Up @@ -79,7 +77,7 @@ class CommandMkdir extends CommandPolykey {
let hasErrored = false;
// TypeScript cannot properly perform type narrowing on this type, so
// the `as` keyword is used to help it out.
for await (const result of response.readable as ReadableStream<SuccessOrErrorMessage>) {
for await (const result of response.readable) {
if (result.type === 'error') {
hasErrored = true;
switch (result.code) {
Expand Down
25 changes: 15 additions & 10 deletions src/secrets/CommandRemove.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type PolykeyClient from 'polykey/dist/PolykeyClient';
import type { SuccessOrErrorMessage } from 'polykey/dist/client/types';
import type { ReadableStream } from 'stream/web';
import CommandPolykey from '../CommandPolykey';
import * as binUtils from '../utils';
import * as binOptions from '../utils/options';
Expand Down Expand Up @@ -56,24 +54,31 @@ class CommandRemove extends CommandPolykey {
const hasErrored = await binUtils.retryAuthentication(async (auth) => {
const response =
await pkClient.rpcClient.methods.vaultsSecretsRemove();
// Extract all unique vault names
const uniqueVaultNames = new Set<string>();
for (const [vaultName] of secretPaths) {
uniqueVaultNames.add(vaultName);
}
const writer = response.writable.getWriter();
let first = true;
// Send the header message first
await writer.write({
type: 'VaultNamesHeaderMessage',
vaultNames: Array.from(uniqueVaultNames),
recursive: options.recursive,
metadata: auth,
});
// Then send all the paths in subsequent messages
for (const [vaultName, secretPath] of secretPaths) {
await writer.write({
type: 'SecretIdentifierMessage',
nameOrId: vaultName,
secretName: secretPath ?? '/',
metadata: first
? { ...auth, options: { recursive: options.recursive } }
: undefined,
});
first = false;
}
await writer.close();
// Check if any errors were raised
let hasErrored = false;
// TypeScript cannot properly perform type narrowing on this type, so
// the `as` keyword is used to help it out.
for await (const result of response.readable as ReadableStream<SuccessOrErrorMessage>) {
for await (const result of response.readable) {
if (result.type === 'error') {
hasErrored = true;
switch (result.code) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function decodeEscaped(str: string): string {
// Length of substr will always be at least 1
const lastChar = substr.at(-1);
if (lastChar == null) {
utils.never();
utils.never('length must be greater than 0');
}
switch (lastChar) {
case 'n':
Expand All @@ -208,7 +208,7 @@ function decodeEscaped(str: string): string {
case '\\':
return lastChar;
}
utils.never();
utils.never(`character "${lastChar}" is not handled`);
});
}

Expand Down
Loading