@pidgeon-ai/cli 1.37.0 → 1.38.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.
@@ -2027,7 +2027,7 @@ function sleep(ms, signal) {
2027
2027
  });
2028
2028
  }
2029
2029
 
2030
- // ../id/dist/chunk-EAXZTLYY.js
2030
+ // ../id/dist/chunk-C5J6V6N2.js
2031
2031
  import { createHash } from "crypto";
2032
2032
  import { chmod, mkdir, readFile, readdir, writeFile } from "fs/promises";
2033
2033
  import { homedir } from "os";
@@ -2562,6 +2562,10 @@ var IdClient = class {
2562
2562
  grant(input) {
2563
2563
  return this.call("POST", "/grants", input);
2564
2564
  }
2565
+ /** Every token Sign in with Pidgeon issued `name`, taken back; its card and grants stand. */
2566
+ revokeSignIns(name) {
2567
+ return this.call("DELETE", `/agents/${encodeURIComponent(name)}/sign-ins`);
2568
+ }
2565
2569
  revokeGrant(id) {
2566
2570
  return this.call("DELETE", `/grants/${encodeURIComponent(id)}`);
2567
2571
  }
@@ -2633,7 +2637,21 @@ async function fetchCard(agent, fetcher = fetch, postHost = (domain) => `https:/
2633
2637
  }
2634
2638
  return body.jws;
2635
2639
  }
2636
- async function signInWithPidgeon(identity, input) {
2640
+ function signInWithPidgeon(identity, input) {
2641
+ return signIn(
2642
+ identity,
2643
+ input,
2644
+ async ({ tokenEndpoint, exchange, headers, agent }) => signRequest(identity, {
2645
+ method: "POST",
2646
+ url: tokenEndpoint,
2647
+ headers,
2648
+ body: exchange,
2649
+ agent,
2650
+ grants: input.grant ? [input.grant] : void 0
2651
+ })
2652
+ );
2653
+ }
2654
+ async function signIn(identity, input, authenticate) {
2637
2655
  const fetcher = input.fetch ?? fetch;
2638
2656
  const agent = input.agent.trim().toLowerCase();
2639
2657
  const site = await siteMetadata(input.site, fetcher);
@@ -2649,21 +2667,15 @@ async function signInWithPidgeon(identity, input) {
2649
2667
  grant_type: TOKEN_EXCHANGE,
2650
2668
  subject_token: card,
2651
2669
  subject_token_type: TOKEN_TYPE_JWT,
2652
- audience: site.client_id
2670
+ audience: site.client_id,
2671
+ ...input.delegation ? { requested_token_type: TOKEN_TYPE_JWT } : {}
2653
2672
  });
2654
2673
  const headers = { "content-type": "application/x-www-form-urlencoded" };
2655
2674
  const issued = await fetcher(tokenEndpoint, {
2656
2675
  method: "POST",
2657
2676
  headers: {
2658
2677
  ...headers,
2659
- ...await signRequest(identity, {
2660
- method: "POST",
2661
- url: tokenEndpoint,
2662
- headers,
2663
- body: exchange,
2664
- agent,
2665
- grants: input.grant ? [input.grant] : void 0
2666
- })
2678
+ ...await authenticate({ tokenEndpoint, exchange, headers, agent, site })
2667
2679
  },
2668
2680
  body: exchange
2669
2681
  });
@@ -2719,7 +2731,9 @@ var HELP = `pidgeon id \u2014 a signed identity for your agents, on your own dom
2719
2731
  grant <name> Grant <name> what it may do, as the domain
2720
2732
  --scope bookings.change --label "manage bookings"
2721
2733
  --subject customer:42 --audience delta.com --days 30
2734
+ --grantor maria@example.com ask a person instead
2722
2735
  revoke-grant <id> Take a grant back now
2736
+ revoke-sign-ins <name> End every token <name> signed in with; its card and grants stand
2723
2737
  sign-in <site> Sign in to a site as an agent --as <name> --grant <jws>
2724
2738
 
2725
2739
  --domain <domain> Which domain, when this machine holds more than one
@@ -2895,14 +2909,23 @@ Or add them by hand:` : "Add these records at your DNS provider:",
2895
2909
  }
2896
2910
  const days = flags.get("days");
2897
2911
  const audience = flags.get("audience");
2912
+ const grantor = flags.get("grantor");
2898
2913
  const grant = await client2(await which()).grant({
2899
2914
  agent: name,
2900
2915
  scope: { name: scope, label },
2901
2916
  subject: { type, id: idParts.join(":") },
2902
2917
  ...typeof audience === "string" ? { audience } : {},
2918
+ ...typeof grantor === "string" ? { grantor: { email: grantor } } : {},
2903
2919
  ...typeof days === "string" ? { expires_at: new Date(Date.now() + Number(days) * 864e5).toISOString() } : {}
2904
2920
  });
2905
2921
  if (json2) return JSON.stringify(grant, null, 2);
2922
+ if (grant.consent_url) {
2923
+ return [
2924
+ `Asked ${typeof grantor === "string" ? grantor : "them"} to let ${grant.agent} ${grant.scope.label} for ${grant.subject.type} ${grant.subject.id}.`,
2925
+ `Send them this link; nothing is allowed until they answer it: ${grant.consent_url}`,
2926
+ `Grant ${grant.id}. \`pidgeon id revoke-grant ${grant.id}\` withdraws the request.`
2927
+ ].join("\n");
2928
+ }
2906
2929
  return [
2907
2930
  `${grant.agent} may ${grant.scope.label} for ${grant.subject.type} ${grant.subject.id}${grant.audience ? ` at ${grant.audience}` : ""}, until ${grant.expires_at}.`,
2908
2931
  `Grant ${grant.id}. The agent carries it as Post-Grant; --json prints the JWS.`
@@ -2915,6 +2938,14 @@ Or add them by hand:` : "Add these records at your DNS provider:",
2915
2938
  if (json2) return JSON.stringify(revoked, null, 2);
2916
2939
  return `Grant ${revoked.id} is revoked. The next check of it fails.`;
2917
2940
  }
2941
+ case "revoke-sign-ins": {
2942
+ const name = rest[0]?.trim().toLowerCase();
2943
+ if (!name)
2944
+ throw new UsageError("Name the agent: `pidgeon id revoke-sign-ins support-agent`.");
2945
+ const done = await client2(await which()).revokeSignIns(name);
2946
+ if (json2) return JSON.stringify(done, null, 2);
2947
+ return `${done.address}: ${done.revoked} token${done.revoked === 1 ? "" : "s"} taken back. Its card and grants stand.`;
2948
+ }
2918
2949
  case "sign-in": {
2919
2950
  const site = rest[0];
2920
2951
  const name = flags.get("as");
@@ -3147,4 +3178,4 @@ export {
3147
3178
  find,
3148
3179
  run
3149
3180
  };
3150
- //# sourceMappingURL=chunk-RWZQSI67.js.map
3181
+ //# sourceMappingURL=chunk-ZDJG3Z7B.js.map