@tomato414941/foundation 0.26.0 → 0.27.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 (2) hide show
  1. package/package.json +1 -1
  2. package/runtime.mjs +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomato414941/foundation",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Foundation CLI: give this machine a WebAuthn credential, 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
@@ -337,7 +337,10 @@ async function main() {
337
337
  if (action === 'join') {
338
338
  const me = await send('/v1/principals/me', undefined, { method: 'GET', accept: data => data.error?.code === 'not_approved' });
339
339
  if (me.principal?.acts_for?.length) { console.log('Already approved on ' + url.origin + '.'); return; }
340
- const answer = await send('/v1/requests', { authorization_details: [{ type: 'relation', relation: 'agent' }] });
340
+ // The one call it may ask for: a line from itself, agent, onto whoever answers (me, to them).
341
+ // One someone already owns asks them; one nobody knows asks whoever opens the page it shows.
342
+ const self = me.principal?.id ?? (await send('/v1/session', undefined, { method: 'GET' })).current?.principal_id, owner = me.principal?.owners?.[0];
343
+ const answer = await send('/v1/requests', { ...(owner ? { to: owner } : {}), operations: [{ method: 'POST', path: '/v1/principals/' + encodeURIComponent(self) + '/relations', body: { relation: 'agent', object_type: 'principal', object_id: 'me' } }] });
341
344
  console.log(JSON.stringify(answer, null, 2));
342
345
  return;
343
346
  }