@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.
- package/README.md +181 -21
- package/out/dist/workers-registry/acp-registry/index.js +128 -2
- package/out/dist/workers-registry/acp-registry/index.js.map +4 -4
- package/out/dist/workers-registry/acp-worker/index.js +1 -3
- package/out/dist/workers-registry/acp-worker/index.js.map +4 -4
- package/out/dist/workers-registry/index.d.ts +1 -0
- package/out/dist/workers-registry/index.js +6 -0
- package/out/dist/workers-registry/openai-agent/index.js +1 -1
- package/out/dist/workers-registry/openai-agent/index.js.map +2 -2
- package/out/dist/workers-registry/registry-launcher/index.js +131 -0
- package/out/dist/workers-registry/registry-launcher/index.js.map +7 -0
- package/out/tsc/workers-registry/acp-worker/src/index.d.ts +0 -10
- package/out/tsc/workers-registry/registry-launcher/src/auth/auth-manager.d.ts +392 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/cli/cli.property.test.d.ts +22 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/cli/index.d.ts +9 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/cli/login-command.d.ts +32 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/cli/logout-command.d.ts +25 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/cli/setup-command.d.ts +25 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/cli/status-command.d.ts +21 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/errors.d.ts +190 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/flows/agent-auth-flow.d.ts +146 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/flows/callback-server.d.ts +131 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/flows/callback-server.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/flows/index.d.ts +11 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/flows/terminal-auth-flow.d.ts +252 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/flows/terminal-auth-flow.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/index.d.ts +33 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/integration.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/anthropic-api-key.d.ts +154 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/index.d.ts +20 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/model-credentials.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/openai-api-key.d.ts +182 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/types.d.ts +186 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.d.ts +61 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/pkce.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/base-provider.d.ts +138 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/base-provider.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/cognito-provider.d.ts +44 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/concrete-providers.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/entra-provider.d.ts +54 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/github-provider.d.ts +19 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/google-provider.d.ts +19 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/index.d.ts +107 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/index.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.d.ts +413 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/oidc-provider.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/providers.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/providers/types.d.ts +28 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/session.d.ts +251 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/session.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/session.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/state.d.ts +26 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/state.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/state.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/credential-store.d.ts +98 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/credential-store.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/encrypted-file-backend.d.ts +101 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/encrypted-file-backend.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/index.d.ts +12 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/keychain-backend.d.ts +80 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/keychain-backend.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/memory-backend.d.ts +54 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/storage.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/storage/types.d.ts +44 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.d.ts +171 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/token-manager.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/types.d.ts +369 -0
- package/out/tsc/workers-registry/registry-launcher/src/auth/types.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/config/config.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/config/config.test.d.ts +1 -0
- package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/index.d.ts +51 -2
- package/out/tsc/workers-registry/registry-launcher/src/registry/index.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/registry/index.test.d.ts +1 -0
- package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/types.d.ts +24 -0
- package/out/tsc/workers-registry/registry-launcher/src/router/message-router.d.ts +770 -0
- package/out/tsc/workers-registry/registry-launcher/src/router/message-router.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/router/message-router.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/runtime/manager.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/runtime/manager.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/stream/ndjson-handler.property.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/src/stream/ndjson-handler.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/auth-flow.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/auth-required-flow.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/api-keys.d.ts +32 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/index.d.ts +17 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/launcher-harness.d.ts +101 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/helpers/registry-server.d.ts +46 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-agent-auth.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-api-keys.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-auth-required.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-cli.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-concurrent.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-lifecycle.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/e2e/production-terminal-auth.e2e.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/integration/agent-auth.integration.test.d.ts +9 -0
- package/out/tsc/workers-registry/registry-launcher/tests/integration/registry-launcher.test.d.ts +1 -0
- package/out/tsc/workers-registry/registry-launcher/tests/integration/terminal-auth.integration.test.d.ts +12 -0
- package/package.json +16 -11
- package/out/tsc/workers-registry/acp-worker/src/registry-launcher/router/message-router.d.ts +0 -199
- /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
- /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
- /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
- /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
- /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
- /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
- /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
- /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
- /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
- /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
- /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
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/api-keys.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/config.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/index.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/config/types.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/index.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/log.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/log.test.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/registry/resolver.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/router/index.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/agent-runtime.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/index.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/manager.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/runtime/types.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/stream/index.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/stream/ndjson-handler.d.ts +0 -0
- /package/out/tsc/workers-registry/{acp-worker/src/registry-launcher → registry-launcher/src}/test-utils/index.d.ts +0 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import type { AuthProviderId, AuthResult, ProviderEndpoints } from '../types.js';
|
|
2
|
+
import type { ICredentialStore } from '../storage/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Authentication mode selected by the user.
|
|
5
|
+
* Requirements: 3.1, 4.2
|
|
6
|
+
*/
|
|
7
|
+
export type AuthenticationMode = 'browser-oauth' | 'manual-api-key';
|
|
8
|
+
/**
|
|
9
|
+
* Result indicating browser OAuth flow should be used.
|
|
10
|
+
* This is returned when the user selects "Browser OAuth" mode.
|
|
11
|
+
*/
|
|
12
|
+
export interface BrowserOAuthResult {
|
|
13
|
+
/** Indicates browser OAuth flow should be used */
|
|
14
|
+
useBrowserOAuth: true;
|
|
15
|
+
/** The selected provider ID */
|
|
16
|
+
providerId: AuthProviderId;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Result indicating manual credential flow completed.
|
|
20
|
+
*/
|
|
21
|
+
export interface ManualCredentialResult {
|
|
22
|
+
/** Indicates manual credential flow was used */
|
|
23
|
+
useBrowserOAuth: false;
|
|
24
|
+
/** The authentication result from manual flow */
|
|
25
|
+
authResult: AuthResult;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Combined result type for terminal auth flow execution.
|
|
29
|
+
*/
|
|
30
|
+
export type TerminalAuthFlowResult = BrowserOAuthResult | ManualCredentialResult;
|
|
31
|
+
/**
|
|
32
|
+
* Provider display information for the selection menu.
|
|
33
|
+
*/
|
|
34
|
+
interface ProviderInfo {
|
|
35
|
+
id: AuthProviderId;
|
|
36
|
+
name: string;
|
|
37
|
+
requiresClientSecret: boolean;
|
|
38
|
+
requiresCustomEndpoints: boolean;
|
|
39
|
+
/** Whether this provider supports simple API key authentication */
|
|
40
|
+
supportsApiKey: boolean;
|
|
41
|
+
/** Whether this provider supports browser-based OAuth flow */
|
|
42
|
+
supportsOAuth: boolean;
|
|
43
|
+
/** Label for the API key (e.g., "API Key", "Personal Access Token") */
|
|
44
|
+
apiKeyLabel?: string;
|
|
45
|
+
/** Environment variable name for the API key */
|
|
46
|
+
apiKeyEnvVar?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Collected credentials from user input.
|
|
50
|
+
*/
|
|
51
|
+
export interface CollectedCredentials {
|
|
52
|
+
clientId: string;
|
|
53
|
+
clientSecret?: string;
|
|
54
|
+
customEndpoints?: ProviderEndpoints;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Dependencies for the terminal auth flow.
|
|
58
|
+
*/
|
|
59
|
+
export interface TerminalAuthFlowDependencies {
|
|
60
|
+
/** Credential store for persisting credentials */
|
|
61
|
+
credentialStore: ICredentialStore;
|
|
62
|
+
/** Function to validate credentials (attempts token request) */
|
|
63
|
+
validateCredentials: (providerId: AuthProviderId, credentials: CollectedCredentials) => Promise<{
|
|
64
|
+
valid: boolean;
|
|
65
|
+
error?: string;
|
|
66
|
+
accessToken?: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Optional custom input/output streams (for testing) */
|
|
69
|
+
input?: NodeJS.ReadableStream;
|
|
70
|
+
output?: NodeJS.WritableStream;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Terminal auth flow - interactive CLI setup.
|
|
74
|
+
*
|
|
75
|
+
* Provides an interactive terminal interface for configuring OAuth credentials
|
|
76
|
+
* in headless environments. The flow:
|
|
77
|
+
* 1. Prompts user to select a provider
|
|
78
|
+
* 2. Prompts for required credentials
|
|
79
|
+
* 3. Validates credentials by attempting a token request
|
|
80
|
+
* 4. Stores credentials securely on success
|
|
81
|
+
* 5. Prompts for re-entry on validation failure
|
|
82
|
+
*/
|
|
83
|
+
export declare class TerminalAuthFlow {
|
|
84
|
+
private readonly credentialStore;
|
|
85
|
+
private readonly validateCredentials;
|
|
86
|
+
private readonly input;
|
|
87
|
+
private readonly output;
|
|
88
|
+
private rl;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new terminal auth flow.
|
|
91
|
+
*
|
|
92
|
+
* @param dependencies - Flow dependencies
|
|
93
|
+
*/
|
|
94
|
+
constructor(dependencies: TerminalAuthFlowDependencies);
|
|
95
|
+
/**
|
|
96
|
+
* Execute the terminal auth flow.
|
|
97
|
+
*
|
|
98
|
+
* Runs the interactive setup wizard to configure OAuth credentials.
|
|
99
|
+
* For providers supporting OAuth, offers a choice between browser OAuth
|
|
100
|
+
* and manual API key entry.
|
|
101
|
+
*
|
|
102
|
+
* Requirements: 3.1, 4.2
|
|
103
|
+
*
|
|
104
|
+
* @param providerId - Optional pre-selected provider (skips provider selection)
|
|
105
|
+
* @returns Terminal auth flow result indicating mode selection and outcome
|
|
106
|
+
*/
|
|
107
|
+
execute(providerId?: AuthProviderId): Promise<TerminalAuthFlowResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Select authentication mode for providers supporting OAuth.
|
|
110
|
+
* Offers choice between browser OAuth (recommended) and manual API key.
|
|
111
|
+
*
|
|
112
|
+
* Requirements: 3.1, 4.2
|
|
113
|
+
*
|
|
114
|
+
* @param providerInfo - Provider information
|
|
115
|
+
* @returns Selected authentication mode
|
|
116
|
+
*/
|
|
117
|
+
private selectAuthenticationMode;
|
|
118
|
+
/**
|
|
119
|
+
* Collect and validate credentials with retry loop.
|
|
120
|
+
* Requirements: 4.3, 4.4, 4.5, 4.6
|
|
121
|
+
*
|
|
122
|
+
* Note: When this method is called, the user has already selected "Manual API Key"
|
|
123
|
+
* in the authentication mode selection. For providers that support simple API key
|
|
124
|
+
* authentication (OpenAI, Anthropic, GitHub), we collect the API key directly.
|
|
125
|
+
* For providers that don't support simple API key (Google, Cognito, Azure),
|
|
126
|
+
* we collect OAuth client credentials.
|
|
127
|
+
*/
|
|
128
|
+
private collectAndValidateWithRetry;
|
|
129
|
+
/**
|
|
130
|
+
* Prompt for a numeric selection within a range.
|
|
131
|
+
* Supports an optional default value that is used when user presses Enter without input.
|
|
132
|
+
*
|
|
133
|
+
* @param message - The prompt message
|
|
134
|
+
* @param min - Minimum valid selection
|
|
135
|
+
* @param max - Maximum valid selection
|
|
136
|
+
* @param defaultValue - Optional default value used when input is empty
|
|
137
|
+
* @returns The selected number
|
|
138
|
+
*/
|
|
139
|
+
private promptSelection;
|
|
140
|
+
/**
|
|
141
|
+
* Collect API key credentials (simple mode for OpenAI, Anthropic, GitHub).
|
|
142
|
+
*/
|
|
143
|
+
private collectApiKeyCredentials;
|
|
144
|
+
/**
|
|
145
|
+
* Prompt user to select a provider from the supported list.
|
|
146
|
+
* Requirement 4.2
|
|
147
|
+
*/
|
|
148
|
+
private selectProvider;
|
|
149
|
+
/**
|
|
150
|
+
* Collect credentials from user input.
|
|
151
|
+
* Requirement 4.3
|
|
152
|
+
*/
|
|
153
|
+
private collectCredentials;
|
|
154
|
+
/**
|
|
155
|
+
* Collect custom endpoints for providers that require them (Cognito/Azure/OIDC).
|
|
156
|
+
* Validates all endpoints to ensure HTTPS and no embedded credentials.
|
|
157
|
+
*/
|
|
158
|
+
private collectCustomEndpoints;
|
|
159
|
+
/**
|
|
160
|
+
* Prompt for a validated HTTPS URL.
|
|
161
|
+
* Ensures the URL is valid, uses HTTPS, and has no embedded credentials.
|
|
162
|
+
*/
|
|
163
|
+
private promptValidatedUrl;
|
|
164
|
+
/**
|
|
165
|
+
* Validate that a URL is a valid HTTPS URL without embedded credentials.
|
|
166
|
+
*/
|
|
167
|
+
private validateHttpsUrl;
|
|
168
|
+
/**
|
|
169
|
+
* Collect Cognito-specific endpoint configuration.
|
|
170
|
+
* Validates input to prevent URL injection attacks.
|
|
171
|
+
*/
|
|
172
|
+
private collectCognitoEndpoints;
|
|
173
|
+
/**
|
|
174
|
+
* Collect Azure AD-specific endpoint configuration.
|
|
175
|
+
* Validates input to prevent URL injection attacks.
|
|
176
|
+
*/
|
|
177
|
+
private collectAzureEndpoints;
|
|
178
|
+
/**
|
|
179
|
+
* Collect Generic OIDC endpoint configuration.
|
|
180
|
+
* Supports issuer-based discovery or manual endpoint entry.
|
|
181
|
+
* Validates input to prevent URL injection attacks.
|
|
182
|
+
*
|
|
183
|
+
* Requirements: 7a.1, 7a.2
|
|
184
|
+
*/
|
|
185
|
+
private collectOidcEndpoints;
|
|
186
|
+
/**
|
|
187
|
+
* Validate Cognito user pool domain.
|
|
188
|
+
* Must be alphanumeric with hyphens, no URL injection characters.
|
|
189
|
+
*/
|
|
190
|
+
private validateCognitoDomain;
|
|
191
|
+
/**
|
|
192
|
+
* Validate AWS region format.
|
|
193
|
+
* Must match pattern like us-east-1, eu-west-2.
|
|
194
|
+
*/
|
|
195
|
+
private validateAwsRegion;
|
|
196
|
+
/**
|
|
197
|
+
* Validate Azure tenant ID.
|
|
198
|
+
* Must be 'common', 'organizations', 'consumers', a valid GUID, or a domain name.
|
|
199
|
+
*/
|
|
200
|
+
private validateAzureTenantId;
|
|
201
|
+
/**
|
|
202
|
+
* Prompt for input with validation.
|
|
203
|
+
*/
|
|
204
|
+
private promptValidated;
|
|
205
|
+
/**
|
|
206
|
+
* Prompt for required input (non-empty).
|
|
207
|
+
*/
|
|
208
|
+
private promptRequired;
|
|
209
|
+
/**
|
|
210
|
+
* Prompt for secret input (hidden if possible).
|
|
211
|
+
* Note: In a real implementation, this would hide input.
|
|
212
|
+
* For headless environments, we accept visible input.
|
|
213
|
+
*/
|
|
214
|
+
private promptSecret;
|
|
215
|
+
/**
|
|
216
|
+
* Prompt for yes/no confirmation.
|
|
217
|
+
*/
|
|
218
|
+
private promptYesNo;
|
|
219
|
+
/**
|
|
220
|
+
* Prompt for user input.
|
|
221
|
+
*/
|
|
222
|
+
private prompt;
|
|
223
|
+
/**
|
|
224
|
+
* Write a line to output.
|
|
225
|
+
*/
|
|
226
|
+
private writeLine;
|
|
227
|
+
/**
|
|
228
|
+
* Clean up resources.
|
|
229
|
+
*/
|
|
230
|
+
private cleanup;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Create a terminal auth flow with the given dependencies.
|
|
234
|
+
*
|
|
235
|
+
* @param dependencies - Flow dependencies
|
|
236
|
+
* @returns A new TerminalAuthFlow instance
|
|
237
|
+
*/
|
|
238
|
+
export declare function createTerminalAuthFlow(dependencies: TerminalAuthFlowDependencies): TerminalAuthFlow;
|
|
239
|
+
/**
|
|
240
|
+
* Get provider information by ID.
|
|
241
|
+
*
|
|
242
|
+
* @param providerId - The provider identifier
|
|
243
|
+
* @returns Provider info or undefined if not found
|
|
244
|
+
*/
|
|
245
|
+
export declare function getProviderInfo(providerId: AuthProviderId): ProviderInfo | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Get all supported provider information.
|
|
248
|
+
*
|
|
249
|
+
* @returns Array of provider information
|
|
250
|
+
*/
|
|
251
|
+
export declare function getAllProviderInfo(): readonly ProviderInfo[];
|
|
252
|
+
export {};
|
package/out/tsc/workers-registry/registry-launcher/src/auth/flows/terminal-auth-flow.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.1 Authentication Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides OAuth 2.1 authentication for the Registry Launcher worker.
|
|
5
|
+
* It supports multiple OAuth providers (GitHub, Google, AWS Cognito, Azure AD)
|
|
6
|
+
* and two authentication modes:
|
|
7
|
+
* - Agent Auth: Browser-based OAuth 2.1 Authorization Code flow with PKCE
|
|
8
|
+
* - Terminal Auth: Interactive CLI setup flow for headless environments
|
|
9
|
+
*
|
|
10
|
+
* @module auth
|
|
11
|
+
*/
|
|
12
|
+
export type { AuthProviderId, StorageBackendType, TokenStatus, AuthErrorCode, TokenResponse, StoredCredentials, TokenInjectionMethod, ProviderEndpoints, AuthorizationParams, CallbackResult, CallbackSuccess, CallbackErrorResult, AgentAuthOptions, AuthResult, AuthResultSuccess, AuthResultFailure, AuthError, AuthStatusEntry, AuthStatusMap, ProviderConfig, AuthConfig, AcpAuthMethod, AuthMethodType, AuthMethodPrecedenceConfig, } from './types.js';
|
|
13
|
+
export { isValidProviderId as isValidProviderIdFromTypes, isValidAuthMethodType, isValidAuthMethodId, resolveAuthMethodIdToProviderId, tryResolveAuthMethodIdToProviderId, UnknownAuthMethodIdError, VALID_PROVIDER_IDS, VALID_AUTH_METHOD_TYPES, VALID_AUTH_METHOD_IDS, AUTH_METHOD_ID_TO_PROVIDER_ID, DEFAULT_AUTH_METHOD_PRECEDENCE, } from './types.js';
|
|
14
|
+
export { generateCodeVerifier, generateCodeChallenge, generatePKCEPair, validateCodeVerifier, PKCE_CODE_CHALLENGE_METHOD, PKCE_VERIFIER_MIN_LENGTH, PKCE_VERIFIER_MAX_LENGTH, } from './pkce.js';
|
|
15
|
+
export { generateState, validateState, } from './state.js';
|
|
16
|
+
export type { IAuthSession } from './session.js';
|
|
17
|
+
export { AuthSession, createSession, SessionManager, DEFAULT_SESSION_TIMEOUT_MS, MAX_SESSION_TIMEOUT_MS, validateTimeout, } from './session.js';
|
|
18
|
+
export type { AuthManagerOptions, AuthMethodSelectionResult, } from './auth-manager.js';
|
|
19
|
+
export { AuthManager, createAuthManager, AuthMethodSelectionError, CLIENT_CREDENTIALS_MARKER, isMarkerToken, } from './auth-manager.js';
|
|
20
|
+
export type { ITokenManager, TokenManagerOptions, ProviderResolver } from './token-manager.js';
|
|
21
|
+
export { TokenManager, createTokenManager, DEFAULT_REFRESH_THRESHOLD_MS } from './token-manager.js';
|
|
22
|
+
export type { IAuthProvider } from './providers/types.js';
|
|
23
|
+
export { getProvider, getSupportedProviders, isValidProviderId, } from './providers/index.js';
|
|
24
|
+
export type { ICredentialStore, IStorageBackend } from './storage/types.js';
|
|
25
|
+
export { CredentialStore } from './storage/credential-store.js';
|
|
26
|
+
export type { ICallbackServer } from './flows/callback-server.js';
|
|
27
|
+
export { AgentAuthFlow } from './flows/agent-auth-flow.js';
|
|
28
|
+
export type { AgentAuthFlowDependencies } from './flows/agent-auth-flow.js';
|
|
29
|
+
export { TerminalAuthFlow, createTerminalAuthFlow, getProviderInfo, getAllProviderInfo, } from './flows/terminal-auth-flow.js';
|
|
30
|
+
export type { TerminalAuthFlowDependencies, CollectedCredentials, } from './flows/terminal-auth-flow.js';
|
|
31
|
+
export { runSetupCommand, runStatusCommand, runLogoutCommand, } from './cli/index.js';
|
|
32
|
+
export { AuthenticationError, InvalidStateError, TimeoutError, NetworkError, InvalidCredentialsError, StorageError, ProviderError, UnsupportedProviderError, CallbackError, TokenRefreshError, parseProviderErrorResponse, parseHttpErrorResponse, isOAuthErrorResponse, formatErrorResponse, createUnsupportedProviderError, createNetworkError, createStorageError, redactSensitiveData, } from './errors.js';
|
|
33
|
+
export type { OAuthErrorResponse } from './errors.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/anthropic-api-key.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic API Key Handler.
|
|
3
|
+
*
|
|
4
|
+
* Handles storage, retrieval, validation, and injection of Anthropic API keys.
|
|
5
|
+
* Anthropic uses the x-api-key header with the raw key (no Bearer prefix).
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 7b.1, 7b.4, 7b.5
|
|
8
|
+
*
|
|
9
|
+
* @module model-credentials/anthropic-api-key
|
|
10
|
+
*/
|
|
11
|
+
import type { ModelProviderId, ModelCredentialResult, ModelCredentialStatusEntry, HeaderInjection } from './types.js';
|
|
12
|
+
import type { IModelCredentialStorage } from './openai-api-key.js';
|
|
13
|
+
/**
|
|
14
|
+
* The provider ID for Anthropic.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ANTHROPIC_PROVIDER_ID: ModelProviderId;
|
|
17
|
+
/**
|
|
18
|
+
* Anthropic API key prefix for validation.
|
|
19
|
+
* Anthropic API keys typically start with 'sk-ant-'.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ANTHROPIC_API_KEY_PREFIX = "sk-ant-";
|
|
22
|
+
/**
|
|
23
|
+
* Minimum length for Anthropic API keys.
|
|
24
|
+
* Anthropic keys are typically 40+ characters.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ANTHROPIC_API_KEY_MIN_LENGTH = 20;
|
|
27
|
+
/**
|
|
28
|
+
* Storage key prefix for Anthropic credentials.
|
|
29
|
+
*/
|
|
30
|
+
export declare const ANTHROPIC_STORAGE_KEY = "model-credential:anthropic";
|
|
31
|
+
/**
|
|
32
|
+
* Anthropic API Key Handler.
|
|
33
|
+
*
|
|
34
|
+
* Provides methods for storing, retrieving, validating, and injecting
|
|
35
|
+
* Anthropic API keys. Integrates with the Credential_Store for secure storage.
|
|
36
|
+
*
|
|
37
|
+
* Requirements: 7b.1, 7b.4, 7b.5
|
|
38
|
+
*/
|
|
39
|
+
export declare class AnthropicApiKeyHandler {
|
|
40
|
+
private readonly storage;
|
|
41
|
+
/**
|
|
42
|
+
* Create a new Anthropic API key handler.
|
|
43
|
+
* @param storage - The credential storage backend
|
|
44
|
+
*/
|
|
45
|
+
constructor(storage: IModelCredentialStorage);
|
|
46
|
+
/**
|
|
47
|
+
* Get the provider ID for this handler.
|
|
48
|
+
* @returns The Anthropic provider ID
|
|
49
|
+
*/
|
|
50
|
+
getProviderId(): ModelProviderId;
|
|
51
|
+
/**
|
|
52
|
+
* Get the injection configuration for Anthropic.
|
|
53
|
+
*
|
|
54
|
+
* Anthropic uses the x-api-key header with the raw key:
|
|
55
|
+
* x-api-key: {key}
|
|
56
|
+
*
|
|
57
|
+
* Requirements: 7b.5
|
|
58
|
+
*
|
|
59
|
+
* @returns The header injection configuration
|
|
60
|
+
*/
|
|
61
|
+
getInjectionConfig(): HeaderInjection;
|
|
62
|
+
/**
|
|
63
|
+
* Validate an Anthropic API key format.
|
|
64
|
+
*
|
|
65
|
+
* Performs basic format validation:
|
|
66
|
+
* - Must be a non-empty string
|
|
67
|
+
* - Must meet minimum length requirement
|
|
68
|
+
* - Optionally checks for 'sk-ant-' prefix (warning only)
|
|
69
|
+
*
|
|
70
|
+
* Note: This does not validate the key against Anthropic's API.
|
|
71
|
+
* Use validateWithApi() for full validation.
|
|
72
|
+
*
|
|
73
|
+
* @param apiKey - The API key to validate
|
|
74
|
+
* @returns Validation result with success flag and optional warning
|
|
75
|
+
*/
|
|
76
|
+
validateFormat(apiKey: string): {
|
|
77
|
+
valid: boolean;
|
|
78
|
+
warning?: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Store an Anthropic API key in the credential store.
|
|
82
|
+
*
|
|
83
|
+
* The key is stored with encryption handled by the storage backend.
|
|
84
|
+
*
|
|
85
|
+
* Requirements: 7b.4
|
|
86
|
+
*
|
|
87
|
+
* @param apiKey - The API key to store
|
|
88
|
+
* @param label - Optional human-readable label
|
|
89
|
+
* @returns Promise that resolves when stored
|
|
90
|
+
* @throws Error if the API key format is invalid
|
|
91
|
+
*/
|
|
92
|
+
store(apiKey: string, label?: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve the stored Anthropic API key.
|
|
95
|
+
*
|
|
96
|
+
* Requirements: 7b.4
|
|
97
|
+
*
|
|
98
|
+
* @returns The credential result with the API key if found
|
|
99
|
+
*/
|
|
100
|
+
retrieve(): Promise<ModelCredentialResult>;
|
|
101
|
+
/**
|
|
102
|
+
* Delete the stored Anthropic API key.
|
|
103
|
+
*
|
|
104
|
+
* @returns Promise that resolves when deleted
|
|
105
|
+
*/
|
|
106
|
+
delete(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Check if an Anthropic API key is configured.
|
|
109
|
+
*
|
|
110
|
+
* @returns True if a valid API key is stored
|
|
111
|
+
*/
|
|
112
|
+
isConfigured(): Promise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Get the status of the Anthropic API key credential.
|
|
115
|
+
*
|
|
116
|
+
* @returns The credential status entry
|
|
117
|
+
*/
|
|
118
|
+
getStatus(): Promise<ModelCredentialStatusEntry>;
|
|
119
|
+
/**
|
|
120
|
+
* Inject the Anthropic API key into request headers.
|
|
121
|
+
*
|
|
122
|
+
* Creates the x-api-key header with the raw key:
|
|
123
|
+
* x-api-key: {key}
|
|
124
|
+
*
|
|
125
|
+
* Requirements: 7b.5
|
|
126
|
+
*
|
|
127
|
+
* @param headers - Existing headers object (will be modified)
|
|
128
|
+
* @returns The headers object with the x-api-key header added
|
|
129
|
+
* @throws Error if no API key is configured
|
|
130
|
+
*/
|
|
131
|
+
injectHeader(headers?: Record<string, string>): Promise<Record<string, string>>;
|
|
132
|
+
/**
|
|
133
|
+
* Get the header injection for a request.
|
|
134
|
+
*
|
|
135
|
+
* Returns the header name and value for injecting the API key.
|
|
136
|
+
* This is useful when you need the header separately from the request.
|
|
137
|
+
*
|
|
138
|
+
* Requirements: 7b.5
|
|
139
|
+
*
|
|
140
|
+
* @returns Object with headerName and headerValue
|
|
141
|
+
* @throws Error if no API key is configured
|
|
142
|
+
*/
|
|
143
|
+
getHeaderInjection(): Promise<{
|
|
144
|
+
headerName: string;
|
|
145
|
+
headerValue: string;
|
|
146
|
+
}>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a new Anthropic API key handler.
|
|
150
|
+
*
|
|
151
|
+
* @param storage - The credential storage backend
|
|
152
|
+
* @returns A new Anthropic API key handler instance
|
|
153
|
+
*/
|
|
154
|
+
export declare function createAnthropicApiKeyHandler(storage: IModelCredentialStorage): AnthropicApiKeyHandler;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Credentials Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides API key management for upstream model providers
|
|
5
|
+
* (OpenAI, Anthropic). These providers do NOT offer public OAuth IdP
|
|
6
|
+
* for third-party login - they use API keys instead.
|
|
7
|
+
*
|
|
8
|
+
* This module clearly separates:
|
|
9
|
+
* - User identity (OAuth/OIDC): Handled by the main auth module
|
|
10
|
+
* - Model API access (API Keys): Handled by this module
|
|
11
|
+
*
|
|
12
|
+
* Requirements: 7b.1, 7b.3
|
|
13
|
+
*
|
|
14
|
+
* @module model-credentials
|
|
15
|
+
*/
|
|
16
|
+
export type { ModelProviderId, ModelCredential, StoredModelCredential, ModelCredentialResult, ModelCredentialInjection, HeaderInjection, ModelCredentialStatus, ModelCredentialStatusEntry, ModelCredentialStatusMap, } from './types.js';
|
|
17
|
+
export { VALID_MODEL_PROVIDER_IDS, isValidModelProviderId, MODEL_CREDENTIAL_INJECTION_CONFIG, } from './types.js';
|
|
18
|
+
export type { IModelCredentialStorage } from './openai-api-key.js';
|
|
19
|
+
export { OpenAIApiKeyHandler, createOpenAIApiKeyHandler, OPENAI_PROVIDER_ID, OPENAI_API_KEY_PREFIX, OPENAI_API_KEY_MIN_LENGTH, OPENAI_STORAGE_KEY, } from './openai-api-key.js';
|
|
20
|
+
export { AnthropicApiKeyHandler, createAnthropicApiKeyHandler, ANTHROPIC_PROVIDER_ID, ANTHROPIC_API_KEY_PREFIX, ANTHROPIC_API_KEY_MIN_LENGTH, ANTHROPIC_STORAGE_KEY, } from './anthropic-api-key.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/out/tsc/workers-registry/registry-launcher/src/auth/model-credentials/openai-api-key.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI API Key Handler.
|
|
3
|
+
*
|
|
4
|
+
* Handles storage, retrieval, validation, and injection of OpenAI API keys.
|
|
5
|
+
* OpenAI uses the Authorization header with Bearer token format.
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 7b.1, 7b.4, 7b.5
|
|
8
|
+
*
|
|
9
|
+
* @module model-credentials/openai-api-key
|
|
10
|
+
*/
|
|
11
|
+
import type { ModelProviderId, StoredModelCredential, ModelCredentialResult, ModelCredentialStatusEntry, HeaderInjection } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* The provider ID for OpenAI.
|
|
14
|
+
*/
|
|
15
|
+
export declare const OPENAI_PROVIDER_ID: ModelProviderId;
|
|
16
|
+
/**
|
|
17
|
+
* OpenAI API key prefix for validation.
|
|
18
|
+
* OpenAI API keys typically start with 'sk-'.
|
|
19
|
+
*/
|
|
20
|
+
export declare const OPENAI_API_KEY_PREFIX = "sk-";
|
|
21
|
+
/**
|
|
22
|
+
* Minimum length for OpenAI API keys.
|
|
23
|
+
* OpenAI keys are typically 51+ characters.
|
|
24
|
+
*/
|
|
25
|
+
export declare const OPENAI_API_KEY_MIN_LENGTH = 20;
|
|
26
|
+
/**
|
|
27
|
+
* Storage key prefix for OpenAI credentials.
|
|
28
|
+
*/
|
|
29
|
+
export declare const OPENAI_STORAGE_KEY = "model-credential:openai";
|
|
30
|
+
/**
|
|
31
|
+
* Interface for credential storage operations.
|
|
32
|
+
* This allows the handler to work with any storage backend.
|
|
33
|
+
*/
|
|
34
|
+
export interface IModelCredentialStorage {
|
|
35
|
+
/**
|
|
36
|
+
* Store a model credential.
|
|
37
|
+
* @param key - The storage key
|
|
38
|
+
* @param credential - The credential to store
|
|
39
|
+
*/
|
|
40
|
+
store(key: string, credential: StoredModelCredential): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve a model credential.
|
|
43
|
+
* @param key - The storage key
|
|
44
|
+
* @returns The stored credential or null if not found
|
|
45
|
+
*/
|
|
46
|
+
retrieve(key: string): Promise<StoredModelCredential | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Delete a model credential.
|
|
49
|
+
* @param key - The storage key
|
|
50
|
+
*/
|
|
51
|
+
delete(key: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a credential exists.
|
|
54
|
+
* @param key - The storage key
|
|
55
|
+
* @returns True if the credential exists
|
|
56
|
+
*/
|
|
57
|
+
exists(key: string): Promise<boolean>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* OpenAI API Key Handler.
|
|
61
|
+
*
|
|
62
|
+
* Provides methods for storing, retrieving, validating, and injecting
|
|
63
|
+
* OpenAI API keys. Integrates with the Credential_Store for secure storage.
|
|
64
|
+
*
|
|
65
|
+
* Requirements: 7b.1, 7b.4, 7b.5
|
|
66
|
+
*/
|
|
67
|
+
export declare class OpenAIApiKeyHandler {
|
|
68
|
+
private readonly storage;
|
|
69
|
+
/**
|
|
70
|
+
* Create a new OpenAI API key handler.
|
|
71
|
+
* @param storage - The credential storage backend
|
|
72
|
+
*/
|
|
73
|
+
constructor(storage: IModelCredentialStorage);
|
|
74
|
+
/**
|
|
75
|
+
* Get the provider ID for this handler.
|
|
76
|
+
* @returns The OpenAI provider ID
|
|
77
|
+
*/
|
|
78
|
+
getProviderId(): ModelProviderId;
|
|
79
|
+
/**
|
|
80
|
+
* Get the injection configuration for OpenAI.
|
|
81
|
+
*
|
|
82
|
+
* OpenAI uses the Authorization header with Bearer token format:
|
|
83
|
+
* Authorization: Bearer {key}
|
|
84
|
+
*
|
|
85
|
+
* Requirements: 7b.5
|
|
86
|
+
*
|
|
87
|
+
* @returns The header injection configuration
|
|
88
|
+
*/
|
|
89
|
+
getInjectionConfig(): HeaderInjection;
|
|
90
|
+
/**
|
|
91
|
+
* Validate an OpenAI API key format.
|
|
92
|
+
*
|
|
93
|
+
* Performs basic format validation:
|
|
94
|
+
* - Must be a non-empty string
|
|
95
|
+
* - Must meet minimum length requirement
|
|
96
|
+
* - Optionally checks for 'sk-' prefix (warning only)
|
|
97
|
+
*
|
|
98
|
+
* Note: This does not validate the key against OpenAI's API.
|
|
99
|
+
* Use validateWithApi() for full validation.
|
|
100
|
+
*
|
|
101
|
+
* @param apiKey - The API key to validate
|
|
102
|
+
* @returns Validation result with success flag and optional warning
|
|
103
|
+
*/
|
|
104
|
+
validateFormat(apiKey: string): {
|
|
105
|
+
valid: boolean;
|
|
106
|
+
warning?: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Store an OpenAI API key in the credential store.
|
|
110
|
+
*
|
|
111
|
+
* The key is stored with encryption handled by the storage backend.
|
|
112
|
+
*
|
|
113
|
+
* Requirements: 7b.4
|
|
114
|
+
*
|
|
115
|
+
* @param apiKey - The API key to store
|
|
116
|
+
* @param label - Optional human-readable label
|
|
117
|
+
* @returns Promise that resolves when stored
|
|
118
|
+
* @throws Error if the API key format is invalid
|
|
119
|
+
*/
|
|
120
|
+
store(apiKey: string, label?: string): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Retrieve the stored OpenAI API key.
|
|
123
|
+
*
|
|
124
|
+
* Requirements: 7b.4
|
|
125
|
+
*
|
|
126
|
+
* @returns The credential result with the API key if found
|
|
127
|
+
*/
|
|
128
|
+
retrieve(): Promise<ModelCredentialResult>;
|
|
129
|
+
/**
|
|
130
|
+
* Delete the stored OpenAI API key.
|
|
131
|
+
*
|
|
132
|
+
* @returns Promise that resolves when deleted
|
|
133
|
+
*/
|
|
134
|
+
delete(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Check if an OpenAI API key is configured.
|
|
137
|
+
*
|
|
138
|
+
* @returns True if a valid API key is stored
|
|
139
|
+
*/
|
|
140
|
+
isConfigured(): Promise<boolean>;
|
|
141
|
+
/**
|
|
142
|
+
* Get the status of the OpenAI API key credential.
|
|
143
|
+
*
|
|
144
|
+
* @returns The credential status entry
|
|
145
|
+
*/
|
|
146
|
+
getStatus(): Promise<ModelCredentialStatusEntry>;
|
|
147
|
+
/**
|
|
148
|
+
* Inject the OpenAI API key into request headers.
|
|
149
|
+
*
|
|
150
|
+
* Creates the Authorization header with Bearer token format:
|
|
151
|
+
* Authorization: Bearer {key}
|
|
152
|
+
*
|
|
153
|
+
* Requirements: 7b.5
|
|
154
|
+
*
|
|
155
|
+
* @param headers - Existing headers object (will be modified)
|
|
156
|
+
* @returns The headers object with the Authorization header added
|
|
157
|
+
* @throws Error if no API key is configured
|
|
158
|
+
*/
|
|
159
|
+
injectHeader(headers?: Record<string, string>): Promise<Record<string, string>>;
|
|
160
|
+
/**
|
|
161
|
+
* Get the header injection for a request.
|
|
162
|
+
*
|
|
163
|
+
* Returns the header name and value for injecting the API key.
|
|
164
|
+
* This is useful when you need the header separately from the request.
|
|
165
|
+
*
|
|
166
|
+
* Requirements: 7b.5
|
|
167
|
+
*
|
|
168
|
+
* @returns Object with headerName and headerValue
|
|
169
|
+
* @throws Error if no API key is configured
|
|
170
|
+
*/
|
|
171
|
+
getHeaderInjection(): Promise<{
|
|
172
|
+
headerName: string;
|
|
173
|
+
headerValue: string;
|
|
174
|
+
}>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a new OpenAI API key handler.
|
|
178
|
+
*
|
|
179
|
+
* @param storage - The credential storage backend
|
|
180
|
+
* @returns A new OpenAI API key handler instance
|
|
181
|
+
*/
|
|
182
|
+
export declare function createOpenAIApiKeyHandler(storage: IModelCredentialStorage): OpenAIApiKeyHandler;
|