@jini-ai/capability-providers 0.1.2 → 0.4.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 +101 -0
- package/README.md +174 -0
- package/dist/adapters/blob-storage/index.d.ts +67 -0
- package/dist/adapters/blob-storage/index.js +62 -0
- package/dist/adapters/jwt-auth/index.d.ts +53 -0
- package/dist/adapters/jwt-auth/index.js +182 -0
- package/dist/adapters/sqlite/index.d.ts +56 -0
- package/dist/adapters/sqlite/index.js +83 -0
- package/dist/adapters/stripe/index.d.ts +94 -0
- package/dist/adapters/stripe/index.js +167 -0
- package/dist/adapters/ws/index.d.ts +95 -0
- package/dist/adapters/ws/index.js +161 -0
- package/dist/auth.d.ts +18 -47
- package/dist/auth.js +11 -178
- package/dist/db.d.ts +9 -51
- package/dist/db.js +10 -79
- package/dist/index.d.ts +8 -13
- package/dist/index.js +8 -13
- package/dist/payments.d.ts +18 -75
- package/dist/payments.js +10 -176
- package/dist/realtime.d.ts +20 -74
- package/dist/realtime.js +10 -141
- package/dist/storage.d.ts +22 -51
- package/dist/storage.js +10 -57
- package/dist/tokens.js +7 -16
- package/dist/unsafe-reference/auth.d.ts +1 -1
- package/dist/unsafe-reference/auth.js +3 -3
- package/dist/unsafe-reference/db.d.ts +2 -2
- package/dist/unsafe-reference/index.d.ts +1 -1
- package/dist/unsafe-reference/index.js +1 -1
- package/dist/unsafe-reference/payments.d.ts +3 -1
- package/dist/unsafe-reference/payments.js +6 -5
- package/dist/unsafe-reference/realtime.d.ts +1 -1
- package/dist/unsafe-reference/realtime.js +4 -4
- package/dist/unsafe-reference/storage.d.ts +3 -1
- package/dist/unsafe-reference/storage.js +7 -6
- package/dist/visitor-auth/definitions.d.ts +32 -0
- package/dist/visitor-auth/definitions.js +57 -0
- package/dist/visitor-auth/index.d.ts +17 -0
- package/dist/visitor-auth/index.js +17 -0
- package/dist/visitor-auth/lifecycle.d.ts +101 -0
- package/dist/visitor-auth/lifecycle.js +326 -0
- package/dist/visitor-auth/ports.d.ts +134 -0
- package/dist/visitor-auth/ports.js +2 -0
- package/dist/visitor-auth/registry.d.ts +38 -0
- package/dist/visitor-auth/registry.js +78 -0
- package/dist/visitor-auth/tokens.d.ts +10 -0
- package/dist/visitor-auth/tokens.js +9 -0
- package/package.json +79 -8
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/db.d.ts.map +0 -1
- package/dist/db.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/payments.d.ts.map +0 -1
- package/dist/payments.js.map +0 -1
- package/dist/realtime.d.ts.map +0 -1
- package/dist/realtime.js.map +0 -1
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js.map +0 -1
- package/dist/tokens.d.ts.map +0 -1
- package/dist/tokens.js.map +0 -1
- package/dist/unsafe-reference/auth.d.ts.map +0 -1
- package/dist/unsafe-reference/auth.js.map +0 -1
- package/dist/unsafe-reference/db.d.ts.map +0 -1
- package/dist/unsafe-reference/db.js.map +0 -1
- package/dist/unsafe-reference/index.d.ts.map +0 -1
- package/dist/unsafe-reference/index.js.map +0 -1
- package/dist/unsafe-reference/payments.d.ts.map +0 -1
- package/dist/unsafe-reference/payments.js.map +0 -1
- package/dist/unsafe-reference/realtime.d.ts.map +0 -1
- package/dist/unsafe-reference/realtime.js.map +0 -1
- package/dist/unsafe-reference/storage.d.ts.map +0 -1
- package/dist/unsafe-reference/storage.js.map +0 -1
|
@@ -18,5 +18,5 @@ export interface InMemoryAuthProviderOptions {
|
|
|
18
18
|
readonly now?: () => number;
|
|
19
19
|
}
|
|
20
20
|
/** Creates the in-memory reference `AuthProvider`. No persistence — state is lost on process exit. */
|
|
21
|
-
export declare function createInMemoryAuthProvider(options?: InMemoryAuthProviderOptions): AuthProvider;
|
|
21
|
+
export declare function createInMemoryAuthProvider(_required: Record<string, never>, options?: InMemoryAuthProviderOptions): AuthProvider;
|
|
22
22
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const DEFAULT_SESSION_TTL_MS = 60 * 60 * 1000;
|
|
2
2
|
/** Creates the in-memory reference `AuthProvider`. No persistence — state is lost on process exit. */
|
|
3
|
-
export function createInMemoryAuthProvider(options = {}) {
|
|
3
|
+
export function createInMemoryAuthProvider(_required, options = {}) {
|
|
4
4
|
const sessionTtlMs = options.sessionTtlMs ?? DEFAULT_SESSION_TTL_MS;
|
|
5
5
|
const now = options.now ?? Date.now;
|
|
6
6
|
const usersByEmail = new Map();
|
|
@@ -34,10 +34,10 @@ export function createInMemoryAuthProvider(options = {}) {
|
|
|
34
34
|
sessions.set(session.token, session);
|
|
35
35
|
return session;
|
|
36
36
|
},
|
|
37
|
-
async signOut(token) {
|
|
37
|
+
async signOut({ token }) {
|
|
38
38
|
sessions.delete(token);
|
|
39
39
|
},
|
|
40
|
-
async verifySession(token) {
|
|
40
|
+
async verifySession({ token }) {
|
|
41
41
|
const session = sessions.get(token);
|
|
42
42
|
if (!session)
|
|
43
43
|
return null;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* `DbProvider` (defined in `../db.ts`) is implementable and unit-testable.
|
|
7
7
|
* Never wire this into anything that handles real user data.
|
|
8
8
|
*
|
|
9
|
-
* A real adapter (`@jini-ai/sqlite`, Supabase Postgres) implements the same
|
|
9
|
+
* A real adapter (`@jini-ai/sqlite-chat`, Supabase Postgres) implements the same
|
|
10
10
|
* `DbProvider` interface without importing this file — this is
|
|
11
|
-
* deliberately not that adapter (see the scope note in `
|
|
11
|
+
* deliberately not that adapter (see the scope note in `archived provenance ledger`).
|
|
12
12
|
*/
|
|
13
13
|
import type { DbProvider } from '../db.js';
|
|
14
14
|
/** Creates the in-memory reference `DbProvider`. No persistence — state is lost on process exit. */
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* requires opting in to this path by name, so they can't be pulled in by
|
|
38
38
|
* accident alongside the port interfaces/types and typed DI tokens (which
|
|
39
39
|
* *are* stable, safe-to-depend-on exports of the normal entry point). See
|
|
40
|
-
* `packages/capability-providers/
|
|
40
|
+
* `packages/capability-providers/archived provenance ledger` and
|
|
41
41
|
* `ADS-memory/reports/security/SEC-remaining-backend-audit-2026-07-21.md`
|
|
42
42
|
* finding SEC-RB-006 for the audit that prompted this split.
|
|
43
43
|
*/
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* requires opting in to this path by name, so they can't be pulled in by
|
|
38
38
|
* accident alongside the port interfaces/types and typed DI tokens (which
|
|
39
39
|
* *are* stable, safe-to-depend-on exports of the normal entry point). See
|
|
40
|
-
* `packages/capability-providers/
|
|
40
|
+
* `packages/capability-providers/archived provenance ledger` and
|
|
41
41
|
* `ADS-memory/reports/security/SEC-remaining-backend-audit-2026-07-21.md`
|
|
42
42
|
* finding SEC-RB-006 for the audit that prompted this split.
|
|
43
43
|
*/
|
|
@@ -13,5 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { PaymentsProvider } from '../payments.js';
|
|
15
15
|
/** Creates the in-memory reference `PaymentsProvider`. No persistence, no real money movement. */
|
|
16
|
-
export declare function createInMemoryPaymentsProvider(
|
|
16
|
+
export declare function createInMemoryPaymentsProvider(_required: Record<string, never>, optional?: {
|
|
17
|
+
now?: () => number;
|
|
18
|
+
}): PaymentsProvider;
|
|
17
19
|
//# sourceMappingURL=payments.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** Creates the in-memory reference `PaymentsProvider`. No persistence, no real money movement. */
|
|
2
|
-
export function createInMemoryPaymentsProvider() {
|
|
2
|
+
export function createInMemoryPaymentsProvider(_required, optional = {}) {
|
|
3
|
+
const now = optional.now ?? Date.now;
|
|
3
4
|
const charges = new Map();
|
|
4
5
|
let nextChargeId = 1;
|
|
5
6
|
return {
|
|
6
|
-
async charge(input) {
|
|
7
|
+
async charge(input, optional = {}) {
|
|
7
8
|
if (input.amountCents <= 0) {
|
|
8
9
|
throw new Error('amountCents must be positive');
|
|
9
10
|
}
|
|
@@ -13,15 +14,15 @@ export function createInMemoryPaymentsProvider() {
|
|
|
13
14
|
amountCents: input.amountCents,
|
|
14
15
|
currency: input.currency,
|
|
15
16
|
customerRef: input.customerRef,
|
|
16
|
-
createdAt:
|
|
17
|
+
createdAt: now(),
|
|
17
18
|
};
|
|
18
19
|
charges.set(record.id, record);
|
|
19
20
|
return record;
|
|
20
21
|
},
|
|
21
|
-
async getCharge(id) {
|
|
22
|
+
async getCharge({ id }) {
|
|
22
23
|
return charges.get(id) ?? null;
|
|
23
24
|
},
|
|
24
|
-
async refund(id) {
|
|
25
|
+
async refund({ id }) {
|
|
25
26
|
const existing = charges.get(id);
|
|
26
27
|
if (!existing) {
|
|
27
28
|
throw new Error(`unknown charge: ${id}`);
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { RealtimeProvider } from '../realtime.js';
|
|
15
15
|
/** Creates the in-memory reference `RealtimeProvider`. Delivery is in-process only — no cross-process fan-out. */
|
|
16
|
-
export declare function createInMemoryRealtimeProvider(): RealtimeProvider;
|
|
16
|
+
export declare function createInMemoryRealtimeProvider(_required: Record<string, never>): RealtimeProvider;
|
|
17
17
|
//# sourceMappingURL=realtime.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Creates the in-memory reference `RealtimeProvider`. Delivery is in-process only — no cross-process fan-out. */
|
|
2
|
-
export function createInMemoryRealtimeProvider() {
|
|
2
|
+
export function createInMemoryRealtimeProvider(_required) {
|
|
3
3
|
const channels = new Map();
|
|
4
4
|
function subscribersFor(channel) {
|
|
5
5
|
let subscribers = channels.get(channel);
|
|
@@ -10,15 +10,15 @@ export function createInMemoryRealtimeProvider() {
|
|
|
10
10
|
return subscribers;
|
|
11
11
|
}
|
|
12
12
|
return {
|
|
13
|
-
async publish(channel, event) {
|
|
13
|
+
async publish({ channel, event }) {
|
|
14
14
|
const subscribers = channels.get(channel);
|
|
15
15
|
if (!subscribers)
|
|
16
16
|
return;
|
|
17
17
|
for (const handler of [...subscribers]) {
|
|
18
|
-
handler(event);
|
|
18
|
+
handler({ event });
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
subscribe(channel, handler) {
|
|
21
|
+
subscribe({ channel, handler }) {
|
|
22
22
|
const subscribers = subscribersFor(channel);
|
|
23
23
|
subscribers.add(handler);
|
|
24
24
|
let unsubscribed = false;
|
|
@@ -12,5 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { StorageProvider } from '../storage.js';
|
|
14
14
|
/** Creates the in-memory reference `StorageProvider`. No persistence — state is lost on process exit. */
|
|
15
|
-
export declare function createInMemoryStorageProvider(
|
|
15
|
+
export declare function createInMemoryStorageProvider(_required: Record<string, never>, optional?: {
|
|
16
|
+
now?: () => number;
|
|
17
|
+
}): StorageProvider;
|
|
16
18
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
/** Creates the in-memory reference `StorageProvider`. No persistence — state is lost on process exit. */
|
|
2
|
-
export function createInMemoryStorageProvider() {
|
|
2
|
+
export function createInMemoryStorageProvider(_required, optional = {}) {
|
|
3
|
+
const now = optional.now ?? Date.now;
|
|
3
4
|
const objects = new Map();
|
|
4
5
|
return {
|
|
5
|
-
async put(key, data, options = {}) {
|
|
6
|
+
async put({ key, data }, options = {}) {
|
|
6
7
|
const meta = {
|
|
7
8
|
key,
|
|
8
9
|
size: data.byteLength,
|
|
9
|
-
updatedAt:
|
|
10
|
+
updatedAt: now(),
|
|
10
11
|
...(options.contentType !== undefined ? { contentType: options.contentType } : {}),
|
|
11
12
|
};
|
|
12
13
|
objects.set(key, { data: data.slice(), meta });
|
|
13
14
|
return meta;
|
|
14
15
|
},
|
|
15
|
-
async get(key) {
|
|
16
|
+
async get({ key }) {
|
|
16
17
|
const entry = objects.get(key);
|
|
17
18
|
return entry ? entry.data.slice() : null;
|
|
18
19
|
},
|
|
19
|
-
async delete(key) {
|
|
20
|
+
async delete({ key }) {
|
|
20
21
|
objects.delete(key);
|
|
21
22
|
},
|
|
22
|
-
async list(prefix = '') {
|
|
23
|
+
async list(_required, { prefix = '' } = {}) {
|
|
23
24
|
return [...objects.values()]
|
|
24
25
|
.map((entry) => entry.meta)
|
|
25
26
|
.filter((meta) => meta.key.startsWith(prefix))
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral metadata for public-site visitor sign-in.
|
|
3
|
+
*
|
|
4
|
+
* These definitions describe configuration, not executable adapters. In
|
|
5
|
+
* particular, their presence does not mean that token exchange, ID-token
|
|
6
|
+
* verification, account linking, or session minting has been wired by a host.
|
|
7
|
+
*/
|
|
8
|
+
export type VisitorAuthProtocol = 'oauth2' | 'oidc';
|
|
9
|
+
export type VisitorAuthCredentialFieldKind = 'public' | 'secret';
|
|
10
|
+
export interface VisitorAuthCredentialFieldDefinition {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly kind: VisitorAuthCredentialFieldKind;
|
|
14
|
+
readonly required: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface VisitorAuthProviderDefinition {
|
|
17
|
+
/** Stable, open identifier. Third-party packages may register additional providers. */
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
readonly protocol: VisitorAuthProtocol;
|
|
21
|
+
readonly credentialSchema: readonly VisitorAuthCredentialFieldDefinition[];
|
|
22
|
+
readonly defaultScopes: readonly string[];
|
|
23
|
+
/** Standard discovery document when the provider publishes one. */
|
|
24
|
+
readonly discoveryUrl?: string;
|
|
25
|
+
/** Makes the current support boundary machine-readable and hard to overstate in a UI. */
|
|
26
|
+
readonly implementation: 'metadata-only';
|
|
27
|
+
}
|
|
28
|
+
export declare const GOOGLE_VISITOR_AUTH_PROVIDER: VisitorAuthProviderDefinition;
|
|
29
|
+
export declare const FACEBOOK_VISITOR_AUTH_PROVIDER: VisitorAuthProviderDefinition;
|
|
30
|
+
export declare const LINKEDIN_VISITOR_AUTH_PROVIDER: VisitorAuthProviderDefinition;
|
|
31
|
+
export declare const BUILT_IN_VISITOR_AUTH_PROVIDERS: readonly VisitorAuthProviderDefinition[];
|
|
32
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral metadata for public-site visitor sign-in.
|
|
3
|
+
*
|
|
4
|
+
* These definitions describe configuration, not executable adapters. In
|
|
5
|
+
* particular, their presence does not mean that token exchange, ID-token
|
|
6
|
+
* verification, account linking, or session minting has been wired by a host.
|
|
7
|
+
*/
|
|
8
|
+
function freezeProviderDefinition(definition) {
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
...definition,
|
|
11
|
+
credentialSchema: Object.freeze(definition.credentialSchema.map((field) => Object.freeze({ ...field }))),
|
|
12
|
+
defaultScopes: Object.freeze([...definition.defaultScopes]),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export const GOOGLE_VISITOR_AUTH_PROVIDER = freezeProviderDefinition({
|
|
16
|
+
id: 'google',
|
|
17
|
+
label: 'Google',
|
|
18
|
+
protocol: 'oidc',
|
|
19
|
+
credentialSchema: [
|
|
20
|
+
{ key: 'clientId', label: 'Client ID', kind: 'public', required: true },
|
|
21
|
+
{ key: 'clientSecret', label: 'Client secret', kind: 'secret', required: true },
|
|
22
|
+
],
|
|
23
|
+
defaultScopes: ['openid', 'profile', 'email'],
|
|
24
|
+
discoveryUrl: 'https://accounts.google.com/.well-known/openid-configuration',
|
|
25
|
+
implementation: 'metadata-only',
|
|
26
|
+
});
|
|
27
|
+
export const FACEBOOK_VISITOR_AUTH_PROVIDER = freezeProviderDefinition({
|
|
28
|
+
id: 'facebook',
|
|
29
|
+
label: 'Facebook',
|
|
30
|
+
protocol: 'oauth2',
|
|
31
|
+
credentialSchema: [
|
|
32
|
+
{ key: 'appId', label: 'App ID', kind: 'public', required: true },
|
|
33
|
+
{ key: 'appSecret', label: 'App secret', kind: 'secret', required: true },
|
|
34
|
+
],
|
|
35
|
+
defaultScopes: ['public_profile', 'email'],
|
|
36
|
+
// Facebook's endpoints are versioned. A concrete adapter must resolve and
|
|
37
|
+
// pin the supported Graph API version rather than this catalogue guessing it.
|
|
38
|
+
implementation: 'metadata-only',
|
|
39
|
+
});
|
|
40
|
+
export const LINKEDIN_VISITOR_AUTH_PROVIDER = freezeProviderDefinition({
|
|
41
|
+
id: 'linkedin',
|
|
42
|
+
label: 'LinkedIn',
|
|
43
|
+
protocol: 'oidc',
|
|
44
|
+
credentialSchema: [
|
|
45
|
+
{ key: 'clientId', label: 'Client ID', kind: 'public', required: true },
|
|
46
|
+
{ key: 'clientSecret', label: 'Client secret', kind: 'secret', required: true },
|
|
47
|
+
],
|
|
48
|
+
defaultScopes: ['openid', 'profile', 'email'],
|
|
49
|
+
discoveryUrl: 'https://www.linkedin.com/oauth/.well-known/openid-configuration',
|
|
50
|
+
implementation: 'metadata-only',
|
|
51
|
+
});
|
|
52
|
+
export const BUILT_IN_VISITOR_AUTH_PROVIDERS = Object.freeze([
|
|
53
|
+
GOOGLE_VISITOR_AUTH_PROVIDER,
|
|
54
|
+
FACEBOOK_VISITOR_AUTH_PROVIDER,
|
|
55
|
+
LINKEDIN_VISITOR_AUTH_PROVIDER,
|
|
56
|
+
]);
|
|
57
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@jini-ai/capability-providers/visitor-auth`
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe, provider-neutral contracts and pure OAuth/OIDC lifecycle
|
|
5
|
+
* decisions for public-site visitor/social login. This is intentionally
|
|
6
|
+
* distinct from the package root's local username/password `AuthProvider`,
|
|
7
|
+
* admin authentication, MCP client authentication, and API-token integrations.
|
|
8
|
+
*
|
|
9
|
+
* No provider SDK, HTTP client, persistence adapter, secret value, token
|
|
10
|
+
* verifier, account linker, or session implementation is exported here.
|
|
11
|
+
*/
|
|
12
|
+
export * from './definitions.js';
|
|
13
|
+
export * from './lifecycle.js';
|
|
14
|
+
export * from './ports.js';
|
|
15
|
+
export * from './registry.js';
|
|
16
|
+
export * from './tokens.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@jini-ai/capability-providers/visitor-auth`
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe, provider-neutral contracts and pure OAuth/OIDC lifecycle
|
|
5
|
+
* decisions for public-site visitor/social login. This is intentionally
|
|
6
|
+
* distinct from the package root's local username/password `AuthProvider`,
|
|
7
|
+
* admin authentication, MCP client authentication, and API-token integrations.
|
|
8
|
+
*
|
|
9
|
+
* No provider SDK, HTTP client, persistence adapter, secret value, token
|
|
10
|
+
* verifier, account linker, or session implementation is exported here.
|
|
11
|
+
*/
|
|
12
|
+
export * from './definitions.js';
|
|
13
|
+
export * from './lifecycle.js';
|
|
14
|
+
export * from './ports.js';
|
|
15
|
+
export * from './registry.js';
|
|
16
|
+
export * from './tokens.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { VisitorAuthProviderDefinition } from './definitions.js';
|
|
2
|
+
import type { VisitorAuthAuthorizationServer, VisitorAuthClientRegistration, VisitorAuthSecurityArtifacts, VisitorAuthTokenExchangeRequest, VisitorAuthTransaction, VisitorAuthVerifiedIdTokenClaims } from './ports.js';
|
|
3
|
+
export type VisitorAuthConfigurationErrorCode = 'invalid-input' | 'insecure-url' | 'provider-mismatch' | 'pkce-s256-required' | 'reserved-parameter';
|
|
4
|
+
export declare class VisitorAuthConfigurationError extends Error {
|
|
5
|
+
readonly code: VisitorAuthConfigurationErrorCode;
|
|
6
|
+
constructor({ code, message }: {
|
|
7
|
+
code: VisitorAuthConfigurationErrorCode;
|
|
8
|
+
message: string;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export interface VisitorAuthAuthorizationPlan {
|
|
12
|
+
readonly authorizationUrl: string;
|
|
13
|
+
readonly transaction: VisitorAuthTransaction;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Produces a side-effect-free authorization plan. The host persists the
|
|
17
|
+
* returned transaction before redirecting and must later consume it through
|
|
18
|
+
* `VisitorAuthTransactionStorePort` exactly once.
|
|
19
|
+
*
|
|
20
|
+
* @param required - Trusted provider/server/registration metadata, browser binding, and fresh security artifacts.
|
|
21
|
+
* @param optional - Bounded transaction lifetime and non-reserved provider parameters.
|
|
22
|
+
* @returns A redirect URL and the sensitive transaction the host must seal before redirecting.
|
|
23
|
+
* @throws {VisitorAuthConfigurationError} When configuration or security material fails closed.
|
|
24
|
+
* @complexity Time and space: O(s + p), where s is scope count and p is extra parameters.
|
|
25
|
+
*/
|
|
26
|
+
export declare function planVisitorAuthAuthorization(required: {
|
|
27
|
+
readonly provider: VisitorAuthProviderDefinition;
|
|
28
|
+
readonly server: VisitorAuthAuthorizationServer;
|
|
29
|
+
readonly registration: VisitorAuthClientRegistration;
|
|
30
|
+
readonly redirectUri: string;
|
|
31
|
+
readonly flowBinding: string;
|
|
32
|
+
readonly security: VisitorAuthSecurityArtifacts;
|
|
33
|
+
readonly nowMs: number;
|
|
34
|
+
}, optional?: {
|
|
35
|
+
readonly ttlMs?: number;
|
|
36
|
+
readonly extraParameters?: Readonly<Record<string, string>>;
|
|
37
|
+
}): VisitorAuthAuthorizationPlan;
|
|
38
|
+
export interface VisitorAuthCallbackParameters {
|
|
39
|
+
readonly state?: string;
|
|
40
|
+
readonly code?: string;
|
|
41
|
+
readonly issuer?: string;
|
|
42
|
+
readonly error?: string;
|
|
43
|
+
readonly errorDescription?: string;
|
|
44
|
+
}
|
|
45
|
+
export type VisitorAuthCallbackRejectionReason = 'expired' | 'flow-binding-mismatch' | 'issuer-mismatch' | 'missing-code' | 'provider-error' | 'state-mismatch' | 'tenant-mismatch';
|
|
46
|
+
export type VisitorAuthCallbackDecision = {
|
|
47
|
+
readonly decision: 'exchange';
|
|
48
|
+
readonly request: VisitorAuthTokenExchangeRequest;
|
|
49
|
+
} | {
|
|
50
|
+
readonly decision: 'reject';
|
|
51
|
+
readonly reason: VisitorAuthCallbackRejectionReason;
|
|
52
|
+
/** Provider error code only; descriptions are intentionally not propagated. */
|
|
53
|
+
readonly providerError?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Evaluates an already atomically consumed transaction. It produces a token
|
|
57
|
+
* exchange request only after every browser, tenant, expiry, state, and issuer
|
|
58
|
+
* binding succeeds; it performs no HTTP and creates no identity/session.
|
|
59
|
+
*
|
|
60
|
+
* @param required - Consumed transaction, parsed callback fields, current tenant/browser binding, and injected time.
|
|
61
|
+
* @returns A discriminated exchange or rejection decision; expected callback failures never throw.
|
|
62
|
+
* @complexity Time and space: O(1).
|
|
63
|
+
*/
|
|
64
|
+
export declare function evaluateVisitorAuthCallback(required: {
|
|
65
|
+
readonly transaction: VisitorAuthTransaction;
|
|
66
|
+
readonly callback: VisitorAuthCallbackParameters;
|
|
67
|
+
readonly tenantId: string;
|
|
68
|
+
readonly flowBinding: string;
|
|
69
|
+
readonly nowMs: number;
|
|
70
|
+
}): VisitorAuthCallbackDecision;
|
|
71
|
+
export type VisitorAuthIdentityClaimsRejectionReason = 'audience-mismatch' | 'authorized-party-mismatch' | 'expired' | 'issuer-mismatch' | 'malformed-claims' | 'nonce-mismatch' | 'subject-missing';
|
|
72
|
+
export type VisitorAuthIdentityClaimsDecision = {
|
|
73
|
+
readonly decision: 'accept';
|
|
74
|
+
readonly identity: {
|
|
75
|
+
readonly providerId: string;
|
|
76
|
+
readonly subject: string;
|
|
77
|
+
readonly email?: string;
|
|
78
|
+
readonly emailVerified?: boolean;
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
readonly decision: 'reject';
|
|
82
|
+
readonly reason: VisitorAuthIdentityClaimsRejectionReason;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Applies OIDC semantic checks to claims returned by
|
|
86
|
+
* `VisitorAuthIdTokenVerifierPort` after cryptographic verification.
|
|
87
|
+
*
|
|
88
|
+
* @param required - The consumed OIDC transaction, verified claims, and injected epoch time.
|
|
89
|
+
* @param optional - A bounded clock-skew allowance (default 60 seconds, maximum 300).
|
|
90
|
+
* @returns A provider-subject identity only after issuer, audience, expiry, and nonce checks pass.
|
|
91
|
+
* @throws {VisitorAuthConfigurationError} When the caller supplies an invalid skew policy.
|
|
92
|
+
* @complexity Time: O(a); space: O(a), where a is the number of audiences.
|
|
93
|
+
*/
|
|
94
|
+
export declare function validateVisitorAuthIdentityClaims(required: {
|
|
95
|
+
readonly transaction: VisitorAuthTransaction;
|
|
96
|
+
readonly claims: VisitorAuthVerifiedIdTokenClaims;
|
|
97
|
+
readonly nowSeconds: number;
|
|
98
|
+
}, optional?: {
|
|
99
|
+
readonly clockSkewSeconds?: number;
|
|
100
|
+
}): VisitorAuthIdentityClaimsDecision;
|
|
101
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|