@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.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -0
- package/dist/api-connections/bundled-client-namespace.d.ts +24 -0
- package/dist/api-connections/bundled-client-namespace.js +22 -0
- package/dist/api-connections/connect.d.ts +2 -10
- package/dist/api-connections/contribution.d.ts +71 -0
- package/dist/api-connections/contribution.js +69 -0
- package/dist/api-connections/form-delivery-connection.d.ts +68 -0
- package/dist/api-connections/form-delivery-connection.js +73 -0
- package/dist/api-connections/hosted-mcp/contracts.d.ts +4 -171
- package/dist/api-connections/hosted-mcp/index.d.ts +2 -0
- package/dist/api-connections/hosted-mcp/oauth-row-writes.d.ts +3 -1
- package/dist/api-connections/hosted-mcp/oauth-row-writes.js +6 -3
- package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +2 -1
- package/dist/api-connections/hosted-mcp/sign-in-configuration.js +1 -1
- package/dist/api-connections/hosted-mcp/sign-in-discovery.js +1 -1
- package/dist/api-connections/hosted-mcp/sign-in-flow.d.ts +9 -3
- package/dist/api-connections/hosted-mcp/sign-in-flow.js +6 -6
- package/dist/api-connections/hosted-mcp/sign-in-provider.d.ts +16 -4
- package/dist/api-connections/hosted-mcp/sign-in-provider.js +3 -3
- package/dist/api-connections/hosted-mcp/sign-in-status.d.ts +13 -2
- package/dist/api-connections/hosted-mcp/sign-in-status.js +17 -4
- package/dist/api-connections/hosted-mcp/sign-in.d.ts +1 -1
- package/dist/api-connections/hosted-mcp/sign-in.js +28 -30
- package/dist/api-connections/shared-api.d.ts +87 -0
- package/dist/api-connections/shared-api.js +135 -0
- package/dist/api-connections/shared-oauth-disconnect.d.ts +73 -0
- package/dist/api-connections/shared-oauth-disconnect.js +41 -0
- package/dist/api-connections/shared-owner.d.ts +107 -0
- package/dist/api-connections/shared-owner.js +79 -0
- package/dist/api-connections/vault-stores.d.ts +110 -0
- package/dist/api-connections/vault-stores.js +202 -0
- package/dist/credentialed-http/auth-schemes.d.ts +2 -9
- package/dist/credentialed-http/tools/index.d.ts +30 -0
- package/dist/credentialed-http/tools/index.js +19 -0
- package/dist/credentialed-http/tools/tool-registrations.js +0 -1
- package/dist/custom-credentials/agent-tools.d.ts +79 -0
- package/dist/custom-credentials/agent-tools.js +98 -0
- package/dist/custom-credentials/card-token.d.ts +15 -0
- package/dist/custom-credentials/card-token.js +35 -0
- package/dist/custom-credentials/credential-ports.d.ts +70 -0
- package/dist/custom-credentials/credential-ports.js +41 -0
- package/dist/custom-credentials/credential-recovery.d.ts +20 -0
- package/dist/custom-credentials/credential-recovery.js +22 -0
- package/dist/custom-credentials/credentialed-request.d.ts +83 -0
- package/dist/custom-credentials/credentialed-request.js +93 -0
- package/dist/custom-credentials/custom-credential-create-ui.d.ts +106 -0
- package/dist/custom-credentials/custom-credential-create-ui.js +136 -0
- package/dist/custom-credentials/custom-credential-set-token-ui.d.ts +84 -0
- package/dist/custom-credentials/custom-credential-set-token-ui.js +104 -0
- package/dist/custom-credentials/delete-request-confirmation-ui.d.ts +33 -0
- package/dist/custom-credentials/delete-request-confirmation-ui.js +35 -0
- package/dist/custom-credentials/provider-settings-card.d.ts +109 -0
- package/dist/custom-credentials/provider-settings-card.js +166 -0
- package/dist/custom-credentials/write-files-validation.d.ts +102 -0
- package/dist/custom-credentials/write-files-validation.js +202 -0
- package/dist/media-providers/catalog-projection.d.ts +29 -0
- package/dist/media-providers/catalog-projection.js +45 -0
- package/dist/media-providers/catalog.d.ts +6 -3
- package/dist/media-providers/catalog.js +4 -3
- package/dist/media-providers/configurable-catalog.d.ts +9 -0
- package/dist/media-providers/configurable-catalog.js +70 -0
- package/dist/media-providers/dispatch/builtin-vendors.js +0 -2
- package/dist/media-providers/dispatch/credentials.d.ts +4 -1
- package/dist/media-providers/dispatch/credentials.js +3 -2
- package/dist/media-providers/dispatch/engine.d.ts +1 -1
- package/dist/media-providers/dispatch/engine.js +17 -5
- package/dist/media-providers/dispatch/index.d.ts +3 -2
- package/dist/media-providers/dispatch/index.js +2 -2
- package/dist/media-providers/dispatch/media-provider-registry.d.ts +23 -4
- package/dist/media-providers/dispatch/media-provider-registry.js +26 -11
- package/dist/media-providers/dispatch/media-wire.d.ts +14 -0
- package/dist/media-providers/dispatch/media-wire.js +22 -0
- package/dist/media-providers/dispatch/node.d.ts +5 -0
- package/dist/media-providers/dispatch/node.js +5 -1
- package/dist/media-providers/dispatch/openai-compatible.d.ts +3 -1
- package/dist/media-providers/dispatch/openai-compatible.js +1 -1
- package/dist/media-providers/dispatch/operation-runtime.js +5 -4
- package/dist/media-providers/dispatch/outbound.d.ts +28 -3
- package/dist/media-providers/dispatch/outbound.js +10 -3
- package/dist/media-providers/dispatch/providers/custom-image.js +1 -1
- package/dist/media-providers/dispatch/providers/imagerouter.js +1 -1
- package/dist/media-providers/dispatch/providers/nanobanana.js +1 -1
- package/dist/media-providers/dispatch/providers/openrouter.js +1 -1
- package/dist/media-providers/dispatch/ssrf-guard.js +2 -2
- package/dist/media-providers/dispatch/types.d.ts +13 -4
- package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
- package/dist/media-providers/index.d.ts +2 -0
- package/dist/media-providers/providers.d.ts +9 -5
- package/dist/media-providers/providers.js +9 -12
- package/dist/media-providers/sqlite-task-store.d.ts +4 -4
- package/dist/media-providers/task-store.d.ts +1 -1
- package/dist/media-providers/task-store.js +1 -1
- package/dist/media-providers/types.d.ts +0 -36
- package/dist/media-providers/ui-defaults.js +0 -4
- package/dist/react/admin-credentials/AdminByokKeyPanel.d.ts +130 -0
- package/dist/react/admin-credentials/AdminByokKeyPanel.js +115 -0
- package/dist/react/admin-credentials/byok-footer-status.d.ts +37 -0
- package/dist/react/admin-credentials/byok-footer-status.js +25 -0
- package/dist/react/credentials/OtherCredentialsSection.d.ts +36 -0
- package/dist/react/credentials/OtherCredentialsSection.hooks.d.ts +55 -0
- package/dist/react/credentials/OtherCredentialsSection.hooks.js +26 -0
- package/dist/react/credentials/OtherCredentialsSection.js +120 -0
- package/dist/react/credentials/access-token-forms.d.ts +219 -0
- package/dist/react/credentials/access-token-forms.js +114 -0
- package/dist/react/credentials/credential-copy.d.ts +17 -0
- package/dist/react/credentials/credential-copy.js +7 -0
- package/dist/react/credentials/other-credential-stores.d.ts +115 -0
- package/dist/react/credentials/other-credential-stores.js +76 -0
- package/dist/react/site-key/SiteKeyRecoveryCard.d.ts +16 -0
- package/dist/react/site-key/SiteKeyRecoveryCard.js +36 -0
- package/dist/react/site-key/SiteKeyTab.d.ts +100 -0
- package/dist/react/site-key/SiteKeyTab.js +127 -0
- package/dist/react/site-key/hooks/use-site-key-recovery.hooks.d.ts +77 -0
- package/dist/react/site-key/hooks/use-site-key-recovery.hooks.js +126 -0
- package/dist/react/site-key/hooks/use-site-key.hooks.d.ts +120 -0
- package/dist/react/site-key/hooks/use-site-key.hooks.js +95 -0
- package/dist/react/webhooks/IntegrationDeliveries.d.ts +41 -0
- package/dist/react/webhooks/IntegrationDeliveries.js +24 -0
- package/dist/react/webhooks/Integrations.d.ts +73 -0
- package/dist/react/webhooks/Integrations.js +97 -0
- package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.d.ts +59 -0
- package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.js +11 -0
- package/dist/react/webhooks/hooks/use-integrations.hooks.d.ts +119 -0
- package/dist/react/webhooks/hooks/use-integrations.hooks.js +129 -0
- package/dist/react/webhooks/rules.d.ts +118 -0
- package/dist/react/webhooks/rules.js +103 -0
- package/dist/saved-requests/execute.js +2 -3
- package/dist/saved-requests/types.d.ts +4 -1
- package/dist/secrets/index.d.ts +3 -0
- package/dist/secrets/index.js +3 -0
- package/dist/secrets/ports.d.ts +25 -0
- package/dist/secrets/ports.js +2 -0
- package/dist/secrets/types.d.ts +10 -0
- package/dist/secrets/types.js +2 -0
- package/dist/vendor-credentials/abort-guarded-repo.d.ts +14 -0
- package/dist/vendor-credentials/abort-guarded-repo.js +41 -0
- package/dist/vendor-credentials/project-scope.d.ts +43 -0
- package/dist/vendor-credentials/project-scope.js +32 -0
- package/dist/vendor-credentials/vault-adapter.d.ts +147 -0
- package/dist/vendor-credentials/vault-adapter.js +195 -0
- package/dist/web-screenshot/capture-files.d.ts +44 -0
- package/dist/web-screenshot/capture-files.js +62 -0
- package/dist/web-screenshot/capture-retention.d.ts +157 -0
- package/dist/web-screenshot/capture-retention.js +134 -0
- package/dist/web-screenshot/capture-root-file-lock.d.ts +20 -0
- package/dist/web-screenshot/capture-root-file-lock.js +15 -0
- package/dist/web-screenshot/desktop-page-capture.d.ts +37 -0
- package/dist/web-screenshot/desktop-page-capture.js +62 -0
- package/dist/web-screenshot/own-site-opener.d.ts +40 -0
- package/dist/web-screenshot/own-site-opener.js +27 -0
- package/dist/web-screenshot/screenshot-image.d.ts +11 -0
- package/dist/web-screenshot/screenshot-image.js +12 -0
- package/dist/web-screenshot/web-screenshot.d.ts +188 -0
- package/dist/web-screenshot/web-screenshot.js +329 -0
- package/dist/webhooks/delivery.d.ts +16 -0
- package/dist/webhooks/delivery.js +41 -1
- package/dist/webhooks/ports.d.ts +1 -29
- package/dist/webhooks/signing.keyring.d.ts +1 -1
- package/dist/webhooks/site/delivery.d.ts +60 -0
- package/dist/webhooks/site/delivery.js +45 -0
- package/dist/webhooks/site/http.memory.d.ts +51 -0
- package/dist/webhooks/site/http.memory.js +28 -0
- package/dist/webhooks/site/repo.memory.d.ts +136 -0
- package/dist/webhooks/site/repo.memory.js +215 -0
- package/dist/webhooks/site/seal-aad-invariant.d.ts +26 -0
- package/dist/webhooks/site/seal-aad-invariant.js +61 -0
- package/dist/webhooks/site/seal-aad-invariant.node.d.ts +42 -0
- package/dist/webhooks/site/seal-aad-invariant.node.js +52 -0
- package/dist/webhooks/site/signing.d.ts +28 -0
- package/dist/webhooks/site/signing.js +27 -0
- package/dist/webhooks/site/signing.keyring.d.ts +29 -0
- package/dist/webhooks/site/signing.keyring.js +30 -0
- package/dist/webhooks/site/subscriptions.d.ts +118 -0
- package/dist/webhooks/site/subscriptions.js +98 -0
- package/dist/webhooks/sql/index.d.ts +4 -0
- package/dist/webhooks/sql/index.js +2 -0
- package/dist/webhooks/sql/repo.rows.d.ts +47 -0
- package/dist/webhooks/sql/repo.rows.js +2 -0
- package/dist/webhooks/sql/webhook-repo.d.ts +152 -0
- package/dist/webhooks/sql/webhook-repo.js +308 -0
- package/dist/webhooks/subscriptions.d.ts +3 -1
- package/dist/webhooks/subscriptions.js +4 -1
- package/dist/webhooks/tools/tool-handlers.js +2 -1
- package/dist/webhooks/types.d.ts +6 -10
- package/package.json +518 -13
- package/dist/media-providers/dispatch/providers/grok.d.ts +0 -55
- package/dist/media-providers/dispatch/providers/grok.js +0 -116
|
@@ -30,7 +30,7 @@ async function persistSelfConfiguration(deps, record, identity, options = {}) {
|
|
|
30
30
|
if (options.configurationOnly)
|
|
31
31
|
return build(record);
|
|
32
32
|
// Sign-in configuration is an editor-visible change: compared on version, retried once (M4).
|
|
33
|
-
return (await updateRowOnce({ repo: deps.repo, key: record, build })) ?? requireOAuthRecord(deps, record.serverId);
|
|
33
|
+
return (await updateRowOnce({ repo: deps.repo, key: record, build })) ?? requireOAuthRecord({ deps, serverId: record.serverId });
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Fills in whatever a connection is missing, persists it, and returns the row as it now stands.
|
|
@@ -112,7 +112,7 @@ export async function mintClientForConnection({ deps, record, discovered, input
|
|
|
112
112
|
}
|
|
113
113
|
return deps.ports.withCopy({ call: () => deps.ports.flow.registerOAuthClientDynamically({
|
|
114
114
|
...deps.httpPorts,
|
|
115
|
-
options: oauthClientOptions(deps.ports, record, input.redirectUri),
|
|
115
|
+
options: oauthClientOptions({ ports: deps.ports, record, redirectUri: input.redirectUri }),
|
|
116
116
|
registrationEndpoint,
|
|
117
117
|
scopes: input.scopes,
|
|
118
118
|
}, {
|
|
@@ -11,10 +11,15 @@ export declare const CLIENT_REJECTED_PROVIDER_CODES: readonly string[];
|
|
|
11
11
|
/** The binding key an authorization `state` is issued against. Workspace-scoped so a state minted in
|
|
12
12
|
* one workspace cannot be redeemed in another, and server-scoped so it cannot be redeemed against a
|
|
13
13
|
* different connection in the same workspace. */
|
|
14
|
-
export declare function ownerKeyOf(workspaceId
|
|
14
|
+
export declare function ownerKeyOf({ workspaceId, serverId }: {
|
|
15
|
+
workspaceId: UUID;
|
|
16
|
+
serverId: string;
|
|
17
|
+
}, _optional?: Record<string, never>): string;
|
|
15
18
|
/** EXTRACT-S5 H3 (moved under `exactOptionalPropertyTypes`): an absent audience is omitted instead of passed as
|
|
16
19
|
* `undefined`; the OAuth operations treat both the same (`input.resource === undefined`). No I/O. */
|
|
17
|
-
export declare function resourceOption(resource
|
|
20
|
+
export declare function resourceOption({ resource }: {
|
|
21
|
+
resource: string | undefined;
|
|
22
|
+
}, _optional?: Record<string, never>): {
|
|
18
23
|
resource?: string;
|
|
19
24
|
};
|
|
20
25
|
/** Device-code grant: start the device authorization, park it for polling, and hand the user code back. */
|
|
@@ -34,9 +39,10 @@ export declare function beginDeviceCodeConnect({ deps, record, provider, client,
|
|
|
34
39
|
* failure is the same `OAUTH_INVALID_STATE`, so a guessed or tampered state is not an oracle.
|
|
35
40
|
* @complexity O(state bytes), bounded by Jini; one site-key seal/open, no pending-store I/O.
|
|
36
41
|
*/
|
|
37
|
-
export declare function sealedRedirectState({ deps, serverId, browserBinding }: {
|
|
42
|
+
export declare function sealedRedirectState({ deps, serverId, browserBinding, config }: {
|
|
38
43
|
deps: SignInDeps;
|
|
39
44
|
serverId: string;
|
|
40
45
|
browserBinding?: string | undefined;
|
|
46
|
+
config: Pick<ExternalMcpServerRecord, "createdAt" | "version">;
|
|
41
47
|
}, _optional?: Record<string, never>): import("@jini-ai/oauth").SealedAuthorizationState;
|
|
42
48
|
//# sourceMappingURL=sign-in-flow.d.ts.map
|
|
@@ -8,19 +8,19 @@ export const CLIENT_REJECTED_PROVIDER_CODES = ["invalid_client", "unauthorized_c
|
|
|
8
8
|
/** The binding key an authorization `state` is issued against. Workspace-scoped so a state minted in
|
|
9
9
|
* one workspace cannot be redeemed in another, and server-scoped so it cannot be redeemed against a
|
|
10
10
|
* different connection in the same workspace. */
|
|
11
|
-
export function ownerKeyOf(workspaceId, serverId) {
|
|
11
|
+
export function ownerKeyOf({ workspaceId, serverId }, _optional = {}) {
|
|
12
12
|
return `${workspaceId}:${serverId}`;
|
|
13
13
|
}
|
|
14
14
|
/** EXTRACT-S5 H3 (moved under `exactOptionalPropertyTypes`): an absent audience is omitted instead of passed as
|
|
15
15
|
* `undefined`; the OAuth operations treat both the same (`input.resource === undefined`). No I/O. */
|
|
16
|
-
export function resourceOption(resource) {
|
|
16
|
+
export function resourceOption({ resource }, _optional = {}) {
|
|
17
17
|
return resource === undefined ? {} : { resource };
|
|
18
18
|
}
|
|
19
19
|
/** Device-code grant: start the device authorization, park it for polling, and hand the user code back. */
|
|
20
20
|
export async function beginDeviceCodeConnect({ deps, record, provider, client, scopes, resource }) {
|
|
21
|
-
const authorization = await deps.ports.withCopy({ call: () => deps.ports.flow.beginDeviceAuthorization({ ...deps.httpPorts, provider, clock: deps.clock, client }, { scopes, ...resourceOption(resource), timeoutMs: CONNECT_TIMEOUT_MS }) });
|
|
21
|
+
const authorization = await deps.ports.withCopy({ call: () => deps.ports.flow.beginDeviceAuthorization({ ...deps.httpPorts, provider, clock: deps.clock, client }, { scopes, ...resourceOption({ resource }), timeoutMs: CONNECT_TIMEOUT_MS }) });
|
|
22
22
|
await deps.devices.put(record.serverId, authorization);
|
|
23
|
-
await setOAuthStatus(deps, record.serverId, "pending");
|
|
23
|
+
await setOAuthStatus({ deps, serverId: record.serverId, status: "pending" });
|
|
24
24
|
const { userCode, verificationUri, verificationUriComplete, expiresAt, intervalSeconds } = authorization;
|
|
25
25
|
return { kind: "device_code", userCode, verificationUri, verificationUriComplete, expiresAt, intervalSeconds };
|
|
26
26
|
}
|
|
@@ -32,11 +32,11 @@ export async function beginDeviceCodeConnect({ deps, record, provider, client, s
|
|
|
32
32
|
* failure is the same `OAUTH_INVALID_STATE`, so a guessed or tampered state is not an oracle.
|
|
33
33
|
* @complexity O(state bytes), bounded by Jini; one site-key seal/open, no pending-store I/O.
|
|
34
34
|
*/
|
|
35
|
-
export function sealedRedirectState({ deps, serverId, browserBinding }, _optional = {}) {
|
|
35
|
+
export function sealedRedirectState({ deps, serverId, browserBinding, config }, _optional = {}) {
|
|
36
36
|
// The HTTP callback always supplies browser proof. Unbound pre-upgrade links cannot decrypt
|
|
37
37
|
// there; persisted grants use their existing vault AAD and remain usable across reconnects.
|
|
38
38
|
const parts = browserBinding === undefined ? [deps.workspaceId, serverId] : [deps.workspaceId, serverId, browserBinding];
|
|
39
|
-
const aad = deps.ports.aad.format({ kind: "oauth-redirect-state", version: "
|
|
39
|
+
const aad = deps.ports.aad.format({ kind: "oauth-redirect-state", version: "v2", parts: [JSON.stringify([...parts, config.createdAt, config.version])] });
|
|
40
40
|
return deps.ports.flow.createSealedAuthorizationState({ clock: deps.clock, workspaceId: deps.workspaceId, serverId, codec: {
|
|
41
41
|
async seal({ plaintext }, _options = {}) {
|
|
42
42
|
const sealed = await deps.sealer.seal({ plaintext, key: await deps.keyring.activeKey({}), aad });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OAuthAppOptions, OAuthClient, OAuthProviderDescriptor, OAuthProviderRegistry } from "@jini-ai/core/contracts/oauth";
|
|
2
2
|
import type { ExternalMcpServerRecord } from "@jini-ai/core/contracts/hosted-mcp";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HostedMcpSignInPorts } from "./contracts.js";
|
|
4
|
+
import type { ExternalMcpOAuthDeps as HostedMcpOAuthDeps } from "@jini-ai/core/contracts/site/api-connections-hosted-mcp";
|
|
4
5
|
import type { SharedExternalMcpOwner } from "./shared-sign-in.js";
|
|
5
6
|
/** {@link ExternalMcpOAuthDeps} as the service holds them: `providers` defaulted once at construction,
|
|
6
7
|
* so nothing downstream builds a second registry. */
|
|
@@ -14,10 +15,17 @@ export type ExternalMcpOAuthServiceDeps = SignInDeps & {
|
|
|
14
15
|
/** Stable registration identity; callback URLs come only from the host's trusted origin policy.
|
|
15
16
|
* Device-only clients deliberately register no redirect URI (RFC 7591).
|
|
16
17
|
*/
|
|
17
|
-
export declare function oauthClientOptions(ports
|
|
18
|
+
export declare function oauthClientOptions({ ports, record, redirectUri }: {
|
|
19
|
+
ports: HostedMcpSignInPorts;
|
|
20
|
+
record: ExternalMcpServerRecord;
|
|
21
|
+
redirectUri: string | undefined;
|
|
22
|
+
}, _optional?: Record<string, never>): OAuthAppOptions;
|
|
18
23
|
/** Loads an OAuth-authenticated row, or explains why it cannot be used.
|
|
19
24
|
* @throws {ExternalMcpValidationError} */
|
|
20
|
-
export declare function requireOAuthRecord(deps
|
|
25
|
+
export declare function requireOAuthRecord({ deps, serverId }: {
|
|
26
|
+
deps: SignInDeps;
|
|
27
|
+
serverId: string;
|
|
28
|
+
}, _optional?: Record<string, never>): Promise<ExternalMcpServerRecord>;
|
|
21
29
|
/** The refusal for a row that names no provider and no token endpoint. One builder for both places
|
|
22
30
|
* that reach it — provider resolution and self-configuration on a row with no URL to discover from —
|
|
23
31
|
* because from the operator's side it is the same problem with the same fix. */
|
|
@@ -76,7 +84,11 @@ export declare function resolveProviderDescriptor(deps: ExternalMcpOAuthServiceD
|
|
|
76
84
|
/** Builds the client identity for one row, unsealing the client secret only when there is one.
|
|
77
85
|
* @throws {OAuthError} When the row carries no client id — a state `saveExternalMcpServer` refuses
|
|
78
86
|
* to create, so reaching it means the row was written by something else. */
|
|
79
|
-
export declare function resolveClient(deps
|
|
87
|
+
export declare function resolveClient({ deps, record, provider }: {
|
|
88
|
+
deps: SignInDeps;
|
|
89
|
+
record: ExternalMcpServerRecord;
|
|
90
|
+
provider: OAuthProviderDescriptor;
|
|
91
|
+
}, _optional?: Record<string, never>): Promise<OAuthClient>;
|
|
80
92
|
/**
|
|
81
93
|
* Whether the row's client is one the host minted by dynamic registration, and so the host's to replace.
|
|
82
94
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/** Stable registration identity; callback URLs come only from the host's trusted origin policy.
|
|
2
2
|
* Device-only clients deliberately register no redirect URI (RFC 7591).
|
|
3
3
|
*/
|
|
4
|
-
export function oauthClientOptions(ports, record, redirectUri) {
|
|
4
|
+
export function oauthClientOptions({ ports, record, redirectUri }, _optional = {}) {
|
|
5
5
|
return { clientDisplayName: ports.registrationIdentity.clientName(record), softwareId: ports.registrationIdentity.softwareId,
|
|
6
6
|
redirectUris: redirectUri === undefined ? [] : [redirectUri] };
|
|
7
7
|
}
|
|
8
8
|
/** Loads an OAuth-authenticated row, or explains why it cannot be used.
|
|
9
9
|
* @throws {ExternalMcpValidationError} */
|
|
10
|
-
export async function requireOAuthRecord(deps, serverId) {
|
|
10
|
+
export async function requireOAuthRecord({ deps, serverId }, _optional = {}) {
|
|
11
11
|
const record = await deps.repo.findByServerId({ workspaceId: deps.workspaceId, serverId });
|
|
12
12
|
if (!record) {
|
|
13
13
|
throw deps.ports.errors.validation(`no external MCP server is configured as '${serverId}'`, "id");
|
|
@@ -93,7 +93,7 @@ export function resolveProviderDescriptor(deps, record) {
|
|
|
93
93
|
/** Builds the client identity for one row, unsealing the client secret only when there is one.
|
|
94
94
|
* @throws {OAuthError} When the row carries no client id — a state `saveExternalMcpServer` refuses
|
|
95
95
|
* to create, so reaching it means the row was written by something else. */
|
|
96
|
-
export async function resolveClient(deps, record, provider) {
|
|
96
|
+
export async function resolveClient({ deps, record, provider }, _optional = {}) {
|
|
97
97
|
if (record.oauthClientId === null) {
|
|
98
98
|
throw deps.ports.errors.oauth({ code: "OAUTH_INVALID_REQUEST", message: `external MCP server '${record.serverId}' has no OAuth client id`, operatorAction: deps.ports.copy.actions.noClientId, });
|
|
99
99
|
}
|
|
@@ -4,16 +4,27 @@ import { type SignInDeps } from "./sign-in-provider.js";
|
|
|
4
4
|
/** Writes a token set into the row: sealed blob (preserving the client secret) plus the PLAINTEXT
|
|
5
5
|
* status and expiry beside it. One place, so the plaintext metadata cannot drift from the blob.
|
|
6
6
|
* @complexity O(1) — one unseal, one seal, one runtime write. */
|
|
7
|
-
export declare function persistTokens(deps
|
|
7
|
+
export declare function persistTokens({ deps, record, tokens }: {
|
|
8
|
+
deps: SignInDeps;
|
|
9
|
+
record: ExternalMcpServerRecord;
|
|
10
|
+
tokens: OAuthTokenSet;
|
|
11
|
+
}, options?: {
|
|
12
|
+
expectedConfig?: Pick<ExternalMcpServerRecord, "createdAt" | "version">;
|
|
13
|
+
}): Promise<void>;
|
|
8
14
|
/** {@link setOAuthStatus}'s options. `forgetSelfRegisteredClient` also drops a client the host minted by
|
|
9
15
|
* dynamic registration — its id and its sealed secret — so the next connect registers afresh. It
|
|
10
16
|
* leaves an operator-typed client alone (see {@link isSelfRegisteredClient}). */
|
|
11
17
|
interface SetOAuthStatusOptions {
|
|
12
18
|
readonly clearToken?: boolean;
|
|
13
19
|
readonly forgetSelfRegisteredClient?: boolean;
|
|
20
|
+
readonly callbackRecord?: ExternalMcpServerRecord;
|
|
14
21
|
}
|
|
15
22
|
/** Moves a row into a terminal or reset OAuth state without touching anything else on it. See
|
|
16
23
|
* {@link resolveClearedTokenPatch} for the `clearToken` decision tree. */
|
|
17
|
-
export declare function setOAuthStatus(deps
|
|
24
|
+
export declare function setOAuthStatus({ deps, serverId, status }: {
|
|
25
|
+
deps: SignInDeps;
|
|
26
|
+
serverId: string;
|
|
27
|
+
status: ExternalMcpOAuthStatus;
|
|
28
|
+
}, options?: SetOAuthStatusOptions): Promise<void>;
|
|
18
29
|
export {};
|
|
19
30
|
//# sourceMappingURL=sign-in-status.d.ts.map
|
|
@@ -13,7 +13,7 @@ const CLEAR_TOKEN_RESEAL_ATTEMPTS = 3;
|
|
|
13
13
|
/** Writes a token set into the row: sealed blob (preserving the client secret) plus the PLAINTEXT
|
|
14
14
|
* status and expiry beside it. One place, so the plaintext metadata cannot drift from the blob.
|
|
15
15
|
* @complexity O(1) — one unseal, one seal, one runtime write. */
|
|
16
|
-
export async function persistTokens(deps, record, tokens) {
|
|
16
|
+
export async function persistTokens({ deps, record, tokens }, options = {}) {
|
|
17
17
|
const existing = await deps.ports.store.openPayload(deps.sealer, record);
|
|
18
18
|
const { sealedOAuth, oauthAadVersion } = await deps.ports.store.sealPayload(deps, record, {
|
|
19
19
|
// Read-modify-write: sealing `{ tokens }` alone would silently delete the operator's client
|
|
@@ -30,7 +30,7 @@ export async function persistTokens(deps, record, tokens) {
|
|
|
30
30
|
// Runtime write: only the token columns, fenced on the credential read above (see oauth-row-writes.ts).
|
|
31
31
|
// `oauthAadVersion` is carried from the seal, never from `record` — it holds the row's OLD version.
|
|
32
32
|
await writeOAuthRuntime({ repo: deps.repo, ports: deps.ports, record, patch: { oauthStatus: "connected",
|
|
33
|
-
oauthExpiresAt: tokens.expiresAt, oauthRefreshLeaseUntil: null, sealedOAuth, oauthAadVersion, updatedAt: readNowIso({ clock: deps.clock }) } });
|
|
33
|
+
oauthExpiresAt: tokens.expiresAt, oauthRefreshLeaseUntil: null, sealedOAuth, oauthAadVersion, updatedAt: readNowIso({ clock: deps.clock }) } }, options);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Resolves {@link setOAuthStatus}'s token-clear patch. Split out purely to keep that function's
|
|
@@ -116,9 +116,9 @@ async function resealClearedOAuthToken(deps, record, clientSecret) {
|
|
|
116
116
|
}
|
|
117
117
|
/** Moves a row into a terminal or reset OAuth state without touching anything else on it. See
|
|
118
118
|
* {@link resolveClearedTokenPatch} for the `clearToken` decision tree. */
|
|
119
|
-
export async function setOAuthStatus(deps, serverId, status, options = {}) {
|
|
119
|
+
export async function setOAuthStatus({ deps, serverId, status }, options = {}) {
|
|
120
120
|
const key = { workspaceId: deps.workspaceId, serverId };
|
|
121
|
-
const record = await deps.repo.findByServerId(key);
|
|
121
|
+
const record = options.callbackRecord ?? await deps.repo.findByServerId(key);
|
|
122
122
|
if (!record)
|
|
123
123
|
return;
|
|
124
124
|
const forgetClient = options.forgetSelfRegisteredClient === true && isSelfRegisteredClient(record, readStoredEndpoints(record));
|
|
@@ -134,10 +134,23 @@ export async function setOAuthStatus(deps, serverId, status, options = {}) {
|
|
|
134
134
|
updatedAt: readNowIso({ clock: deps.clock }),
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
|
+
if (options.callbackRecord) {
|
|
138
|
+
await writeCallbackCleanup({ deps, record, next: await nextRow(record), forgetClient });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
137
141
|
// Forgetting the client is an edit (version-compared, M4); every other state change is a runtime write (S1).
|
|
138
142
|
if (forgetClient)
|
|
139
143
|
await updateRowOnce({ repo: deps.repo, key, build: nextRow });
|
|
140
144
|
else
|
|
141
145
|
await writeOAuthRuntime({ repo: deps.repo, ports: deps.ports, record, patch: runtimePatchOf(await nextRow(record)) });
|
|
142
146
|
}
|
|
147
|
+
async function writeCallbackCleanup({ deps, record, next, forgetClient }, _optional = {}) {
|
|
148
|
+
if (forgetClient) {
|
|
149
|
+
await deps.repo.updateIfVersion({ record: next, expectedVersion: record.version, expectedCreatedAt: record.createdAt,
|
|
150
|
+
replaces: { sealedEnv: record.sealedEnv, sealedOAuth: record.sealedOAuth } });
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
await deps.repo.updateOAuthRuntime({ key: record, expectedSealedOAuth: record.sealedOAuth,
|
|
154
|
+
expectedConfig: { createdAt: record.createdAt, version: record.version }, patch: runtimePatchOf(next) });
|
|
155
|
+
}
|
|
143
156
|
//# sourceMappingURL=sign-in-status.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeviceAuthorizationStore, ExternalMcpOAuthService } from "
|
|
1
|
+
import type { DeviceAuthorizationStore, ExternalMcpOAuthService } from "@jini-ai/core/contracts/site/api-connections-hosted-mcp";
|
|
2
2
|
import { type SignInDeps } from "./sign-in-provider.js";
|
|
3
3
|
/** Bounded by the per-workspace server cap, so no explicit eviction policy is needed beyond
|
|
4
4
|
* overwriting a connection's own previous attempt. */
|
|
@@ -79,19 +79,19 @@ function createConnectionTokenRefresher(deps) {
|
|
|
79
79
|
: { ...payload.tokens, scopes: [...payload.tokens.scopes] };
|
|
80
80
|
},
|
|
81
81
|
async refresh({ key: serverId, refreshToken }) {
|
|
82
|
-
const record = await requireOAuthRecord(deps, serverId);
|
|
82
|
+
const record = await requireOAuthRecord({ deps, serverId });
|
|
83
83
|
const provider = resolveProviderDescriptor(deps, record);
|
|
84
84
|
return deps.ports.withCopy({ call: async () => deps.ports.flow.refreshAccessToken({ ...deps.httpPorts, clock: deps.clock, tokenEndpoint: provider.tokenEndpoint,
|
|
85
|
-
client: await resolveClient(deps, record, provider), refreshToken }, { scopes: readStoredScopes(record), ...resourceOption(readStoredEndpoints(record).resource), timeoutMs: CONNECT_TIMEOUT_MS }) });
|
|
85
|
+
client: await resolveClient({ deps, record, provider }), refreshToken }, { scopes: readStoredScopes(record), ...resourceOption({ resource: readStoredEndpoints(record).resource }), timeoutMs: CONNECT_TIMEOUT_MS }) });
|
|
86
86
|
},
|
|
87
87
|
async persist({ key: serverId, tokens }) {
|
|
88
|
-
const record = await requireOAuthRecord(deps, serverId);
|
|
89
|
-
await persistTokens(deps, record, tokens);
|
|
88
|
+
const record = await requireOAuthRecord({ deps, serverId });
|
|
89
|
+
await persistTokens({ deps, record, tokens });
|
|
90
90
|
},
|
|
91
91
|
async markNeedsReauth({ key: serverId }) {
|
|
92
92
|
// The token is CLEARED, not kept: it is known dead, and a dead credential sitting in the
|
|
93
93
|
// row is one accidental read away from being sent to a provider that will reject it.
|
|
94
|
-
await setOAuthStatus(deps, serverId, "needs_reauth", { clearToken: true });
|
|
94
|
+
await setOAuthStatus({ deps, serverId, status: "needs_reauth" }, { clearToken: true });
|
|
95
95
|
},
|
|
96
96
|
async tryAcquireRefreshLease({ key: serverId }) {
|
|
97
97
|
const nowIso = readNowIso({ clock: deps.clock });
|
|
@@ -110,10 +110,10 @@ function createConnectionTokenRefresher(deps) {
|
|
|
110
110
|
}
|
|
111
111
|
function createSharedConnectionService(deps) {
|
|
112
112
|
return deps.shared ? createSharedExternalMcpOAuth({ deps, shared: deps.shared, ports: deps.ports, resolveProvider: record => resolveProviderDescriptor(deps, record), configure: async (input) => {
|
|
113
|
-
const record = await selfConfigureConnection({ deps, record: await requireOAuthRecord(deps, input.serverId), redirectUri: input.redirectUri, options: { configurationOnly: true } });
|
|
113
|
+
const record = await selfConfigureConnection({ deps, record: await requireOAuthRecord({ deps, serverId: input.serverId }), redirectUri: input.redirectUri, options: { configurationOnly: true } });
|
|
114
114
|
const provider = resolveProviderDescriptor(deps, record);
|
|
115
115
|
const endpoints = readStoredEndpoints(record);
|
|
116
|
-
return { record, provider, client: await resolveClient(deps, record, provider), scopes: readStoredScopes(record),
|
|
116
|
+
return { record, provider, client: await resolveClient({ deps, record, provider }), scopes: readStoredScopes(record),
|
|
117
117
|
resource: endpoints.resource ?? record.url ?? undefined, issuer: endpoints.issuer };
|
|
118
118
|
} }) : undefined;
|
|
119
119
|
}
|
|
@@ -124,9 +124,9 @@ async function beginConnectionAuthorization({ deps, shared }, input) {
|
|
|
124
124
|
return shared.beginConnect(input);
|
|
125
125
|
// Self-configuration first: a row that names no endpoints or no client id gets them here, once,
|
|
126
126
|
// and every step below then reads an ordinary fully-specified connection.
|
|
127
|
-
const record = await selfConfigureConnection({ deps, record: await requireOAuthRecord(deps, input.serverId), redirectUri: input.redirectUri });
|
|
127
|
+
const record = await selfConfigureConnection({ deps, record: await requireOAuthRecord({ deps, serverId: input.serverId }), redirectUri: input.redirectUri });
|
|
128
128
|
const provider = resolveProviderDescriptor(deps, record);
|
|
129
|
-
const client = await resolveClient(deps, record, provider);
|
|
129
|
+
const client = await resolveClient({ deps, record, provider });
|
|
130
130
|
const scopes = readStoredScopes(record);
|
|
131
131
|
// Keep the advertised audience across grants; the MCP URL need not be the resource id.
|
|
132
132
|
const resource = readStoredEndpoints(record).resource;
|
|
@@ -142,25 +142,25 @@ async function beginConnectionAuthorization({ deps, shared }, input) {
|
|
|
142
142
|
// The authenticated GET sets the shared browser-binding cookie before revealing a provider
|
|
143
143
|
// URL. This also works when the daemon prepared the connection in another process.
|
|
144
144
|
if (input.delivery === 'hosted') {
|
|
145
|
-
await setOAuthStatus(deps, record.serverId, 'pending');
|
|
145
|
+
await setOAuthStatus({ deps, serverId: record.serverId, status: 'pending' });
|
|
146
146
|
return {
|
|
147
147
|
kind: 'redirect_required',
|
|
148
148
|
authorizationUrl: deps.ports.signInLink({ callbackUrl: redirectUri, workspaceId: deps.workspaceId, serverId: record.serverId }),
|
|
149
149
|
expiresAt: new Date(deps.clock.nowMs() + 600_000).toISOString(),
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
const started = await deps.ports.withCopy({ call: () => deps.ports.flow.beginAuthorizationCode({ provider, stateless: sealedRedirectState({ deps, serverId: record.serverId, browserBinding: input.browserBinding }), guard: deps.httpPorts.guard,
|
|
152
|
+
const started = await deps.ports.withCopy({ call: () => deps.ports.flow.beginAuthorizationCode({ provider, stateless: sealedRedirectState({ deps, serverId: record.serverId, browserBinding: input.browserBinding, config: record }), guard: deps.httpPorts.guard,
|
|
153
153
|
randomBytesFn: ({ byteLength }) => randomBytes(byteLength),
|
|
154
|
-
options: oauthClientOptions(deps.ports, record, redirectUri),
|
|
155
|
-
ownerKey: ownerKeyOf(deps.workspaceId, record.serverId),
|
|
154
|
+
options: oauthClientOptions({ ports: deps.ports, record, redirectUri }),
|
|
155
|
+
ownerKey: ownerKeyOf({ workspaceId: deps.workspaceId, serverId: record.serverId }),
|
|
156
156
|
client,
|
|
157
157
|
redirectUri,
|
|
158
158
|
}, {
|
|
159
159
|
scopes,
|
|
160
|
-
...resourceOption(resource),
|
|
160
|
+
...resourceOption({ resource }),
|
|
161
161
|
messages: deps.ports.oauthMessages,
|
|
162
162
|
}) });
|
|
163
|
-
await setOAuthStatus(deps, record.serverId, "pending");
|
|
163
|
+
await setOAuthStatus({ deps, serverId: record.serverId, status: "pending" });
|
|
164
164
|
return { kind: "redirect_required", authorizationUrl: started.authorizationUrl, expiresAt: started.expiresAt };
|
|
165
165
|
}
|
|
166
166
|
async function completeConnectionAuthorization({ deps, shared }, input, _options = {}) {
|
|
@@ -169,14 +169,14 @@ async function completeConnectionAuthorization({ deps, shared }, input, _options
|
|
|
169
169
|
await notifyConnected(deps, input.serverId);
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const record = await requireOAuthRecord(deps, input.serverId);
|
|
172
|
+
const record = await requireOAuthRecord({ deps, serverId: input.serverId });
|
|
173
173
|
const provider = resolveProviderDescriptor(deps, record);
|
|
174
|
-
const client = await resolveClient(deps, record, provider);
|
|
174
|
+
const client = await resolveClient({ deps, record, provider });
|
|
175
175
|
let tokens;
|
|
176
176
|
try {
|
|
177
|
-
tokens = await deps.ports.withCopy({ call: () => deps.ports.flow.completeAuthorizationCode({ ...deps.httpPorts, provider, stateless: sealedRedirectState({ deps, serverId: record.serverId, browserBinding: input.browserBinding }), clock: deps.clock,
|
|
177
|
+
tokens = await deps.ports.withCopy({ call: () => deps.ports.flow.completeAuthorizationCode({ ...deps.httpPorts, provider, stateless: sealedRedirectState({ deps, serverId: record.serverId, browserBinding: input.browserBinding, config: record }), clock: deps.clock,
|
|
178
178
|
redirectUri: input.redirectUri,
|
|
179
|
-
ownerKey: ownerKeyOf(deps.workspaceId, record.serverId),
|
|
179
|
+
ownerKey: ownerKeyOf({ workspaceId: deps.workspaceId, serverId: record.serverId }),
|
|
180
180
|
client,
|
|
181
181
|
params: input.params,
|
|
182
182
|
}, {
|
|
@@ -188,13 +188,11 @@ async function completeConnectionAuthorization({ deps, shared }, input, _options
|
|
|
188
188
|
// so a self-registered one is dropped and the next connect mints a fresh one. The provider's
|
|
189
189
|
// error still reaches the caller.
|
|
190
190
|
if (deps.ports.errors.isOAuthError(error) && CLIENT_REJECTED_PROVIDER_CODES.includes(error.providerErrorCode ?? "")) {
|
|
191
|
-
await setOAuthStatus(deps, record.serverId, "disconnected", { clearToken: true, forgetSelfRegisteredClient: true });
|
|
191
|
+
await setOAuthStatus({ deps, serverId: record.serverId, status: "disconnected" }, { clearToken: true, forgetSelfRegisteredClient: true, callbackRecord: record });
|
|
192
192
|
}
|
|
193
193
|
throw error;
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
// stale copy would resurrect the pre-connect row wholesale.
|
|
197
|
-
await persistTokens(deps, await requireOAuthRecord(deps, input.serverId), tokens);
|
|
195
|
+
await persistTokens({ deps, record, tokens }, { expectedConfig: { createdAt: record.createdAt, version: record.version } });
|
|
198
196
|
await notifyConnected(deps, input.serverId);
|
|
199
197
|
}
|
|
200
198
|
async function pollConnectionAuthorization({ deps, shared }, input) {
|
|
@@ -204,13 +202,13 @@ async function pollConnectionAuthorization({ deps, shared }, input) {
|
|
|
204
202
|
await notifyConnected(deps, input.serverId);
|
|
205
203
|
return result;
|
|
206
204
|
}
|
|
207
|
-
const record = await requireOAuthRecord(deps, input.serverId);
|
|
205
|
+
const record = await requireOAuthRecord({ deps, serverId: input.serverId });
|
|
208
206
|
const authorization = await deps.devices.get(input.serverId);
|
|
209
207
|
if (!authorization) {
|
|
210
208
|
throw deps.ports.errors.oauth({ code: "OAUTH_INVALID_STATE", message: `no device authorization is in progress for '${input.serverId}'`, operatorAction: deps.ports.copy.actions.restartDevice, });
|
|
211
209
|
}
|
|
212
210
|
const provider = resolveProviderDescriptor(deps, record);
|
|
213
|
-
const client = await resolveClient(deps, record, provider);
|
|
211
|
+
const client = await resolveClient({ deps, record, provider });
|
|
214
212
|
try {
|
|
215
213
|
const tokens = await deps.ports.withCopy({ call: () => deps.ports.flow.pollDeviceAuthorizationOnce({ ...deps.httpPorts, provider, clock: deps.clock,
|
|
216
214
|
client,
|
|
@@ -218,11 +216,11 @@ async function pollConnectionAuthorization({ deps, shared }, input) {
|
|
|
218
216
|
expiresAt: authorization.expiresAt,
|
|
219
217
|
}, {
|
|
220
218
|
// The token request names the same audience the device start asked for (RFC 8707).
|
|
221
|
-
...resourceOption(readStoredEndpoints(record).resource),
|
|
219
|
+
...resourceOption({ resource: readStoredEndpoints(record).resource }),
|
|
222
220
|
timeoutMs: CONNECT_TIMEOUT_MS,
|
|
223
221
|
}) });
|
|
224
222
|
await deps.devices.delete(input.serverId);
|
|
225
|
-
await persistTokens(deps, record, tokens);
|
|
223
|
+
await persistTokens({ deps, record, tokens });
|
|
226
224
|
await notifyConnected(deps, input.serverId);
|
|
227
225
|
return { status: "connected" };
|
|
228
226
|
}
|
|
@@ -233,7 +231,7 @@ async function pollConnectionAuthorization({ deps, shared }, input) {
|
|
|
233
231
|
return { status: "pending", retryAfterSeconds: error.retryAfterSeconds ?? authorization.intervalSeconds };
|
|
234
232
|
}
|
|
235
233
|
await deps.devices.delete(input.serverId);
|
|
236
|
-
await setOAuthStatus(deps, input.serverId, "disconnected");
|
|
234
|
+
await setOAuthStatus({ deps, serverId: input.serverId, status: "disconnected" });
|
|
237
235
|
throw error;
|
|
238
236
|
}
|
|
239
237
|
}
|
|
@@ -245,7 +243,7 @@ async function disconnectConnection({ deps, shared }, input) {
|
|
|
245
243
|
await deps.devices.delete(input.serverId);
|
|
246
244
|
// A self-registered client goes too, so a reconnect is a clean one: a client the vendor has
|
|
247
245
|
// since dropped would otherwise be reused forever. An operator-typed client is kept.
|
|
248
|
-
await setOAuthStatus(deps, input.serverId, "disconnected", { clearToken: true, forgetSelfRegisteredClient: true });
|
|
246
|
+
await setOAuthStatus({ deps, serverId: input.serverId, status: "disconnected" }, { clearToken: true, forgetSelfRegisteredClient: true });
|
|
249
247
|
}
|
|
250
248
|
async function reportConnectionAuthFailure({ deps, shared }, serverId, error) {
|
|
251
249
|
if (shared && await shared.hasBinding({ serverId })) {
|
|
@@ -273,7 +271,7 @@ async function reportConnectionAuthFailure({ deps, shared }, serverId, error) {
|
|
|
273
271
|
// grant must not re-clear an already-cleared token or bump `updatedAt` needlessly.
|
|
274
272
|
if (deps.ports.projections.oauthStatus(record) !== "needs_reauth") {
|
|
275
273
|
try {
|
|
276
|
-
await setOAuthStatus(deps, serverId, "needs_reauth", { clearToken: true });
|
|
274
|
+
await setOAuthStatus({ deps, serverId, status: "needs_reauth" }, { clearToken: true });
|
|
277
275
|
}
|
|
278
276
|
catch (writeError) {
|
|
279
277
|
statusWriteFailure = writeError;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ApiConnectionSharedFactoryInput, ApiConnectionSharedIssuingContext, ApiConnectionSharedStorage, DeclaredApiConnection } from './host-ports.js';
|
|
2
|
+
import type { ApiConnectionService } from './service.js';
|
|
3
|
+
import { type SharedOAuthConnection } from './shared.js';
|
|
4
|
+
type SharedOAuthIssuingContext = ApiConnectionSharedIssuingContext;
|
|
5
|
+
/** The host's sealed owner store (the runtime host's shared storage) plus its connection read and one context save. */
|
|
6
|
+
export interface SharedApiOwnerStorage extends ApiConnectionSharedStorage {
|
|
7
|
+
readConnection(required: {
|
|
8
|
+
credentialId: string;
|
|
9
|
+
}): Promise<SharedOAuthConnection | null>;
|
|
10
|
+
saveContext(required: {
|
|
11
|
+
credentialId: string;
|
|
12
|
+
context: SharedOAuthIssuingContext;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/** The host's token-free per-site binding of one consumer to one shared credential. */
|
|
16
|
+
export interface SharedApiSiteBindings {
|
|
17
|
+
read(input: {
|
|
18
|
+
consumerId: string;
|
|
19
|
+
}, options?: Record<string, never>): Promise<{
|
|
20
|
+
credentialId: string;
|
|
21
|
+
} | null>;
|
|
22
|
+
set(input: {
|
|
23
|
+
consumerId: string;
|
|
24
|
+
credentialId: string;
|
|
25
|
+
}, options?: Record<string, never>): Promise<void>;
|
|
26
|
+
remove(input: {
|
|
27
|
+
consumerId: string;
|
|
28
|
+
}, options?: Record<string, never>): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/** The host's site-to-key grants; only the meta UUID identifies a site. */
|
|
31
|
+
export interface SharedApiKeyAttachments {
|
|
32
|
+
attach(required: {
|
|
33
|
+
siteId: string;
|
|
34
|
+
keyId: string;
|
|
35
|
+
siteName: string;
|
|
36
|
+
}, optional?: Record<string, never>): Promise<void>;
|
|
37
|
+
detach(required: {
|
|
38
|
+
siteId: string;
|
|
39
|
+
keyId: string;
|
|
40
|
+
}, optional?: Record<string, never>): Promise<void>;
|
|
41
|
+
isAttached(required: {
|
|
42
|
+
siteId: string;
|
|
43
|
+
keyId: string;
|
|
44
|
+
}, optional?: Record<string, never>): Promise<boolean>;
|
|
45
|
+
}
|
|
46
|
+
/** The host's owner transaction: grant, binding and generation checks run inside one `run`. */
|
|
47
|
+
export type SharedApiTransaction = <T>(required: {
|
|
48
|
+
run: () => Promise<T>;
|
|
49
|
+
}, optional?: Record<string, never>) => Promise<T>;
|
|
50
|
+
export interface SharedApiConnectionDeps {
|
|
51
|
+
readonly storage: SharedApiOwnerStorage;
|
|
52
|
+
readonly bindings: SharedApiSiteBindings;
|
|
53
|
+
readonly attachments: SharedApiKeyAttachments;
|
|
54
|
+
readonly transaction: SharedApiTransaction;
|
|
55
|
+
readonly siteId: string;
|
|
56
|
+
readonly siteName: string;
|
|
57
|
+
readonly ownerPrincipalId: Promise<string>;
|
|
58
|
+
}
|
|
59
|
+
/** Wires the generic consumer to the owner store and this immutable site's binding.
|
|
60
|
+
* @complexity Selected binding/grant/record reads per use, no authorization cache or background work.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createSharedApiConnections(required: SharedApiConnectionDeps & ApiConnectionSharedFactoryInput, _optional?: {}): {
|
|
63
|
+
bind: ({ keyId, use }: {
|
|
64
|
+
keyId: string;
|
|
65
|
+
use: boolean;
|
|
66
|
+
}, _options?: {}) => Promise<void>;
|
|
67
|
+
hasBinding: (connection: DeclaredApiConnection, _options?: {}) => Promise<boolean>;
|
|
68
|
+
getStatus: (connection: DeclaredApiConnection, _options?: {}) => Promise<SharedOAuthConnection | null>;
|
|
69
|
+
readAccount(connection: DeclaredApiConnection, _options?: {}): Promise<import("./types.js").ApiConnectionAccount | null>;
|
|
70
|
+
getAccessToken: (connection: DeclaredApiConnection, options?: {
|
|
71
|
+
expectedAccountId?: string;
|
|
72
|
+
}) => Promise<string>;
|
|
73
|
+
selectLocal(connection: DeclaredApiConnection, _options?: {}): Promise<void>;
|
|
74
|
+
stopUsing(connection: DeclaredApiConnection, _options?: {}): Promise<void>;
|
|
75
|
+
prepare: ({ connection, actorId, context, redirectUri }: {
|
|
76
|
+
connection: DeclaredApiConnection;
|
|
77
|
+
actorId: string;
|
|
78
|
+
context: SharedOAuthIssuingContext;
|
|
79
|
+
redirectUri?: string;
|
|
80
|
+
}, _options?: {}) => Promise<{
|
|
81
|
+
service: ApiConnectionService;
|
|
82
|
+
workspaceId: string;
|
|
83
|
+
onCompleted(): Promise<void>;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=shared-api.d.ts.map
|