@jini-ai/integrations 0.7.3-next.1 → 0.7.3-next.3

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 (188) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -0
  3. package/dist/api-connections/bundled-client-namespace.d.ts +24 -0
  4. package/dist/api-connections/bundled-client-namespace.js +22 -0
  5. package/dist/api-connections/connect.d.ts +2 -10
  6. package/dist/api-connections/contribution.d.ts +71 -0
  7. package/dist/api-connections/contribution.js +69 -0
  8. package/dist/api-connections/form-delivery-connection.d.ts +68 -0
  9. package/dist/api-connections/form-delivery-connection.js +73 -0
  10. package/dist/api-connections/hosted-mcp/contracts.d.ts +4 -171
  11. package/dist/api-connections/hosted-mcp/index.d.ts +2 -0
  12. package/dist/api-connections/hosted-mcp/oauth-row-writes.d.ts +3 -1
  13. package/dist/api-connections/hosted-mcp/oauth-row-writes.js +6 -3
  14. package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +2 -1
  15. package/dist/api-connections/hosted-mcp/sign-in-configuration.js +1 -1
  16. package/dist/api-connections/hosted-mcp/sign-in-discovery.js +1 -1
  17. package/dist/api-connections/hosted-mcp/sign-in-flow.d.ts +9 -3
  18. package/dist/api-connections/hosted-mcp/sign-in-flow.js +6 -6
  19. package/dist/api-connections/hosted-mcp/sign-in-provider.d.ts +16 -4
  20. package/dist/api-connections/hosted-mcp/sign-in-provider.js +3 -3
  21. package/dist/api-connections/hosted-mcp/sign-in-status.d.ts +13 -2
  22. package/dist/api-connections/hosted-mcp/sign-in-status.js +17 -4
  23. package/dist/api-connections/hosted-mcp/sign-in.d.ts +1 -1
  24. package/dist/api-connections/hosted-mcp/sign-in.js +28 -30
  25. package/dist/api-connections/shared-api.d.ts +87 -0
  26. package/dist/api-connections/shared-api.js +135 -0
  27. package/dist/api-connections/shared-oauth-disconnect.d.ts +73 -0
  28. package/dist/api-connections/shared-oauth-disconnect.js +41 -0
  29. package/dist/api-connections/shared-owner.d.ts +107 -0
  30. package/dist/api-connections/shared-owner.js +79 -0
  31. package/dist/api-connections/vault-stores.d.ts +110 -0
  32. package/dist/api-connections/vault-stores.js +202 -0
  33. package/dist/credentialed-http/auth-schemes.d.ts +2 -9
  34. package/dist/credentialed-http/tools/index.d.ts +30 -0
  35. package/dist/credentialed-http/tools/index.js +19 -0
  36. package/dist/credentialed-http/tools/tool-registrations.js +0 -1
  37. package/dist/custom-credentials/agent-tools.d.ts +79 -0
  38. package/dist/custom-credentials/agent-tools.js +98 -0
  39. package/dist/custom-credentials/card-token.d.ts +15 -0
  40. package/dist/custom-credentials/card-token.js +35 -0
  41. package/dist/custom-credentials/credential-ports.d.ts +70 -0
  42. package/dist/custom-credentials/credential-ports.js +41 -0
  43. package/dist/custom-credentials/credential-recovery.d.ts +20 -0
  44. package/dist/custom-credentials/credential-recovery.js +22 -0
  45. package/dist/custom-credentials/credentialed-request.d.ts +83 -0
  46. package/dist/custom-credentials/credentialed-request.js +93 -0
  47. package/dist/custom-credentials/custom-credential-create-ui.d.ts +106 -0
  48. package/dist/custom-credentials/custom-credential-create-ui.js +136 -0
  49. package/dist/custom-credentials/custom-credential-set-token-ui.d.ts +84 -0
  50. package/dist/custom-credentials/custom-credential-set-token-ui.js +104 -0
  51. package/dist/custom-credentials/delete-request-confirmation-ui.d.ts +33 -0
  52. package/dist/custom-credentials/delete-request-confirmation-ui.js +35 -0
  53. package/dist/custom-credentials/provider-settings-card.d.ts +109 -0
  54. package/dist/custom-credentials/provider-settings-card.js +166 -0
  55. package/dist/custom-credentials/write-files-validation.d.ts +102 -0
  56. package/dist/custom-credentials/write-files-validation.js +202 -0
  57. package/dist/media-providers/catalog-projection.d.ts +29 -0
  58. package/dist/media-providers/catalog-projection.js +45 -0
  59. package/dist/media-providers/catalog.d.ts +6 -3
  60. package/dist/media-providers/catalog.js +4 -3
  61. package/dist/media-providers/configurable-catalog.d.ts +9 -0
  62. package/dist/media-providers/configurable-catalog.js +70 -0
  63. package/dist/media-providers/dispatch/builtin-vendors.js +0 -2
  64. package/dist/media-providers/dispatch/credentials.d.ts +4 -1
  65. package/dist/media-providers/dispatch/credentials.js +3 -2
  66. package/dist/media-providers/dispatch/engine.d.ts +1 -1
  67. package/dist/media-providers/dispatch/engine.js +17 -5
  68. package/dist/media-providers/dispatch/index.d.ts +3 -2
  69. package/dist/media-providers/dispatch/index.js +2 -2
  70. package/dist/media-providers/dispatch/media-provider-registry.d.ts +23 -4
  71. package/dist/media-providers/dispatch/media-provider-registry.js +26 -11
  72. package/dist/media-providers/dispatch/media-wire.d.ts +14 -0
  73. package/dist/media-providers/dispatch/media-wire.js +22 -0
  74. package/dist/media-providers/dispatch/node.d.ts +5 -0
  75. package/dist/media-providers/dispatch/node.js +5 -1
  76. package/dist/media-providers/dispatch/openai-compatible.d.ts +3 -1
  77. package/dist/media-providers/dispatch/openai-compatible.js +1 -1
  78. package/dist/media-providers/dispatch/operation-runtime.js +5 -4
  79. package/dist/media-providers/dispatch/outbound.d.ts +28 -3
  80. package/dist/media-providers/dispatch/outbound.js +10 -3
  81. package/dist/media-providers/dispatch/providers/custom-image.js +1 -1
  82. package/dist/media-providers/dispatch/providers/imagerouter.js +1 -1
  83. package/dist/media-providers/dispatch/providers/nanobanana.js +1 -1
  84. package/dist/media-providers/dispatch/providers/openrouter.js +1 -1
  85. package/dist/media-providers/dispatch/ssrf-guard.js +2 -2
  86. package/dist/media-providers/dispatch/types.d.ts +13 -4
  87. package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
  88. package/dist/media-providers/index.d.ts +2 -0
  89. package/dist/media-providers/providers.d.ts +9 -5
  90. package/dist/media-providers/providers.js +9 -12
  91. package/dist/media-providers/sqlite-task-store.d.ts +4 -4
  92. package/dist/media-providers/task-store.d.ts +1 -1
  93. package/dist/media-providers/task-store.js +1 -1
  94. package/dist/media-providers/types.d.ts +0 -36
  95. package/dist/media-providers/ui-defaults.js +0 -4
  96. package/dist/react/admin-credentials/AdminByokKeyPanel.d.ts +130 -0
  97. package/dist/react/admin-credentials/AdminByokKeyPanel.js +115 -0
  98. package/dist/react/admin-credentials/byok-footer-status.d.ts +37 -0
  99. package/dist/react/admin-credentials/byok-footer-status.js +25 -0
  100. package/dist/react/credentials/OtherCredentialsSection.d.ts +36 -0
  101. package/dist/react/credentials/OtherCredentialsSection.hooks.d.ts +55 -0
  102. package/dist/react/credentials/OtherCredentialsSection.hooks.js +26 -0
  103. package/dist/react/credentials/OtherCredentialsSection.js +120 -0
  104. package/dist/react/credentials/access-token-forms.d.ts +219 -0
  105. package/dist/react/credentials/access-token-forms.js +114 -0
  106. package/dist/react/credentials/credential-copy.d.ts +17 -0
  107. package/dist/react/credentials/credential-copy.js +7 -0
  108. package/dist/react/credentials/other-credential-stores.d.ts +115 -0
  109. package/dist/react/credentials/other-credential-stores.js +76 -0
  110. package/dist/react/site-key/SiteKeyRecoveryCard.d.ts +16 -0
  111. package/dist/react/site-key/SiteKeyRecoveryCard.js +36 -0
  112. package/dist/react/site-key/SiteKeyTab.d.ts +100 -0
  113. package/dist/react/site-key/SiteKeyTab.js +127 -0
  114. package/dist/react/site-key/hooks/use-site-key-recovery.hooks.d.ts +77 -0
  115. package/dist/react/site-key/hooks/use-site-key-recovery.hooks.js +126 -0
  116. package/dist/react/site-key/hooks/use-site-key.hooks.d.ts +120 -0
  117. package/dist/react/site-key/hooks/use-site-key.hooks.js +95 -0
  118. package/dist/react/webhooks/IntegrationDeliveries.d.ts +41 -0
  119. package/dist/react/webhooks/IntegrationDeliveries.js +24 -0
  120. package/dist/react/webhooks/Integrations.d.ts +73 -0
  121. package/dist/react/webhooks/Integrations.js +97 -0
  122. package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.d.ts +59 -0
  123. package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.js +11 -0
  124. package/dist/react/webhooks/hooks/use-integrations.hooks.d.ts +119 -0
  125. package/dist/react/webhooks/hooks/use-integrations.hooks.js +129 -0
  126. package/dist/react/webhooks/rules.d.ts +118 -0
  127. package/dist/react/webhooks/rules.js +103 -0
  128. package/dist/saved-requests/execute.js +2 -3
  129. package/dist/saved-requests/types.d.ts +4 -1
  130. package/dist/secrets/index.d.ts +3 -0
  131. package/dist/secrets/index.js +3 -0
  132. package/dist/secrets/ports.d.ts +25 -0
  133. package/dist/secrets/ports.js +2 -0
  134. package/dist/secrets/types.d.ts +10 -0
  135. package/dist/secrets/types.js +2 -0
  136. package/dist/vendor-credentials/abort-guarded-repo.d.ts +14 -0
  137. package/dist/vendor-credentials/abort-guarded-repo.js +41 -0
  138. package/dist/vendor-credentials/project-scope.d.ts +43 -0
  139. package/dist/vendor-credentials/project-scope.js +32 -0
  140. package/dist/vendor-credentials/vault-adapter.d.ts +147 -0
  141. package/dist/vendor-credentials/vault-adapter.js +195 -0
  142. package/dist/web-screenshot/capture-files.d.ts +44 -0
  143. package/dist/web-screenshot/capture-files.js +62 -0
  144. package/dist/web-screenshot/capture-retention.d.ts +157 -0
  145. package/dist/web-screenshot/capture-retention.js +134 -0
  146. package/dist/web-screenshot/capture-root-file-lock.d.ts +20 -0
  147. package/dist/web-screenshot/capture-root-file-lock.js +15 -0
  148. package/dist/web-screenshot/desktop-page-capture.d.ts +37 -0
  149. package/dist/web-screenshot/desktop-page-capture.js +62 -0
  150. package/dist/web-screenshot/own-site-opener.d.ts +40 -0
  151. package/dist/web-screenshot/own-site-opener.js +27 -0
  152. package/dist/web-screenshot/screenshot-image.d.ts +11 -0
  153. package/dist/web-screenshot/screenshot-image.js +12 -0
  154. package/dist/web-screenshot/web-screenshot.d.ts +188 -0
  155. package/dist/web-screenshot/web-screenshot.js +329 -0
  156. package/dist/webhooks/delivery.d.ts +16 -0
  157. package/dist/webhooks/delivery.js +41 -1
  158. package/dist/webhooks/ports.d.ts +1 -29
  159. package/dist/webhooks/signing.keyring.d.ts +1 -1
  160. package/dist/webhooks/site/delivery.d.ts +60 -0
  161. package/dist/webhooks/site/delivery.js +45 -0
  162. package/dist/webhooks/site/http.memory.d.ts +51 -0
  163. package/dist/webhooks/site/http.memory.js +28 -0
  164. package/dist/webhooks/site/repo.memory.d.ts +136 -0
  165. package/dist/webhooks/site/repo.memory.js +215 -0
  166. package/dist/webhooks/site/seal-aad-invariant.d.ts +26 -0
  167. package/dist/webhooks/site/seal-aad-invariant.js +61 -0
  168. package/dist/webhooks/site/seal-aad-invariant.node.d.ts +42 -0
  169. package/dist/webhooks/site/seal-aad-invariant.node.js +52 -0
  170. package/dist/webhooks/site/signing.d.ts +28 -0
  171. package/dist/webhooks/site/signing.js +27 -0
  172. package/dist/webhooks/site/signing.keyring.d.ts +29 -0
  173. package/dist/webhooks/site/signing.keyring.js +30 -0
  174. package/dist/webhooks/site/subscriptions.d.ts +118 -0
  175. package/dist/webhooks/site/subscriptions.js +98 -0
  176. package/dist/webhooks/sql/index.d.ts +4 -0
  177. package/dist/webhooks/sql/index.js +2 -0
  178. package/dist/webhooks/sql/repo.rows.d.ts +47 -0
  179. package/dist/webhooks/sql/repo.rows.js +2 -0
  180. package/dist/webhooks/sql/webhook-repo.d.ts +152 -0
  181. package/dist/webhooks/sql/webhook-repo.js +308 -0
  182. package/dist/webhooks/subscriptions.d.ts +3 -1
  183. package/dist/webhooks/subscriptions.js +4 -1
  184. package/dist/webhooks/tools/tool-handlers.js +2 -1
  185. package/dist/webhooks/types.d.ts +6 -10
  186. package/package.json +518 -13
  187. package/dist/media-providers/dispatch/providers/grok.d.ts +0 -55
  188. package/dist/media-providers/dispatch/providers/grok.js +0 -116
@@ -0,0 +1,114 @@
1
+ /** Whether the provider's required extra fields are filled. @complexity O(f). */
2
+ function accessTokenRequiredFieldsFilled(fields, info, deps) {
3
+ return deps.requiredFieldsFilled({ fields: info.extraFields, values: fields.values });
4
+ }
5
+ /** Whether a token form has enough typed to save — a non-empty Name (new here; neither origin store's
6
+ * own form ever asked for one) PLUS whatever `info` says this provider cannot function without
7
+ * (`token`, always; a host descriptor's required fields). Does not check name uniqueness — that is {@link accessTokenNameTaken}'s job, surfaced
8
+ * as its own inline error rather than folded into the Save button's disabled state, so a collision
9
+ * reads as a specific, fixable reason rather than an unexplained disabled button.
10
+ * @complexity O(k) in this provider's own required-field count (at most one). */
11
+ export function accessTokenRowReadyToSave({ fields, info, deps }, _optional = {}) {
12
+ if (fields.name.trim() === "")
13
+ return false;
14
+ if (fields.token.trim() === "")
15
+ return false;
16
+ return accessTokenRequiredFieldsFilled(fields, info, deps);
17
+ }
18
+ /**
19
+ * The Replace-flow variant of {@link accessTokenRowReadyToSave} — an EXISTING row's Save button,
20
+ * which this page can enable in one more case neither `StaticSiteTab.tsx` nor `ProvidersTab.tsx`
21
+ * supports today: a rename with no new token typed. Both origin pages require a fresh token on every
22
+ * save regardless of connected state (`credentialFormReadyToSave`/
23
+ * `sourceControlCredentialRowReadyToSave` both unconditionally check `token.trim() !== ""`) — this
24
+ * page's own new Name field makes "I just want to rename this, not rotate it" a real, common action
25
+ * (the brief's own "give it whatever name you want" framing), so gating it behind a mandatory token
26
+ * retype would make the rename feature it introduces effectively unusable for that case.
27
+ *
28
+ * Three cases: nothing typed at all → not ready (there is no diff to send). A new name only (token
29
+ * blank) → ready, sent as a label-only `PUT` (no `connection` field, so the stored secret is
30
+ * untouched — same "omitting `connection` keeps the secret" contract `updatePublishCredential`'s own
31
+ * doc states). A new token (rename or not) → ready only once this provider's required extra fields
32
+ * are ALSO filled, same as create — a token replace still needs its extra fields/`username` alongside it
33
+ * because a fresh `connection` object is a full replacement, not a per-field patch.
34
+ * @complexity O(k) in this provider's own required-field count (at most one).
35
+ */
36
+ export function accessTokenReplaceReadyToSave({ fields, currentName, info, deps }, _options = {}) {
37
+ if (fields.name.trim() === "")
38
+ return false;
39
+ const nameChanged = fields.name.trim() !== currentName.trim();
40
+ const hasToken = fields.token.trim() !== "";
41
+ if (!hasToken)
42
+ return nameChanged;
43
+ return accessTokenRequiredFieldsFilled(fields, info, deps);
44
+ }
45
+ /**
46
+ * Builds the wire connection input for a create/update call — dispatches to
47
+ * `buildCredentialConnectionInput` (a host's descriptor fields, the typed token under its
48
+ * `tokenField`) / `buildSourceControlConnectionInput` by `fields.ref.kind` rather than re-deriving
49
+ * either provider's shape (this file's own header). A publish provider without a credential spec
50
+ * (only the bare fallback entry {@link accessTokenProviderInfo} makes) sends the token as `token`.
51
+ * @complexity O(f).
52
+ */
53
+ export function buildAccessTokenConnectionInput({ fields, info, deps }, _optional = {}) {
54
+ if (fields.ref.kind === "publish") {
55
+ const spec = info.publishCredential ?? { tokenField: "token", fields: [{ name: "token", label: "Access token", required: true }] };
56
+ const providerId = fields.ref.providerId;
57
+ return deps.buildCredentialConnectionInput({ providerId, spec, values: { ...fields.values, [spec.tokenField]: fields.token } });
58
+ }
59
+ return deps.buildSourceControlConnectionInput({ fields: { providerId: fields.ref.providerId, token: fields.token, values: fields.values }, declaredFields: info.extraFields });
60
+ }
61
+ /** The DOM/agent id suffix of one extra field's input. `accountId` keeps its old `account` suffix
62
+ * (pinned by agent tooling); every other field uses its own name, hyphenated. @complexity O(n). */
63
+ export function accessTokenExtraFieldIdSuffix({ fieldName, deps }, _options = {}) {
64
+ return fieldName === "accountId" ? "account" : deps.fieldNameHandleSegment({ asciiSlug: deps.asciiSlug, fieldName });
65
+ }
66
+ /** Builds an update patch's non-secret/secret halves independently — split out of the hook's own
67
+ * `replaceToken` purely so that function's own branch count (readiness guard, uniqueness guard,
68
+ * try/catch, kind dispatch) stays under this repo's complexity gate. `label` is included only when
69
+ * the operator actually changed the name (a same-value PUT is a no-op write neither store needs to
70
+ * see); `connection` is included only when a new token was typed — see
71
+ * {@link accessTokenReplaceReadyToSave}'s own doc for why either can be true alone.
72
+ * @complexity O(1). */
73
+ export function buildAccessTokenUpdatePatch({ fields, nameChanged, hasToken, info, deps }, { currentWorksFor = [] } = {}) {
74
+ return {
75
+ ...(fields.ref.kind === "publish" && deps.accessTokenWorksForChanged({ draft: fields.worksFor, saved: currentWorksFor }) ? { worksFor: fields.worksFor } : {}),
76
+ ...(nameChanged ? { label: fields.name.trim() } : {}),
77
+ ...(hasToken ? { connection: buildAccessTokenConnectionInput({ fields, info, deps }) } : {}),
78
+ };
79
+ }
80
+ /**
81
+ * Classifies a rejected create/update/delete call. Reads `e.code`, falling back to `e.message`, for
82
+ * the two known markers, same reasoning `classifyCredentialSubmitError` in
83
+ * `@jini-ai/admin/shell/lib/credential-submit-error` documents.
84
+ * @complexity O(1).
85
+ */
86
+ export function classifyAccessTokenSubmitError({ e, isApiError }, _options = {}) {
87
+ if (!isApiError(e))
88
+ return { kind: "generic" };
89
+ const marker = e.code ?? e.message;
90
+ if (marker === "DUPLICATE_LABEL")
91
+ return { kind: "duplicate-label" };
92
+ if (marker === "VALIDATION") {
93
+ const detail = typeof e.body?.detail === "string" ? e.body.detail : e.message;
94
+ return { kind: "validation", detail };
95
+ }
96
+ return { kind: "generic" };
97
+ }
98
+ /** The Save-readiness gate for a SAVED row's Replace form, picked by row kind — the same split
99
+ * `use-access-tokens.hooks.ts`'s `replaceToken` makes before writing: a custom row uses
100
+ * {@link customCredentialReplaceReadyToSave} (a username-only change is a real edit), every catalog
101
+ * row keeps {@link accessTokenReplaceReadyToSave}. `ExistingTokenFields` used to call the catalog
102
+ * gate for every row, so a custom row's username-only fix left Save disabled even though the
103
+ * controller would have sent it. Works-for-only edits also enable Save without a token.
104
+ * @complexity O(draft + saved) time/space for compatibility membership. */
105
+ export function accessTokenExistingRowReadyToSave({ fields, row, info, SOURCE_CONTROL, deps }, _options = {}) {
106
+ // Metadata edits use the same secret-preserving update path as a rename. A supplied token
107
+ // still requires the provider's complete connection fields.
108
+ if (row.kind !== SOURCE_CONTROL && fields.name.trim() && !fields.token.trim() && deps.accessTokenWorksForChanged({ draft: fields.worksFor, saved: row.worksFor }))
109
+ return true;
110
+ if (row.kind === "custom")
111
+ return deps.customCredentialReplaceReadyToSave({ fields, currentName: row.name, currentUsername: row.username });
112
+ return accessTokenReplaceReadyToSave({ fields, currentName: row.name, info, deps });
113
+ }
114
+ //# sourceMappingURL=access-token-forms.js.map
@@ -0,0 +1,17 @@
1
+ import type { CredentialTokenHint } from "@jini-ai/core/contracts/site/secrets-credential-token";
2
+ /** Only server-derived metadata describes a stored key. A legacy server may still send a mask. */
3
+ export declare function storedCredentialHint({ stored, formatHint, storedKeyIsForOtherEndpoint }: {
4
+ stored: {
5
+ isSet: boolean;
6
+ masked: string | null;
7
+ tokenHint?: CredentialTokenHint | null;
8
+ } | null;
9
+ formatHint: (required: {
10
+ hint: CredentialTokenHint | null | undefined;
11
+ locale: string;
12
+ }) => string;
13
+ storedKeyIsForOtherEndpoint?: boolean;
14
+ }, { locale }?: {
15
+ locale?: string;
16
+ }): string | undefined;
17
+ //# sourceMappingURL=credential-copy.d.ts.map
@@ -0,0 +1,7 @@
1
+ /** Only server-derived metadata describes a stored key. A legacy server may still send a mask. */
2
+ export function storedCredentialHint({ stored, formatHint, storedKeyIsForOtherEndpoint = false }, { locale = 'en' } = {}) {
3
+ if (storedKeyIsForOtherEndpoint || !stored?.isSet)
4
+ return undefined;
5
+ return formatHint({ hint: stored.tokenHint, locale }) || stored.masked || undefined;
6
+ }
7
+ //# sourceMappingURL=credential-copy.js.map
@@ -0,0 +1,115 @@
1
+ import { type Translate } from '@jini-ai/core/text';
2
+ import type { AdminCustomCredentialCategoryId as AccessTokenRowCategoryId } from "@jini-ai/core/contracts/site/api-security-api-types";
3
+ /** A stable id for one of the four Tier-2 credential stores — `AccessTokenRow.id`'s counterpart for
4
+ * the stores this page reads through a completely different set of endpoints (see
5
+ * `@jini-ai/admin/security/host/hooks/other-credentials-port.hooks`). This id names the ROW this page renders, not the table. */
6
+ export type OtherCredentialStoreId = "site-assistant" | "admin-byok" | "media-provider" | "external-mcp";
7
+ /**
8
+ * One Tier-2 credential store — single connection per scope, or per-provider/per-server, but never
9
+ * *named* the way Tier 1 is (no operator-typed label, so no Name field and no `[+ Add]` — see
10
+ * `Security.tsx`'s own header for why Create stays on each store's OWN screen). Read + Replace +
11
+ * Remove + a deep link is the 2026-08-16 owner ruling for every row this produces
12
+ * (`ACCESS-TOKENS-VISUAL-SPEC.md`'s "OWNER RULING" section) — `supportsReplace` narrows that for the
13
+ * one store where "replace" has no honest single-field meaning:
14
+ *
15
+ * - `external-mcp`: a multi-field server config (transport, command, args, allowed tools), not a
16
+ * single token — a real "Replace" would have to reproduce that whole form, which is exactly the
17
+ * second-entry-point risk the session-6 handoff warns against for a cross-cutting page. Remove
18
+ * (`deleteExternalMcpServer`) still applies; editing the rest stays on Settings → External MCP.
19
+ *
20
+ * The other three (`site-assistant`, `admin-byok`, `media-provider`) are all a
21
+ * single `apiKey` field end to end — `supportsReplace: true`, wired through the same
22
+ * retype-and-save shape Tier 1's own Replace already uses.
23
+ */
24
+ export interface OtherCredentialStoreInfo {
25
+ readonly id: OtherCredentialStoreId;
26
+ /** The store's own generic label — shown as a row's heading only when the store has nothing
27
+ * configured yet (a "— none —" placeholder needs SOME name to search on); a configured row is
28
+ * headed by its OWN item name instead (a media provider's catalog label, an MCP server's own
29
+ * label) — see `use-other-credentials.hooks.ts` for where that split happens. */
30
+ readonly label: string;
31
+ /** The category-filter bucket this store's rows land in — see {@link ACCESS_TOKEN_CATEGORIES}. */
32
+ readonly category: AccessTokenRowCategoryId;
33
+ /** Shown next to a row's name the same way Tier 1's `purposeLabel` is (`" · {purposeLabel}"`) — the
34
+ * human-readable form of {@link category}, e.g. "Media", "AI", "Ops". */
35
+ readonly purposeLabel: string;
36
+ readonly supportsReplace: boolean;
37
+ /** Deep-link text, e.g. "Manage on AI Assistant". */
38
+ readonly screenLabel: string;
39
+ /** In-app route for the deep link (`lib/router.ts`'s route-path shape, e.g. `/ai-assistant`) —
40
+ * always this store's OWN screen, since Create/the full field set lives there and nowhere else. */
41
+ readonly screenPath: string;
42
+ }
43
+ /** Looks up one store's registry entry, falling back to the first — same "the row list can never
44
+ * render something absent from its own table" guarantee {@link accessTokenProviderInfo} gives Tier 1.
45
+ * @complexity O(1) — the array has exactly four entries. */
46
+ export declare function otherCredentialStoreInfo({ id, stores }: {
47
+ id: OtherCredentialStoreId;
48
+ stores: readonly OtherCredentialStoreInfo[];
49
+ }, _optional?: Record<string, never>): OtherCredentialStoreInfo;
50
+ /** Whether a Tier-2 store (or, for a multi-item store, one of its own item names) matches an active
51
+ * search `query` — mirrors {@link accessTokenProviderMatchesQuery} exactly: the store's generic
52
+ * label, its purpose subtitle, or (when given) the specific configured item's own name.
53
+ * @complexity O(1). */
54
+ export declare function otherCredentialMatchesQuery({ store, itemName, query }: {
55
+ store: OtherCredentialStoreInfo;
56
+ itemName: string | undefined;
57
+ query: string;
58
+ }, _options?: {}): boolean;
59
+ /** A media provider's human catalog label (e.g. `"grok"` → `"xAI Grok Imagine"`) — same
60
+ * `MEDIA_PROVIDER_CATALOG` lookup `Media.tsx` itself uses, so a media-provider row on this page
61
+ * reads with the identical name an operator already sees on the Media → External Providers tab. Falls
62
+ * back to the raw provider id for one this workspace has a stored key under but the catalog no
63
+ * longer lists (a removed vendor) — a stale id is still a fact worth showing, not a reason to hide
64
+ * the row. @complexity O(n) in the catalog's own (small, fixed) size. */
65
+ export declare function mediaProviderLabel({ providerId, catalog }: {
66
+ providerId: string;
67
+ catalog: readonly MediaProviderCatalogEntry[];
68
+ }, _options?: {}): string;
69
+ /** One live-catalog card as far as a label lookup needs it. */
70
+ export interface MediaProviderCatalogEntry {
71
+ readonly id: string;
72
+ readonly label: string;
73
+ }
74
+ /** The cards of a `GET …/media/providers/catalog` body whose id and label are strings; anything else
75
+ * (or an unreadable body) yields `[]`, so rows fall back to raw ids. @complexity O(p). */
76
+ export declare function mediaProviderCatalogFrom({ body }: {
77
+ body: {
78
+ providers?: unknown;
79
+ } | null | undefined;
80
+ }, _options?: {}): readonly MediaProviderCatalogEntry[];
81
+ /** The masked-tail value fact for a configured single-`apiKey` row (`site-assistant`/`admin-byok`/
82
+ * `media-provider` — the three stores whose GET response carries a precomputed last-4, per the
83
+ * visual spec §10: "that's ALL they ever return"). `tail` is already the last 4 characters with no
84
+ * leading `••••` — those API shapes agree on the bare-tail contract, so this is the one place
85
+ * that prefix gets added. @complexity O(1). */
86
+ export declare function maskedTailFact({ tail }: {
87
+ tail: string;
88
+ }, _options?: {}): string;
89
+ /** The value fact for an `external-mcp` row — there is no single token to characterize (§10: "no
90
+ * per-field tail"), so this reports how many environment variable NAMES are set instead (`envNames`,
91
+ * already plaintext — see `AdminExternalMcpServer.envNames`'s own doc in `lib/api.ts`). Zero reads as
92
+ * a fact, not an error: an MCP server can be fully configured with no secrets at all (a local stdio
93
+ * tool needing no credentials). @complexity O(1). */
94
+ export declare function envNamesFact({ envNames }: {
95
+ envNames: readonly string[];
96
+ }, { t }?: {
97
+ t?: Translate;
98
+ }): string;
99
+ /** `AccessTokensSearch`'s own count line (the search box's `role="status"` caption) — whole-sentence
100
+ * templates keyed by the plural of `totalCount`, not string-fragment concatenation. Gluing
101
+ * translated words in English order (`"${count} ${tokenWord} ${translate("saved")}"`) can't read
102
+ * naturally in a language that puts the verb, the count, or the quoted query somewhere else in the
103
+ * sentence (ja/ko/zh/th all reorder this), so each plural form is one full translated sentence
104
+ * instead. The plural is chosen by `totalCount` alone (never `matchCount`) — see this file's own
105
+ * callers for why the visible noun stays anchored to the total, not the filtered subset. `query` is
106
+ * interpolated raw (not trimmed) to match the box's own display of what was typed.
107
+ * @complexity O(1). */
108
+ export declare function accessTokensCountText({ totalCount, matchCount, query }: {
109
+ totalCount: number;
110
+ matchCount: number;
111
+ query: string;
112
+ }, { t }?: {
113
+ t?: Translate;
114
+ }): string;
115
+ //# sourceMappingURL=other-credential-stores.d.ts.map
@@ -0,0 +1,76 @@
1
+ import {} from '@jini-ai/core/text';
2
+ /** Looks up one store's registry entry, falling back to the first — same "the row list can never
3
+ * render something absent from its own table" guarantee {@link accessTokenProviderInfo} gives Tier 1.
4
+ * @complexity O(1) — the array has exactly four entries. */
5
+ export function otherCredentialStoreInfo({ id, stores }, _optional = {}) {
6
+ return stores.find((store) => store.id === id) ?? stores[0];
7
+ }
8
+ /** Whether a Tier-2 store (or, for a multi-item store, one of its own item names) matches an active
9
+ * search `query` — mirrors {@link accessTokenProviderMatchesQuery} exactly: the store's generic
10
+ * label, its purpose subtitle, or (when given) the specific configured item's own name.
11
+ * @complexity O(1). */
12
+ export function otherCredentialMatchesQuery({ store, itemName, query }, _options = {}) {
13
+ const q = query.trim().toLowerCase();
14
+ if (q === "")
15
+ return true;
16
+ if (store.label.toLowerCase().includes(q) || store.purposeLabel.toLowerCase().includes(q))
17
+ return true;
18
+ return itemName !== undefined && itemName.toLowerCase().includes(q);
19
+ }
20
+ /** A media provider's human catalog label (e.g. `"grok"` → `"xAI Grok Imagine"`) — same
21
+ * `MEDIA_PROVIDER_CATALOG` lookup `Media.tsx` itself uses, so a media-provider row on this page
22
+ * reads with the identical name an operator already sees on the Media → External Providers tab. Falls
23
+ * back to the raw provider id for one this workspace has a stored key under but the catalog no
24
+ * longer lists (a removed vendor) — a stale id is still a fact worth showing, not a reason to hide
25
+ * the row. @complexity O(n) in the catalog's own (small, fixed) size. */
26
+ export function mediaProviderLabel({ providerId, catalog }, _options = {}) {
27
+ // The LIVE catalog, not the static one: providers such as grok are contributed at runtime by plugins.
28
+ return catalog.find((provider) => provider.id === providerId)?.label ?? providerId;
29
+ }
30
+ /** The cards of a `GET …/media/providers/catalog` body whose id and label are strings; anything else
31
+ * (or an unreadable body) yields `[]`, so rows fall back to raw ids. @complexity O(p). */
32
+ export function mediaProviderCatalogFrom({ body }, _options = {}) {
33
+ const providers = body?.providers;
34
+ if (!Array.isArray(providers))
35
+ return [];
36
+ return providers.filter((card) => typeof card?.id === "string" && typeof card?.label === "string");
37
+ }
38
+ /** The masked-tail value fact for a configured single-`apiKey` row (`site-assistant`/`admin-byok`/
39
+ * `media-provider` — the three stores whose GET response carries a precomputed last-4, per the
40
+ * visual spec §10: "that's ALL they ever return"). `tail` is already the last 4 characters with no
41
+ * leading `••••` — those API shapes agree on the bare-tail contract, so this is the one place
42
+ * that prefix gets added. @complexity O(1). */
43
+ export function maskedTailFact({ tail }, _options = {}) {
44
+ return `••••${tail}`;
45
+ }
46
+ /** The value fact for an `external-mcp` row — there is no single token to characterize (§10: "no
47
+ * per-field tail"), so this reports how many environment variable NAMES are set instead (`envNames`,
48
+ * already plaintext — see `AdminExternalMcpServer.envNames`'s own doc in `lib/api.ts`). Zero reads as
49
+ * a fact, not an error: an MCP server can be fully configured with no secrets at all (a local stdio
50
+ * tool needing no credentials). @complexity O(1). */
51
+ export function envNamesFact({ envNames }, { t = (key) => key } = {}) {
52
+ if (envNames.length === 0)
53
+ return t("No environment variables set");
54
+ if (envNames.length === 1)
55
+ return t("1 environment variable set");
56
+ return t("{count} environment variables set").replace("{count}", String(envNames.length));
57
+ }
58
+ /** `AccessTokensSearch`'s own count line (the search box's `role="status"` caption) — whole-sentence
59
+ * templates keyed by the plural of `totalCount`, not string-fragment concatenation. Gluing
60
+ * translated words in English order (`"${count} ${tokenWord} ${translate("saved")}"`) can't read
61
+ * naturally in a language that puts the verb, the count, or the quoted query somewhere else in the
62
+ * sentence (ja/ko/zh/th all reorder this), so each plural form is one full translated sentence
63
+ * instead. The plural is chosen by `totalCount` alone (never `matchCount`) — see this file's own
64
+ * callers for why the visible noun stays anchored to the total, not the filtered subset. `query` is
65
+ * interpolated raw (not trimmed) to match the box's own display of what was typed.
66
+ * @complexity O(1). */
67
+ export function accessTokensCountText({ totalCount, matchCount, query }, { t = (key) => key } = {}) {
68
+ if (query.trim() === "") {
69
+ return t(totalCount === 1 ? "{count} token saved" : "{count} tokens saved").replace("{count}", String(totalCount));
70
+ }
71
+ return t(totalCount === 1 ? "{matched} of {count} token matching “{query}”" : "{matched} of {count} tokens matching “{query}”")
72
+ .replace("{matched}", String(matchCount))
73
+ .replace("{count}", String(totalCount))
74
+ .replace("{query}", () => query);
75
+ }
76
+ //# sourceMappingURL=other-credential-stores.js.map
@@ -0,0 +1,16 @@
1
+ import { type SiteKeyRecoveryController } from "./hooks/use-site-key-recovery.hooks.js";
2
+ import type { SiteKeyTabProps } from "./SiteKeyTab.js";
3
+ /**
4
+ * @file The Site key tab's recovery card for a locked site: "Paste your old site key" and "Start
5
+ * fresh" (one typed confirmation). Render only — state, copy and requests live in
6
+ * `hooks/use-site-key-recovery.hooks.ts`.
7
+ *
8
+ * The token field is a password field marked agent-private, so the assistant can never read a
9
+ * pasted key. The final Start fresh button has no agent handle: it removes saved credentials, so a
10
+ * person confirms it.
11
+ */
12
+ export declare function SiteKeyRecoveryCard({ recovery, kit }: {
13
+ recovery: SiteKeyRecoveryController;
14
+ kit: SiteKeyTabProps["kit"];
15
+ }): import("react").JSX.Element;
16
+ //# sourceMappingURL=SiteKeyRecoveryCard.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AGENT_PRIVATE_ATTRIBUTE, agentHandle } from "@jini-ai/core/agent-handles";
3
+ import { START_FRESH_CONFIRMATION } from "./hooks/use-site-key-recovery.hooks.js";
4
+ /**
5
+ * @file The Site key tab's recovery card for a locked site: "Paste your old site key" and "Start
6
+ * fresh" (one typed confirmation). Render only — state, copy and requests live in
7
+ * `hooks/use-site-key-recovery.hooks.ts`.
8
+ *
9
+ * The token field is a password field marked agent-private, so the assistant can never read a
10
+ * pasted key. The final Start fresh button has no agent handle: it removes saved credentials, so a
11
+ * person confirms it.
12
+ */
13
+ export function SiteKeyRecoveryCard({ recovery, kit }) {
14
+ const translate = recovery.t;
15
+ return (_jsxs("section", { className: "card site-key-recovery-card", ...agentHandle({ handle: "security-site-key-recovery" }, { role: "region", label: "Unlock saved credentials locked with a different site key" }), children: [_jsx("h3", { className: "site-key-status-heading", children: translate("Your saved credentials are locked") }), recovery.resultMessage ? (_jsx("p", { className: "notice", role: "status", children: recovery.resultMessage })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "site-key-status-note", children: translate("They were locked with a site key that isn't on this computer.") }), _jsx(SiteKeyUnlockForm, { recovery: recovery, kit: kit }), _jsx(SiteKeyStartFresh, { recovery: recovery })] }))] }));
16
+ }
17
+ function SiteKeyUnlockForm({ recovery, kit: { SecretInput } }) {
18
+ const translate = recovery.t;
19
+ return (_jsxs("form", { className: "site-key-recovery-unlock", onSubmit: (event) => {
20
+ event.preventDefault();
21
+ void recovery.unlock();
22
+ }, children: [_jsx("label", { htmlFor: "site-key-recovery-key", children: translate("Paste your old site key") }), _jsxs("div", { className: "site-key-recovery-row", children: [_jsx(SecretInput, { label: translate("Paste your old site key"), id: "site-key-recovery-key",
23
+ // Chrome ignores "off" on a password field and offers a saved login password here; this is
24
+ // a pasted secret, never a sign-in, so it uses "new-password" like every other secret field.
25
+ autoComplete: "new-password", spellCheck: false, placeholder: translate("64 characters, 0-9 and a-f"), value: recovery.siteKey, onChange: (event) => recovery.setSiteKey(event.target.value), [AGENT_PRIVATE_ATTRIBUTE]: "" }), _jsx("button", { type: "submit", className: "btn-primary", disabled: recovery.unlocking || recovery.siteKey.trim() === "", children: recovery.unlocking ? translate("Unlocking…") : translate("Unlock") })] }), recovery.unlockError ? _jsx("p", { className: "notice error", role: "status", children: recovery.unlockError }) : null] }));
26
+ }
27
+ function SiteKeyStartFresh({ recovery }) {
28
+ const translate = recovery.t;
29
+ if (recovery.startFreshStep === "closed") {
30
+ return (_jsxs("div", { className: "site-key-recovery-start-fresh", children: [_jsx("p", { className: "jini-field-hint", children: translate("Lost it? A restore point is saved first, then only the credentials that can't be unlocked are removed.") }), _jsx("button", { type: "button", className: "btn-secondary", onClick: () => void recovery.openStartFresh(), ...agentHandle({ handle: "security-site-key-start-fresh-open" }, { role: "button", label: "Show what starting fresh would remove" }), children: translate("Start fresh…") })] }));
31
+ }
32
+ if (recovery.startFreshStep === "loading")
33
+ return _jsx("p", { className: "site-key-loading", children: translate("Checking what would change…") });
34
+ return (_jsxs("div", { className: "site-key-recovery-start-fresh site-key-recovery-confirm", children: [recovery.preview ? _jsx("p", { children: recovery.preview.detail }) : null, _jsx("label", { htmlFor: "site-key-recovery-confirm", children: translate("Type START FRESH to confirm") }), _jsxs("div", { className: "site-key-recovery-row", children: [_jsx("input", { id: "site-key-recovery-confirm", type: "text", autoComplete: "off", spellCheck: false, placeholder: START_FRESH_CONFIRMATION, value: recovery.confirmText, onChange: (event) => recovery.setConfirmText(event.target.value) }), _jsx("button", { type: "button", className: "btn-danger", disabled: !recovery.canConfirmStartFresh, onClick: () => void recovery.startFresh(), children: recovery.startingFresh ? translate("Starting fresh…") : translate("Start fresh") }), _jsx("button", { type: "button", className: "btn-ghost", onClick: recovery.cancelStartFresh, ...agentHandle({ handle: "security-site-key-start-fresh-cancel" }, { role: "button", label: "Cancel starting fresh" }), children: translate("Cancel") })] }), recovery.startFreshError ? _jsx("p", { className: "notice error", role: "status", children: recovery.startFreshError }) : null] }));
35
+ }
36
+ //# sourceMappingURL=SiteKeyRecoveryCard.js.map
@@ -0,0 +1,100 @@
1
+ import type { ComponentType, InputHTMLAttributes } from "react";
2
+ import type { AdminSiteKeyStatus } from "@jini-ai/core/contracts/site/site-key";
3
+ import type { Translate } from "@jini-ai/core/text";
4
+ import type { SiteKeyController } from "./hooks/use-site-key.hooks.js";
5
+ import { type SiteKeyRecoveryController } from "./hooks/use-site-key-recovery.hooks.js";
6
+ type Empty = Record<string, never>;
7
+ /**
8
+ * @file The Secrets page's Site key tab — view/reveal/generate the file half of
9
+ * the host site-key environment variable's resolution (`features/webhooks/keyring.env.ts`, server-side).
10
+ *
11
+ * ## What this tab covers, as of the 2026-09-09 durability fix
12
+ *
13
+ * A generated key file now genuinely protects production too: it lives on the durable data volume
14
+ * (not the container's ephemeral rootfs), the production boot gate accepts it, and the keyring
15
+ * that seals every real stored credential (BYOK, publish/source-control/custom creds,
16
+ * media-provider secrets) can now read one. {@link SiteKeyScopeNotice} still discloses the one
17
+ * remaining gap: webhook signing / newsletter tokens still require the env var in production —
18
+ * that keyring's own construction is deliberately unchanged this pass (a committed regression
19
+ * test pins it). See `server/inbound/admin-http/routes/system/site-key.ts`'s header for the
20
+ * full account, including the accepted tradeoff (a key file now lives beside the database it
21
+ * protects — a volume backup carries both).
22
+ *
23
+ * ## No rotate/replace
24
+ *
25
+ * `POST .../generate` only ever creates. Replacing an existing key would orphan every secret
26
+ * already sealed under the old one, and a confirmation strong enough for that (not a generic "are
27
+ * you sure") is a separate, NOT-built feature — reported as out of scope rather than half-built.
28
+ * Once a key is active (`status.active`), {@link SiteKeyGenerateAction} shows no control that
29
+ * could be mistaken for one.
30
+ *
31
+ * ## Reveal — one mechanism, available any time a key is active
32
+ *
33
+ * An earlier brief had generate show its new value once, at creation, fingerprint-only after
34
+ * that. The owner superseded it: "i want that token to be visible to admins or else when it
35
+ * breaks they have no idea whats going on." {@link SiteKeyRevealAction} is the ONE place this
36
+ * tab ever renders a key VALUE — never on page load, only behind its own explicit click, and
37
+ * usable at any time afterward (not just right after a generate), for exactly the diagnostic
38
+ * reason the owner gave: confirming the value here matches what's set in the host's secrets, or
39
+ * figuring out why credentials stopped decrypting. No audit trail on reveal — this codebase has
40
+ * no general-purpose sensitive-read audit mechanism to hook into (checked, not built here).
41
+ */
42
+ export interface SiteKeyTabProps {
43
+ /** DI seam for tests — same convention as every other wired-hook prop in this app. */
44
+ useSiteKeyHook: () => SiteKeyController;
45
+ /** DI seam for the locked site's recovery card. */
46
+ useSiteKeyRecoveryHook: (required: {
47
+ onRecovered: (() => Promise<void> | void) | undefined;
48
+ }, options?: Empty) => SiteKeyRecoveryController;
49
+ useRevealedKeyCopyHook: (required: {
50
+ hex: string;
51
+ clipboard: {
52
+ writeText: (text: string) => Promise<void>;
53
+ };
54
+ scheduler: {
55
+ setTimeout: (callback: () => void, ms: number) => unknown;
56
+ clearTimeout: (handle: unknown) => void;
57
+ };
58
+ }, options?: Empty) => {
59
+ copied: boolean;
60
+ copy: () => Promise<void>;
61
+ };
62
+ useAdminLocaleHook: () => string;
63
+ kit: {
64
+ SecretInput: ComponentType<Pick<InputHTMLAttributes<HTMLInputElement>, "id" | "autoComplete" | "spellCheck" | "placeholder" | "value" | "onChange"> & {
65
+ label: string;
66
+ "data-agent-private"?: string;
67
+ }>;
68
+ };
69
+ copy: {
70
+ siteKeyEnvVarName: string;
71
+ scope: string;
72
+ invalidEnv: string;
73
+ invalidFileSuffix: string;
74
+ siteKeyStatusBadgeLabel: (required: {
75
+ status: Pick<AdminSiteKeyStatus, "active" | "source" | "envVarName">;
76
+ t: Translate;
77
+ fallbackEnvVarName: string;
78
+ }, options?: Empty) => string;
79
+ siteKeyGenerateErrorMessage: (required: {
80
+ locale: string;
81
+ error: string;
82
+ }, options?: Empty) => string;
83
+ };
84
+ }
85
+ export declare function SiteKeyTab({ useSiteKeyHook, useSiteKeyRecoveryHook: useRecoveryHook, ...props }: SiteKeyTabProps): import("react").JSX.Element;
86
+ /** The Generate button + its own error banner. Shown only for the genuinely decidable case — no
87
+ * key at all (`status.source === "none"`) — never once a key is active, and never for an
88
+ * existing-but-invalid file or env var either (sol packet-3 finding 3-1, 2026-09-16): the server
89
+ * route only ever CREATES a key file, so offering Generate against a file that already exists
90
+ * (valid or not) is a guaranteed 409 with no path to success. A confirmed replace/rotate flow for
91
+ * that state is a separate, deliberately NOT-built feature (this file's own header). Works in
92
+ * every runtime mode now (2026-09-09 durability fix) — no longer disabled in production.
93
+ * @complexity O(1). */
94
+ export declare function SiteKeyGenerateAction({ controller, useAdminLocaleHook, copy }: {
95
+ controller: SiteKeyController;
96
+ } & Pick<SiteKeyTabProps, "useAdminLocaleHook"> & {
97
+ copy: Pick<SiteKeyTabProps["copy"], "siteKeyGenerateErrorMessage">;
98
+ }): import("react").JSX.Element | null;
99
+ export {};
100
+ //# sourceMappingURL=SiteKeyTab.d.ts.map
@@ -0,0 +1,127 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AGENT_PRIVATE_ATTRIBUTE, agentHandle } from "@jini-ai/core/agent-handles";
3
+ import { isSiteKeyLocked, siteKeyLockedNote } from "./hooks/use-site-key-recovery.hooks.js";
4
+ import { SiteKeyRecoveryCard } from "./SiteKeyRecoveryCard.js";
5
+ export function SiteKeyTab({ useSiteKeyHook, useSiteKeyRecoveryHook: useRecoveryHook, ...props }) {
6
+ const controller = useSiteKeyHook();
7
+ const recovery = useRecoveryHook({ onRecovered: controller.refresh });
8
+ return (_jsx("div", { className: "site-key-tab", ...agentHandle({ handle: "security-site-key" }, {
9
+ role: "region",
10
+ label: controller.t("View and reveal the site key"),
11
+ }), children: _jsx(SiteKeyBody, { controller: controller, recovery: recovery, ...props }) }));
12
+ }
13
+ /** Loading/error/loaded split — pulled out purely for the complexity gate, same reasoning
14
+ * `AccessTokensBody` documents in `AccessTokensTab.tsx`. */
15
+ function SiteKeyBody({ controller, recovery, kit, copy, useRevealedKeyCopyHook }) {
16
+ const translate = controller.t;
17
+ if (controller.loadError) {
18
+ return (_jsx("p", { className: "notice error", role: "status", ...agentHandle({ handle: "security-site-key-load-error" }, { role: "status", label: "Shows the error when the site key's status could not be loaded" }), children: controller.loadError }));
19
+ }
20
+ if (controller.status === undefined) {
21
+ return _jsx("p", { className: "site-key-loading", children: translate("Loading…") });
22
+ }
23
+ return (_jsxs(_Fragment, { children: [_jsx(SiteKeyScopeNotice, { runtimeMode: controller.status.runtimeMode, t: translate, copy: copy }), isSiteKeyLocked({ status: controller.status, generateError: controller.generateError }) || recovery.resultMessage ? _jsx(SiteKeyRecoveryCard, { recovery: recovery, kit: kit }) : null, _jsx(SiteKeyStatusCard, { controller: controller, status: controller.status, copy: copy, useRevealedKeyCopyHook: useRevealedKeyCopyHook })] }));
24
+ }
25
+ /** The always-visible "what this covers" disclosure — see this file's header. Rendered
26
+ * unconditionally, not just on failure: the fact it states is true whether or not anything has
27
+ * gone wrong, and the owner's own "self-contained" framing is exactly what this exists to make
28
+ * precise before anyone clicks anything.
29
+ *
30
+ * Rewritten 2026-09-09 per the owner's live review ("the site key content needs to be simpler
31
+ * ... users are not gonna know what this even is"): leads with one plain sentence any operator
32
+ * can act on, keeps the production-only storage tradeoff visible (it changes what someone should
33
+ * do, not just background trivia), and demotes the webhook/newsletter exception to a de-emphasized
34
+ * note — same `.jini-field-hint` convention `AgentPlugins.tsx`'s section footnotes use — since it's
35
+ * a real but secondary caveat, not something a first-time reader needs to parse up front. */
36
+ function SiteKeyScopeNotice({ runtimeMode, t: translate, copy }) {
37
+ return (_jsxs("div", { className: "notice warning site-key-scope-notice", ...agentHandle({ handle: "security-site-key-scope-notice" }, { role: "status", label: "What this site key does and does not cover" }), children: [_jsx("p", { children: translate(copy.scope) }), runtimeMode === "production" ? (_jsx("p", { children: translate("On a live site, this key is stored right next to your database. Anyone who gets a full backup of your server would get both your data and the key that unlocks it.") })) : null, _jsx("p", { className: "jini-field-hint site-key-scope-detail", children: translate("One exception: webhook signing and newsletter unsubscribe links use a separate key on your live site.") })] }));
38
+ }
39
+ /** The status card — badge + fingerprint + source-specific note + Reveal + Generate. Split out
40
+ * purely for the complexity gate. Only rendered once the status has loaded, so `status` is the
41
+ * controller's own, already-narrowed value. */
42
+ function SiteKeyStatusCard({ controller, status, copy, useRevealedKeyCopyHook }) {
43
+ const translate = controller.t;
44
+ return (_jsxs("section", { className: "card site-key-status-card", ...agentHandle({ handle: "security-site-key-status" }, { role: "region", label: "The active site key's source, fingerprint, and reveal control" }), children: [_jsx("h3", { className: "site-key-status-heading", children: translate("Site key") }), _jsxs("p", { className: "site-key-status-badge-row", children: [_jsx("span", { className: `status ${siteKeyStatusBadgeClass({ active: status.active }, { invalid: status.invalid })}`, children: copy.siteKeyStatusBadgeLabel({ status, t: translate, fallbackEnvVarName: copy.siteKeyEnvVarName }, {}) }), status.fingerprint ? (_jsxs("span", { className: "site-key-fingerprint-group", title: translate("A short ID for this key. It changes if the key changes."), children: [_jsx("span", { className: "site-key-fingerprint-label", children: translate("Fingerprint") }), _jsx("code", { className: "site-key-fingerprint", children: status.fingerprint })] })) : null] }), _jsx("p", { className: "site-key-status-note", children: siteKeyLockedNote({ status, generateError: controller.generateError, t: translate }) ?? siteKeyStatusNote(status, translate, copy) }), _jsx(SiteKeyRevealAction, { controller: controller, useRevealedKeyCopyHook: useRevealedKeyCopyHook })] }));
45
+ }
46
+ function siteKeyStatusBadgeClass({ active }, { invalid = false } = {}) {
47
+ if (invalid)
48
+ return "status-warning";
49
+ return active ? "status-ok" : "status-neutral";
50
+ }
51
+ /** The source-specific explanatory line under the badge — one sentence per case, no `{path}`
52
+ * template needed (the path is rendered as its own `<code>`, not interpolated into translated
53
+ * prose). Reworded 2026-09-09 alongside {@link SiteKeyScopeNotice} so the badge's
54
+ * "environment variable" vs. "key file" distinction is explained in plain terms here rather than
55
+ * assumed — the badge itself stays terse, this line carries the plain-language context. The
56
+ * host site-key environment variable name stays in the invalid-env case since fixing it requires
57
+ * that exact name. The `"none"` case was reworded again for the site-key plan (2026-09-24) item 3:
58
+ * it used to promise that clicking Generate would save a key to `status.keyFilePath` — stale ever
59
+ * since Generate was hidden by default (§A.6) in favor of `ensureSiteKeyForBoot` minting one
60
+ * automatically at boot, and doubly so once no fixed path is even guaranteed to be the one that
61
+ * ends up used (per-site keys, §A.1). @complexity O(1). */
62
+ function siteKeyStatusNote(status, translate, copy) {
63
+ if (status.invalid) {
64
+ return status.source === "env" ? (_jsx(_Fragment, { children: translate(copy.invalidEnv) })) : (_jsxs(_Fragment, { children: [translate("The key file at"), " ", _jsx("code", { children: status.keyFilePath }), " ", translate(copy.invalidFileSuffix)] }));
65
+ }
66
+ if (status.source === "env") {
67
+ return _jsx(_Fragment, { children: translate("This key was set up directly on the server rather than as a file, and it's already active — there's nothing to do here. Changing it means updating it on the server and restarting.") });
68
+ }
69
+ if (status.source === "file") {
70
+ return (_jsxs(_Fragment, { children: [translate("Stored in a file on this server, at"), " ", _jsx("code", { children: status.keyFilePath })] }));
71
+ }
72
+ return _jsx(_Fragment, { children: translate("A key is created automatically when this site starts.") });
73
+ }
74
+ /** Reveal — never shown on page load; the button is present whenever a key is active, and clicking
75
+ * it fetches (and displays, with a copy control) the raw value. Human-only: Reveal carries no agent
76
+ * handle, so the assistant's page driver cannot click it. {@link SiteKeyRevealedValue}'s
77
+ * own Hide button toggles it back off, client-side only (no server call). @complexity O(1). */
78
+ function SiteKeyRevealAction({ controller, useRevealedKeyCopyHook }) {
79
+ const translate = controller.t;
80
+ const status = controller.status;
81
+ if (!status?.active)
82
+ return null;
83
+ if (controller.revealedHex) {
84
+ return _jsx(SiteKeyRevealedValue, { hex: controller.revealedHex, onHide: controller.hideRevealed, t: translate, useRevealedKeyCopyHook: useRevealedKeyCopyHook });
85
+ }
86
+ return (_jsxs("div", { className: "site-key-reveal-action", [AGENT_PRIVATE_ATTRIBUTE]: "", children: [_jsx("button", { type: "button", className: "btn-secondary", disabled: controller.revealing, onClick: () => void controller.reveal(), children: controller.revealing ? translate("Revealing…") : translate("Reveal") }), controller.revealError ? (_jsx("p", { className: "notice error", role: "status", ...agentHandle({ handle: "security-site-key-reveal-error" }, { role: "status", label: "Shows the error when revealing the site key failed" }), children: controller.revealError })) : null] }));
87
+ }
88
+ /** The browser clipboard and timers bound for `useRevealedKeyCopy`, which only sees these ports. */
89
+ const browserClipboard = { writeText: (text) => navigator.clipboard.writeText(text) };
90
+ const browserScheduler = {
91
+ setTimeout: (callback, ms) => setTimeout(callback, ms),
92
+ clearTimeout: (handle) => clearTimeout(handle),
93
+ };
94
+ /** The revealed value itself, plus Copy/Hide — the ONLY place in this tab that ever renders a key
95
+ * VALUE rather than a fingerprint. The value is `data-agent-private`, so no published ancestor's
96
+ * text carries it to the agent, and neither it nor Copy has a handle. @complexity O(1). */
97
+ function SiteKeyRevealedValue({ hex, onHide, t: translate, useRevealedKeyCopyHook }) {
98
+ const { copied, copy } = useRevealedKeyCopyHook({ hex, clipboard: browserClipboard, scheduler: browserScheduler });
99
+ return (_jsxs("div", { className: "site-key-revealed-value", [AGENT_PRIVATE_ATTRIBUTE]: "", children: [_jsx("code", { [AGENT_PRIVATE_ATTRIBUTE]: "", children: hex }), _jsxs("div", { className: "site-key-revealed-actions", children: [_jsx("button", { type: "button", className: "btn-secondary", onClick: () => void copy(), children: copied ? translate("Copied!") : translate("Copy") }), _jsx("button", { type: "button", className: "btn-ghost", onClick: onHide, children: translate("Hide") })] })] }));
100
+ }
101
+ /** The Generate button + its own error banner. Shown only for the genuinely decidable case — no
102
+ * key at all (`status.source === "none"`) — never once a key is active, and never for an
103
+ * existing-but-invalid file or env var either (sol packet-3 finding 3-1, 2026-09-16): the server
104
+ * route only ever CREATES a key file, so offering Generate against a file that already exists
105
+ * (valid or not) is a guaranteed 409 with no path to success. A confirmed replace/rotate flow for
106
+ * that state is a separate, deliberately NOT-built feature (this file's own header). Works in
107
+ * every runtime mode now (2026-09-09 durability fix) — no longer disabled in production.
108
+ * @complexity O(1). */
109
+ export function SiteKeyGenerateAction({ controller, useAdminLocaleHook, copy }) {
110
+ const translate = controller.t;
111
+ const status = controller.status;
112
+ if (!status || status.source !== "none")
113
+ return null;
114
+ return (_jsxs("div", { className: "site-key-generate-action", children: [_jsx("button", { type: "button", className: "btn-primary", disabled: controller.generating, onClick: () => void controller.generate(), ...agentHandle({ handle: "security-site-key-generate" }, { role: "button", label: "Generate a site key file for this install" }), children: controller.generating ? translate("Generating…") : translate("Generate a key") }), controller.generateError ? _jsx(SiteKeyGenerateErrorNote, { failure: controller.generateError, t: translate, useAdminLocaleHook: useAdminLocaleHook, siteKeyGenerateErrorMessage: copy.siteKeyGenerateErrorMessage }) : null] }));
115
+ }
116
+ function siteKeyGenerateFailureText({ failure, translate, locale, siteKeyGenerateErrorMessage }, _optional = {}) {
117
+ if (failure.kind === "already-exists") {
118
+ return translate("A key file already exists. This tab only creates a new key — it never overwrites one.");
119
+ }
120
+ return failure.kind === "generic" ? siteKeyGenerateErrorMessage({ locale, error: failure.detail }) : failure.detail;
121
+ }
122
+ function SiteKeyGenerateErrorNote({ failure, t: translate, useAdminLocaleHook, siteKeyGenerateErrorMessage }) {
123
+ const locale = useAdminLocaleHook();
124
+ const text = siteKeyGenerateFailureText({ failure, translate, locale, siteKeyGenerateErrorMessage });
125
+ return (_jsx("p", { className: "notice error", role: "status", ...agentHandle({ handle: "security-site-key-generate-error" }, { role: "status", label: "Shows the error when generating a site key file failed" }), children: text }));
126
+ }
127
+ //# sourceMappingURL=SiteKeyTab.js.map