@codeguide/core 0.0.23 → 0.0.25
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 +176 -292
- package/__tests__/services/codespace/codespace-models.test.ts +458 -0
- package/__tests__/services/security-keys.test.ts +587 -0
- package/codeguide.ts +3 -1
- package/dist/codeguide.d.ts +2 -1
- package/dist/codeguide.js +1 -0
- package/dist/services/codespace/codespace-service.d.ts +54 -1
- package/dist/services/codespace/codespace-service.js +136 -0
- package/dist/services/codespace/codespace-types.d.ts +60 -0
- package/dist/services/codespace/index.d.ts +1 -1
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +4 -1
- package/dist/services/security-keys/index.d.ts +3 -0
- package/dist/services/security-keys/index.js +21 -0
- package/dist/services/security-keys/security-keys-service.d.ts +111 -0
- package/dist/services/security-keys/security-keys-service.js +190 -0
- package/dist/services/security-keys/security-keys-types.d.ts +105 -0
- package/dist/services/security-keys/security-keys-types.js +8 -0
- package/package.json +1 -1
- package/services/codespace/codespace-service.ts +162 -0
- package/services/codespace/codespace-types.ts +82 -1
- package/services/codespace/index.ts +14 -1
- package/services/index.ts +2 -0
- package/services/security-keys/index.ts +25 -0
- package/services/security-keys/security-keys-service.ts +229 -0
- package/services/security-keys/security-keys-types.ts +187 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Keys Service Types
|
|
3
|
+
*
|
|
4
|
+
* This file contains type definitions for the Security Keys service,
|
|
5
|
+
* which manages provider API keys and GitHub tokens.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Core Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export interface SecurityKeyData {
|
|
13
|
+
id: string
|
|
14
|
+
created_at: string
|
|
15
|
+
user_id: string
|
|
16
|
+
name: string
|
|
17
|
+
displayed_name: string
|
|
18
|
+
value_masked: string
|
|
19
|
+
value?: string // Only included when reveal=true
|
|
20
|
+
object_value: Record<string, any>
|
|
21
|
+
encryption: string
|
|
22
|
+
key_version: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ProviderAPIKeyData extends SecurityKeyData {
|
|
26
|
+
provider_id: string
|
|
27
|
+
provider_name: string
|
|
28
|
+
provider_key: string
|
|
29
|
+
provider_logo_src?: string // Only included in list endpoint
|
|
30
|
+
object_value: {
|
|
31
|
+
provider_id: string
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface GitHubTokenData extends SecurityKeyData {
|
|
36
|
+
object_value: {
|
|
37
|
+
token_type: string
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Common Response Types
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
export interface SuccessResponse<T> {
|
|
46
|
+
status: 'success'
|
|
47
|
+
data: T
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ErrorResponse {
|
|
51
|
+
detail: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// Provider API Key Types
|
|
56
|
+
// ============================================================================
|
|
57
|
+
|
|
58
|
+
export interface CreateProviderAPIKeyRequest {
|
|
59
|
+
provider_key: string
|
|
60
|
+
api_key: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface CreateProviderAPIKeyResponse extends SuccessResponse<ProviderAPIKeyData> {}
|
|
64
|
+
|
|
65
|
+
export interface GetProviderAPIKeyResponse extends SuccessResponse<ProviderAPIKeyData> {}
|
|
66
|
+
|
|
67
|
+
export interface ListProviderAPIKeysResponse extends SuccessResponse<ProviderAPIKeyData[]> {}
|
|
68
|
+
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// GitHub Token Types
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
73
|
+
export interface CreateGitHubTokenRequest {
|
|
74
|
+
github_token: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface CreateGitHubTokenResponse extends SuccessResponse<GitHubTokenData> {}
|
|
78
|
+
|
|
79
|
+
export interface GetGitHubTokenResponse extends SuccessResponse<GitHubTokenData> {}
|
|
80
|
+
|
|
81
|
+
// ============================================================================
|
|
82
|
+
// Error Response Types
|
|
83
|
+
// ============================================================================
|
|
84
|
+
|
|
85
|
+
export interface ProviderNotFoundError extends ErrorResponse {
|
|
86
|
+
detail: string // "Provider 'invalid_provider' not found. Please choose a valid provider."
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface DuplicateKeyError extends ErrorResponse {
|
|
90
|
+
detail: string // "API key for provider 'openai' already exists. Use update endpoint to change it."
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface KeyNotFoundError extends ErrorResponse {
|
|
94
|
+
detail: string // "No API key found for provider 'anthropic'"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface InvalidGitHubTokenFormatError extends ErrorResponse {
|
|
98
|
+
detail: string // "Invalid GitHub token format. Expected format: ghp_*, gho_*, ghu_*, ghs_*, or ghr_* followed by 36 characters"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface GitHubTokenValidationError extends ErrorResponse {
|
|
102
|
+
detail: string // "GitHub token validation failed. Please check that the token is valid and has the necessary permissions."
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface DuplicateGitHubTokenError extends ErrorResponse {
|
|
106
|
+
detail: string // "GitHub token already exists. Use update endpoint to change it."
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface GitHubTokenNotFoundError extends ErrorResponse {
|
|
110
|
+
detail: string // "No GitHub token found"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface AuthenticationError extends ErrorResponse {
|
|
114
|
+
detail: string // "Authentication required. Provide either Bearer token (JWT or sk_...) or X-API-Key with X-User-ID headers"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface InternalServerError extends ErrorResponse {
|
|
118
|
+
detail: string // "Failed to save provider API key"
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ============================================================================
|
|
122
|
+
// Request/Response Type Unions
|
|
123
|
+
// ============================================================================
|
|
124
|
+
|
|
125
|
+
export type ProviderAPIKeyResponse =
|
|
126
|
+
| CreateProviderAPIKeyResponse
|
|
127
|
+
| GetProviderAPIKeyResponse
|
|
128
|
+
| ListProviderAPIKeysResponse
|
|
129
|
+
| RevokeProviderAPIKeyResponse
|
|
130
|
+
| SecurityKeysError
|
|
131
|
+
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// DELETE Response Types
|
|
134
|
+
// ============================================================================
|
|
135
|
+
|
|
136
|
+
export interface RevokeProviderAPIKeyResponse {
|
|
137
|
+
status: string
|
|
138
|
+
message: string
|
|
139
|
+
revoked_provider_id: string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface RevokeGitHubTokenResponse {
|
|
143
|
+
status: string
|
|
144
|
+
message: string
|
|
145
|
+
revoked_at: string
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// DELETE Error Types
|
|
150
|
+
// ============================================================================
|
|
151
|
+
|
|
152
|
+
export interface ProviderAPIKeyNotFoundError extends ErrorResponse {
|
|
153
|
+
detail: string // "No API key found for provider 'openai'"
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface ProviderAPIKeyDeletionError extends ErrorResponse {
|
|
157
|
+
detail: string // "Failed to delete provider API key"
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface GitHubTokenDeletionError extends ErrorResponse {
|
|
161
|
+
detail: string // "Failed to delete GitHub token"
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ============================================================================
|
|
165
|
+
// Union Types for Error Handling
|
|
166
|
+
// ============================================================================
|
|
167
|
+
|
|
168
|
+
export type SecurityKeysError =
|
|
169
|
+
| ProviderNotFoundError
|
|
170
|
+
| DuplicateKeyError
|
|
171
|
+
| KeyNotFoundError
|
|
172
|
+
| InvalidGitHubTokenFormatError
|
|
173
|
+
| GitHubTokenValidationError
|
|
174
|
+
| DuplicateGitHubTokenError
|
|
175
|
+
| GitHubTokenNotFoundError
|
|
176
|
+
| ProviderAPIKeyNotFoundError
|
|
177
|
+
| ProviderAPIKeyDeletionError
|
|
178
|
+
| GitHubTokenDeletionError
|
|
179
|
+
| AuthenticationError
|
|
180
|
+
| InternalServerError
|
|
181
|
+
| ErrorResponse
|
|
182
|
+
|
|
183
|
+
export type GitHubTokenResponse =
|
|
184
|
+
| CreateGitHubTokenResponse
|
|
185
|
+
| GetGitHubTokenResponse
|
|
186
|
+
| RevokeGitHubTokenResponse
|
|
187
|
+
| SecurityKeysError
|