Skip to content

Commit 09217c8

Browse files
Type fixes needed to support anaconda's extension for api keys (#6)
1 parent a912f4c commit 09217c8

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type ExtensionErrorOptions = {
1616
message?: string; // User-friendly message describing what happened
1717
responsePayload?: Record<string, unknown>; // Extra JSON data to be returned to the client
1818
debugPayload?: Record<string, unknown>; // Extra JSON data for debugging. Not returned to the client in production
19-
cause?: Error; // The underlying error, if any
19+
cause?: unknown; // The underlying error, if any
2020
};
2121

2222
export type ErrorPayload = {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ export * from './providers/shared';
33
export * from './errors';
44

55
export type BackendExtension = {
6-
apiKey?: ApiKeyProvider;
6+
apiKey: ApiKeyProvider;
77
};

src/providers/api_key.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum ApiKeyCapabilities {
55
Revoke = 'revoke',
66
Delete = 'delete',
77
CreateWithResources = 'create_with_resources',
8+
ListKeysPaginated = 'list_keys_paginated',
89
}
910

1011
export type CreateApiKeyRequest = {

src/providers/shared.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ import type {
99
export type ProviderEnv = {
1010
DB: D1Database;
1111
AUTH_ISSUER: string;
12+
EXTENSION_CONFIG?: string; // JSON string containing arbitrary data the extension needs
1213
};
1314

1415
export enum AuthType {
1516
OAuth = 'oauth',
1617
ApiKey = 'api_key',
1718
}
1819

19-
export type Scope = 'runt:read' | 'runt:execute';
20+
export enum Scope {
21+
RuntRead = 'runt:read',
22+
RuntExecute = 'runt:execute',
23+
}
2024

2125
export type User = {
2226
id: string;

0 commit comments

Comments
 (0)