diff --git a/npmDepsHash b/npmDepsHash index ff5d1acf..c0085b3d 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-D8wYv85LH0iSHUSfh7oUwaE6Xxn+yDhFHnhguf7ss5M= +sha256-GCy9PbuauZqmT3Bf4NR/Va2RAYnXWiUgS/+1mSQ6cZk= diff --git a/package-lock.json b/package-lock.json index b2915ba7..3159aec3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polykey-cli", - "version": "0.16.5", + "version": "0.16.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "polykey-cli", - "version": "0.16.5", + "version": "0.16.6", "license": "GPL-3.0", "bin": { "pk": "dist/polykey.js", @@ -42,7 +42,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", @@ -1668,9 +1668,9 @@ "devOptional": true }, "node_modules/@matrixai/rpc": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@matrixai/rpc/-/rpc-0.6.0.tgz", - "integrity": "sha512-ENjJO2h7CmPLaHhObHs2nvpv98YZPxa79/jf+TqEPEfbhE1BkNCys9pXDE/CYDP9vxb4seS39WkR9cNivQU50A==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/@matrixai/rpc/-/rpc-0.6.3.tgz", + "integrity": "sha512-jLR+SpAnv6NR2xRtXGBnyBGipLBv/Nnn/8b6OYx2loyNT4WHoxtqh51U6QwKCHU6qZii/K/2L5XRRKxYUgmmVg==", "dev": true, "dependencies": { "@matrixai/async-init": "^1.10.0", @@ -7602,9 +7602,9 @@ } }, "node_modules/polykey": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/polykey/-/polykey-1.17.0.tgz", - "integrity": "sha512-DstSWzSpV3MygF/PZHAMI7ypUyqsA3MxlEXfvrpp6V6/m/ujkfmFDJAW5d3y6La40pc/t8cx6zB7lj3sNiDeXA==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/polykey/-/polykey-1.17.1.tgz", + "integrity": "sha512-IcP4PS/leYlUVr/mqEYjEjdbMeD74ba0YhmY0Jc+6XIPaw1eExD550bWTaqXkQUCOSvkTeBFAQlkPpfAAmOAOQ==", "dev": true, "dependencies": { "@matrixai/async-cancellable": "^1.1.1", @@ -7619,7 +7619,7 @@ "@matrixai/mdns": "^1.2.6", "@matrixai/quic": "^1.3.2", "@matrixai/resources": "^1.1.5", - "@matrixai/rpc": "^0.6.0", + "@matrixai/rpc": "^0.6.2", "@matrixai/timer": "^1.1.3", "@matrixai/workers": "^1.3.7", "@matrixai/ws": "^1.1.7", diff --git a/package.json b/package.json index f7d03047..4a74fa52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polykey-cli", - "version": "0.16.5", + "version": "0.16.6", "homepage": "https://polykey.com", "author": "Roger Qiu", "contributors": [ @@ -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", diff --git a/src/identities/CommandAllow.ts b/src/identities/CommandAllow.ts index 8aadf2c4..b17edc51 100644 --- a/src/identities/CommandAllow.ts +++ b/src/identities/CommandAllow.ts @@ -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(); diff --git a/src/identities/CommandAuthenticate.ts b/src/identities/CommandAuthenticate.ts index 4064d995..15deef90 100644 --- a/src/identities/CommandAuthenticate.ts +++ b/src/identities/CommandAuthenticate.ts @@ -112,7 +112,7 @@ class CommandAuthenticate extends CommandPolykey { }), ); } else { - never(); + never(`either message request or response must be defined`); } } }, auth); diff --git a/src/identities/CommandDisallow.ts b/src/identities/CommandDisallow.ts index f56fb580..cf0f88c0 100644 --- a/src/identities/CommandDisallow.ts +++ b/src/identities/CommandDisallow.ts @@ -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(); diff --git a/src/identities/CommandDiscover.ts b/src/identities/CommandDiscover.ts index a3f12cb3..e6d6f2b6 100644 --- a/src/identities/CommandDiscover.ts +++ b/src/identities/CommandDiscover.ts @@ -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 { diff --git a/src/identities/CommandGet.ts b/src/identities/CommandGet.ts index 28514107..03b42539 100644 --- a/src/identities/CommandGet.ts +++ b/src/identities/CommandGet.ts @@ -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') { diff --git a/src/identities/CommandPermissions.ts b/src/identities/CommandPermissions.ts index 803ae521..227396be 100644 --- a/src/identities/CommandPermissions.ts +++ b/src/identities/CommandPermissions.ts @@ -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( diff --git a/src/identities/CommandTrust.ts b/src/identities/CommandTrust.ts index bb42a62a..3d6d8705 100644 --- a/src/identities/CommandTrust.ts +++ b/src/identities/CommandTrust.ts @@ -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(); diff --git a/src/identities/CommandUntrust.ts b/src/identities/CommandUntrust.ts index 722d9bd9..72984012 100644 --- a/src/identities/CommandUntrust.ts +++ b/src/identities/CommandUntrust.ts @@ -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(); diff --git a/src/secrets/CommandCat.ts b/src/secrets/CommandCat.ts index cec05106..62a91c31 100644 --- a/src/secrets/CommandCat.ts +++ b/src/secrets/CommandCat.ts @@ -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'; @@ -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) { + for await (const result of response.readable) { if (result.type === 'error') { hasErrored = true; switch (result.code) { diff --git a/src/secrets/CommandEdit.ts b/src/secrets/CommandEdit.ts index 7ea722f9..9b1aaa86 100644 --- a/src/secrets/CommandEdit.ts +++ b/src/secrets/CommandEdit.ts @@ -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; } diff --git a/src/secrets/CommandEnv.ts b/src/secrets/CommandEnv.ts index 755c0b4a..8a7526fb 100644 --- a/src/secrets/CommandEnv.ts +++ b/src/secrets/CommandEnv.ts @@ -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; @@ -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`, + ); } } @@ -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 { diff --git a/src/secrets/CommandMkdir.ts b/src/secrets/CommandMkdir.ts index 012124b1..b4f1c272 100644 --- a/src/secrets/CommandMkdir.ts +++ b/src/secrets/CommandMkdir.ts @@ -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'; @@ -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) { + for await (const result of response.readable) { if (result.type === 'error') { hasErrored = true; switch (result.code) { diff --git a/src/secrets/CommandRemove.ts b/src/secrets/CommandRemove.ts index 91df3a9c..4c2839f7 100644 --- a/src/secrets/CommandRemove.ts +++ b/src/secrets/CommandRemove.ts @@ -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'; @@ -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(); + 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) { + for await (const result of response.readable) { if (result.type === 'error') { hasErrored = true; switch (result.code) { diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 9343d454..425c0c8d 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -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': @@ -208,7 +208,7 @@ function decodeEscaped(str: string): string { case '\\': return lastChar; } - utils.never(); + utils.never(`character "${lastChar}" is not handled`); }); }