@jini-ai/integrations 0.7.2 → 0.7.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -8
- package/README.md +1 -0
- package/dist/api-connections/access-token.js +4 -4
- package/dist/api-connections/account-actions.d.ts +10 -4
- package/dist/api-connections/account-actions.js +13 -13
- package/dist/api-connections/attempt-state.d.ts +11 -5
- package/dist/api-connections/attempt-state.js +4 -4
- package/dist/api-connections/authorization.d.ts +7 -3
- package/dist/api-connections/authorization.js +18 -18
- package/dist/api-connections/finish-authorization.d.ts +8 -4
- package/dist/api-connections/finish-authorization.js +9 -9
- package/dist/api-connections/host.d.ts +30 -32
- package/dist/api-connections/host.js +232 -205
- package/dist/api-connections/hosted-mcp/contracts.d.ts +1 -1
- package/dist/api-connections/hosted-mcp/oauth-row-writes.d.ts +50 -0
- package/dist/api-connections/hosted-mcp/oauth-row-writes.js +38 -0
- package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +40 -40
- package/dist/api-connections/hosted-mcp/shared-sign-in.js +98 -22
- package/dist/api-connections/hosted-mcp/sign-in-configuration.d.ts +29 -0
- package/dist/api-connections/hosted-mcp/sign-in-configuration.js +127 -0
- package/dist/api-connections/hosted-mcp/sign-in-discovery.d.ts +72 -0
- package/dist/api-connections/hosted-mcp/sign-in-discovery.js +131 -0
- package/dist/api-connections/hosted-mcp/sign-in-flow.d.ts +42 -0
- package/dist/api-connections/hosted-mcp/sign-in-flow.js +50 -0
- package/dist/api-connections/hosted-mcp/sign-in-provider.d.ts +103 -0
- package/dist/api-connections/hosted-mcp/sign-in-provider.js +142 -0
- package/dist/api-connections/hosted-mcp/sign-in-status.d.ts +19 -0
- package/dist/api-connections/hosted-mcp/sign-in-status.js +143 -0
- package/dist/api-connections/hosted-mcp/sign-in.d.ts +2 -9
- package/dist/api-connections/hosted-mcp/sign-in.js +219 -770
- package/dist/api-connections/index.js +1 -1
- package/dist/api-connections/install-credential.d.ts +4 -2
- package/dist/api-connections/install-credential.js +7 -7
- package/dist/api-connections/records.d.ts +17 -5
- package/dist/api-connections/records.js +5 -5
- package/dist/api-connections/request-checks.d.ts +29 -9
- package/dist/api-connections/request-checks.js +13 -13
- package/dist/api-connections/service.d.ts +1 -1
- package/dist/api-connections/service.js +6 -6
- package/dist/api-connections/status.d.ts +3 -1
- package/dist/api-connections/status.js +3 -3
- package/dist/api-connections/token-store/errors.d.ts +3 -1
- package/dist/api-connections/token-store/errors.js +1 -1
- package/dist/api-connections/token-store/vault-token-store.js +186 -173
- package/dist/args.d.ts +4 -1
- package/dist/args.js +1 -1
- package/dist/credentialed-http/credentialed-request.d.ts +5 -5
- package/dist/credentialed-http/credentialed-request.js +8 -8
- package/dist/credentialed-http/response-redaction.d.ts +18 -4
- package/dist/credentialed-http/response-redaction.js +7 -7
- package/dist/credentialed-http/sets/vault-repo.js +5 -1
- package/dist/credentialed-http/tools/credential-copy-tool.js +20 -15
- package/dist/credentialed-http/tools/tool-registrations.js +272 -249
- package/dist/media-providers/catalog.d.ts +1 -0
- package/dist/media-providers/catalog.js +1 -0
- package/dist/media-providers/dispatch/async-operation-store.d.ts +6 -4
- package/dist/media-providers/dispatch/async-operation-store.js +100 -88
- package/dist/media-providers/dispatch/context.js +1 -1
- package/dist/media-providers/dispatch/engine.d.ts +5 -1
- package/dist/media-providers/dispatch/engine.js +2 -2
- package/dist/media-providers/dispatch/index.d.ts +1 -1
- package/dist/media-providers/dispatch/index.js +1 -1
- package/dist/media-providers/dispatch/node.d.ts +1 -1
- package/dist/media-providers/dispatch/node.js +1 -1
- package/dist/media-providers/dispatch/openai-compatible.d.ts +50 -11
- package/dist/media-providers/dispatch/openai-compatible.js +21 -17
- package/dist/media-providers/dispatch/operation-runtime.js +18 -18
- package/dist/media-providers/dispatch/outbound.d.ts +2 -2
- package/dist/media-providers/dispatch/outbound.js +1 -1
- package/dist/media-providers/dispatch/polling-adapter.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/aihubmix-shared.d.ts +20 -6
- package/dist/media-providers/dispatch/providers/aihubmix-shared.js +8 -8
- package/dist/media-providers/dispatch/providers/aihubmix.js +12 -12
- package/dist/media-providers/dispatch/providers/custom-image.js +4 -4
- package/dist/media-providers/dispatch/providers/fishaudio.js +2 -9
- package/dist/media-providers/dispatch/providers/grok.js +5 -19
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.js +22 -20
- package/dist/media-providers/dispatch/providers/imagerouter.js +7 -21
- package/dist/media-providers/dispatch/providers/minimax.js +2 -9
- package/dist/media-providers/dispatch/providers/nanobanana.js +2 -2
- package/dist/media-providers/dispatch/providers/openai.js +6 -6
- package/dist/media-providers/dispatch/providers/openrouter.js +4 -4
- package/dist/media-providers/dispatch/providers/senseaudio.js +5 -19
- package/dist/media-providers/dispatch/providers/volcengine.js +5 -12
- package/dist/media-providers/dispatch/response-parsers.js +3 -3
- package/dist/media-providers/dispatch/sqlite-async-operation-store.d.ts +1 -1
- package/dist/media-providers/dispatch/sqlite-async-operation-store.js +31 -5
- package/dist/media-providers/dispatch/ssrf-guard.js +5 -12
- package/dist/media-providers/dispatch/stub.js +2 -2
- package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
- package/dist/media-providers/image-model-ids.d.ts +36 -0
- package/dist/media-providers/image-model-ids.js +24 -0
- package/dist/media-providers/sqlite-driver.adapter.d.ts +1 -1
- package/dist/media-providers/sqlite-task-store.d.ts +2 -2
- package/dist/media-providers/sqlite-task-store.js +31 -4
- package/dist/media-providers/task-lifecycle.d.ts +17 -4
- package/dist/media-providers/task-lifecycle.js +4 -4
- package/dist/media-providers/task-store.js +28 -24
- package/dist/media-providers/ui-defaults.d.ts +7 -0
- package/dist/media-providers/ui-defaults.js +11 -17
- package/dist/saved-requests/types.d.ts +1 -1
- package/dist/webhooks/delivery.js +31 -27
- package/dist/webhooks/ports.d.ts +4 -1
- package/dist/webhooks/subscriptions.d.ts +7 -2
- package/dist/webhooks/subscriptions.js +30 -37
- package/dist/webhooks/tools/agent-tools.d.ts +82 -0
- package/dist/webhooks/tools/agent-tools.js +120 -0
- package/dist/webhooks/tools/index.d.ts +7 -0
- package/dist/webhooks/tools/index.js +5 -0
- package/dist/webhooks/tools/tool-handlers.d.ts +22 -0
- package/dist/webhooks/tools/tool-handlers.js +154 -0
- package/dist/webhooks/tools/tool-handlers.types.d.ts +64 -0
- package/dist/webhooks/tools/tool-handlers.types.js +2 -0
- package/dist/webhooks/tools/tool-registrations.d.ts +35 -0
- package/dist/webhooks/tools/tool-registrations.js +95 -0
- package/dist/webhooks/tools/tool-views.d.ts +62 -0
- package/dist/webhooks/tools/tool-views.js +50 -0
- package/dist/webhooks/types.d.ts +2 -0
- package/dist/webhooks/worker.d.ts +7 -4
- package/dist/webhooks/worker.js +22 -20
- package/package.json +16 -18
- package/dist/composio/bounded-data.d.ts +0 -36
- package/dist/composio/bounded-data.js +0 -181
- package/dist/composio/catalog.d.ts +0 -147
- package/dist/composio/catalog.js +0 -126
- package/dist/composio/composio-config.d.ts +0 -42
- package/dist/composio/composio-config.js +0 -145
- package/dist/composio/composio-descriptions.d.ts +0 -16
- package/dist/composio/composio-descriptions.js +0 -766
- package/dist/composio/composio.d.ts +0 -364
- package/dist/composio/composio.js +0 -1902
- package/dist/composio/errors.d.ts +0 -15
- package/dist/composio/errors.js +0 -16
- package/dist/composio/file-lock.d.ts +0 -13
- package/dist/composio/file-lock.js +0 -92
- package/dist/composio/index.d.ts +0 -18
- package/dist/composio/index.js +0 -7
- package/dist/composio/json-schema.d.ts +0 -93
- package/dist/composio/json-schema.js +0 -498
- package/dist/composio/output-protection.d.ts +0 -32
- package/dist/composio/output-protection.js +0 -105
- package/dist/composio/service.d.ts +0 -181
- package/dist/composio/service.js +0 -758
|
@@ -14,7 +14,7 @@ export { createVaultOAuthTokenStore, parseOAuthTokenVaultMeta, parseTokenPayload
|
|
|
14
14
|
* @complexity Selected record/token operations plus the existing bounded provider revocation.
|
|
15
15
|
*/
|
|
16
16
|
export function disconnectApiConnection({ deps, ...connection }, _optional = {}) {
|
|
17
|
-
return runDisconnect(deps, connection);
|
|
17
|
+
return runDisconnect({ deps, ...connection });
|
|
18
18
|
}
|
|
19
19
|
export { asApiConnectionHooksModule, checkApiConnectionClientNamespace, parseApiConnectionsFile, } from './declarations.js';
|
|
20
20
|
export { ConnectionBudgetExceededError, createConnectionBudgets, HOST_BUDGET_MAXIMUM, parseConnectionBudgets, } from './budgets.js';
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
import type { OAuthTokenSet } from '@jini-ai/core/contracts/oauth';
|
|
11
11
|
import type { ApiConnectionServiceDeps } from './deps.js';
|
|
12
12
|
import type { ApiConnectionAccount, ApiConnectionRecord } from './types.js';
|
|
13
|
-
export declare function installCredential(deps
|
|
13
|
+
export declare function installCredential({ deps, ...requiredArgs }: {
|
|
14
|
+
deps: Pick<ApiConnectionServiceDeps, 'records' | 'tokens' | 'clock' | 'descriptor'>;
|
|
15
|
+
} & {
|
|
14
16
|
readonly current: ApiConnectionRecord;
|
|
15
17
|
readonly tokens: OAuthTokenSet;
|
|
16
18
|
readonly account: ApiConnectionAccount;
|
|
17
19
|
readonly grantedScopes: readonly string[];
|
|
18
|
-
}): Promise<ApiConnectionRecord>;
|
|
20
|
+
}, _optional?: Record<string, never>): Promise<ApiConnectionRecord>;
|
|
19
21
|
//# sourceMappingURL=install-credential.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { writeRecord } from './records.js';
|
|
2
|
-
export async function installCredential(deps, requiredArgs) {
|
|
3
|
-
const fenced = await writeRecord(deps, requiredArgs.current, {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export async function installCredential({ deps, ...requiredArgs }, _optional = {}) {
|
|
3
|
+
const fenced = await writeRecord({ deps, current: requiredArgs.current, patch: {
|
|
4
|
+
status: 'reconnect-required', generation: requiredArgs.current.generation + 1, staged: null,
|
|
5
|
+
} });
|
|
6
6
|
// Fenced on the new generation: a disconnect, switch or newer attempt that moves it first wins.
|
|
7
7
|
await deps.tokens.install({ key: fenced.key, tokens: requiredArgs.tokens, generation: fenced.generation });
|
|
8
|
-
return writeRecord(deps, fenced, {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
return writeRecord({ deps, current: fenced, patch: {
|
|
9
|
+
status: 'connected', account: requiredArgs.account, grantedScopes: [...requiredArgs.grantedScopes], revocationFailure: null,
|
|
10
|
+
} });
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=install-credential.js.map
|
|
@@ -13,15 +13,27 @@ export interface OwnedRecordArgs {
|
|
|
13
13
|
* A service bound to one plugin connection must never act on another plugin's record, and a ref
|
|
14
14
|
* from another workspace is refused here too, so a host cannot serve one by forgetting to check.
|
|
15
15
|
*/
|
|
16
|
-
export declare function isOwnedRecord(record
|
|
16
|
+
export declare function isOwnedRecord({ record, deps, workspaceId }: {
|
|
17
|
+
record: ApiConnectionRecord;
|
|
18
|
+
deps: Pick<RecordDeps, 'descriptor'>;
|
|
19
|
+
workspaceId: string;
|
|
20
|
+
}, _optional?: Record<string, never>): boolean;
|
|
17
21
|
/** Load a record owned by this service's plugin connection in `workspaceId`, or throw `connection-not-found`. */
|
|
18
|
-
export declare function loadOwnedRecord(deps
|
|
22
|
+
export declare function loadOwnedRecord({ deps, ...requiredArgs }: {
|
|
23
|
+
deps: RecordDeps;
|
|
24
|
+
} & OwnedRecordArgs, _optional?: Record<string, never>): Promise<ApiConnectionRecord>;
|
|
19
25
|
/** Empty record for a first connect; revision 0 means "absent" to compare-and-set. */
|
|
20
|
-
export declare function blankRecord(deps
|
|
26
|
+
export declare function blankRecord({ deps, ...requiredArgs }: {
|
|
27
|
+
deps: RecordDeps;
|
|
28
|
+
} & {
|
|
21
29
|
readonly key: string;
|
|
22
30
|
readonly workspaceId: string;
|
|
23
|
-
}): ApiConnectionRecord;
|
|
31
|
+
}, _optional?: Record<string, never>): ApiConnectionRecord;
|
|
24
32
|
/** Apply `patch` iff nobody wrote since `current` was read; returns the stored record. */
|
|
25
|
-
export declare function writeRecord(deps
|
|
33
|
+
export declare function writeRecord({ deps, current, patch }: {
|
|
34
|
+
deps: RecordDeps;
|
|
35
|
+
current: ApiConnectionRecord;
|
|
36
|
+
patch: RecordPatch;
|
|
37
|
+
}, _optional?: Record<string, never>): Promise<ApiConnectionRecord>;
|
|
26
38
|
export {};
|
|
27
39
|
//# sourceMappingURL=records.d.ts.map
|
|
@@ -17,19 +17,19 @@ export function connectionNotFound() {
|
|
|
17
17
|
* A service bound to one plugin connection must never act on another plugin's record, and a ref
|
|
18
18
|
* from another workspace is refused here too, so a host cannot serve one by forgetting to check.
|
|
19
19
|
*/
|
|
20
|
-
export function isOwnedRecord(record, deps, workspaceId) {
|
|
20
|
+
export function isOwnedRecord({ record, deps, workspaceId }, _optional = {}) {
|
|
21
21
|
return record.pluginId === deps.descriptor.pluginId && record.connectionId === deps.descriptor.connectionId
|
|
22
22
|
&& record.workspaceId === workspaceId;
|
|
23
23
|
}
|
|
24
24
|
/** Load a record owned by this service's plugin connection in `workspaceId`, or throw `connection-not-found`. */
|
|
25
|
-
export async function loadOwnedRecord(deps, requiredArgs) {
|
|
25
|
+
export async function loadOwnedRecord({ deps, ...requiredArgs }, _optional = {}) {
|
|
26
26
|
const record = await deps.records.read({ key: requiredArgs.connectionRef });
|
|
27
|
-
if (record === null || !isOwnedRecord(record, deps, requiredArgs.workspaceId))
|
|
27
|
+
if (record === null || !isOwnedRecord({ record, deps, workspaceId: requiredArgs.workspaceId }))
|
|
28
28
|
throw connectionNotFound();
|
|
29
29
|
return record;
|
|
30
30
|
}
|
|
31
31
|
/** Empty record for a first connect; revision 0 means "absent" to compare-and-set. */
|
|
32
|
-
export function blankRecord(deps, requiredArgs) {
|
|
32
|
+
export function blankRecord({ deps, ...requiredArgs }, _optional = {}) {
|
|
33
33
|
return {
|
|
34
34
|
key: requiredArgs.key, workspaceId: requiredArgs.workspaceId,
|
|
35
35
|
pluginId: deps.descriptor.pluginId, connectionId: deps.descriptor.connectionId,
|
|
@@ -38,7 +38,7 @@ export function blankRecord(deps, requiredArgs) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
/** Apply `patch` iff nobody wrote since `current` was read; returns the stored record. */
|
|
41
|
-
export async function writeRecord(deps, current, patch) {
|
|
41
|
+
export async function writeRecord({ deps, current, patch }, _optional = {}) {
|
|
42
42
|
const next = { ...current, ...patch, revision: current.revision + 1, updatedAt: nowIso({ clock: deps.clock }) };
|
|
43
43
|
const written = await deps.records.compareAndSet({ key: current.key, expectedRevision: current.revision, record: next });
|
|
44
44
|
if (!written) {
|
|
@@ -7,22 +7,42 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { ApiConnectionError } from './errors.js';
|
|
9
9
|
import type { ApiConnectionBoundedField } from './types.js';
|
|
10
|
-
export declare function requestInvalid(detail
|
|
11
|
-
|
|
10
|
+
export declare function requestInvalid({ detail }: {
|
|
11
|
+
detail: string;
|
|
12
|
+
}, _optional?: Record<string, never>): ApiConnectionError;
|
|
13
|
+
export declare function assertId(required: {
|
|
14
|
+
value: unknown;
|
|
15
|
+
name: string;
|
|
16
|
+
}, _optional?: Record<string, never>): asserts required is {
|
|
17
|
+
value: string;
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
12
20
|
/** Non-empty, de-duplicated scope list in RFC 6749 token syntax. */
|
|
13
|
-
export declare function checkScopes(value
|
|
21
|
+
export declare function checkScopes({ value }: {
|
|
22
|
+
value: unknown;
|
|
23
|
+
}, _optional?: Record<string, never>): readonly string[];
|
|
14
24
|
/** Keep only allowlisted names; refuse a declared value over its limit rather than truncate it. */
|
|
15
|
-
export declare function pickBoundedFields(fields
|
|
25
|
+
export declare function pickBoundedFields({ fields, values, where }: {
|
|
26
|
+
fields: readonly ApiConnectionBoundedField[];
|
|
27
|
+
values: Readonly<Record<string, string>>;
|
|
28
|
+
where: string;
|
|
29
|
+
}, _optional?: Record<string, never>): Record<string, string>;
|
|
16
30
|
/** Every name a caller passes must be declared; silently ignoring one would hide a plugin bug. */
|
|
17
|
-
export declare function checkStartParams(fields
|
|
31
|
+
export declare function checkStartParams({ fields, values }: {
|
|
32
|
+
fields: readonly ApiConnectionBoundedField[];
|
|
33
|
+
values: Readonly<Record<string, string>>;
|
|
34
|
+
}, _optional?: Record<string, never>): Record<string, string>;
|
|
18
35
|
export interface CheckedCallback {
|
|
19
36
|
readonly state: string;
|
|
20
37
|
readonly code?: string;
|
|
21
38
|
readonly error?: string;
|
|
22
39
|
}
|
|
23
40
|
/** Bound the raw callback before anything is consumed; OAuth names are validated by the core. */
|
|
24
|
-
export declare function checkCallbackParams(value
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
41
|
+
export declare function checkCallbackParams({ value, limits }: {
|
|
42
|
+
value: Readonly<Record<string, string>>;
|
|
43
|
+
limits: {
|
|
44
|
+
readonly maxAuthorizationStateLength: number;
|
|
45
|
+
readonly maxCallbackFieldLength: number;
|
|
46
|
+
};
|
|
47
|
+
}, _optional?: Record<string, never>): CheckedCallback;
|
|
28
48
|
//# sourceMappingURL=request-checks.d.ts.map
|
|
@@ -12,50 +12,50 @@ const MAX_SCOPES = 64;
|
|
|
12
12
|
const SCOPE_TOKEN = /^[\x21\x23-\x5b\x5d-\x7e]{1,512}$/;
|
|
13
13
|
const MAX_CALLBACK_PARAMS = 64;
|
|
14
14
|
const OAUTH_CALLBACK_NAMES = ['state', 'code', 'error'];
|
|
15
|
-
export function requestInvalid(detail) {
|
|
15
|
+
export function requestInvalid({ detail }, _optional = {}) {
|
|
16
16
|
return new ApiConnectionError({
|
|
17
17
|
code: 'request-invalid',
|
|
18
18
|
message: `The connection request is invalid (${detail}). Start connecting again from the connection settings.`,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
export function assertId(
|
|
22
|
-
if (typeof value !== 'string' || value === '' || value.length > MAX_ID_LENGTH)
|
|
23
|
-
throw requestInvalid(name);
|
|
21
|
+
export function assertId(required, _optional = {}) {
|
|
22
|
+
if (typeof required.value !== 'string' || required.value === '' || required.value.length > MAX_ID_LENGTH)
|
|
23
|
+
throw requestInvalid({ detail: required.name });
|
|
24
24
|
}
|
|
25
25
|
/** Non-empty, de-duplicated scope list in RFC 6749 token syntax. */
|
|
26
|
-
export function checkScopes(value) {
|
|
26
|
+
export function checkScopes({ value }, _optional = {}) {
|
|
27
27
|
if (!Array.isArray(value) || value.length === 0 || value.length > MAX_SCOPES
|
|
28
28
|
|| !value.every(scope => typeof scope === 'string' && SCOPE_TOKEN.test(scope))) {
|
|
29
|
-
throw requestInvalid('the plugin resolved no valid scope set');
|
|
29
|
+
throw requestInvalid({ detail: 'the plugin resolved no valid scope set' });
|
|
30
30
|
}
|
|
31
31
|
return [...new Set(value)];
|
|
32
32
|
}
|
|
33
33
|
/** Keep only allowlisted names; refuse a declared value over its limit rather than truncate it. */
|
|
34
|
-
export function pickBoundedFields(fields, values, where) {
|
|
34
|
+
export function pickBoundedFields({ fields, values, where }, _optional = {}) {
|
|
35
35
|
const picked = {};
|
|
36
36
|
for (const field of fields) {
|
|
37
37
|
const value = values[field.name];
|
|
38
38
|
if (value === undefined)
|
|
39
39
|
continue;
|
|
40
40
|
if (typeof value !== 'string' || value.length > field.maxLength)
|
|
41
|
-
throw requestInvalid(`${where} '${field.name}' is too large`);
|
|
41
|
+
throw requestInvalid({ detail: `${where} '${field.name}' is too large` });
|
|
42
42
|
picked[field.name] = value;
|
|
43
43
|
}
|
|
44
44
|
return picked;
|
|
45
45
|
}
|
|
46
46
|
/** Every name a caller passes must be declared; silently ignoring one would hide a plugin bug. */
|
|
47
|
-
export function checkStartParams(fields, values) {
|
|
47
|
+
export function checkStartParams({ fields, values }, _optional = {}) {
|
|
48
48
|
const unknown = Object.keys(values).find(name => !fields.some(field => field.name === name));
|
|
49
49
|
if (unknown !== undefined)
|
|
50
|
-
throw requestInvalid(`start parameter '${unknown}' is not declared by the plugin`);
|
|
51
|
-
return pickBoundedFields(fields, values, 'start parameter');
|
|
50
|
+
throw requestInvalid({ detail: `start parameter '${unknown}' is not declared by the plugin` });
|
|
51
|
+
return pickBoundedFields({ fields, values, where: 'start parameter' });
|
|
52
52
|
}
|
|
53
53
|
/** Bound the raw callback before anything is consumed; OAuth names are validated by the core. */
|
|
54
|
-
export function checkCallbackParams(value, limits) {
|
|
54
|
+
export function checkCallbackParams({ value, limits }, _optional = {}) {
|
|
55
55
|
const entries = Object.entries(value);
|
|
56
56
|
if (entries.length > MAX_CALLBACK_PARAMS
|
|
57
57
|
|| !entries.every(([, raw]) => typeof raw === 'string' && raw.length <= Math.max(limits.maxCallbackFieldLength, limits.maxAuthorizationStateLength))) {
|
|
58
|
-
throw requestInvalid('the callback carried too many or oversized fields');
|
|
58
|
+
throw requestInvalid({ detail: 'the callback carried too many or oversized fields' });
|
|
59
59
|
}
|
|
60
60
|
const checked = {};
|
|
61
61
|
for (const name of OAUTH_CALLBACK_NAMES)
|
|
@@ -9,7 +9,7 @@ import { cancelSwitchAccount, confirmSwitchAccount, disconnectApiConnection } fr
|
|
|
9
9
|
import { completeApiConnectionAuthorization, startApiConnectionAuthorization } from './authorization.js';
|
|
10
10
|
import { type ApiConnectionServiceDeps } from './deps.js';
|
|
11
11
|
import { getApiConnectionStatus } from './status.js';
|
|
12
|
-
type Bound<F> = F extends (
|
|
12
|
+
type Bound<F> = F extends (required: infer A, ...rest: infer O) => infer R ? (requiredArgs: Omit<A, 'deps'>, ...rest: O) => R : never;
|
|
13
13
|
export interface ApiConnectionService {
|
|
14
14
|
readonly start: Bound<typeof startApiConnectionAuthorization>;
|
|
15
15
|
readonly complete: Bound<typeof completeApiConnectionAuthorization>;
|
|
@@ -14,12 +14,12 @@ export function createApiConnectionService(deps) {
|
|
|
14
14
|
assertClientWiring(deps);
|
|
15
15
|
const accessTokens = createApiConnectionAccessTokens(deps);
|
|
16
16
|
return {
|
|
17
|
-
start: (
|
|
18
|
-
complete: (
|
|
19
|
-
confirmSwitchAccount: (
|
|
20
|
-
cancelSwitchAccount: (
|
|
21
|
-
disconnect: (
|
|
22
|
-
getStatus: (
|
|
17
|
+
start: (requiredArgs, optionalArgs) => startApiConnectionAuthorization({ deps, ...requiredArgs }, optionalArgs),
|
|
18
|
+
complete: (requiredArgs) => completeApiConnectionAuthorization({ deps, ...requiredArgs }),
|
|
19
|
+
confirmSwitchAccount: (requiredArgs) => confirmSwitchAccount({ deps, ...requiredArgs }),
|
|
20
|
+
cancelSwitchAccount: (requiredArgs) => cancelSwitchAccount({ deps, ...requiredArgs }),
|
|
21
|
+
disconnect: (requiredArgs) => disconnectApiConnection({ deps, ...requiredArgs }),
|
|
22
|
+
getStatus: (requiredArgs) => getApiConnectionStatus({ deps, ...requiredArgs }),
|
|
23
23
|
getAccessToken: (...args) => accessTokens.getAccessToken(...args),
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -24,5 +24,7 @@ export declare function toStatusView(record: ApiConnectionRecord): ApiConnection
|
|
|
24
24
|
* never rewrites or deletes the stored credential. Other storage failures still propagate.
|
|
25
25
|
* @complexity One record read and, only for a connected record, one token-store load; no HTTP.
|
|
26
26
|
*/
|
|
27
|
-
export declare function getApiConnectionStatus(deps
|
|
27
|
+
export declare function getApiConnectionStatus({ deps, ...requiredArgs }: {
|
|
28
|
+
deps: Pick<ApiConnectionServiceDeps, 'records' | 'descriptor' | 'tokens'>;
|
|
29
|
+
} & OwnedRecordArgs, _optional?: Record<string, never>): Promise<ApiConnectionStatusView>;
|
|
28
30
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -14,17 +14,17 @@ export function toStatusView(record) {
|
|
|
14
14
|
* never rewrites or deletes the stored credential. Other storage failures still propagate.
|
|
15
15
|
* @complexity One record read and, only for a connected record, one token-store load; no HTTP.
|
|
16
16
|
*/
|
|
17
|
-
export async function getApiConnectionStatus(deps, requiredArgs) {
|
|
17
|
+
export async function getApiConnectionStatus({ deps, ...requiredArgs }, _optional = {}) {
|
|
18
18
|
const record = await deps.records.read({ key: requiredArgs.connectionRef });
|
|
19
19
|
if (record === null) {
|
|
20
20
|
return { connectionRef: requiredArgs.connectionRef, status: 'disconnected', account: null, grantedScopes: [], pendingSwitch: null,
|
|
21
21
|
revocationFailure: null };
|
|
22
22
|
}
|
|
23
|
-
if (!isOwnedRecord(record, deps, requiredArgs.workspaceId))
|
|
23
|
+
if (!isOwnedRecord({ record, deps, workspaceId: requiredArgs.workspaceId }))
|
|
24
24
|
throw connectionNotFound();
|
|
25
25
|
if (record.status === 'connected') {
|
|
26
26
|
const tokens = await deps.tokens.load({ key: record.key }).catch((error) => {
|
|
27
|
-
if (isUnreadableTokenRecord(error))
|
|
27
|
+
if (isUnreadableTokenRecord({ error }))
|
|
28
28
|
return null;
|
|
29
29
|
throw error;
|
|
30
30
|
});
|
|
@@ -16,5 +16,7 @@ export declare class OAuthTokenStoreError extends IntegrationError {
|
|
|
16
16
|
/** True for a stored row this owner cannot open (sealed for another client id, or malformed). Only
|
|
17
17
|
* a new sign-in can replace such a row, so callers treat it as "no usable credential" instead of
|
|
18
18
|
* failing for good. Other store failures (vault outages, conflicts) are not this. */
|
|
19
|
-
export declare function isUnreadableTokenRecord(error
|
|
19
|
+
export declare function isUnreadableTokenRecord({ error }: {
|
|
20
|
+
error: unknown;
|
|
21
|
+
}, _optional?: Record<string, never>): boolean;
|
|
20
22
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -32,7 +32,7 @@ export class OAuthTokenStoreError extends IntegrationError {
|
|
|
32
32
|
/** True for a stored row this owner cannot open (sealed for another client id, or malformed). Only
|
|
33
33
|
* a new sign-in can replace such a row, so callers treat it as "no usable credential" instead of
|
|
34
34
|
* failing for good. Other store failures (vault outages, conflicts) are not this. */
|
|
35
|
-
export function isUnreadableTokenRecord(error) {
|
|
35
|
+
export function isUnreadableTokenRecord({ error }, _optional = {}) {
|
|
36
36
|
return error instanceof OAuthTokenStoreError && (error.code === "owner-mismatch" || error.code === "invalid-record");
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=errors.js.map
|