@clavis.nexus/setup 2.0.0 → 3.0.1

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.
package/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # `@clavis.nexus/setup`
2
2
 
3
- developers で Org/App を始める手順を、CLI と MCP から進められます。
3
+ CLI and MCP for starting an Org and an App on developers.
4
4
 
5
- Passkey・カード決済・DNS の掲載は、人間がブラウザまたはインフラで行います。エージェントは順序・下書き・状態確認を担います。手順は [docs.clavis.nexus](https://docs.clavis.nexus) の Quickstart(CLI/エージェント)に合わせます。
5
+ A person handles the passkey, the card checkout and publishing DNS, in a browser or on their infrastructure. An agent handles order, drafts and reading status. The steps follow the Quickstart (CLI and agents) on [docs.clavis.nexus](https://docs.clavis.nexus).
6
6
 
7
- ## インストール
7
+ ## Install
8
8
 
9
9
  ```bash
10
10
  npm install -g @clavis.nexus/setup
11
11
  clavis status
12
12
  ```
13
13
 
14
- 入れずに一度だけ実行するときは `npx -y @clavis.nexus/setup status` です。
14
+ To run it once without installing, use `npx -y @clavis.nexus/setup status`.
15
15
 
16
- MCP(Cursor 等)の例:
16
+ Example MCP configuration (Cursor and similar):
17
17
 
18
18
  ```json
19
19
  {
@@ -31,7 +31,7 @@ MCP(Cursor 等)の例:
31
31
  }
32
32
  ```
33
33
 
34
- `clavis mcp` でも同じプロセスを起動できます。
34
+ `clavis mcp` starts the same process.
35
35
 
36
36
  ## CLI
37
37
 
@@ -41,94 +41,96 @@ export CLAVIS_ID_ORIGIN=https://id.clavis.nexus
41
41
  export CLAVIS_DEVELOPERS_ORIGIN=https://developers.clavis.nexus
42
42
 
43
43
  clavis login
44
- # ブラウザで Passkey 後、developers /setup/login に出る JSON を貼る
45
- # (非対話: clavis login --bridge-json-file ./bridge.json。トークンは引数に載せない)
44
+ # After the passkey in the browser, paste the JSON from developers /setup/login
45
+ # Non-interactive: clavis login --bridge-json-file ./bridge.json
46
+ # Keep the token off the command line
46
47
  clavis status
47
48
  clavis org-anchor-plan example.com "Example Org" --incorporation JP --accept-customer-terms
48
- # Passkey → org-anchor-finish → DNS 掲載 → org-verify-anchor
49
+ # passkey, then org-anchor-finish, then publish DNS, then org-verify-anchor
49
50
  clavis org-verify-anchor --domain example.com --nonce <nonce> --incorporation JP --accept-customer-terms
50
51
  clavis card-checkout <orgId>
51
- # human.message の同意の文を顧客に見せ、同意を得てから
52
+ # Show the customer the consent statement in human.message, and continue only after they consent
52
53
  clavis card-checkout <orgId> --consent-billing-data
53
54
  clavis app-register --org <orgId> --host app.example.com --name "My App"
54
55
  clavis app-host-plan <orgId> <appId>
55
56
  clavis app-verify-host <orgId> <appId>
56
- clavis declaration-set --org <orgId> --app <appId> --end-users "社内利用者" --use signature="承認する"
57
+ clavis declaration-set --org <orgId> --app <appId> --end-users "People on our team" --use signature="Approve"
57
58
  clavis emit-env --app <appId>
58
- # 任意: 新しい接続を受け付ける地域を絞る
59
+ # optional: narrow the regions that accept new connections
59
60
  clavis app-regions-set <orgId> <appId> --regions JP
60
61
  ```
61
62
 
62
- `app-register` のあと、operate 秘密鍵は `~/.config/clavis/apps/<appId>/operate-private.jwk.json`(0600)に保存されます。CLI と MCP の JSON に載るのは、そのファイルパスです。
63
+ After `app-register`, the operate private key is saved at `~/.config/clavis/apps/<appId>/operate-private.jwk.json` (mode 0600). CLI and MCP JSON carry that file path.
63
64
 
64
- `emit-env` は同ディレクトリに `app.env`(0600)を書き、応答では `env_file` と `shell`(`source` 用)を返します。JWKS を検証するため、`CLAVIS_MASTER_PUBLIC_JWK_JSON` に `GET {apiOrigin}/.well-known/jwks.json` の `master` 公開 JWK JSON を渡します。
65
+ `emit-env` writes `app.env` (mode 0600) in the same directory, and the response returns `env_file` and `shell` (for `source`). Set `CLAVIS_TRUST_ROOT` to Clavis's Master public JWK. The value is on docs.clavis.nexus. `emit-env` checks, with the verifier, that the trust documents on the trust surface chain to that key, then writes `CLAVIS_TRUST_ROOT` into `app.env` for `@clavis.nexus/app`'s `trustRoot`.
65
66
 
66
- セッションは `~/.config/clavis/session.json` です(`CLAVIS_SESSION_PATH` で変更できます)。
67
+ The session file is `~/.config/clavis/session.json` (`CLAVIS_SESSION_PATH` changes the path).
67
68
 
68
- ### ログイン(貼り付け)
69
+ ### Login (paste)
69
70
 
70
- ブラウザから localhost へトークンを POST しません。`clavis login` は developers `/developers/setup/login?state=…` を開き、画面の JSON(`state` + `accessToken`)を stdin または `--bridge-json-file` で受け取ります。アクセストークンと operate 秘密鍵はコマンド引数に載せません。MCP の `clavis_login` は初回でブラウザを開き、2 回目に `bridge_json` を渡します。operate 鍵は `app-register` が書いたファイルから読みます。
71
+ The browser does not POST the token to localhost. `clavis login` opens developers at `/developers/setup/login?state=…` and takes the page's JSON (`state` and `accessToken`) on stdin or with `--bridge-json-file`. Keep the access token and the operate private key off command-line arguments. MCP `clavis_login` opens the browser on the first call and takes `bridge_json` on the second. The operate key is read from the file `app-register` wrote.
71
72
 
72
- ### Org の作成(設立地と組織の契約)
73
+ ### Creating an Org (place of incorporation and the organisation agreement)
73
74
 
74
- `org-anchor-plan` と `org-verify-anchor` には、次の 2 つを渡します。MCP では `incorporation` と `accept_customer_terms` です。
75
+ `org-anchor-plan` and `org-verify-anchor` both take the following. In MCP the fields are `incorporation` and `accept_customer_terms`.
75
76
 
76
- - `--incorporation`: Org の設立地です。`JP`、`GB-EAW`(イングランド・ウェールズ)、EEA の国コード(例: `DE`)、`US-XX`(例: `US-DE`)のいずれかです。
77
- - `--accept-customer-terms`: 顧客がこの Org について、組織の契約(Customer Terms)とデータ処理契約(DPA)に同意したことを示します。同意するかは顧客が決めます。同意を得てから渡してください。CLI も MCP も、既定で同意にはしません。エージェントは自分で付けず、人間に確かめます。無いときの応答には `needs_human: terms` が付きます。
77
+ - `--incorporation`: the Org's place of incorporation. One of `JP`, `GB-EAW` (England and Wales), an EEA country code (for example `DE`), or `US-XX` (for example `US-DE`).
78
+ - `--accept-customer-terms`: records that the customer has agreed to the Customer Terms and the Data Processing Agreement (DPA) for this Org. Whether to agree is the customer's decision. Pass it after they agree. The CLI and MCP leave agreement off by default. An agent asks a person and does not set the flag itself. A response without it carries `needs_human: terms`.
78
79
 
79
- いま新しく申告できない設立地(`GET /orgs/regions` の `closed_incorporations`)は、`org-anchor-plan` が Passkey の前に断ります。API が 403 `REGION_CLOSED` を返したときも、応答の `error` は `region_closed` で始まります。
80
+ A place of incorporation closed to new declarations right now (`closed_incorporations` on `GET /orgs/regions`) is refused by `org-anchor-plan` before the passkey. When the API returns 403 `REGION_CLOSED`, the response's `error` starts with `region_closed`.
80
81
 
81
- ### 設立地の申告し直し
82
+ ### Declaring the place of incorporation again
82
83
 
83
- 組織の契約と DPA の版が新しくなったあと、購入の前に設立地を申告し直します。
84
+ After the Customer Terms and the DPA move to a new version, declare the place of incorporation again before a purchase.
84
85
 
85
86
  ```bash
86
87
  clavis incorporation-set <orgId> --incorporation JP --accept-customer-terms
87
88
  ```
88
89
 
89
- - 申告は、その時点の組織の契約と DPA の版に結ばれます。版が新しいと、`clavis status` の `incorporation.terms_current` が `false` です。
90
- - 新しい版への同意になるため、`--accept-customer-terms` が要ります(MCP は `clavis_incorporation_set`)。
91
- - 今の設立地のままの申告し直しは、その地域が閉じていても続けられます。
90
+ - A declaration binds to the Customer Terms and DPA versions current at that time. When the versions are newer, `incorporation.terms_current` in `clavis status` is `false`.
91
+ - Agreement to the new versions needs `--accept-customer-terms` (MCP: `clavis_incorporation_set`).
92
+ - Declaring the current place again continues even when that region is closed.
92
93
 
93
- ### 署名のカードの購入
94
+ ### Buying the signature card
94
95
 
95
- Passkey のあと、署名のカードの Checkout をブラウザで開き、カードの入力は人間が行います。
96
+ After the passkey, signature-card checkout opens in the browser. A person enters the card.
96
97
 
97
98
  ```bash
98
99
  clavis card-checkout <orgId>
99
- # human.message の同意の文を顧客に見せ、同意を得てから
100
+ # Show the customer the consent statement in human.message, and continue only after they consent
100
101
  clavis card-checkout <orgId> --consent-billing-data
101
102
  ```
102
103
 
103
- - 設立地が今の版で申告済みであることが要ります。足りないときの `error` は `incorporation_required` か `incorporation_stale` です。
104
- - 決済と請求のため、Clavis アカウント識別子、Org ID と購入する機能、購入後の利用量(件数と日時)を、米国の Polar Software Inc. に提供します。この提供への顧客本人の同意が要ります。`--consent-billing-data` を付けずに実行すると、応答の `human.message`(`needs_human: terms`)に同意の文と組織の契約・DPA の版が出ます。顧客に見せ、同意を得てから `--consent-billing-data`(MCP: `consent_billing_data: true`)を付けて実行し直します。エージェントは自分で付けません。
105
- - 同意の文は `--lang ja` で日本語です(既定は英語)。購入の記録は、見せた言語の文に結ばれます。
106
- - 月額の束で購入するときは `--offer bundle` です。既定は従量(`meter`)です。
104
+ - The place of incorporation must already be declared against the current versions. When it is missing, `error` is `incorporation_required` or `incorporation_stale`.
105
+ - Payment and billing need the customer's own consent to provide their Clavis account identifier, the Org ID, the feature being purchased, and, after purchase, usage of that feature (counts and times) to Polar Software Inc. in the United States. Run the command once without `--consent-billing-data`. The response's `human.message` (`needs_human: terms`) carries the consent statement and the Customer Terms and DPA versions. Show that statement to the customer, and run again with `--consent-billing-data` (MCP: `consent_billing_data: true`) only after they consent. An agent does not set the flag itself.
106
+ - `--lang ja` shows the consent statement in Japanese (the default is English). The purchase record is tied to the statement in the language that was shown.
107
+ - `--offer bundle` buys the monthly bundle. The default is metered (`meter`).
107
108
 
108
- ### App の受け入れる地域
109
+ ### Regions an app accepts
109
110
 
110
- App ごとに、新しい接続を受け付ける国・地域を絞れます。任意の設定です。
111
+ Each app can narrow the countries and regions it takes new connections from. The setting is optional.
111
112
 
112
113
  ```bash
113
114
  clavis app-regions-set <orgId> <appId> --regions JP,US
114
- # Clavis が受け付ける地域すべてに戻す
115
+ # back to every region Clavis accepts
115
116
  clavis app-regions-set <orgId> <appId> --all
116
117
  ```
117
118
 
118
- - 地域は `JP`、`US`、`GB`、`EEA` です。MCP は `clavis_app_regions_set` の `regions` か `all: true` です。
119
- - 選べるのは、いま Clavis が受け付けている地域だけです(`GET /orgs/regions` の `app_regions`)。それ以外は Passkey の前に断り、`error` は `region_not_open` で始まります。
120
- - 地域は接続元の国で判定します。国を判定できない接続は、選んだ地域の外として扱います。
121
- - 絞っても、すでに接続している人はそのまま使えます。止めるのは、新しい同意、初めてのアプリ接続、アカウント連携、署名する人を決めていない署名です。
122
- - 同じ地域がすでに保存されているときは、Passkey を開かずに `unchanged: true` を返します。
123
- - 変えられるのは Org の owner と admin です。停止中の App は変えられません。
119
+ - The regions are `JP`, `US`, `GB` and `EEA`. In MCP, pass `regions` or `all: true` to `clavis_app_regions_set`.
120
+ - The choice is limited to regions Clavis accepts right now (`app_regions` on `GET /orgs/regions`). Any other region is refused before the passkey, and `error` starts with `region_not_open`.
121
+ - The region is the country the connection comes from. A connection whose country cannot be determined counts as outside the chosen regions.
122
+ - People who are already connected keep using the app. What stops is a new agreement, a first app connection, an account link, and a signature whose request names no signer.
123
+ - When the same regions are already saved, the command returns `unchanged: true` and does not open a passkey.
124
+ - An Org owner or admin can change the list. A stopped app cannot be changed.
124
125
 
125
- ### この CLI が扱う範囲
126
+ ### What this CLI covers
126
127
 
127
- - `clavis status` が返すのは、Org・App・ホスト確認・用途の申告と、App の受け入れる地域(絞ったときだけ `accepted_regions`)、署名のカードの状態(止めている理由は `signature_card_blockers`)、設立地です。台帳の購読は developers で確認します。
128
- - `clavis card-checkout` が開くのは、署名のカードの Checkout です。台帳のカードは developers で購読します。
129
- - `declaration-set` の `--use` には `signature` と `ledger` を渡せます。CLI は 1 回に 1 つで、その申告が前の申告を置き換えます。1 つの App で複数の機能を申告するときは、MCP の `uses` 配列か developers で書きます。
128
+ - `clavis status` returns the Org, apps, host confirmation, the use declaration, the app's accepted regions (`accepted_regions` only when the list is narrowed), the signature card (`signature_card_blockers` is what holds it back) and the place of incorporation. Check the ledger subscription on developers.
129
+ - `clavis card-checkout` opens checkout for the signature card. Subscribe to the ledger card on developers.
130
+ - `--use` on `declaration-set` accepts `signature` and `ledger`. The CLI takes one per run, and that declaration replaces the previous one. To declare more than one feature for one app, use the `uses` array in MCP, or developers.
131
+ - `clavis policy-bootstrap <orgId>` creates the Org policy, with a passkey. `app-register` runs it for you, so you need it on its own only when the policy is missing. A policy already in place returns `already_active: true` and opens no passkey.
130
132
 
131
- ## ライブラリ
133
+ ## Library
132
134
 
133
135
  ```ts
134
136
  import { createSetupClient } from "@clavis.nexus/setup";
@@ -137,6 +139,10 @@ const setup = createSetupClient();
137
139
  const status = await setup.status();
138
140
  ```
139
141
 
140
- ツール応答に `needs_human: passkey | payment | dns | login | terms` が付くときは、人間の操作が必要です。`terms` は、顧客が自分で決める同意(組織の契約、決済のためのデータ提供)の段階です。
142
+ When a tool response carries `needs_human: passkey | payment | dns | login | terms`, a person has to act. `terms` is an agreement only the customer can give: the Customer Terms, or providing data for a card checkout.
141
143
 
142
- 署名依頼の登録と完了の読み取りは [`@clavis.nexus/app`](https://www.npmjs.com/package/@clavis.nexus/app) です。
144
+ Registering a signature request and reading its completion are [`@clavis.nexus/app`](https://www.npmjs.com/package/@clavis.nexus/app).
145
+
146
+ ## License
147
+
148
+ MIT. Copyright (c) 2026 DeepDive, Inc.
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { promisify } from 'util';
4
4
  import { readFile, chmod, unlink, mkdir, writeFile, lstat } from 'fs/promises';
5
5
  import path, { dirname, join, resolve, relative, isAbsolute } from 'path';
6
6
  import { homedir } from 'os';
7
- import { generateKeyPair, exportJWK, createRemoteJWKSet, jwtVerify } from 'jose';
7
+ import { generateKeyPair, exportJWK, jwtVerify, importJWK } from 'jose';
8
8
  import { createInterface } from 'readline/promises';
9
9
  import { stdin, stdout } from 'process';
10
10
  import { randomBytes } from 'crypto';
@@ -183,19 +183,10 @@ async function postCardCheckout(apiOrigin, bearer, orgId, args) {
183
183
  }
184
184
  });
185
185
  }
186
- async function fetchJwksDocument(apiOrigin) {
187
- const res = await fetch(`${apiOrigin.replace(/\/+$/, "")}/.well-known/jwks.json`, {
188
- redirect: "error",
189
- headers: { Accept: "application/json" }
190
- });
191
- if (!res.ok) throw new SetupApiError(res.status, "JWKS_FETCH", `jwks ${res.status}`);
192
- return res.json();
193
- }
194
- async function getMasterJwkJson(apiOrigin, masterPinJson) {
195
- const { verifySignedJwksDocument } = await import('@clavis.nexus/app');
196
- const doc = await fetchJwksDocument(apiOrigin);
197
- await verifySignedJwksDocument(doc, masterPinJson);
198
- return JSON.stringify(doc.master);
186
+ async function checkTrustRoot(apiOrigin, trustRootJson) {
187
+ const { createVerifier } = await import('@clavis.nexus/app');
188
+ await createVerifier({ trustRoot: trustRootJson, apiOrigin }).trust();
189
+ return JSON.stringify(JSON.parse(trustRootJson));
199
190
  }
200
191
  var SetupApiError;
201
192
  var init_org_api = __esm({
@@ -575,6 +566,17 @@ async function digestOf(value) {
575
566
  const bytes = new TextEncoder().encode(canonicalStringify(value));
576
567
  return `sha256:${bytesToBase64Url(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)))}`;
577
568
  }
569
+ async function valueDigest(type, value) {
570
+ return digestOf({ type, value });
571
+ }
572
+ async function orgPayloadDigest(payload) {
573
+ let value = payload;
574
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
575
+ const { proposer_receipt: _receipt, ...rest } = payload;
576
+ value = rest;
577
+ }
578
+ return valueDigest("org.payload@1", value);
579
+ }
578
580
  function orgAnchorPublishStatement(input2) {
579
581
  return { type: "org.anchor.publish@1", domain: input2.domain.trim().toLowerCase(), nonce: input2.nonce, exp: input2.exp };
580
582
  }
@@ -582,7 +584,7 @@ function orgPolicyBootstrapStatement(input2) {
582
584
  return { type: "org.policy.bootstrap@1", org: input2.org.trim(), domain: input2.domain.trim().toLowerCase() };
583
585
  }
584
586
  function orgAppRegisterStatement(input2) {
585
- return { type: "org.app.register@1", org: input2.org.trim(), payload: input2.payload.trim().toLowerCase() };
587
+ return { type: "org.app.register@1", org: input2.org.trim(), payload: input2.payload.trim() };
586
588
  }
587
589
  function orgAppVerifyHostStatement(input2) {
588
590
  return {
@@ -598,7 +600,7 @@ async function orgAppDeclarationStatement(input2) {
598
600
  type: "org.app.declaration@1",
599
601
  org: input2.org.trim(),
600
602
  app: input2.app.trim(),
601
- declaration: input2.declaration === null ? null : await digestOf({ endUsers: input2.declaration.endUsers, uses: input2.declaration.uses })
603
+ declaration: input2.declaration === null ? null : await valueDigest("app.declaration@1", { endUsers: input2.declaration.endUsers, uses: input2.declaration.uses })
602
604
  };
603
605
  }
604
606
  function orgAppRegionsStatement(input2) {
@@ -635,13 +637,6 @@ function sameStatement(a, b) {
635
637
  return false;
636
638
  }
637
639
  }
638
- async function computePayloadCommitmentHex(payload) {
639
- const o = payload && typeof payload === "object" ? { ...payload } : payload;
640
- if (o && typeof o === "object" && !Array.isArray(o)) {
641
- delete o.proposer_receipt;
642
- }
643
- return sha256HexUtf8(canonicalStringify(o));
644
- }
645
640
  async function hashManifestBody(body) {
646
641
  return sha256HexUtf8(canonicalStringify(body));
647
642
  }
@@ -657,14 +652,10 @@ var init_statements = __esm({
657
652
 
658
653
  // src/ceremony.ts
659
654
  function receiptFromCeremonyPayload(payload) {
660
- if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
655
+ if (typeof payload !== "string" || payload.length === 0) {
661
656
  throw new Error("Passkey confirmation did not return a receipt.");
662
657
  }
663
- const o = payload;
664
- if (o.type !== "receipt@1" || o.statement === null || typeof o.statement !== "object") {
665
- throw new Error("Passkey confirmation did not return a receipt.");
666
- }
667
- return o;
658
+ return payload;
668
659
  }
669
660
  async function startCeremony(args) {
670
661
  const res = await fetch(`${args.apiOrigin.replace(/\/+$/, "")}/webauthn/authentication/ceremony/start`, {
@@ -808,19 +799,17 @@ var init_operate_key_store = __esm({
808
799
 
809
800
  // src/emit-env.ts
810
801
  async function emitAppEnv(args) {
811
- const pin = args.masterPublicJwkJson?.trim() || process.env.CLAVIS_MASTER_PUBLIC_JWK_JSON?.trim() || "";
802
+ const pin = args.trustRoot?.trim() || process.env.CLAVIS_TRUST_ROOT?.trim() || "";
812
803
  if (!pin) {
813
- throw new Error(
814
- "CLAVIS_MASTER_PUBLIC_JWK_JSON is required. Set it to the master public JWK from GET {apiOrigin}/.well-known/jwks.json."
815
- );
804
+ throw new Error("CLAVIS_TRUST_ROOT is required. Set it to the Clavis Master public JWK (docs.clavis.nexus).");
816
805
  }
817
- const master = await getMasterJwkJson(args.origins.apiOrigin, pin);
806
+ const trustRoot = await checkTrustRoot(args.origins.apiOrigin, pin);
818
807
  const operatePath = await saveOperatePrivateJwk(args.appId, args.operatePrivateJwkJson);
819
808
  const envRecord = {
820
809
  CLAVIS_API_ORIGIN: args.origins.apiOrigin,
821
810
  CLAVIS_APP_ID: args.appId,
822
811
  OPERATE_PRIVATE_JWK: args.operatePrivateJwkJson,
823
- MASTER_PUBLIC_JWK_JSON: master
812
+ CLAVIS_TRUST_ROOT: trustRoot
824
813
  };
825
814
  const envFile = await writeAppEnvFile(args.appId, formatEnvExport(envRecord));
826
815
  return {
@@ -866,26 +855,47 @@ var init_keys = __esm({
866
855
  "src/keys.ts"() {
867
856
  }
868
857
  });
858
+ async function sessionKey(origin, kid) {
859
+ const res = await fetch(`${origin}/.well-known/jwks.json`, { redirect: "error", headers: { Accept: "application/json" } });
860
+ if (!res.ok) throw new Error(`jwks ${res.status}`);
861
+ const doc = await res.json();
862
+ const key = (doc.keys ?? []).find((k) => k && k.kid === kid);
863
+ if (!key) return null;
864
+ const slot = Object.entries(key).find(([name]) => SLOT_FIELD.test(name))?.[1];
865
+ if (slot !== SESSION_SLOT) return null;
866
+ const jwk = {};
867
+ for (const m of JWK_MEMBERS) if (key[m] !== void 0) jwk[m] = key[m];
868
+ return importJWK(jwk, "ES256");
869
+ }
869
870
  async function verifyDevelopersAccessToken(accessToken, apiOrigin) {
870
871
  const origin = new URL(apiOrigin).origin;
871
- const jwks = createRemoteJWKSet(new URL(`${origin}/.well-known/jwks.json`));
872
- const { payload, protectedHeader } = await jwtVerify(accessToken, jwks, {
873
- algorithms: ["ES256"],
874
- issuer: origin,
875
- audience: origin,
876
- requiredClaims: ["exp", "iss", "aud", "sub"]
872
+ let refused = false;
873
+ const { payload } = await jwtVerify(
874
+ accessToken,
875
+ async (header) => {
876
+ const key = typeof header.kid === "string" ? await sessionKey(origin, header.kid) : null;
877
+ if (!key) {
878
+ refused = true;
879
+ throw new Error("invalid_access_token_kid");
880
+ }
881
+ return key;
882
+ },
883
+ { algorithms: ["ES256"], issuer: origin, audience: origin, requiredClaims: ["exp", "iss", "aud", "sub"] }
884
+ ).catch((e) => {
885
+ if (refused) throw new Error("invalid_access_token_kid");
886
+ throw e;
877
887
  });
878
- const kid = typeof protectedHeader.kid === "string" ? protectedHeader.kid : "";
879
- if (!SESSION_SLOT_RE.test(kid)) throw new Error("invalid_access_token_kid");
880
888
  if (payload.tk !== "access") throw new Error("invalid_access_token_kind");
881
889
  if (typeof payload.sub !== "string" || payload.sub.length === 0) throw new Error("invalid_access_token_sub");
882
890
  if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp)) throw new Error("invalid_access_token_exp");
883
891
  return { sub: payload.sub, expiresAt: payload.exp };
884
892
  }
885
- var SESSION_SLOT_RE;
893
+ var SESSION_SLOT, SLOT_FIELD, JWK_MEMBERS;
886
894
  var init_access_token_verify = __esm({
887
895
  "src/access-token-verify.ts"() {
888
- SESSION_SLOT_RE = /^[a-z][a-z0-9]{1,31}-wauthn-auth-jwt(?:-\d{6})?$/;
896
+ SESSION_SLOT = "wauthn-auth-jwt";
897
+ SLOT_FIELD = /^[a-z][a-z0-9]{1,31}-slot$/;
898
+ JWK_MEMBERS = ["kty", "crv", "x", "y", "kid", "alg"];
889
899
  }
890
900
  });
891
901
  function defaultSessionPath() {
@@ -1591,7 +1601,7 @@ function createSetupClient(options = {}) {
1591
1601
  operate_public_jwk: keys.publicJwk,
1592
1602
  redirect_paths: paths
1593
1603
  };
1594
- const payload_hash = await computePayloadCommitmentHex(manifest);
1604
+ const payload_hash = await orgPayloadDigest(manifest);
1595
1605
  const cer = await runPasskeyCeremony({
1596
1606
  origins: auth.data.origins,
1597
1607
  bearer: auth.data.session.accessToken,
@@ -2142,7 +2152,7 @@ var init_mcp_server = __esm({
2142
2152
  },
2143
2153
  {
2144
2154
  name: "clavis_emit_app_env",
2145
- description: "Emit environment variables for @clavis.nexus/app after setup.",
2155
+ description: "Emit environment variables for @clavis.nexus/app after setup. Needs CLAVIS_TRUST_ROOT (the Clavis Master public JWK) in the environment.",
2146
2156
  inputSchema: {
2147
2157
  type: "object",
2148
2158
  properties: {
@@ -2244,7 +2254,7 @@ org-anchor-plan and org-verify-anchor need both flags. --incorporation is the Or
2244
2254
  A place of incorporation that is closed to new Orgs right now is refused before Passkey.
2245
2255
  incorporation-set declares the place again after the Customer Terms change (status shows terms_current false). It needs the customer's agreement too.
2246
2256
  card-checkout needs --consent-billing-data: the customer's consent to provide billing data to the payment provider. Run it once without the flag to get the statement to show them.
2247
- Secrets stay in ~/.config/clavis/apps/<appId>/ (mode 0600). Command output includes the file path. emit-env needs CLAVIS_MASTER_PUBLIC_JWK_JSON set to the master public JWK from /.well-known/jwks.json.
2257
+ Secrets stay in ~/.config/clavis/apps/<appId>/ (mode 0600). Command output includes the file path. emit-env needs CLAVIS_TRUST_ROOT set to the Clavis Master public JWK (docs.clavis.nexus); it checks that the trust documents chain to it before writing CLAVIS_TRUST_ROOT for @clavis.nexus/app.
2248
2258
  app-regions-set chooses where the App accepts new connections from: JP, US, GB, EEA (comma-separated). --all accepts every region Clavis accepts. People already connected keep using the App.
2249
2259
  declaration-set replaces the App's current declaration. Pass every use to keep. status reports the signature card and the place of incorporation. Ledger subscription is on developers.
2250
2260