@tomato414941/foundation 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/guide.mjs +20 -14
  2. package/package.json +1 -1
  3. package/runtime.mjs +5 -2
package/guide.mjs CHANGED
@@ -39,15 +39,20 @@ export function guide(connectors) {
39
39
  ' Acting for exactly one principal, their holdings are what the calls below reach. For several, name one: ?as=<id>.',
40
40
  ' PATCH /v1/principals/me {"name"} DELETE /v1/principals/me a new name; leaving (your key stops working).',
41
41
  ' GET /v1/requests/<id> one of your requests and what happened at its page (events). DELETE cancels it.',
42
- ' GET /v1/relations every line you are on. GET /v1/records what was done in your name or to you.', '',
42
+ ' GET /v1/relations every line you are on. GET /v1/records what was done in your name or to you.',
43
+ ' Everything kept has an id, shown in every listing. The holder shows one thing to another principal with',
44
+ ' POST /v1/relations {"subject":"<principal id>","relation":"viewer"|"editor","object_type":"holding","object_id":"<id>"} DELETE takes it back.',
45
+ ' GET /v1/holdings what others have shown you. GET /v1/holdings/<id> one thing, whoever holds it.',
46
+ ' GET /v1/holdings/<id>/content reads it; PUT writes it, as editor. Lines point at the id, so renaming changes nothing.', '',
43
47
  'WHAT IS KEPT',
44
- ' PUT /v1/secrets?name=<name>&secret=true body: raw bytes, up to 1MB. The same exact name replaces that value.',
45
- ' secret=true blocks direct GET by an access key. The owner can read it; authorized delivery can still return it.',
46
- ' This is not a boundary against an agent with the approved key. Do not print delivered values into its context.',
47
- ' GET /v1/secrets names, sizes, read permissions and timestamps, not contents.',
48
- ' GET /v1/secrets?prefix=<literal prefix> optional case-sensitive text filtering, not a directory.',
49
- ' GET /v1/secrets?name=<name> bytes, as written; 403 write_only for a secret.',
50
- ' DELETE /v1/secrets?name=<name>',
48
+ ' PUT /v1/holdings?kind=secret&name=<name> body: raw bytes, up to 1MB. The same exact name replaces that value; the answer carries its id.',
49
+ ' What you keep for the holder you may read back (an editor line is drawn for you). What the holder kept, or a',
50
+ ' connection handed over, you may deliver into a command but not read, unless the holder draws you a line.',
51
+ ' Do not print delivered values into your context.',
52
+ ' GET /v1/holdings?kind=secret ids, names, sizes and timestamps, not contents. &prefix=<literal prefix> narrows by text, not directory.',
53
+ ' GET /v1/holdings?kind=secret&name=<name> the one thing by name: its id and metadata. 404 if no such name.',
54
+ ' GET /v1/holdings/<id>/content bytes, as written; 403 forbidden without a line to it. PUT writes them.',
55
+ ' PATCH /v1/holdings/<id> {"name"} a new name for the same thing. DELETE /v1/holdings/<id> removes it.',
51
56
  ' URL-encode the name. A name is any text, which is why it travels as a query and not as a path. Names are 1-200 characters without control characters; case, spaces, slashes and punctuation',
52
57
  ' remain literal. No normalization, hierarchy, service ownership or automatic renewal is inferred.',
53
58
  ' The owner can read, rename or delete any saved value. Stored copies survive OAuth disconnection.', '',
@@ -60,7 +65,7 @@ export function guide(connectors) {
60
65
  ' Calling this into an agent context exposes values. Use exec when the intent is to run a local command.', '',
61
66
  'FILLING THE STORE',
62
67
  '',
63
- '1. Put it there yourself. Anything you obtained or wrote: PUT /v1/secrets?name=<name>, above.',
68
+ '1. Put it there yourself. Anything you obtained or wrote: PUT /v1/holdings?kind=secret&name=<name>, above.',
64
69
  '',
65
70
  '2. ASKING THE OWNER, for what only they can fetch -- an API token, a key, a certificate they must go and create.',
66
71
  ' POST /v1/requests {"kind":"store", "input":{"fields":[{...}]}, "purpose":"...", "steps":["..."], "valid_minutes":30}',
@@ -68,7 +73,7 @@ export function guide(connectors) {
68
73
  ' fields[].label what they are being asked for, in their language. It titles the screen and names the field.',
69
74
 
70
75
  ' fields[].site the page where they make it, offered as a link',
71
- ' fields[].secret false lets you read it back afterwards; the default is that you cannot',
76
+ ' fields[].readable true asks to read it back afterwards (a viewer line); the default is that you cannot',
72
77
  ' fields[].multiline true for something like a PEM',
73
78
  ' fields[].replace true to put the value in place of the one already kept under that exact name (rotation).',
74
79
  ' Refused at creation: name_taken when the name exists and replace is not declared, name_missing',
@@ -109,9 +114,10 @@ export function guide(connectors) {
109
114
  ' reconnect_required (the service rejected it) / already_connected. A key approval shows its own events at',
110
115
  ' GET /v1/requests/<id>: confirmation_required (a wrong code) / confirmation_locked (5 tries).', '',
111
116
  'A PLACE FOR FILES (object storage the owner did not have to sign up for)',
112
- ' PUT /v1/objects/<key> body is the bytes; the Content-Type you send is what a reader gets back. Up to 25MB.',
113
- ' GET /v1/objects/<key> the bytes. DELETE removes it. GET /v1/objects?prefix=<p>&cursor=<c> lists what is there.',
114
- ' POST /v1/objects/<key>/link {"minutes":n} a time-limited URL anyone can read, for a thing that only takes a URL.',
117
+ ' PUT /v1/holdings?kind=object&name=<key> body is the bytes; the Content-Type you send is what a reader gets back. Up to 25MB.',
118
+ ' GET /v1/holdings?kind=object&prefix=<p> lists what is there, with ids. &name=<key> finds one.',
119
+ ' GET /v1/holdings/<id>/content the bytes. PUT writes them. DELETE /v1/holdings/<id> removes it. PATCH renames it.',
120
+ ' POST /v1/holdings/<id>/link {"minutes":n} a time-limited URL anyone can read, for a thing that only takes a URL.',
115
121
  ' Keys look like a path (a/b/c.txt) but name one whole object: no renaming, no directories, no partial reads or writes.',
116
122
  ' This is not a filesystem. If the owner needs one, they need a machine to mount it on.',
117
123
  ' Where the bytes live is the owner\'s business: a space lent to them now, a bucket of their own later. Nothing you call changes.', '',
@@ -143,7 +149,7 @@ export function guide(connectors) {
143
149
  ' Use this instead of POST /v1/deliveries whenever the point is to run something.',
144
150
  ` foundation exec --output '{"name":"login config","as":"AUTH_FILE","filename":"auth.json"}' -- <command>`,
145
151
  ' Creates one empty private file and sets as to its path. Tell the command to write its authentication result there.',
146
- ' After exit 0, saves the file bytes under the exact name with secret=true, then removes the temporary file.',
152
+ ' After exit 0, saves the file bytes under the exact name, then removes the temporary file.',
147
153
  ' An existing value at that name is replaced. Output must be a private regular file containing 1 byte to 1MB.',
148
154
  ' May be combined with inputs, using a different environment variable. A failed command never saves its output.',
149
155
  ' If upload cannot be confirmed, exits with an error and reports the retained private file for recovery; inputs are',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomato414941/foundation",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Foundation CLI: make a key, and hand what is kept to a command without it passing through the agent.",
5
5
  "type": "module",
6
6
  "engines": {
package/runtime.mjs CHANGED
@@ -250,7 +250,7 @@ async function main() {
250
250
  }
251
251
  }
252
252
  };
253
- const recovery = () => 'Foundation could not confirm the output was saved. The private output file is retained for recovery: ' + outputPath + '\nRetry with foundation api PUT "/v1/secrets?name=<URL-encoded-name>&secret=true" --from <file>, then remove that recovery file.';
253
+ const recovery = () => 'Foundation could not confirm the output was saved. The private output file is retained for recovery: ' + outputPath + '\nRetry with foundation api PUT "/v1/holdings?kind=secret&name=<URL-encoded-name>" --from <file>, then remove that recovery file.';
254
254
  process.once('exit', cleanup);
255
255
  for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.once(signal, () => {
256
256
  interrupted = true;
@@ -287,8 +287,11 @@ async function main() {
287
287
  if (output && process.exitCode === 0) {
288
288
  const bytes = await outputBytes(outputPath);
289
289
  retainOutput = true;
290
- try { await send('/v1/secrets?name=' + encodeURIComponent(output.name) + '&secret=true', bytes, { method: 'PUT', type: 'application/octet-stream' }); }
290
+ // The command wrote it; the agent never saw it, and keeps it that way: the line drawn for the one who kept it is declined.
291
+ let saved;
292
+ try { saved = await send('/v1/holdings?kind=secret&name=' + encodeURIComponent(output.name), bytes, { method: 'PUT', type: 'application/octet-stream' }); }
291
293
  catch { throw new Error(recovery()); }
294
+ try { await send('/v1/relations', { relation: 'editor', object_type: 'holding', object_id: saved.holding.id }, { method: 'DELETE' }); } catch {}
292
295
  retainOutput = false;
293
296
  console.error('Saved output as ' + JSON.stringify(output.name) + '.');
294
297
  }