- Introduced `SecretRef` class to represent stored secrets without their values. - Updated `SecretStore` to manage `SecretRef` instances, allowing for better handling of secret resolution and status checks. - Added `resolve` and `status` methods to `SecretStore` for retrieving secret values and checking their availability. - Refactored in-memory secret store to support the new structure and added a default in-memory secret provider. - Updated OpenAPI plugin to resolve secret-backed headers during invocation, improving security handling in API requests. - Enhanced tests to cover new secret management features and ensure proper resolution of secrets in headers. All changes are aimed at improving the flexibility and security of secret handling within the SDK.
Showing the changes to packages/plugins/openapi/src/plugin.ts (1 of 11 files). Show all
Unified · Split
| @@ -29,12 +29,15 @@ import { · 28 unmodified lines | |||
| 29 | // Plugin config | 29 | // Plugin config |
| 30 | // --------------------------------------------------------------------------- | 30 | // --------------------------------------------------------------------------- |
| 31 | 31 | ||
| 32 | /** A header value — either a static string or a reference to a secret */ | ||
| 33 | export type HeaderValue = string | { readonly secretId: string; readonly prefix?: string }; | ||
| 34 | |||
| 32 | export interface OpenApiSpecConfig { | 35 | export interface OpenApiSpecConfig { |
| 33 | readonly spec: string; | 36 | readonly spec: string; |
| 34 | readonly baseUrl?: string; | 37 | readonly baseUrl?: string; |
| 35 | readonly namespace?: string; | 38 | readonly namespace?: string; |
| 36 | /** Static headers applied to every request for this spec */ | 39 | /** Headers applied to every request. Values can reference secrets. */ |
| 37 | readonly headers?: Record<string, string>; | 40 | readonly headers?: Record<string, HeaderValue>; |
| 38 | } | 41 | } |
| 39 | 42 | ||
| 40 | // --------------------------------------------------------------------------- | 43 | // --------------------------------------------------------------------------- |
| @@ -105,7 +108,12 @@ export const openApiPlugin = (options?: { · 64 unmodified lines | |||
| 105 | Effect.gen(function* () { | 108 | Effect.gen(function* () { |
| 106 | yield* ctx.tools.registerInvoker( | 109 | yield* ctx.tools.registerInvoker( |
| 107 | "openapi", | 110 | "openapi", |
| 108 | makeOpenApiInvoker(operationStore, httpClientLayer), | 111 | makeOpenApiInvoker({ |
| 112 | operationStore, | ||
| 113 | httpClientLayer, | ||
| 114 | secrets: ctx.secrets, | ||
| 115 | scopeId: ctx.scope.id, | ||
| 116 | }), | ||
| 109 | ); | 117 | ); |
| 110 | 118 | ||
| 111 | return { | 119 | return { |