@stdiobus/workers-registry 1.4.14 → 1.5.0-beta.2

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 (129) hide show
  1. package/README.md +181 -21
  2. package/out/dist/workers-registry/acp-registry/index.js +128 -2
  3. package/out/dist/workers-registry/acp-registry/index.js.map +4 -4
  4. package/out/dist/workers-registry/acp-worker/index.js +1 -3
  5. package/out/dist/workers-registry/acp-worker/index.js.map +4 -4
  6. package/out/dist/workers-registry/index.d.ts +1 -0
  7. package/out/dist/workers-registry/index.js +6 -0
  8. package/out/dist/workers-registry/openai-agent/index.js +1 -1
  9. package/out/dist/workers-registry/openai-agent/index.js.map +2 -2
  10. package/out/dist/workers-registry/registry-launcher/index.js +131 -0
  11. package/out/dist/workers-registry/registry-launcher/index.js.map +7 -0
  12. package/out/tsc/workers-registry/acp-worker/src/index.d.ts +0 -10
  13. package/out/tsc/workers-registry/registry-launcher/src/auth/auth-manager.d.ts +392 -0
  14. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/cli.property.test.d.ts +22 -0
  15. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/index.d.ts +9 -0
  16. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/login-command.d.ts +32 -0
  17. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/logout-command.d.ts +25 -0
  18. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/setup-command.d.ts +25 -0
  19. package/out/tsc/workers-registry/registry-launcher/src/auth/cli/status-command.d.ts +21 -0
  20. package/out/tsc/workers-registry/registry-launcher/src/auth/errors.d.ts +190 -0
  21. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/agent-auth-flow.d.ts +146 -0
  22. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/callback-server.d.ts +131 -0
  23. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/callback-server.test.d.ts +1 -0
  24. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/index.d.ts +11 -0
  25. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/terminal-auth-flow.d.ts +252 -0
  26. package/out/tsc/workers-registry/registry-launcher/src/auth/flows/terminal-auth-flow.test.d.ts +1 -0
  27. package/out/tsc/workers-registry/registry-launcher/src/auth/index.d.ts +33 -0
  28. package/out/tsc/workers-registry/registry-launcher/src/auth/integration.test.d.ts +1 -0
  29. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/anthropic-api-key.d.ts +154 -0
  30. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/index.d.ts +20 -0
  31. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/model-credentials.test.d.ts +1 -0
  32. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/openai-api-key.d.ts +182 -0
  33. package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/types.d.ts +186 -0
  34. package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.d.ts +61 -0
  35. package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.property.test.d.ts +1 -0
  36. package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.test.d.ts +1 -0
  37. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/base-provider.d.ts +138 -0
  38. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/base-provider.test.d.ts +1 -0
  39. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/cognito-provider.d.ts +44 -0
  40. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/concrete-providers.test.d.ts +1 -0
  41. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/entra-provider.d.ts +54 -0
  42. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/github-provider.d.ts +19 -0
  43. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/google-provider.d.ts +19 -0
  44. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/index.d.ts +107 -0
  45. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/index.test.d.ts +1 -0
  46. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.d.ts +413 -0
  47. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.property.test.d.ts +1 -0
  48. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.test.d.ts +1 -0
  49. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/providers.property.test.d.ts +1 -0
  50. package/out/tsc/workers-registry/registry-launcher/src/auth/providers/types.d.ts +28 -0
  51. package/out/tsc/workers-registry/registry-launcher/src/auth/session.d.ts +251 -0
  52. package/out/tsc/workers-registry/registry-launcher/src/auth/session.property.test.d.ts +1 -0
  53. package/out/tsc/workers-registry/registry-launcher/src/auth/session.test.d.ts +1 -0
  54. package/out/tsc/workers-registry/registry-launcher/src/auth/state.d.ts +26 -0
  55. package/out/tsc/workers-registry/registry-launcher/src/auth/state.property.test.d.ts +1 -0
  56. package/out/tsc/workers-registry/registry-launcher/src/auth/state.test.d.ts +1 -0
  57. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/credential-store.d.ts +98 -0
  58. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/credential-store.test.d.ts +1 -0
  59. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/encrypted-file-backend.d.ts +101 -0
  60. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/encrypted-file-backend.test.d.ts +1 -0
  61. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/index.d.ts +12 -0
  62. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/keychain-backend.d.ts +80 -0
  63. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/keychain-backend.test.d.ts +1 -0
  64. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/memory-backend.d.ts +54 -0
  65. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/storage.property.test.d.ts +1 -0
  66. package/out/tsc/workers-registry/registry-launcher/src/auth/storage/types.d.ts +44 -0
  67. package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.d.ts +171 -0
  68. package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.property.test.d.ts +1 -0
  69. package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.test.d.ts +1 -0
  70. package/out/tsc/workers-registry/registry-launcher/src/auth/types.d.ts +369 -0
  71. package/out/tsc/workers-registry/registry-launcher/src/auth/types.test.d.ts +1 -0
  72. package/out/tsc/workers-registry/registry-launcher/src/config/config.property.test.d.ts +1 -0
  73. package/out/tsc/workers-registry/registry-launcher/src/config/config.test.d.ts +1 -0
  74. package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/index.d.ts +51 -2
  75. package/out/tsc/workers-registry/registry-launcher/src/registry/index.property.test.d.ts +1 -0
  76. package/out/tsc/workers-registry/registry-launcher/src/registry/index.test.d.ts +1 -0
  77. package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/types.d.ts +24 -0
  78. package/out/tsc/workers-registry/registry-launcher/src/router/message-router.d.ts +770 -0
  79. package/out/tsc/workers-registry/registry-launcher/src/router/message-router.property.test.d.ts +1 -0
  80. package/out/tsc/workers-registry/registry-launcher/src/router/message-router.test.d.ts +1 -0
  81. package/out/tsc/workers-registry/registry-launcher/src/runtime/manager.property.test.d.ts +1 -0
  82. package/out/tsc/workers-registry/registry-launcher/src/runtime/manager.test.d.ts +1 -0
  83. package/out/tsc/workers-registry/registry-launcher/src/stream/ndjson-handler.property.test.d.ts +1 -0
  84. package/out/tsc/workers-registry/registry-launcher/src/stream/ndjson-handler.test.d.ts +1 -0
  85. package/out/tsc/workers-registry/registry-launcher/tests/e2e/auth-flow.e2e.test.d.ts +1 -0
  86. package/out/tsc/workers-registry/registry-launcher/tests/e2e/auth-required-flow.e2e.test.d.ts +1 -0
  87. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/api-keys.d.ts +32 -0
  88. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/index.d.ts +17 -0
  89. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/launcher-harness.d.ts +101 -0
  90. package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/registry-server.d.ts +46 -0
  91. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-agent-auth.e2e.test.d.ts +1 -0
  92. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-api-keys.e2e.test.d.ts +1 -0
  93. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-auth-required.e2e.test.d.ts +1 -0
  94. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-cli.e2e.test.d.ts +1 -0
  95. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-concurrent.e2e.test.d.ts +1 -0
  96. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-lifecycle.e2e.test.d.ts +1 -0
  97. package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-terminal-auth.e2e.test.d.ts +1 -0
  98. package/out/tsc/workers-registry/registry-launcher/tests/integration/agent-auth.integration.test.d.ts +9 -0
  99. package/out/tsc/workers-registry/registry-launcher/tests/integration/registry-launcher.test.d.ts +1 -0
  100. package/out/tsc/workers-registry/registry-launcher/tests/integration/terminal-auth.integration.test.d.ts +12 -0
  101. package/package.json +16 -11
  102. package/out/tsc/workers-registry/acp-worker/src/registry-launcher/router/message-router.d.ts +0 -199
  103. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/config/config.property.test.d.ts → registry-launcher/src/auth/auth-manager.property.test.d.ts} +0 -0
  104. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/config/config.test.d.ts → registry-launcher/src/auth/auth-manager.test.d.ts} +0 -0
  105. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/registry/index.property.test.d.ts → registry-launcher/src/auth/cli/cli.test.d.ts} +0 -0
  106. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/registry/index.test.d.ts → registry-launcher/src/auth/cli/login-command.test.d.ts} +0 -0
  107. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/router/message-router.property.test.d.ts → registry-launcher/src/auth/cli/provider-config.test.d.ts} +0 -0
  108. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/router/message-router.test.d.ts → registry-launcher/src/auth/cli/setup-command.test.d.ts} +0 -0
  109. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/runtime/manager.property.test.d.ts → registry-launcher/src/auth/cli/status-command.test.d.ts} +0 -0
  110. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/runtime/manager.test.d.ts → registry-launcher/src/auth/errors.property.test.d.ts} +0 -0
  111. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/stream/ndjson-handler.property.test.d.ts → registry-launcher/src/auth/errors.test.d.ts} +0 -0
  112. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher/stream/ndjson-handler.test.d.ts → registry-launcher/src/auth/flows/agent-auth-flow.test.d.ts} +0 -0
  113. /package/out/tsc/workers-registry/{acp-worker/tests/integration/registry-launcher.test.d.ts → registry-launcher/src/auth/flows/callback-server.property.test.d.ts} +0 -0
  114. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/api-keys.d.ts +0 -0
  115. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/config.d.ts +0 -0
  116. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/index.d.ts +0 -0
  117. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/types.d.ts +0 -0
  118. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/index.d.ts +0 -0
  119. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/log.d.ts +0 -0
  120. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/log.test.d.ts +0 -0
  121. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/resolver.d.ts +0 -0
  122. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/router/index.d.ts +0 -0
  123. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/agent-runtime.d.ts +0 -0
  124. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/index.d.ts +0 -0
  125. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/manager.d.ts +0 -0
  126. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/types.d.ts +0 -0
  127. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/stream/index.d.ts +0 -0
  128. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/stream/ndjson-handler.d.ts +0 -0
  129. /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/test-utils/index.d.ts +0 -0
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Type definitions for model API credentials.
3
+ *
4
+ * This module defines types for upstream model provider credentials (API keys).
5
+ * These providers (OpenAI, Anthropic) do NOT offer public OAuth IdP for
6
+ * third-party login - they use API keys instead.
7
+ *
8
+ * This separation clearly distinguishes:
9
+ * - User identity (OAuth/OIDC): Google, Microsoft Entra ID, AWS Cognito, GitHub, Generic OIDC
10
+ * - Model API access (API Keys): OpenAI, Anthropic
11
+ *
12
+ * Requirements: 7b.1, 7b.3
13
+ *
14
+ * @module model-credentials/types
15
+ */
16
+ /**
17
+ * Model API provider identifiers.
18
+ *
19
+ * These providers use API keys for authentication, NOT OAuth.
20
+ * They do not offer public OAuth IdP for third-party login.
21
+ *
22
+ * Requirements: 7b.1, 7b.2
23
+ */
24
+ export type ModelProviderId = 'openai' | 'anthropic';
25
+ /**
26
+ * Valid model provider IDs for runtime validation.
27
+ */
28
+ export declare const VALID_MODEL_PROVIDER_IDS: readonly ModelProviderId[];
29
+ /**
30
+ * Type guard to check if a value is a valid ModelProviderId.
31
+ *
32
+ * @param value - The value to check
33
+ * @returns True if the value is a valid ModelProviderId
34
+ */
35
+ export declare function isValidModelProviderId(value: unknown): value is ModelProviderId;
36
+ /**
37
+ * Model credential for storing API keys.
38
+ *
39
+ * Represents an API key credential for a model provider.
40
+ * These credentials are stored securely in the Credential_Store.
41
+ *
42
+ * Requirements: 7b.1, 7b.4
43
+ */
44
+ export interface ModelCredential {
45
+ /**
46
+ * The model provider this credential is for.
47
+ */
48
+ providerId: ModelProviderId;
49
+ /**
50
+ * The API key value.
51
+ * This is stored encrypted in the Credential_Store.
52
+ */
53
+ apiKey: string;
54
+ /**
55
+ * Optional human-readable label for this credential.
56
+ * Useful when multiple keys are stored for the same provider.
57
+ */
58
+ label?: string;
59
+ /**
60
+ * Unix timestamp when this credential was stored.
61
+ */
62
+ storedAt: number;
63
+ /**
64
+ * Optional Unix timestamp when this credential expires.
65
+ * Most API keys don't expire, but some providers may issue
66
+ * time-limited keys.
67
+ */
68
+ expiresAt?: number;
69
+ }
70
+ /**
71
+ * Header injection type for model credentials.
72
+ */
73
+ export interface HeaderInjection {
74
+ type: 'header';
75
+ /**
76
+ * The header name to use.
77
+ * e.g., 'Authorization' for OpenAI, 'x-api-key' for Anthropic
78
+ */
79
+ headerName: string;
80
+ /**
81
+ * Optional format string for the header value.
82
+ * Use '{key}' as placeholder for the API key.
83
+ * e.g., 'Bearer {key}' for OpenAI
84
+ * If not provided, the API key is used directly.
85
+ */
86
+ format?: string;
87
+ }
88
+ /**
89
+ * Model credential injection configuration.
90
+ *
91
+ * Defines how API keys should be injected into requests
92
+ * for each model provider.
93
+ *
94
+ * Requirements: 7b.5
95
+ */
96
+ export type ModelCredentialInjection = HeaderInjection;
97
+ /**
98
+ * Provider-specific injection configurations.
99
+ *
100
+ * OpenAI: Authorization header with Bearer token
101
+ * Anthropic: x-api-key header with raw key
102
+ *
103
+ * Requirements: 7b.5
104
+ */
105
+ export declare const MODEL_CREDENTIAL_INJECTION_CONFIG: Readonly<Record<ModelProviderId, ModelCredentialInjection>>;
106
+ /**
107
+ * Stored model credentials in the credential store.
108
+ *
109
+ * This is the format used when persisting model credentials
110
+ * to the Credential_Store.
111
+ *
112
+ * Requirements: 7b.4
113
+ */
114
+ export interface StoredModelCredential {
115
+ /**
116
+ * The model provider this credential is for.
117
+ */
118
+ providerId: ModelProviderId;
119
+ /**
120
+ * The encrypted API key value.
121
+ * Encryption is handled by the storage backend.
122
+ */
123
+ apiKey: string;
124
+ /**
125
+ * Optional human-readable label.
126
+ */
127
+ label?: string;
128
+ /**
129
+ * Unix timestamp when this credential was stored.
130
+ */
131
+ storedAt: number;
132
+ /**
133
+ * Optional Unix timestamp when this credential expires.
134
+ */
135
+ expiresAt?: number;
136
+ }
137
+ /**
138
+ * Result of a model credential retrieval operation.
139
+ */
140
+ export interface ModelCredentialResult {
141
+ /**
142
+ * Whether the credential was found.
143
+ */
144
+ found: boolean;
145
+ /**
146
+ * The credential, if found.
147
+ */
148
+ credential?: ModelCredential;
149
+ /**
150
+ * Error message if retrieval failed.
151
+ */
152
+ error?: string;
153
+ }
154
+ /**
155
+ * Status of a model credential.
156
+ */
157
+ export type ModelCredentialStatus = 'configured' | 'not-configured' | 'expired';
158
+ /**
159
+ * Model credential status entry for display.
160
+ */
161
+ export interface ModelCredentialStatusEntry {
162
+ /**
163
+ * The model provider.
164
+ */
165
+ providerId: ModelProviderId;
166
+ /**
167
+ * Current status of the credential.
168
+ */
169
+ status: ModelCredentialStatus;
170
+ /**
171
+ * Optional label for the credential.
172
+ */
173
+ label?: string;
174
+ /**
175
+ * Unix timestamp when the credential was stored.
176
+ */
177
+ storedAt?: number;
178
+ /**
179
+ * Unix timestamp when the credential expires.
180
+ */
181
+ expiresAt?: number;
182
+ }
183
+ /**
184
+ * Map of model provider IDs to their credential status.
185
+ */
186
+ export type ModelCredentialStatusMap = Map<ModelProviderId, ModelCredentialStatusEntry>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Minimum length for PKCE code verifier per RFC 7636.
3
+ */
4
+ export declare const PKCE_VERIFIER_MIN_LENGTH = 43;
5
+ /**
6
+ * Maximum length for PKCE code verifier per RFC 7636.
7
+ */
8
+ export declare const PKCE_VERIFIER_MAX_LENGTH = 128;
9
+ /**
10
+ * PKCE code challenge method.
11
+ * OAuth 2.1 requires S256 (SHA-256) method.
12
+ */
13
+ export declare const PKCE_CODE_CHALLENGE_METHOD: "S256";
14
+ /**
15
+ * Generate a cryptographically secure PKCE code verifier.
16
+ *
17
+ * The verifier is generated using crypto.randomBytes for cryptographic randomness,
18
+ * then encoded using only unreserved URI characters as specified in RFC 7636.
19
+ * Uses rejection sampling to avoid modulo bias.
20
+ *
21
+ * @param length - Optional length of the verifier (default: 64, must be 43-128)
22
+ * @returns A random string between 43-128 characters using unreserved URI characters
23
+ * @throws Error if length is outside the valid range (43-128) or not a valid integer
24
+ */
25
+ export declare function generateCodeVerifier(length?: number): string;
26
+ /**
27
+ * Validate a PKCE code verifier format.
28
+ *
29
+ * Checks that the verifier meets RFC 7636 requirements:
30
+ * - Length between 43 and 128 characters
31
+ * - Contains only unreserved URI characters
32
+ *
33
+ * @param verifier - The code verifier to validate
34
+ * @returns True if the verifier is valid, false otherwise
35
+ */
36
+ export declare function validateCodeVerifier(verifier: string): boolean;
37
+ /**
38
+ * Generate a PKCE code challenge from a code verifier.
39
+ *
40
+ * Computes the SHA-256 hash of the verifier and encodes it as base64url
41
+ * without padding, as required by RFC 7636 S256 method.
42
+ *
43
+ * @param verifier - The code verifier to hash
44
+ * @param strict - If true, validates verifier format (default: false for backward compatibility)
45
+ * @returns Base64url-encoded SHA-256 hash of the verifier (without padding)
46
+ * @throws Error if strict mode is enabled and verifier format is invalid
47
+ */
48
+ export declare function generateCodeChallenge(verifier: string, strict?: boolean): string;
49
+ /**
50
+ * Generate a PKCE pair (verifier and challenge).
51
+ *
52
+ * Creates a cryptographically secure code verifier and computes
53
+ * the corresponding S256 code challenge.
54
+ *
55
+ * @param length - Optional length of the verifier (default: 64, must be 43-128)
56
+ * @returns Object containing both the verifier and challenge
57
+ */
58
+ export declare function generatePKCEPair(length?: number): {
59
+ verifier: string;
60
+ challenge: string;
61
+ };
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Base OAuth 2.1 provider implementation.
3
+ *
4
+ * Provides common OAuth 2.1 URL building logic and HTTPS endpoint validation.
5
+ *
6
+ * @module providers/base-provider
7
+ */
8
+ import type { AuthProviderId, AuthorizationParams, TokenResponse, TokenInjectionMethod, ProviderEndpoints } from '../types.js';
9
+ import type { IAuthProvider } from './types.js';
10
+ /**
11
+ * Configuration for a base auth provider.
12
+ */
13
+ export interface BaseProviderConfig {
14
+ /** Unique provider identifier */
15
+ id: AuthProviderId;
16
+ /** Human-readable provider name */
17
+ name: string;
18
+ /** OAuth authorization endpoint URL */
19
+ authorizationEndpoint: string;
20
+ /** OAuth token endpoint URL */
21
+ tokenEndpoint: string;
22
+ /** Default scopes for this provider */
23
+ defaultScopes: string[];
24
+ /** Token injection method for agent requests */
25
+ tokenInjection: TokenInjectionMethod;
26
+ /** Client ID for OAuth flow */
27
+ clientId?: string;
28
+ /** Client secret for OAuth flow (optional, for confidential clients) */
29
+ clientSecret?: string;
30
+ }
31
+ /**
32
+ * Abstract base class for OAuth 2.1 providers.
33
+ *
34
+ * Implements common OAuth 2.1 functionality:
35
+ * - Authorization URL building with required parameters
36
+ * - HTTPS endpoint validation
37
+ * - Token exchange and refresh
38
+ *
39
+ * Requirements: 3.2, 3.6, 7.5
40
+ */
41
+ export declare abstract class BaseAuthProvider implements IAuthProvider {
42
+ readonly id: AuthProviderId;
43
+ readonly name: string;
44
+ readonly defaultScopes: readonly string[];
45
+ protected readonly authorizationEndpoint: string;
46
+ protected readonly tokenEndpoint: string;
47
+ protected readonly tokenInjection: TokenInjectionMethod;
48
+ protected clientId?: string;
49
+ protected clientSecret?: string;
50
+ /** Default timeout for HTTP requests in milliseconds (30 seconds) */
51
+ protected static readonly DEFAULT_REQUEST_TIMEOUT_MS = 30000;
52
+ /**
53
+ * Security-critical OAuth parameters that cannot be overridden by additionalParams.
54
+ * These parameters are set by the OAuth flow and must not be tampered with.
55
+ */
56
+ private static readonly PROTECTED_PARAMS;
57
+ /**
58
+ * Create a new base auth provider.
59
+ * @param config - Provider configuration
60
+ * @throws Error if endpoints are not HTTPS or contain embedded credentials
61
+ */
62
+ constructor(config: BaseProviderConfig);
63
+ /**
64
+ * Build the authorization URL for the OAuth flow.
65
+ *
66
+ * Includes all required OAuth 2.1 parameters:
67
+ * - client_id
68
+ * - redirect_uri
69
+ * - response_type=code
70
+ * - scope
71
+ * - state
72
+ * - code_challenge
73
+ * - code_challenge_method=S256
74
+ *
75
+ * @param params - Authorization parameters
76
+ * @returns The complete authorization URL
77
+ * @throws Error if additionalParams attempts to override protected parameters
78
+ */
79
+ buildAuthorizationUrl(params: AuthorizationParams): string;
80
+ /**
81
+ * Exchange authorization code for tokens.
82
+ *
83
+ * @param code - The authorization code from the callback
84
+ * @param codeVerifier - The PKCE code verifier
85
+ * @param redirectUri - The redirect URI used in the authorization request
86
+ * @returns The token response
87
+ */
88
+ exchangeCode(code: string, codeVerifier: string, redirectUri: string): Promise<TokenResponse>;
89
+ /**
90
+ * Refresh an access token using a refresh token.
91
+ *
92
+ * @param refreshToken - The refresh token
93
+ * @returns The new token response
94
+ */
95
+ refreshToken(refreshToken: string): Promise<TokenResponse>;
96
+ /**
97
+ * Validate provider configuration.
98
+ *
99
+ * Ensures all endpoints use HTTPS (required for OAuth 2.1).
100
+ *
101
+ * @throws Error if configuration is invalid
102
+ */
103
+ validateConfig(): void;
104
+ /**
105
+ * Get token injection method for agent requests.
106
+ *
107
+ * @returns The token injection configuration
108
+ */
109
+ getTokenInjection(): TokenInjectionMethod;
110
+ /**
111
+ * Get the provider endpoints.
112
+ *
113
+ * @returns The provider endpoint URLs
114
+ */
115
+ getEndpoints(): ProviderEndpoints;
116
+ /**
117
+ * Set the client credentials.
118
+ *
119
+ * @param clientId - The OAuth client ID
120
+ * @param clientSecret - The OAuth client secret (optional)
121
+ */
122
+ setClientCredentials(clientId: string, clientSecret?: string): void;
123
+ /**
124
+ * Validate that an endpoint uses HTTPS and has no embedded credentials.
125
+ *
126
+ * @param endpoint - The endpoint URL to validate
127
+ * @param name - The name of the endpoint (for error messages)
128
+ * @throws Error if the endpoint does not use HTTPS or contains embedded credentials
129
+ */
130
+ protected validateHttpsEndpoint(endpoint: string, name: string): void;
131
+ /**
132
+ * Parse a token response from the provider.
133
+ *
134
+ * @param data - The raw response data
135
+ * @returns The parsed token response
136
+ */
137
+ protected parseTokenResponse(data: Record<string, unknown>): TokenResponse;
138
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * AWS Cognito OAuth 2.1 provider implementation.
3
+ *
4
+ * @module providers/cognito-provider
5
+ */
6
+ import { BaseAuthProvider } from './base-provider.js';
7
+ /**
8
+ * Configuration options for Cognito provider.
9
+ */
10
+ export interface CognitoProviderConfig {
11
+ /** Cognito user pool domain (e.g., 'my-app' for my-app.auth.us-east-1.amazoncognito.com) */
12
+ userPoolDomain: string;
13
+ /** AWS region (e.g., 'us-east-1') */
14
+ region: string;
15
+ /** OAuth client ID */
16
+ clientId?: string;
17
+ /** OAuth client secret (optional) */
18
+ clientSecret?: string;
19
+ }
20
+ /**
21
+ * AWS Cognito OAuth provider.
22
+ *
23
+ * Endpoints are dynamically constructed based on user pool domain and region:
24
+ * - Authorization: https://{domain}.auth.{region}.amazoncognito.com/oauth2/authorize
25
+ * - Token: https://{domain}.auth.{region}.amazoncognito.com/oauth2/token
26
+ *
27
+ * Default scopes: openid, profile
28
+ * Token injection: Bearer header
29
+ */
30
+ export declare class CognitoProvider extends BaseAuthProvider {
31
+ constructor(config: CognitoProviderConfig);
32
+ /**
33
+ * Validate Cognito user pool domain name.
34
+ * @param domain - The user pool domain to validate
35
+ * @throws Error if domain is invalid or contains injection characters
36
+ */
37
+ private static validateUserPoolDomain;
38
+ /**
39
+ * Validate AWS region name.
40
+ * @param region - The AWS region to validate
41
+ * @throws Error if region is invalid or contains injection characters
42
+ */
43
+ private static validateRegion;
44
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Microsoft Entra ID (formerly Azure AD) OAuth 2.1 provider implementation.
3
+ *
4
+ * @module providers/entra-provider
5
+ */
6
+ import { BaseAuthProvider } from './base-provider.js';
7
+ /**
8
+ * Configuration options for Microsoft Entra ID provider.
9
+ *
10
+ * @remarks
11
+ * Microsoft renamed Azure AD to Microsoft Entra ID in 2023.
12
+ * This provider supports both single-tenant and multi-tenant configurations.
13
+ */
14
+ export interface EntraProviderConfig {
15
+ /** Microsoft Entra ID tenant ID or 'common' for multi-tenant */
16
+ tenantId: string;
17
+ /** OAuth client ID */
18
+ clientId?: string;
19
+ /** OAuth client secret (optional) */
20
+ clientSecret?: string;
21
+ }
22
+ /**
23
+ * @deprecated Use EntraProviderConfig instead. Kept for backward compatibility.
24
+ */
25
+ export type AzureProviderConfig = EntraProviderConfig;
26
+ /**
27
+ * Microsoft Entra ID (formerly Azure AD) OAuth provider.
28
+ *
29
+ * Endpoints are dynamically constructed based on tenant ID:
30
+ * - Authorization: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize
31
+ * - Token: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
32
+ *
33
+ * Use 'common' for multi-tenant applications.
34
+ *
35
+ * Default scopes: openid, profile
36
+ * Token injection: Bearer header
37
+ *
38
+ * @remarks
39
+ * The provider ID remains 'azure' for backward compatibility with existing
40
+ * configurations and the ACP Registry.
41
+ */
42
+ export declare class EntraIdProvider extends BaseAuthProvider {
43
+ constructor(config: EntraProviderConfig);
44
+ /**
45
+ * Validate Microsoft Entra ID tenant ID.
46
+ * @param tenantId - The tenant ID to validate
47
+ * @throws Error if tenantId is invalid or contains injection characters
48
+ */
49
+ private static validateTenantId;
50
+ }
51
+ /**
52
+ * @deprecated Use EntraIdProvider instead. Kept for backward compatibility.
53
+ */
54
+ export declare const AzureProvider: typeof EntraIdProvider;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * GitHub OAuth 2.1 provider implementation.
3
+ *
4
+ * @module providers/github-provider
5
+ */
6
+ import { BaseAuthProvider } from './base-provider.js';
7
+ /**
8
+ * GitHub OAuth provider.
9
+ *
10
+ * Endpoints:
11
+ * - Authorization: https://github.com/login/oauth/authorize
12
+ * - Token: https://github.com/login/oauth/access_token
13
+ *
14
+ * Default scopes: read:user
15
+ * Token injection: Bearer header
16
+ */
17
+ export declare class GitHubProvider extends BaseAuthProvider {
18
+ constructor(clientId?: string, clientSecret?: string);
19
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Google OAuth 2.1 provider implementation.
3
+ *
4
+ * @module providers/google-provider
5
+ */
6
+ import { BaseAuthProvider } from './base-provider.js';
7
+ /**
8
+ * Google OAuth provider.
9
+ *
10
+ * Endpoints:
11
+ * - Authorization: https://accounts.google.com/o/oauth2/v2/auth
12
+ * - Token: https://oauth2.googleapis.com/token
13
+ *
14
+ * Default scopes: openid, profile, email
15
+ * Token injection: Bearer header
16
+ */
17
+ export declare class GoogleProvider extends BaseAuthProvider {
18
+ constructor(clientId?: string, clientSecret?: string);
19
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Provider registry and factory.
3
+ *
4
+ * Provides access to OAuth provider implementations.
5
+ *
6
+ * @module providers
7
+ */
8
+ import type { AuthProviderId } from '../types.js';
9
+ import type { IAuthProvider } from './types.js';
10
+ /**
11
+ * Provider factory function type.
12
+ */
13
+ export type ProviderFactory = () => IAuthProvider;
14
+ /**
15
+ * List of supported OAuth provider IDs.
16
+ *
17
+ * Note: OpenAI and Anthropic are NOT included - they use API keys, not OAuth.
18
+ * See model-credentials module for API key handling.
19
+ */
20
+ export declare const SUPPORTED_PROVIDERS: readonly AuthProviderId[];
21
+ /**
22
+ * Register a provider factory.
23
+ *
24
+ * @param providerId - The provider identifier
25
+ * @param factory - Factory function that creates the provider
26
+ * @throws Error if providerId is not a valid supported provider ID
27
+ */
28
+ export declare function registerProvider(providerId: AuthProviderId, factory: ProviderFactory): void;
29
+ /**
30
+ * Unregister a provider.
31
+ *
32
+ * @param providerId - The provider identifier to unregister
33
+ * @returns True if the provider was unregistered
34
+ */
35
+ export declare function unregisterProvider(providerId: AuthProviderId): boolean;
36
+ /**
37
+ * Clear all registered providers.
38
+ * Useful for testing.
39
+ */
40
+ export declare function clearProviders(): void;
41
+ /**
42
+ * Get a provider implementation by ID.
43
+ *
44
+ * @param providerId - The provider identifier
45
+ * @returns The provider implementation
46
+ * @throws Error if provider is not registered
47
+ */
48
+ export declare function getProvider(providerId: AuthProviderId): IAuthProvider;
49
+ /**
50
+ * Check if a provider is registered.
51
+ *
52
+ * @param providerId - The provider identifier
53
+ * @returns True if the provider is registered
54
+ */
55
+ export declare function hasProvider(providerId: AuthProviderId): boolean;
56
+ /**
57
+ * Get the list of registered provider IDs.
58
+ *
59
+ * @returns Array of registered provider identifiers
60
+ */
61
+ export declare function getRegisteredProviders(): AuthProviderId[];
62
+ /**
63
+ * Get the list of supported provider IDs.
64
+ *
65
+ * @returns Array of supported provider identifiers
66
+ */
67
+ export declare function getSupportedProviders(): readonly AuthProviderId[];
68
+ /**
69
+ * Check if a provider ID is valid (supported).
70
+ * Re-exports the centralized type guard from types.ts.
71
+ *
72
+ * @param providerId - The provider identifier to check
73
+ * @returns True if the provider is supported
74
+ */
75
+ export declare function isValidProviderId(providerId: unknown): providerId is AuthProviderId;
76
+ /**
77
+ * Check if a provider ID is registered and available.
78
+ *
79
+ * @param providerId - The provider identifier to check
80
+ * @returns True if the provider is registered
81
+ */
82
+ export declare function isProviderAvailable(providerId: string): boolean;
83
+ export type { IAuthProvider } from './types.js';
84
+ export { BaseAuthProvider } from './base-provider.js';
85
+ export type { BaseProviderConfig } from './base-provider.js';
86
+ export { GitHubProvider } from './github-provider.js';
87
+ export { GoogleProvider } from './google-provider.js';
88
+ export { CognitoProvider } from './cognito-provider.js';
89
+ export type { CognitoProviderConfig } from './cognito-provider.js';
90
+ export { EntraIdProvider, AzureProvider } from './entra-provider.js';
91
+ export type { EntraProviderConfig, AzureProviderConfig } from './entra-provider.js';
92
+ export { OIDCProvider } from './oidc-provider.js';
93
+ export type { OIDCProviderConfig, OIDCDiscoveryDocument, OIDCDiscoveryResult } from './oidc-provider.js';
94
+ /**
95
+ * Initialize all OAuth providers.
96
+ * Must be called before using AuthManager.
97
+ *
98
+ * This registers all supported OAuth provider implementations
99
+ * in the provider registry.
100
+ *
101
+ * Note: OpenAI and Anthropic are NOT registered here - they use API keys, not OAuth.
102
+ * See model-credentials module for API key handling.
103
+ *
104
+ * Note: Cognito, Azure, and OIDC require environment-specific configuration
105
+ * and are only registered if their config is available via env vars.
106
+ */
107
+ export declare function initializeProviders(): void;