History

feat: enhance secret management in SDK

- 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.

Rhys Sullivan committed 7 months ago

Commit 8d3cddf1 parent 673821a11 files · +441 −87Browse files

Showing the changes to packages/plugins/openapi/src/plugin.ts (1 of 11 files). Show all

Unified · Split

packages/plugins/openapi/src/plugin.ts+11−3
@@ -29,12 +29,15 @@ import { · 28 unmodified lines
2929 // Plugin config
3030 // ---------------------------------------------------------------------------
3131
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+
3235 export interface OpenApiSpecConfig {
3336 readonly spec: string;
3437 readonly baseUrl?: string;
3538 readonly namespace?: string;
36− /** Static headers applied to every request for this spec */
37− readonly headers?: Record<string, string>;
39+ /** Headers applied to every request. Values can reference secrets. */
40+ readonly headers?: Record<string, HeaderValue>;
3841 }
3942
4043 // ---------------------------------------------------------------------------
@@ -105,7 +108,12 @@ export const openApiPlugin = (options?: { · 64 unmodified lines
105108 Effect.gen(function* () {
106109 yield* ctx.tools.registerInvoker(
107110 "openapi",
108− makeOpenApiInvoker(operationStore, httpClientLayer),
111+ makeOpenApiInvoker({
112+ operationStore,
113+ httpClientLayer,
114+ secrets: ctx.secrets,
115+ scopeId: ctx.scope.id,
116+ }),
109117 );
110118
111119 return {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t