@jini-ai/capability-providers 0.1.2 → 0.4.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +174 -0
  3. package/dist/adapters/blob-storage/index.d.ts +67 -0
  4. package/dist/adapters/blob-storage/index.js +62 -0
  5. package/dist/adapters/jwt-auth/index.d.ts +53 -0
  6. package/dist/adapters/jwt-auth/index.js +182 -0
  7. package/dist/adapters/sqlite/index.d.ts +56 -0
  8. package/dist/adapters/sqlite/index.js +83 -0
  9. package/dist/adapters/stripe/index.d.ts +94 -0
  10. package/dist/adapters/stripe/index.js +167 -0
  11. package/dist/adapters/ws/index.d.ts +95 -0
  12. package/dist/adapters/ws/index.js +161 -0
  13. package/dist/auth.d.ts +22 -47
  14. package/dist/auth.js +10 -173
  15. package/dist/db.d.ts +11 -48
  16. package/dist/db.js +15 -79
  17. package/dist/index.d.ts +54 -1
  18. package/dist/index.js +54 -1
  19. package/dist/payments.d.ts +21 -74
  20. package/dist/payments.js +13 -175
  21. package/dist/realtime.d.ts +24 -73
  22. package/dist/realtime.js +14 -140
  23. package/dist/storage.d.ts +23 -49
  24. package/dist/storage.js +13 -57
  25. package/dist/tokens.js +6 -6
  26. package/dist/unsafe-reference/auth.d.ts +1 -1
  27. package/dist/unsafe-reference/auth.js +3 -3
  28. package/dist/unsafe-reference/db.d.ts +2 -2
  29. package/dist/unsafe-reference/index.d.ts +1 -1
  30. package/dist/unsafe-reference/index.js +1 -1
  31. package/dist/unsafe-reference/payments.d.ts +3 -1
  32. package/dist/unsafe-reference/payments.js +6 -5
  33. package/dist/unsafe-reference/realtime.d.ts +1 -1
  34. package/dist/unsafe-reference/realtime.js +4 -4
  35. package/dist/unsafe-reference/storage.d.ts +3 -1
  36. package/dist/unsafe-reference/storage.js +7 -6
  37. package/dist/visitor-auth/definitions.d.ts +32 -0
  38. package/dist/visitor-auth/definitions.js +57 -0
  39. package/dist/visitor-auth/index.d.ts +17 -0
  40. package/dist/visitor-auth/index.js +17 -0
  41. package/dist/visitor-auth/lifecycle.d.ts +101 -0
  42. package/dist/visitor-auth/lifecycle.js +326 -0
  43. package/dist/visitor-auth/ports.d.ts +134 -0
  44. package/dist/visitor-auth/ports.js +2 -0
  45. package/dist/visitor-auth/registry.d.ts +38 -0
  46. package/dist/visitor-auth/registry.js +78 -0
  47. package/dist/visitor-auth/tokens.d.ts +10 -0
  48. package/dist/visitor-auth/tokens.js +9 -0
  49. package/package.json +66 -9
  50. package/dist/auth.d.ts.map +0 -1
  51. package/dist/auth.js.map +0 -1
  52. package/dist/db.d.ts.map +0 -1
  53. package/dist/db.js.map +0 -1
  54. package/dist/index.d.ts.map +0 -1
  55. package/dist/index.js.map +0 -1
  56. package/dist/payments.d.ts.map +0 -1
  57. package/dist/payments.js.map +0 -1
  58. package/dist/realtime.d.ts.map +0 -1
  59. package/dist/realtime.js.map +0 -1
  60. package/dist/storage.d.ts.map +0 -1
  61. package/dist/storage.js.map +0 -1
  62. package/dist/tokens.d.ts.map +0 -1
  63. package/dist/tokens.js.map +0 -1
  64. package/dist/unsafe-reference/auth.d.ts.map +0 -1
  65. package/dist/unsafe-reference/auth.js.map +0 -1
  66. package/dist/unsafe-reference/db.d.ts.map +0 -1
  67. package/dist/unsafe-reference/db.js.map +0 -1
  68. package/dist/unsafe-reference/index.d.ts.map +0 -1
  69. package/dist/unsafe-reference/index.js.map +0 -1
  70. package/dist/unsafe-reference/payments.d.ts.map +0 -1
  71. package/dist/unsafe-reference/payments.js.map +0 -1
  72. package/dist/unsafe-reference/realtime.d.ts.map +0 -1
  73. package/dist/unsafe-reference/realtime.js.map +0 -1
  74. package/dist/unsafe-reference/storage.d.ts.map +0 -1
  75. package/dist/unsafe-reference/storage.js.map +0 -1
package/dist/storage.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * `StorageProvider` — a swappable blob-storage port (file uploads, generated
3
- * assets). Speculative port-design exploration (see `source-map.md`) — no OD
3
+ * assets). Speculative port-design exploration (see `archived provenance ledger`) — no OD
4
4
  * source; the shape is the object-storage capability Zana's `app-chassis`
5
- * (`packages/storage`) and Tovu-Runner's ports layer both name explicitly.
5
+ * (`packages/storage`) and a fleet orchestrator's ports layer both name explicitly.
6
6
  *
7
- * This file defines the port's stable interface/type surface, plus one real,
8
- * production-quality adapter (`BlobStorageProvider`, added 2026-07-21 — see
9
- * `source-map.md`'s dated section). The in-memory reference implementation
10
- * (`createInMemoryStorageProvider`) is a separate, non-production stub that
11
- * lives under `src/unsafe-reference/`, exported only from the separate
12
- * `@jini-ai/capability-providers/unsafe-reference` entry point — see that
13
- * directory's `index.ts` header for the full warning.
7
+ * This file defines the port's stable interface/type surface and nothing else —
8
+ * it has no imports at all, so a consumer implementing `StorageProvider`
9
+ * themselves installs nothing. The one real, production-quality adapter
10
+ * (`BlobStorageProvider`, delegating to `@jini-ai/platform`'s `BlobStorage`)
11
+ * lives at the separate `@jini-ai/capability-providers/adapters/blob-storage`
12
+ * entry point; the non-production in-memory reference stub
13
+ * (`createInMemoryStorageProvider`) lives under `src/unsafe-reference/`,
14
+ * exported only from `@jini-ai/capability-providers/unsafe-reference`.
14
15
  */
15
- import type { BlobStorage } from '@jini-ai/platform';
16
16
  export interface StorageObjectMeta {
17
17
  readonly key: string;
18
18
  readonly size: number;
@@ -24,47 +24,21 @@ export interface StoragePutOptions {
24
24
  }
25
25
  export interface StorageProvider {
26
26
  /** Writes `data` at `key`, overwriting any existing object. */
27
- put(key: string, data: Uint8Array, options?: StoragePutOptions): Promise<StorageObjectMeta>;
27
+ put(required: {
28
+ key: string;
29
+ data: Uint8Array;
30
+ }, options?: StoragePutOptions): Promise<StorageObjectMeta>;
28
31
  /** Reads the object at `key`, or `null` if it doesn't exist. */
29
- get(key: string): Promise<Uint8Array | null>;
32
+ get(required: {
33
+ key: string;
34
+ }): Promise<Uint8Array | null>;
30
35
  /** Deletes the object at `key`. A no-op if it doesn't exist. */
31
- delete(key: string): Promise<void>;
36
+ delete(required: {
37
+ key: string;
38
+ }): Promise<void>;
32
39
  /** Lists objects whose key starts with `prefix` (all objects when `prefix` is omitted), sorted by key. */
33
- list(prefix?: string): Promise<StorageObjectMeta[]>;
34
- }
35
- export interface BlobStorageProviderOptions {
36
- /**
37
- * The `BlobStorage` namespace this provider scopes every `StorageProvider` key under (see
38
- * `BlobStorage`'s own module doc: "a tenant id, a workspace id, a project id, whatever the
39
- * host application scopes storage by"). `StorageProvider`'s `key` maps 1:1 onto `BlobStorage`'s
40
- * `relpath` within this fixed namespace — this adapter does not expose namespace switching,
41
- * matching `StorageProvider`'s single flat `key` surface (bind a separate `BlobStorageProvider`
42
- * per namespace if a host needs more than one).
43
- */
44
- readonly namespace: string;
45
- }
46
- /**
47
- * `StorageProvider` adapter that delegates to an injected `BlobStorage` instance
48
- * (`@jini-ai/platform`'s real, tested port — `LocalBlobStorage` or `S3BlobStorage`). A thin
49
- * method-shape mapping, not a reimplementation: every operation is one `BlobStorage` call plus
50
- * field renaming (`path`→`key`, `mtimeMs`→`updatedAt`).
51
- *
52
- * Known limitation: `BlobFileMeta` (the metadata `BlobStorage` actually persists) has no
53
- * `contentType` field, so `StoragePutOptions.contentType` cannot be durably stored — `put()`
54
- * echoes it straight back in the `StorageObjectMeta` it returns (matching the option the caller
55
- * just passed), but a later `get`-equivalent lookup (`list()`) can never recover it, since
56
- * nothing under `../platform` persists it. `StorageObjectMeta.contentType` is optional
57
- * specifically so an adapter is free to omit it when the backing store can't carry it — this is
58
- * a deliberate, documented adapter-level gap, not a `StorageProvider` interface change.
59
- */
60
- export declare class BlobStorageProvider implements StorageProvider {
61
- private readonly blobStorage;
62
- private readonly options;
63
- constructor(blobStorage: BlobStorage, options: BlobStorageProviderOptions);
64
- put(key: string, data: Uint8Array, options?: StoragePutOptions): Promise<StorageObjectMeta>;
65
- get(key: string): Promise<Uint8Array | null>;
66
- delete(key: string): Promise<void>;
67
- list(prefix?: string): Promise<StorageObjectMeta[]>;
68
- private toObjectMeta;
40
+ list(required: Record<string, never>, optional?: {
41
+ prefix?: string;
42
+ }): Promise<StorageObjectMeta[]>;
69
43
  }
70
44
  //# sourceMappingURL=storage.d.ts.map
package/dist/storage.js CHANGED
@@ -1,61 +1,17 @@
1
- import { StorageError as BlobStorageError } from '@jini-ai/platform';
2
1
  /**
3
- * `StorageProvider` adapter that delegates to an injected `BlobStorage` instance
4
- * (`@jini-ai/platform`'s real, tested port — `LocalBlobStorage` or `S3BlobStorage`). A thin
5
- * method-shape mapping, not a reimplementation: every operation is one `BlobStorage` call plus
6
- * field renaming (`path`→`key`, `mtimeMs`→`updatedAt`).
2
+ * `StorageProvider` — a swappable blob-storage port (file uploads, generated
3
+ * assets). Speculative port-design exploration (see `archived provenance ledger`) — no OD
4
+ * source; the shape is the object-storage capability Zana's `app-chassis`
5
+ * (`packages/storage`) and a fleet orchestrator's ports layer both name explicitly.
7
6
  *
8
- * Known limitation: `BlobFileMeta` (the metadata `BlobStorage` actually persists) has no
9
- * `contentType` field, so `StoragePutOptions.contentType` cannot be durably stored — `put()`
10
- * echoes it straight back in the `StorageObjectMeta` it returns (matching the option the caller
11
- * just passed), but a later `get`-equivalent lookup (`list()`) can never recover it, since
12
- * nothing under `../platform` persists it. `StorageObjectMeta.contentType` is optional
13
- * specifically so an adapter is free to omit it when the backing store can't carry it — this is
14
- * a deliberate, documented adapter-level gap, not a `StorageProvider` interface change.
7
+ * This file defines the port's stable interface/type surface and nothing else —
8
+ * it has no imports at all, so a consumer implementing `StorageProvider`
9
+ * themselves installs nothing. The one real, production-quality adapter
10
+ * (`BlobStorageProvider`, delegating to `@jini-ai/platform`'s `BlobStorage`)
11
+ * lives at the separate `@jini-ai/capability-providers/adapters/blob-storage`
12
+ * entry point; the non-production in-memory reference stub
13
+ * (`createInMemoryStorageProvider`) lives under `src/unsafe-reference/`,
14
+ * exported only from `@jini-ai/capability-providers/unsafe-reference`.
15
15
  */
16
- export class BlobStorageProvider {
17
- blobStorage;
18
- options;
19
- constructor(blobStorage, options) {
20
- this.blobStorage = blobStorage;
21
- this.options = options;
22
- if (!options.namespace) {
23
- throw new Error('BlobStorageProvider requires a non-empty options.namespace');
24
- }
25
- }
26
- async put(key, data, options = {}) {
27
- const meta = await this.blobStorage.writeFile(this.options.namespace, key, Buffer.from(data));
28
- return this.toObjectMeta(meta, options.contentType);
29
- }
30
- async get(key) {
31
- try {
32
- return await this.blobStorage.readFile(this.options.namespace, key);
33
- }
34
- catch (err) {
35
- if (err instanceof BlobStorageError && err.code === 'NOT_FOUND')
36
- return null;
37
- throw err;
38
- }
39
- }
40
- async delete(key) {
41
- // `BlobStorage.deleteFile` is already documented idempotent (missing files don't throw),
42
- // matching `StorageProvider.delete`'s "no-op if it doesn't exist" contract directly.
43
- await this.blobStorage.deleteFile(this.options.namespace, key);
44
- }
45
- async list(prefix = '') {
46
- const files = await this.blobStorage.listFiles(this.options.namespace);
47
- return files
48
- .filter((file) => file.path.startsWith(prefix))
49
- .map((file) => this.toObjectMeta(file))
50
- .sort((a, b) => a.key.localeCompare(b.key));
51
- }
52
- toObjectMeta(meta, contentType) {
53
- return {
54
- key: meta.path,
55
- size: meta.size,
56
- updatedAt: meta.mtimeMs,
57
- ...(contentType !== undefined ? { contentType } : {}),
58
- };
59
- }
60
- }
16
+ export {};
61
17
  //# sourceMappingURL=storage.js.map
package/dist/tokens.js CHANGED
@@ -7,12 +7,12 @@
7
7
  *
8
8
  * These tokens are exported for a future consumer to `bind()` in its own
9
9
  * composition — this package itself does not bind them anywhere, and
10
- * nothing else in this repo imports this package (see `source-map.md`).
10
+ * nothing else in this repo imports this package (see `archived provenance ledger`).
11
11
  */
12
12
  import { token } from '@jini-ai/core';
13
- export const AuthProviderToken = token('jini.capabilityProviders.auth');
14
- export const StorageProviderToken = token('jini.capabilityProviders.storage');
15
- export const PaymentsProviderToken = token('jini.capabilityProviders.payments');
16
- export const DbProviderToken = token('jini.capabilityProviders.db');
17
- export const RealtimeProviderToken = token('jini.capabilityProviders.realtime');
13
+ export const AuthProviderToken = token({ id: 'jini.capabilityProviders.auth' });
14
+ export const StorageProviderToken = token({ id: 'jini.capabilityProviders.storage' });
15
+ export const PaymentsProviderToken = token({ id: 'jini.capabilityProviders.payments' });
16
+ export const DbProviderToken = token({ id: 'jini.capabilityProviders.db' });
17
+ export const RealtimeProviderToken = token({ id: 'jini.capabilityProviders.realtime' });
18
18
  //# sourceMappingURL=tokens.js.map
@@ -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 `source-map.md`).
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/source-map.md` and
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/source-map.md` and
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(): PaymentsProvider;
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: Date.now(),
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(): StorageProvider;
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: Date.now(),
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