@jini-ai/core 0.6.22 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/approval.d.ts +49 -3
- package/dist/approval.js +47 -10
- package/dist/batch-tool-inputs.d.ts +13 -0
- package/dist/batch-tool-inputs.js +37 -6
- package/dist/contracts/cards.d.ts +382 -0
- package/dist/contracts/cards.js +2 -0
- package/dist/contracts/content-types.d.ts +32 -0
- package/dist/contracts/content-types.js +3 -0
- package/dist/contracts/credentials.d.ts +402 -0
- package/dist/contracts/credentials.js +2 -0
- package/dist/contracts/hosted-mcp/config.d.ts +253 -0
- package/dist/contracts/hosted-mcp/config.js +2 -0
- package/dist/contracts/hosted-mcp/record.d.ts +198 -0
- package/dist/contracts/hosted-mcp/record.js +2 -0
- package/dist/contracts/hosted-mcp/vocabulary.d.ts +14 -0
- package/dist/contracts/hosted-mcp/vocabulary.js +2 -0
- package/dist/contracts/hosted-mcp.d.ts +5 -0
- package/dist/contracts/hosted-mcp.js +2 -0
- package/dist/contracts/mail/adapter-module.d.ts +31 -0
- package/dist/contracts/mail/adapter-module.js +2 -0
- package/dist/contracts/mail/engine-contracts.d.ts +130 -0
- package/dist/contracts/mail/engine-contracts.js +2 -0
- package/dist/contracts/mail/ports.d.ts +93 -0
- package/dist/contracts/mail/ports.js +3 -0
- package/dist/contracts/mail/provider.d.ts +84 -0
- package/dist/contracts/mail/provider.js +2 -0
- package/dist/contracts/mail.d.ts +128 -0
- package/dist/contracts/mail.js +3 -0
- package/dist/contracts/oauth/details.d.ts +46 -0
- package/dist/contracts/oauth/details.js +2 -0
- package/dist/contracts/oauth/flow.d.ts +253 -0
- package/dist/contracts/oauth/flow.js +2 -0
- package/dist/contracts/oauth.d.ts +139 -0
- package/dist/contracts/oauth.js +2 -0
- package/dist/contracts/vault/ports.d.ts +34 -0
- package/dist/contracts/vault/ports.js +2 -0
- package/dist/contracts/vault/records.d.ts +149 -0
- package/dist/contracts/vault/records.js +2 -0
- package/dist/contracts/vault/vendor-credential-sets.d.ts +75 -0
- package/dist/contracts/vault/vendor-credential-sets.js +7 -0
- package/dist/contracts/vault.d.ts +14 -0
- package/dist/contracts/vault.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/primitives/http.d.ts +2 -0
- package/dist/settings/agent-value-write-tools.d.ts +3 -1
- package/dist/settings/agent-value-write-tools.js +11 -4
- package/dist/settings/tool-registrations.js +1 -1
- package/dist/surface-cards.d.ts +2 -0
- package/dist/surface-cards.js +2 -0
- package/dist/teardown.d.ts +30 -0
- package/dist/teardown.js +43 -0
- package/dist/text/descriptor-i18n.d.ts +24 -0
- package/dist/text/descriptor-i18n.js +65 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.js +1 -0
- package/dist/tool-metadata-types.d.ts +6 -0
- package/dist/user-facing-error.d.ts +28 -1
- package/dist/user-facing-error.js +87 -4
- package/package.json +44 -2
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** @agent-note Types only. The runtime parts come from the host; this area usually from `@jini-ai/platform`. */
|
|
2
|
+
import type { ISODateTime, UUID } from "../primitives/index.js";
|
|
3
|
+
export interface OutboundEmail {
|
|
4
|
+
workspaceId: UUID;
|
|
5
|
+
to: EmailAddress;
|
|
6
|
+
from: EmailAddress;
|
|
7
|
+
replyTo?: EmailAddress;
|
|
8
|
+
subject: string;
|
|
9
|
+
/** At least one of html/text must be supplied; the transport does not render missing content. */
|
|
10
|
+
html?: string;
|
|
11
|
+
/** A plain-text alternative improves accessibility and deliverability. */
|
|
12
|
+
text?: string;
|
|
13
|
+
/** Allows caller-owned List-Unsubscribe and RFC 8058 one-click headers without provider coupling. */
|
|
14
|
+
headers?: Readonly<Record<string, string>>;
|
|
15
|
+
/** Additive/optional for existing consumers; content is base64 so no live stream/path crosses the ABI. */
|
|
16
|
+
attachments?: readonly EmailAttachment[];
|
|
17
|
+
}
|
|
18
|
+
export interface EmailAddress {
|
|
19
|
+
email: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface EmailAttachment {
|
|
23
|
+
filename: string;
|
|
24
|
+
contentType: string;
|
|
25
|
+
contentBase64: string;
|
|
26
|
+
}
|
|
27
|
+
export interface MailerSendOptions {
|
|
28
|
+
/** Redelivery must reuse this identity; generating a new key defeats outbox deduplication. */
|
|
29
|
+
idempotencyKey: string;
|
|
30
|
+
/** Scope suppression and send dedup to the same delivery boundary. */
|
|
31
|
+
workspaceId: UUID;
|
|
32
|
+
/** Preserve provenance so delivery feedback can be attributed to the originating campaign/module. */
|
|
33
|
+
sourceContext: {
|
|
34
|
+
module: string;
|
|
35
|
+
ref?: string;
|
|
36
|
+
};
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
purpose?: "transactional" | "bulk" | `feature:${string}`;
|
|
39
|
+
/** Keep interaction separate from notification readiness: a shared transactional purpose cannot
|
|
40
|
+
* distinguish them. Unmapped/absent lanes resolve to notification rather than opening the
|
|
41
|
+
* interactive bypass; the caller-facing facade applies that fail-closed allowlist. */
|
|
42
|
+
lane?: "interactive" | "notification";
|
|
43
|
+
/** Configuration facts approved by the caller, rechecked immediately before delivery. */
|
|
44
|
+
mailTestApproval?: MailTestApproval;
|
|
45
|
+
}
|
|
46
|
+
/** Serializable outcomes cross the adapter ABI; live thrown objects cannot be carried as results. */
|
|
47
|
+
export type MailerSendResult = {
|
|
48
|
+
ok: true;
|
|
49
|
+
providerMessageId: string;
|
|
50
|
+
acceptedAt: ISODateTime;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
retryable: boolean;
|
|
54
|
+
errorCode: string;
|
|
55
|
+
message: string;
|
|
56
|
+
/** The provider may have accepted the message (timeout after submit, crash mid-send): never
|
|
57
|
+
* auto-retry under a new identity; the send ledger records the outcome as `unknown`. */
|
|
58
|
+
unknown?: boolean;
|
|
59
|
+
/** Rate-limit hint (provider 429 or the local token bucket); absent means "caller's backoff". */
|
|
60
|
+
retryAfterMs?: number;
|
|
61
|
+
};
|
|
62
|
+
export interface MailerCapabilities {
|
|
63
|
+
driver: string;
|
|
64
|
+
supportsIdempotencyKey: boolean;
|
|
65
|
+
supportsWebhookFeedback: boolean;
|
|
66
|
+
/** A limit of one means sequential send fallback, not an optional batch method consumers branch on. */
|
|
67
|
+
maxBatchSize: number;
|
|
68
|
+
/** Required attachments must be refused when unsupported, never dropped while reporting success. */
|
|
69
|
+
supportsAttachments: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface MailerFeedbackEvent {
|
|
72
|
+
workspaceId: UUID;
|
|
73
|
+
providerMessageId: string;
|
|
74
|
+
sourceContext: {
|
|
75
|
+
module: string;
|
|
76
|
+
ref?: string;
|
|
77
|
+
};
|
|
78
|
+
kind: "delivered" | "bounced" | "complained";
|
|
79
|
+
/** Provider event id: the inbox dedups replays on (providerId, eventId). Optional for v1 parsers. */
|
|
80
|
+
eventId?: string;
|
|
81
|
+
/** Lower-cased recipient address; suppression needs it, provider message ids alone cannot key it. */
|
|
82
|
+
recipient?: string;
|
|
83
|
+
hardBounce: boolean;
|
|
84
|
+
occurredAt: ISODateTime;
|
|
85
|
+
}
|
|
86
|
+
/** Required delivery identity/provenance belongs in the first argument of every send. */
|
|
87
|
+
export type MailerDelivery = Pick<MailerSendOptions, "idempotencyKey" | "workspaceId" | "sourceContext">;
|
|
88
|
+
export type MailerOptional = Omit<MailerSendOptions, keyof MailerDelivery>;
|
|
89
|
+
export type MailerSendRequired = MailerDelivery & {
|
|
90
|
+
message: OutboundEmail;
|
|
91
|
+
};
|
|
92
|
+
export type MailerBatchRequired = MailerDelivery & {
|
|
93
|
+
messages: readonly OutboundEmail[];
|
|
94
|
+
};
|
|
95
|
+
/** Persisted test-mode shape; capture availability is decided separately by the delivery wrapper. */
|
|
96
|
+
export type MailTestModeSetting = {
|
|
97
|
+
mode: "off";
|
|
98
|
+
} | {
|
|
99
|
+
mode: "redirect";
|
|
100
|
+
to: string;
|
|
101
|
+
} | {
|
|
102
|
+
mode: "capture";
|
|
103
|
+
};
|
|
104
|
+
/** Preserve field order when constructing/comparing approvals: approval bytes are caller-owned. */
|
|
105
|
+
export interface MailTestApproval {
|
|
106
|
+
providerId: string | null;
|
|
107
|
+
driver: string;
|
|
108
|
+
from: OutboundEmail["from"];
|
|
109
|
+
mode: MailTestModeSetting["mode"];
|
|
110
|
+
effectiveRecipient: string;
|
|
111
|
+
}
|
|
112
|
+
export type * from './mail/ports.js';
|
|
113
|
+
export type * from './mail/engine-contracts.js';
|
|
114
|
+
export type * from './mail/adapter-module.js';
|
|
115
|
+
export type * from './mail/provider.js';
|
|
116
|
+
/** Plugin modules keep a positional ABI; hosts adapt their guarded ports explicitly. */
|
|
117
|
+
export interface PositionalMailer {
|
|
118
|
+
capabilities(): MailerCapabilities;
|
|
119
|
+
send(message: OutboundEmail, options: MailerSendOptions): Promise<MailerSendResult>;
|
|
120
|
+
sendBatch(messages: readonly OutboundEmail[], options: MailerSendOptions): Promise<readonly MailerSendResult[]>;
|
|
121
|
+
}
|
|
122
|
+
/** @agent-note The host supplies its guarded HTTP client through the plugin ABI adapter. */
|
|
123
|
+
export interface PluginMailHttpClient {
|
|
124
|
+
send(request: import("../primitives/http.js").HttpRequest, optional?: {
|
|
125
|
+
redirect?: import("../primitives/http.js").RequestRedirect;
|
|
126
|
+
}): Promise<import("../primitives/http.js").HttpResponse>;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=mail.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ISODateTime } from '../../primitives/index.js';
|
|
2
|
+
import type { OAuthProviderDescriptor } from '../oauth.js';
|
|
3
|
+
/** @agent-note Types only. The runtime parts come from the host; this area usually from `@jini-ai/oauth`. */
|
|
4
|
+
export interface DeviceAuthorization {
|
|
5
|
+
readonly deviceCode: string;
|
|
6
|
+
readonly userCode: string;
|
|
7
|
+
readonly verificationUri: string;
|
|
8
|
+
readonly verificationUriComplete: string | null;
|
|
9
|
+
readonly expiresAt: ISODateTime;
|
|
10
|
+
readonly intervalSeconds: number;
|
|
11
|
+
}
|
|
12
|
+
export interface DiscoveredAuthorizationServer {
|
|
13
|
+
readonly issuer: string;
|
|
14
|
+
readonly authorizationEndpoint: string | null;
|
|
15
|
+
readonly tokenEndpoint: string;
|
|
16
|
+
readonly deviceAuthorizationEndpoint: string | null;
|
|
17
|
+
readonly registrationEndpoint: string | null;
|
|
18
|
+
readonly scopesSupported: readonly string[];
|
|
19
|
+
readonly grantTypesSupported: readonly string[];
|
|
20
|
+
readonly codeChallengeMethodsSupported: readonly string[];
|
|
21
|
+
readonly tokenEndpointAuthMethodsSupported: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export interface DiscoveredOAuthConfiguration {
|
|
24
|
+
readonly server: DiscoveredAuthorizationServer;
|
|
25
|
+
readonly resourceScopes: readonly string[];
|
|
26
|
+
/** Pass to grant APIs as the RFC 8707 resource; absent when no resource metadata was found. */
|
|
27
|
+
readonly resource?: string | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** A new registry starts empty. Returned snapshots cannot mutate its stored configuration. */
|
|
30
|
+
export interface OAuthProviderRegistry {
|
|
31
|
+
register(requiredArgs: {
|
|
32
|
+
readonly descriptor: OAuthProviderDescriptor;
|
|
33
|
+
}): void;
|
|
34
|
+
list(requiredArgs: OAuthEmptyArgs): readonly OAuthProviderDescriptor[];
|
|
35
|
+
get(requiredArgs: {
|
|
36
|
+
readonly providerId: string;
|
|
37
|
+
}): OAuthProviderDescriptor;
|
|
38
|
+
}
|
|
39
|
+
export interface AuthorizationCallbackParams {
|
|
40
|
+
readonly state: string;
|
|
41
|
+
readonly code?: string;
|
|
42
|
+
readonly error?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Explicit input for operations without values or dependencies. */
|
|
45
|
+
export type OAuthEmptyArgs = Readonly<Record<string, never>>;
|
|
46
|
+
//# sourceMappingURL=details.d.ts.map
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Type-only signature closure of the OAuth flow operations, moved from `@jini-ai/oauth`
|
|
3
|
+
* (args.ts, pending-authorizations.ts, sealed-state.ts, authorization-code.ts, token-endpoint.ts,
|
|
4
|
+
* device-code.ts, discovery-policy.ts, discovery.ts, refresh.ts, registration.ts, registry.ts at
|
|
5
|
+
* Jini 6ab1d818) so a consumer can depend on the operations through an injected value without
|
|
6
|
+
* importing the OAuth runtime. `@jini-ai/oauth` re-exports every name it exported before.
|
|
7
|
+
*/
|
|
8
|
+
import type { Clock, ISODateTime } from '../../primitives/index.js';
|
|
9
|
+
import type { DeviceAuthorization, DiscoveredOAuthConfiguration, OAuthEmptyArgs, OAuthProviderRegistry, AuthorizationCallbackParams } from './details.js';
|
|
10
|
+
import type { OAuthAppOptions, OAuthClient, OAuthClientAuthMethod, OAuthHttpPorts, OAuthProviderDescriptor, OAuthRandomBytes, OAuthResource, OAuthSleep, OAuthTokenSet, OAuthUrlGuard, RegisteredOAuthClient, TokenRefreshPort } from '../oauth.js';
|
|
11
|
+
/**
|
|
12
|
+
* Host-replaceable neutral OAuth copy; `@jini-ai/oauth` `defaultOAuthMessages` is the stock value.
|
|
13
|
+
* @agent-note Fulfilled by the host or by `defaultOAuthMessages`; message text never changes protocol identity or error codes.
|
|
14
|
+
*/
|
|
15
|
+
export interface OAuthMessages {
|
|
16
|
+
readonly reservedAuthorizationParameter: ({ parameter }: {
|
|
17
|
+
readonly parameter: string;
|
|
18
|
+
}) => string;
|
|
19
|
+
readonly reservedAuthorizationParameterAction: string;
|
|
20
|
+
readonly registrationRejectedAction: string;
|
|
21
|
+
}
|
|
22
|
+
/** Separate required inputs from optional settings on every public operation. */
|
|
23
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
24
|
+
export type OAuthRequiredArgs<T> = Pick<T, {
|
|
25
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
26
|
+
}[keyof T]>;
|
|
27
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
28
|
+
export type OAuthOptionalArgs<T> = Pick<T, {
|
|
29
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
30
|
+
}[keyof T]>;
|
|
31
|
+
/** Keep codeVerifier secret and preserve redirectUri and optional resource binding verbatim. */
|
|
32
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
33
|
+
export interface PendingAuthorization {
|
|
34
|
+
readonly state: string;
|
|
35
|
+
readonly ownerKey: string;
|
|
36
|
+
readonly providerId: string;
|
|
37
|
+
readonly codeVerifier: string;
|
|
38
|
+
readonly redirectUri: string;
|
|
39
|
+
readonly scopes: readonly string[];
|
|
40
|
+
readonly resource?: OAuthResource;
|
|
41
|
+
readonly createdAt: ISODateTime;
|
|
42
|
+
readonly expiresAt: ISODateTime;
|
|
43
|
+
}
|
|
44
|
+
/** take must atomically consume across processes and use the same error for every redemption failure. */
|
|
45
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
46
|
+
export interface PendingAuthorizationStore {
|
|
47
|
+
put(requiredArgs: OAuthRequiredArgs<Omit<PendingAuthorization, "state" | "createdAt" | "expiresAt">>, optionalArgs?: OAuthOptionalArgs<Omit<PendingAuthorization, "state" | "createdAt" | "expiresAt">>): Promise<PendingAuthorization>;
|
|
48
|
+
take(input: {
|
|
49
|
+
state: string;
|
|
50
|
+
ownerKey: string;
|
|
51
|
+
}): Promise<PendingAuthorization>;
|
|
52
|
+
size(requiredArgs: OAuthEmptyArgs): Promise<number>;
|
|
53
|
+
}
|
|
54
|
+
/** Host adapter uses its existing authenticated sealer and context AAD; no crypto lives here. */
|
|
55
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
56
|
+
export interface AuthorizationStateCodec {
|
|
57
|
+
seal(requiredArgs: {
|
|
58
|
+
plaintext: string;
|
|
59
|
+
}, optionalArgs?: Record<string, never>): Promise<string>;
|
|
60
|
+
open(requiredArgs: {
|
|
61
|
+
state: string;
|
|
62
|
+
}, optionalArgs?: Record<string, never>): Promise<string>;
|
|
63
|
+
}
|
|
64
|
+
type AuthorizationEntry = Omit<PendingAuthorization, 'state' | 'createdAt' | 'expiresAt'>;
|
|
65
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
66
|
+
export interface SealedAuthorizationState {
|
|
67
|
+
seal(requiredArgs: {
|
|
68
|
+
entry: AuthorizationEntry;
|
|
69
|
+
}, optionalArgs?: Record<string, never>): Promise<PendingAuthorization>;
|
|
70
|
+
open(requiredArgs: {
|
|
71
|
+
state: string;
|
|
72
|
+
ownerKey: string;
|
|
73
|
+
providerId: string;
|
|
74
|
+
redirectUri: string;
|
|
75
|
+
}, optionalArgs?: Record<string, never>): Promise<PendingAuthorization>;
|
|
76
|
+
}
|
|
77
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
78
|
+
export interface BeginAuthorizationCodeDeps {
|
|
79
|
+
readonly provider: OAuthProviderDescriptor;
|
|
80
|
+
readonly pending: PendingAuthorizationStore;
|
|
81
|
+
readonly randomBytesFn: OAuthRandomBytes;
|
|
82
|
+
readonly guard: OAuthUrlGuard;
|
|
83
|
+
readonly options: OAuthAppOptions;
|
|
84
|
+
}
|
|
85
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
86
|
+
export interface BeginAuthorizationCodeInput {
|
|
87
|
+
readonly messages?: OAuthMessages;
|
|
88
|
+
readonly ownerKey: string;
|
|
89
|
+
readonly client: OAuthClient;
|
|
90
|
+
readonly redirectUri: string;
|
|
91
|
+
readonly resource?: OAuthResource;
|
|
92
|
+
readonly scopes?: readonly string[];
|
|
93
|
+
readonly extraAuthorizationParams?: Readonly<Record<string, string>>;
|
|
94
|
+
}
|
|
95
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
96
|
+
export interface BeginAuthorizationCodeResult {
|
|
97
|
+
readonly authorizationUrl: string;
|
|
98
|
+
readonly state: string;
|
|
99
|
+
readonly expiresAt: string;
|
|
100
|
+
}
|
|
101
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
102
|
+
export type BeginAuthorizationCodeArgs = OAuthRequiredArgs<Omit<BeginAuthorizationCodeDeps, 'pending'> & BeginAuthorizationCodeInput> & ({
|
|
103
|
+
pending: PendingAuthorizationStore;
|
|
104
|
+
} | {
|
|
105
|
+
stateless: SealedAuthorizationState;
|
|
106
|
+
});
|
|
107
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
108
|
+
export interface CompleteAuthorizationCodeDeps extends TokenRequestDeps {
|
|
109
|
+
readonly provider: OAuthProviderDescriptor;
|
|
110
|
+
readonly pending: PendingAuthorizationStore;
|
|
111
|
+
}
|
|
112
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
113
|
+
export interface CompleteAuthorizationCodeInput {
|
|
114
|
+
readonly ownerKey: string;
|
|
115
|
+
readonly client: OAuthClient;
|
|
116
|
+
readonly params: AuthorizationCallbackParams;
|
|
117
|
+
readonly timeoutMs?: number;
|
|
118
|
+
}
|
|
119
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
120
|
+
export type CompleteAuthorizationCodeArgs = OAuthRequiredArgs<Omit<CompleteAuthorizationCodeDeps, 'pending'> & CompleteAuthorizationCodeInput> & ({
|
|
121
|
+
pending: PendingAuthorizationStore;
|
|
122
|
+
} | {
|
|
123
|
+
stateless: SealedAuthorizationState;
|
|
124
|
+
redirectUri: string;
|
|
125
|
+
});
|
|
126
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
127
|
+
export interface TokenRequestDeps extends OAuthHttpPorts {
|
|
128
|
+
readonly clock: Clock;
|
|
129
|
+
}
|
|
130
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
131
|
+
export interface DeviceAuthorizationDeps extends OAuthHttpPorts {
|
|
132
|
+
readonly provider: OAuthProviderDescriptor;
|
|
133
|
+
readonly clock: Clock;
|
|
134
|
+
}
|
|
135
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
136
|
+
export interface BeginDeviceAuthorizationInput {
|
|
137
|
+
readonly resource?: OAuthResource;
|
|
138
|
+
readonly client: OAuthClient;
|
|
139
|
+
readonly scopes?: readonly string[];
|
|
140
|
+
readonly timeoutMs?: number;
|
|
141
|
+
}
|
|
142
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
143
|
+
export interface PollDeviceAuthorizationInput {
|
|
144
|
+
readonly resource?: OAuthResource;
|
|
145
|
+
readonly client: OAuthClient;
|
|
146
|
+
readonly deviceCode: string;
|
|
147
|
+
readonly expiresAt: ISODateTime;
|
|
148
|
+
readonly timeoutMs?: number;
|
|
149
|
+
}
|
|
150
|
+
/** A host chooses its metadata trust policy separately from its outbound URL policy. */
|
|
151
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
152
|
+
export interface OAuthDiscoveryPolicy {
|
|
153
|
+
assertMetadata(requiredArgs: {
|
|
154
|
+
issuer: string;
|
|
155
|
+
document: Readonly<Record<string, unknown>>;
|
|
156
|
+
}): void;
|
|
157
|
+
}
|
|
158
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
159
|
+
export interface OAuthDiscoveryDeps extends OAuthHttpPorts {
|
|
160
|
+
}
|
|
161
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
162
|
+
export interface DiscoverAuthorizationServerInput {
|
|
163
|
+
readonly resourceUrl: string;
|
|
164
|
+
readonly wwwAuthenticate?: string;
|
|
165
|
+
/** Origin-wide fallback is opt-in so a tenant cannot silently select another issuer. */
|
|
166
|
+
readonly allowOriginFallback?: boolean;
|
|
167
|
+
readonly timeoutMs?: number;
|
|
168
|
+
readonly metadataPolicy?: OAuthDiscoveryPolicy | 'none';
|
|
169
|
+
}
|
|
170
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
171
|
+
export interface TokenRefresherDeps {
|
|
172
|
+
readonly clock: Clock;
|
|
173
|
+
readonly port: TokenRefreshPort;
|
|
174
|
+
readonly refreshSkewMs?: number;
|
|
175
|
+
readonly leaseWaitMs?: number;
|
|
176
|
+
readonly leasePollMs?: number;
|
|
177
|
+
readonly sleep: OAuthSleep;
|
|
178
|
+
}
|
|
179
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
180
|
+
export interface TokenRefresher {
|
|
181
|
+
getAccessToken(requiredArgs: {
|
|
182
|
+
readonly key: string;
|
|
183
|
+
}): Promise<string>;
|
|
184
|
+
inFlightCount(requiredArgs: OAuthEmptyArgs): number;
|
|
185
|
+
}
|
|
186
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
187
|
+
export interface RefreshAccessTokenInput {
|
|
188
|
+
readonly tokenEndpoint: string;
|
|
189
|
+
readonly client: OAuthClient;
|
|
190
|
+
readonly refreshToken: string;
|
|
191
|
+
readonly scopes?: readonly string[];
|
|
192
|
+
readonly resource?: OAuthResource;
|
|
193
|
+
readonly timeoutMs?: number;
|
|
194
|
+
}
|
|
195
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
196
|
+
export interface DynamicClientRegistrationDeps extends OAuthHttpPorts {
|
|
197
|
+
readonly options: OAuthAppOptions;
|
|
198
|
+
}
|
|
199
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
200
|
+
export interface DynamicClientRegistrationInput {
|
|
201
|
+
readonly messages?: OAuthMessages;
|
|
202
|
+
readonly registrationEndpoint: string;
|
|
203
|
+
readonly scopes: readonly string[];
|
|
204
|
+
readonly grantTypes?: readonly string[];
|
|
205
|
+
readonly responseTypes?: readonly string[];
|
|
206
|
+
readonly tokenEndpointAuthMethod?: OAuthClientAuthMethod;
|
|
207
|
+
readonly authMethodsSupported?: readonly string[];
|
|
208
|
+
readonly initialAccessToken?: string;
|
|
209
|
+
readonly timeoutMs?: number;
|
|
210
|
+
}
|
|
211
|
+
/** @agent-note Moved from `@jini-ai/oauth` unchanged (it re-exports this name); part of the `OAuthFlowOperations` signature closure, fulfilled by `@jini-ai/oauth` or a conforming host implementation. */
|
|
212
|
+
export interface OperatorOAuthProviderInput {
|
|
213
|
+
readonly providerId: string;
|
|
214
|
+
readonly label: string;
|
|
215
|
+
readonly tokenEndpoint: string;
|
|
216
|
+
readonly authorizationEndpoint?: string;
|
|
217
|
+
readonly deviceAuthorizationEndpoint?: string;
|
|
218
|
+
readonly scopes?: readonly string[];
|
|
219
|
+
readonly clientAuth?: OAuthProviderDescriptor["clientAuth"];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The eleven OAuth flow operations a host binds as ONE value (`@jini-ai/oauth` `oauthFlowOperations`).
|
|
223
|
+
* @agent-note Fulfilled by the host from `@jini-ai/oauth`'s `oauthFlowOperations` (one value per composition, `satisfies` this type);
|
|
224
|
+
* consumers call only the members they need and never re-implement PKCE, state, pending storage or refresh leases. Errors thrown
|
|
225
|
+
* are the OAuth package's real `OAuthError` instances (identity, codes and retryability preserved); classify them only through a
|
|
226
|
+
* host-injected classifier bound to that class.
|
|
227
|
+
*/
|
|
228
|
+
export interface OAuthFlowOperations {
|
|
229
|
+
beginAuthorizationCode(requiredArgs: BeginAuthorizationCodeArgs, optionalArgs?: OAuthOptionalArgs<BeginAuthorizationCodeDeps & BeginAuthorizationCodeInput>): Promise<BeginAuthorizationCodeResult>;
|
|
230
|
+
beginDeviceAuthorization(requiredArgs: OAuthRequiredArgs<DeviceAuthorizationDeps & BeginDeviceAuthorizationInput>, optionalArgs?: OAuthOptionalArgs<DeviceAuthorizationDeps & BeginDeviceAuthorizationInput>): Promise<DeviceAuthorization>;
|
|
231
|
+
buildOperatorOAuthProvider(requiredArgs: OAuthRequiredArgs<OperatorOAuthProviderInput> & {
|
|
232
|
+
readonly guard: OAuthUrlGuard;
|
|
233
|
+
}, optionalArgs?: OAuthOptionalArgs<OperatorOAuthProviderInput>): OAuthProviderDescriptor;
|
|
234
|
+
completeAuthorizationCode(requiredArgs: CompleteAuthorizationCodeArgs, optionalArgs?: OAuthOptionalArgs<CompleteAuthorizationCodeDeps & CompleteAuthorizationCodeInput>): Promise<OAuthTokenSet>;
|
|
235
|
+
createSealedAuthorizationState(requiredArgs: {
|
|
236
|
+
clock: Clock;
|
|
237
|
+
codec: AuthorizationStateCodec;
|
|
238
|
+
workspaceId: string;
|
|
239
|
+
serverId: string;
|
|
240
|
+
}, optionalArgs?: {
|
|
241
|
+
principalId?: string;
|
|
242
|
+
}): SealedAuthorizationState;
|
|
243
|
+
createTokenRefresher(deps: OAuthRequiredArgs<TokenRefresherDeps>, optionalArgs?: OAuthOptionalArgs<TokenRefresherDeps>): TokenRefresher;
|
|
244
|
+
discoverAuthorizationServer(requiredArgs: OAuthRequiredArgs<OAuthDiscoveryDeps & DiscoverAuthorizationServerInput>, optionalArgs?: OAuthOptionalArgs<OAuthDiscoveryDeps & DiscoverAuthorizationServerInput>): Promise<DiscoveredOAuthConfiguration>;
|
|
245
|
+
createOAuthProviderRegistry(deps: {
|
|
246
|
+
readonly guard: OAuthUrlGuard;
|
|
247
|
+
}): OAuthProviderRegistry;
|
|
248
|
+
refreshAccessToken(requiredArgs: OAuthRequiredArgs<TokenRequestDeps & RefreshAccessTokenInput>, optionalArgs?: OAuthOptionalArgs<TokenRequestDeps & RefreshAccessTokenInput>): Promise<OAuthTokenSet>;
|
|
249
|
+
pollDeviceAuthorizationOnce(requiredArgs: OAuthRequiredArgs<DeviceAuthorizationDeps & TokenRequestDeps & PollDeviceAuthorizationInput>, optionalArgs?: OAuthOptionalArgs<DeviceAuthorizationDeps & TokenRequestDeps & PollDeviceAuthorizationInput>): Promise<OAuthTokenSet>;
|
|
250
|
+
registerOAuthClientDynamically(requiredArgs: OAuthRequiredArgs<DynamicClientRegistrationDeps & DynamicClientRegistrationInput>, optionalArgs?: OAuthOptionalArgs<DynamicClientRegistrationDeps & DynamicClientRegistrationInput>): Promise<RegisteredOAuthClient>;
|
|
251
|
+
}
|
|
252
|
+
export {};
|
|
253
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** @agent-note Types only. The runtime parts come from the host; this area usually from `@jini-ai/oauth`. */
|
|
2
|
+
import type { ISODateTime } from '../primitives/index.js';
|
|
3
|
+
/** OAuth value types and required effect boundaries. No host or vendor types enter this module. */
|
|
4
|
+
export type OAuthGrantKind = "authorization_code" | "device_code";
|
|
5
|
+
export type OAuthClientAuthMethod = "none" | "client_secret_post" | "client_secret_basic";
|
|
6
|
+
/** A provider declares endpoints and grant capability; it contains no client or token secrets. */
|
|
7
|
+
export interface OAuthProviderDescriptor {
|
|
8
|
+
readonly providerId: string;
|
|
9
|
+
readonly label: string;
|
|
10
|
+
readonly supportedGrants: readonly OAuthGrantKind[];
|
|
11
|
+
readonly authorizationEndpoint?: string;
|
|
12
|
+
readonly tokenEndpoint: string;
|
|
13
|
+
readonly deviceAuthorizationEndpoint?: string;
|
|
14
|
+
readonly defaultScopes: readonly string[];
|
|
15
|
+
readonly usesPkce: boolean;
|
|
16
|
+
readonly clientAuth: OAuthClientAuthMethod;
|
|
17
|
+
}
|
|
18
|
+
/** Per-request identity: explicit public, POST-secret or HTTP Basic authentication. */
|
|
19
|
+
export interface OAuthClient {
|
|
20
|
+
readonly clientId: string;
|
|
21
|
+
readonly clientSecret?: string;
|
|
22
|
+
readonly authMethod: OAuthClientAuthMethod;
|
|
23
|
+
}
|
|
24
|
+
/** Normalized token set. Expiry is absolute; null means the provider gave no lifetime. */
|
|
25
|
+
export interface OAuthTokenSet {
|
|
26
|
+
readonly accessToken: string;
|
|
27
|
+
/** Sensitive, unvalidated OIDC token. Validate with validateOidcIdToken before trusting identity. */
|
|
28
|
+
readonly idToken?: string;
|
|
29
|
+
/** Secret; null means the provider did not issue one. */
|
|
30
|
+
readonly refreshToken: string | null;
|
|
31
|
+
readonly tokenType: string;
|
|
32
|
+
readonly scopes: readonly string[];
|
|
33
|
+
readonly expiresAt: ISODateTime | null;
|
|
34
|
+
}
|
|
35
|
+
/** Trusted OIDC configuration supplied by the host, never inferred from a token or token URL. */
|
|
36
|
+
export interface OidcTrustConfiguration {
|
|
37
|
+
readonly issuer: string;
|
|
38
|
+
readonly jwksUri: string;
|
|
39
|
+
readonly clientId: string;
|
|
40
|
+
}
|
|
41
|
+
/** Claims returned only after issuer, audience, time, nonce and application signature validation. */
|
|
42
|
+
export interface OidcIdTokenClaims {
|
|
43
|
+
readonly iss: string;
|
|
44
|
+
readonly sub: string;
|
|
45
|
+
readonly aud: string | readonly string[];
|
|
46
|
+
readonly iat: number;
|
|
47
|
+
readonly exp: number;
|
|
48
|
+
readonly nonce?: string;
|
|
49
|
+
readonly auth_time?: number;
|
|
50
|
+
readonly azp?: string;
|
|
51
|
+
readonly [claim: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
/** Digital signatures only; MACs and unsigned ID tokens cannot establish issuer identity here. */
|
|
54
|
+
export type OidcSigningAlgorithm = 'RS256' | 'RS384' | 'RS512' | 'PS256' | 'PS384' | 'PS512' | 'ES256' | 'ES384' | 'ES512' | 'EdDSA' | 'Ed25519';
|
|
55
|
+
export type OAuthTokenTypeHint = 'access_token' | 'refresh_token';
|
|
56
|
+
/** HTTP port. Must honor redirect refusal, abort signals and the application DNS/egress policy. */
|
|
57
|
+
export type OAuthFetch = (requiredArgs: {
|
|
58
|
+
readonly url: string | URL | Request;
|
|
59
|
+
}, optionalArgs?: RequestInit) => Promise<Response>;
|
|
60
|
+
/** Cryptographic entropy port. Return exactly the requested number of bytes; never use Math.random. */
|
|
61
|
+
export type OAuthRandomBytes = (requiredArgs: {
|
|
62
|
+
readonly byteLength: number;
|
|
63
|
+
}) => Uint8Array;
|
|
64
|
+
/** Application identity is explicit and has no library defaults. */
|
|
65
|
+
export interface OAuthAppOptions {
|
|
66
|
+
readonly clientDisplayName: string;
|
|
67
|
+
readonly redirectUris: readonly string[];
|
|
68
|
+
readonly softwareId: string;
|
|
69
|
+
}
|
|
70
|
+
/** A synchronous URL policy. Connection-time DNS enforcement belongs in the paired fetch port. */
|
|
71
|
+
export interface OAuthUrlGuard {
|
|
72
|
+
assertSafeUrl(requiredArgs: {
|
|
73
|
+
readonly raw: string;
|
|
74
|
+
readonly label: string;
|
|
75
|
+
}): URL;
|
|
76
|
+
}
|
|
77
|
+
/** Required outbound HTTP and safety ports; callers adapt their native fetch to the object contract. */
|
|
78
|
+
export interface OAuthHttpPorts {
|
|
79
|
+
readonly fetchFn: OAuthFetch;
|
|
80
|
+
readonly guard: OAuthUrlGuard;
|
|
81
|
+
}
|
|
82
|
+
/** Injected wait operation used only by the refresh-lease coordinator. */
|
|
83
|
+
export type OAuthSleep = (requiredArgs: {
|
|
84
|
+
readonly ms: number;
|
|
85
|
+
}) => Promise<void>;
|
|
86
|
+
/** RFC 8707 permits multiple resource indicators. These are identifiers, never fetched here. */
|
|
87
|
+
export type OAuthResource = string | readonly string[];
|
|
88
|
+
/** Application-owned token persistence, durable status transitions and optional refresh leases. */
|
|
89
|
+
export interface OAuthTokenStore {
|
|
90
|
+
load(requiredArgs: {
|
|
91
|
+
readonly key: string;
|
|
92
|
+
}): Promise<OAuthTokenSet | null>;
|
|
93
|
+
persist(requiredArgs: {
|
|
94
|
+
readonly key: string;
|
|
95
|
+
readonly tokens: OAuthTokenSet;
|
|
96
|
+
}): Promise<void>;
|
|
97
|
+
markNeedsReauth(requiredArgs: {
|
|
98
|
+
readonly key: string;
|
|
99
|
+
readonly reason: string;
|
|
100
|
+
}): Promise<void>;
|
|
101
|
+
tryAcquireRefreshLease?(requiredArgs: {
|
|
102
|
+
readonly key: string;
|
|
103
|
+
}): Promise<boolean>;
|
|
104
|
+
releaseRefreshLease?(requiredArgs: {
|
|
105
|
+
readonly key: string;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
/** The refresh operation and its store must use the same connection identity. */
|
|
109
|
+
export interface TokenRefreshPort extends OAuthTokenStore {
|
|
110
|
+
refresh(requiredArgs: {
|
|
111
|
+
readonly key: string;
|
|
112
|
+
readonly refreshToken: string;
|
|
113
|
+
}): Promise<OAuthTokenSet>;
|
|
114
|
+
}
|
|
115
|
+
/** Normalized registration data shared by registration and the host-owned cache. */
|
|
116
|
+
export interface RegisteredOAuthClient {
|
|
117
|
+
readonly clientId: string;
|
|
118
|
+
readonly clientSecret: string | null;
|
|
119
|
+
readonly tokenEndpointAuthMethod: OAuthClientAuthMethod;
|
|
120
|
+
readonly registrationClientUri: string | null;
|
|
121
|
+
readonly clientIdIssuedAt: number | null;
|
|
122
|
+
readonly clientSecretExpiresAt: number | null;
|
|
123
|
+
}
|
|
124
|
+
/** Registration values can contain client secrets; adapters must protect them accordingly. */
|
|
125
|
+
export interface ClientRegistrationCache {
|
|
126
|
+
get(requiredArgs: {
|
|
127
|
+
readonly key: string;
|
|
128
|
+
}): Promise<RegisteredOAuthClient | null>;
|
|
129
|
+
set(requiredArgs: {
|
|
130
|
+
readonly key: string;
|
|
131
|
+
readonly client: RegisteredOAuthClient;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
delete(requiredArgs: {
|
|
134
|
+
readonly key: string;
|
|
135
|
+
}): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
export type * from './oauth/details.js';
|
|
138
|
+
export type * from './oauth/flow.js';
|
|
139
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** @agent-note Types only. The runtime parts come from the host; this area usually from `@jini-ai/platform`. */
|
|
2
|
+
import type { SealedSecret } from "../vault.js";
|
|
3
|
+
/** Generation identity only: a sealed record never carries root-key bytes. */
|
|
4
|
+
export interface RootKeyHandle {
|
|
5
|
+
readonly keyId: string;
|
|
6
|
+
}
|
|
7
|
+
/** Swappable root-key adapter with two stable HKDF info layouts. */
|
|
8
|
+
export interface KeyringPort {
|
|
9
|
+
activeKey(_required: Record<string, never>): Promise<RootKeyHandle>;
|
|
10
|
+
deriveSigningSecret(input: {
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
subscriptionId: string;
|
|
13
|
+
version: number;
|
|
14
|
+
}): Promise<Uint8Array>;
|
|
15
|
+
derive(input: {
|
|
16
|
+
workspaceId: string;
|
|
17
|
+
purpose: string;
|
|
18
|
+
info: string;
|
|
19
|
+
}): Promise<Uint8Array>;
|
|
20
|
+
}
|
|
21
|
+
/** AAD binds new ciphertext to its context; absent open AAD supports historical records only. */
|
|
22
|
+
export interface SecretSealerPort {
|
|
23
|
+
seal(input: {
|
|
24
|
+
plaintext: string;
|
|
25
|
+
key: RootKeyHandle;
|
|
26
|
+
aad: string;
|
|
27
|
+
}): Promise<SealedSecret>;
|
|
28
|
+
open(input: {
|
|
29
|
+
sealed: SealedSecret;
|
|
30
|
+
}, optional?: {
|
|
31
|
+
aad?: string;
|
|
32
|
+
}): Promise<string>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ports.d.ts.map
|