enclave-link 0.0.0-stage → 0.1.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.
@@ -0,0 +1,35 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ export {
32
+ __commonJS,
33
+ __export,
34
+ __toESM
35
+ };
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ vault
4
+ } from "./chunk-LUHJCCBX.js";
5
+ import "./chunk-U67V476Y.js";
6
+
7
+ // src/cli.ts
8
+ var usage = `enclave: ask a person for a secret through a one-time link, without ever seeing it
9
+
10
+ enclave ask <name> [field...] print a link asking for <name> (fields default to password)
11
+ enclave wait <name> wait for the answer and save it to the vault
12
+ enclave run VAR=<name>/<field>... cmd run cmd with secrets in its environment, hidden in its output
13
+ enclave get <name> <field> print a saved value, only ever into a pipe or $(...)
14
+ enclave passkey <name> [field] let the browser sign in with a saved passkey, once, in the next 5 minutes
15
+ enclave sign sign a passkey request from the browser extension (JSON on stdin)
16
+ enclave import proton <vault> copy a Proton Pass vault in, through pass-cli
17
+ enclave list saved names and their fields
18
+ enclave rm <name> delete a saved item
19
+ enclave mcp serve all of this to an agent over MCP (stdio)
20
+
21
+ A field named totp holds a 2FA setup key, and get gives its current code. A field named passkey
22
+ holds a passkey: enclave signs with it and never hands out its key.
23
+ ENCLAVE_FROM names who's asking on the page, ENCLAVE_HOME holds the vault (~/.enclave),
24
+ and ENCLAVE_RELAY points at a self-hosted relay.`;
25
+ var [command, name, ...rest] = process.argv.slice(2);
26
+ try {
27
+ if (command === "ask" && name) {
28
+ console.log((await vault.ask(name, rest.length ? rest : void 0)).url);
29
+ console.error(`Send this link to the person, then run \`enclave wait ${name}\` in the background.`);
30
+ } else if (command === "wait" && name) {
31
+ console.log(`saved ${name}: ${(await vault.wait(name)).join(", ")}`);
32
+ } else if (command === "run" && name) {
33
+ const args = [name, ...rest];
34
+ const split = args.findIndex((arg) => !/^[A-Za-z_]\w*=/.test(arg));
35
+ if (split < 1) throw new Error("usage: enclave run VAR=<name>/<field>... <command...>");
36
+ const secrets = Object.fromEntries(args.slice(0, split).map((arg) => [arg.slice(0, arg.indexOf("=")), arg.slice(arg.indexOf("=") + 1)]));
37
+ process.exitCode = await vault.run(args.slice(split), secrets);
38
+ } else if (command === "get" && name && rest[0]) {
39
+ process.stdout.write(await vault.get(name, rest[0]));
40
+ } else if (command === "passkey" && name) {
41
+ const { signedIn } = await vault.passkey(name, rest[0]);
42
+ console.log(`${name}'s passkey is ready for 5 minutes: sign in with a passkey in the browser now`);
43
+ await signedIn;
44
+ console.log(`signed in with ${name}'s passkey`);
45
+ } else if (command === "sign") {
46
+ const request = JSON.parse(await new Response(process.stdin).text());
47
+ process.stdout.write(JSON.stringify(await vault.sign(request)));
48
+ } else if (command === "import" && name === "proton" && rest[0]) {
49
+ const items = [...(await vault.importProton(rest[0])).values()];
50
+ const count = (field) => items.filter((item) => Object.keys(item).some((key) => key.split(" ")[0] === field)).length;
51
+ console.log(`imported ${items.length} items: ${count("password")} with a password, ${count("totp")} with 2FA, ${count("passkey")} with a passkey`);
52
+ } else if (command === "list") {
53
+ for (const item of await vault.list()) console.log(`${item.name}: ${item.fields.join(", ")}`);
54
+ } else if (command === "rm" && name) {
55
+ await vault.remove(name);
56
+ } else if (command === "mcp") {
57
+ const { serve } = await import("./mcp-WPCCWEA2.js");
58
+ await serve(vault);
59
+ } else {
60
+ console.log(usage);
61
+ process.exitCode = command && command !== "help" ? 1 : 0;
62
+ }
63
+ } catch (error) {
64
+ console.error(`enclave: ${error instanceof Error ? error.message : error}`);
65
+ process.exitCode = 1;
66
+ }
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import {
2
+ openVault,
3
+ vault
4
+ } from "./chunk-LUHJCCBX.js";
5
+ import "./chunk-U67V476Y.js";
6
+ export {
7
+ openVault,
8
+ vault
9
+ };