hanzio 2.0.0 → 2.2.0
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/LICENSE +21 -0
- package/README.md +5 -6
- package/dist/api-wrapper/endpoint.d.ts +8 -5
- package/dist/api-wrapper/transport.d.ts +1 -0
- package/dist/api-wrapper/types.d.ts +7 -0
- package/dist/{index-wjyb9bsd.js → index-hyt6c56h.js} +39 -12
- package/dist/index-ktynw3vs.js +37 -0
- package/dist/{index-181e6vfw.js → index-w882zry3.js} +1 -1
- package/dist/{index-j1ybktbr.js → index-zbj9s3s3.js} +6 -4
- package/dist/secrets/core.d.ts +7 -0
- package/dist/secrets/index.d.ts +3 -1
- package/dist/secrets/public-config.d.ts +7 -0
- package/dist/secrets/vite.d.ts +1 -0
- package/dist/secrets/worker.d.ts +1 -0
- package/dist/src/api-wrapper/index.js +1 -1
- package/dist/src/secrets/index.js +14 -8
- package/dist/src/secrets/vite.js +5 -1
- package/dist/src/secrets/worker.js +8 -4
- package/package.json +10 -3
- package/src/api-wrapper/README.md +738 -0
- package/src/api-wrapper/create-client.ts +9 -3
- package/src/api-wrapper/endpoint.ts +19 -5
- package/src/api-wrapper/transport.ts +6 -2
- package/src/api-wrapper/types.ts +13 -0
- package/src/crypto/README.md +144 -0
- package/src/format/README.md +120 -0
- package/src/i18n/README.md +65 -0
- package/src/jwt/README.md +70 -0
- package/src/p-queue/README.md +237 -0
- package/src/secrets/README.md +413 -0
- package/src/secrets/core.ts +72 -16
- package/src/secrets/index.ts +16 -4
- package/src/secrets/public-config.ts +47 -0
- package/src/secrets/vite.ts +2 -0
- package/src/secrets/worker.ts +2 -0
- package/src/sitemap/README.md +61 -0
- package/src/storage/README.md +71 -0
- package/src/typedswitch/README.md +319 -0
- package/dist/index-srt06xd2.js +0 -15
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kristoffer Hansen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1156,9 +1156,8 @@ bun run build
|
|
|
1156
1156
|
|
|
1157
1157
|
## Releasing
|
|
1158
1158
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
publishes to npm. Nobody runs `npm publish` locally.
|
|
1159
|
+
Squash PRs with conventional titles (`fix:`, `feat:`, or `feat!:`). Release Please keeps the version and changelog in a release PR; merge that PR to publish with release notes and npm provenance. See [release and recovery instructions](docs/releasing.md).
|
|
1160
|
+
|
|
1161
|
+
## License
|
|
1162
|
+
|
|
1163
|
+
[MIT](LICENSE).
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import type { ApiEndpoint } from './types';
|
|
2
|
+
import type { ApiEndpoint, CheckResponseContext } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Defines an endpoint with full inference, as an alternative to
|
|
5
5
|
* `satisfies ApiEndpoint`: `resFormatter` must return what `resSchema`
|
|
6
|
-
* accepts,
|
|
7
|
-
*
|
|
6
|
+
* accepts, `checkResponse` receives the parsed `resSchema` output, and a
|
|
7
|
+
* literal `path` types its `:params` (making `reqParams` required when
|
|
8
|
+
* there's no `reqParamsSchema`).
|
|
8
9
|
*
|
|
9
10
|
* @example
|
|
10
11
|
* export const usersGet = defineEndpoint({
|
|
@@ -13,6 +14,8 @@ import type { ApiEndpoint } from './types';
|
|
|
13
14
|
* resSchema: User
|
|
14
15
|
* })
|
|
15
16
|
*/
|
|
16
|
-
export declare function defineEndpoint<const TEndpoint extends ApiEndpoint>(endpoint: TEndpoint & {
|
|
17
|
-
|
|
17
|
+
export declare function defineEndpoint<const TEndpoint extends Omit<ApiEndpoint, 'checkResponse'>, TRes extends z.ZodType = TEndpoint['resSchema']>(endpoint: TEndpoint & {
|
|
18
|
+
resSchema: TRes;
|
|
19
|
+
resFormatter?: (data: unknown, headers: Record<string, string>) => z.input<TRes>;
|
|
20
|
+
checkResponse?: ((data: z.output<TRes>, context: CheckResponseContext) => void | Promise<void>) | false;
|
|
18
21
|
}): TEndpoint;
|
|
@@ -49,6 +49,7 @@ export declare function makeRequestWithRetry<TValidated>(args: MakeRequestArgs<T
|
|
|
49
49
|
export declare function validateAndTransformResponse<T extends z.ZodType>(endpoint: ApiEndpoint<z.ZodType | undefined, z.ZodType | undefined, z.ZodType | undefined, z.ZodType | undefined, T>, response: Response, ctx: (over?: Partial<ApiErrorContext>) => ApiErrorContext): Promise<{
|
|
50
50
|
data: z.infer<T>;
|
|
51
51
|
responseSizeBytes: number;
|
|
52
|
+
headers: Record<string, string>;
|
|
52
53
|
}>;
|
|
53
54
|
export declare function defaultShouldRetry(ctx: RetryContext): boolean;
|
|
54
55
|
export {};
|
|
@@ -17,6 +17,11 @@ export interface ApiEndpoint<TReqBody extends z.ZodType | undefined = z.ZodType
|
|
|
17
17
|
resFormatter?: (data: unknown, headers: Record<string, string>) => z.input<TResponse>;
|
|
18
18
|
reqDefaultQueryParams?: QueryParams;
|
|
19
19
|
doNotEncodeQueryParams?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Replaces the client's `checkResponse` for this endpoint; `false` skips it.
|
|
22
|
+
* `defineEndpoint` types `data` as the parsed `resSchema` output.
|
|
23
|
+
*/
|
|
24
|
+
checkResponse?: ((data: any, context: CheckResponseContext) => void | Promise<void>) | false;
|
|
20
25
|
}
|
|
21
26
|
export interface ApiWrapperResponse<T> {
|
|
22
27
|
data: T;
|
|
@@ -25,6 +30,8 @@ export interface ApiWrapperResponse<T> {
|
|
|
25
30
|
responseTimeMs: number;
|
|
26
31
|
httpStatus: number;
|
|
27
32
|
retryCount: number;
|
|
33
|
+
/** Response headers of the final attempt, keyed by lowercase name. */
|
|
34
|
+
headers: Record<string, string>;
|
|
28
35
|
}
|
|
29
36
|
export type RetryContext = {
|
|
30
37
|
error?: unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SecretLoadError2
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-ktynw3vs.js";
|
|
4
4
|
|
|
5
5
|
// src/secrets/environment.ts
|
|
6
6
|
function getProcessEnvironment() {
|
|
@@ -92,9 +92,10 @@ function readOverrides(keys, env) {
|
|
|
92
92
|
return value ? [[key, value]] : [];
|
|
93
93
|
}));
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
function createSecretSet2(keys, options, environmentVariables) {
|
|
96
96
|
const keySet = [...new Set(keys)];
|
|
97
|
-
|
|
97
|
+
let environment;
|
|
98
|
+
let initialized = false;
|
|
98
99
|
const logger = options.logger === false ? undefined : options.logger ?? defaultLogger;
|
|
99
100
|
let cached;
|
|
100
101
|
let parsed;
|
|
@@ -105,7 +106,7 @@ async function defineSecretSet2(keys, options, environmentVariables) {
|
|
|
105
106
|
logger?.[level](message, attributes);
|
|
106
107
|
} catch {}
|
|
107
108
|
};
|
|
108
|
-
const loadSnapshot = async (request, signal) => {
|
|
109
|
+
const loadSnapshot = async (request, signal, environment) => {
|
|
109
110
|
const local = readOverrides(keySet, environmentVariables);
|
|
110
111
|
const missing = keySet.filter((key) => !Object.hasOwn(local, key));
|
|
111
112
|
let loaderSource = options.loader.source ?? "custom loader";
|
|
@@ -171,6 +172,7 @@ async function defineSecretSet2(keys, options, environmentVariables) {
|
|
|
171
172
|
cached = next;
|
|
172
173
|
parsed = nextParsed;
|
|
173
174
|
sources = nextSources;
|
|
175
|
+
initialized = true;
|
|
174
176
|
};
|
|
175
177
|
const load = (request = {}) => {
|
|
176
178
|
if (inFlight) {
|
|
@@ -179,10 +181,12 @@ async function defineSecretSet2(keys, options, environmentVariables) {
|
|
|
179
181
|
inFlight = (async () => {
|
|
180
182
|
const start = Date.now();
|
|
181
183
|
try {
|
|
184
|
+
environment ??= resolveSecretEnvironment(options.environment, environmentVariables);
|
|
185
|
+
const resolvedEnvironment = environment;
|
|
182
186
|
await withSecretDeadline({
|
|
183
187
|
timeoutMs: request.timeoutMs ?? options.timeoutMs,
|
|
184
188
|
signal: request.signal ?? options.signal
|
|
185
|
-
}, (signal) => loadSnapshot(request, signal));
|
|
189
|
+
}, (signal) => loadSnapshot(request, signal, resolvedEnvironment));
|
|
186
190
|
const sourceCounts = new Map;
|
|
187
191
|
for (const key of keySet) {
|
|
188
192
|
const source = sources[key];
|
|
@@ -190,7 +194,7 @@ async function defineSecretSet2(keys, options, environmentVariables) {
|
|
|
190
194
|
}
|
|
191
195
|
const counts = Object.fromEntries(sourceCounts);
|
|
192
196
|
log("info", "Loaded secrets", {
|
|
193
|
-
environment,
|
|
197
|
+
environment: resolvedEnvironment,
|
|
194
198
|
count: keySet.length,
|
|
195
199
|
durationMs: Date.now() - start,
|
|
196
200
|
source: Object.keys(counts).join(" + ") || "none",
|
|
@@ -199,7 +203,7 @@ async function defineSecretSet2(keys, options, environmentVariables) {
|
|
|
199
203
|
} catch (error) {
|
|
200
204
|
const safe = error instanceof SecretLoadError2 ? error : new SecretLoadError2("LOADER", "Secret loading failed.");
|
|
201
205
|
log("error", "Secret loading failed", {
|
|
202
|
-
environment,
|
|
206
|
+
environment: environment ?? "unresolved",
|
|
203
207
|
count: keySet.length,
|
|
204
208
|
durationMs: Date.now() - start,
|
|
205
209
|
code: safe.code
|
|
@@ -211,24 +215,47 @@ async function defineSecretSet2(keys, options, environmentVariables) {
|
|
|
211
215
|
});
|
|
212
216
|
return inFlight;
|
|
213
217
|
};
|
|
218
|
+
const assertLoaded = () => {
|
|
219
|
+
if (!initialized) {
|
|
220
|
+
throw new SecretLoadError2("CONFIGURATION", "Secret set has not been loaded. Await load() before reading values.");
|
|
221
|
+
}
|
|
222
|
+
};
|
|
214
223
|
const secretSet = {
|
|
215
224
|
secret(key) {
|
|
225
|
+
assertLoaded();
|
|
216
226
|
if (!Object.hasOwn(cached, key)) {
|
|
217
227
|
throw new SecretLoadError2("MISSING_SECRETS", `Secret ${key} not found`);
|
|
218
228
|
}
|
|
219
229
|
return cached[key];
|
|
220
230
|
},
|
|
221
|
-
secrets
|
|
222
|
-
|
|
223
|
-
|
|
231
|
+
secrets() {
|
|
232
|
+
assertLoaded();
|
|
233
|
+
return { ...cached };
|
|
234
|
+
},
|
|
235
|
+
parsed() {
|
|
236
|
+
assertLoaded();
|
|
237
|
+
return structuredClone(parsed);
|
|
238
|
+
},
|
|
239
|
+
sources() {
|
|
240
|
+
assertLoaded();
|
|
241
|
+
return { ...sources };
|
|
242
|
+
},
|
|
243
|
+
async load(request) {
|
|
244
|
+
if (!initialized) {
|
|
245
|
+
await load(request);
|
|
246
|
+
}
|
|
247
|
+
return secretSet;
|
|
248
|
+
},
|
|
224
249
|
async reload(request) {
|
|
225
250
|
await load(request);
|
|
226
251
|
return secretSet;
|
|
227
252
|
}
|
|
228
253
|
};
|
|
229
|
-
await load();
|
|
230
254
|
return secretSet;
|
|
231
255
|
}
|
|
256
|
+
async function defineSecretSet2(keys, options, environmentVariables) {
|
|
257
|
+
return createSecretSet2(keys, options, environmentVariables).load();
|
|
258
|
+
}
|
|
232
259
|
|
|
233
260
|
// src/secrets/worker-loader.ts
|
|
234
261
|
function cloudflareWorkerEnvLoader2(workerEnv) {
|
|
@@ -260,4 +287,4 @@ function workerBindingToString(value) {
|
|
|
260
287
|
return String(value);
|
|
261
288
|
}
|
|
262
289
|
|
|
263
|
-
export { withSecretDeadline, getProcessEnvironment, resolveSecretEnvironment, defineSecretSet2, cloudflareWorkerEnvLoader2 };
|
|
290
|
+
export { withSecretDeadline, getProcessEnvironment, resolveSecretEnvironment, createSecretSet2, defineSecretSet2, cloudflareWorkerEnvLoader2 };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/secrets/errors.ts
|
|
2
|
+
class SecretLoadError2 extends Error {
|
|
3
|
+
code;
|
|
4
|
+
operation;
|
|
5
|
+
status;
|
|
6
|
+
constructor(code, message, details = {}) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "SecretLoadError";
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.operation = details.operation;
|
|
11
|
+
this.status = details.status;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/secrets/public-config.ts
|
|
16
|
+
function readPublicConfig2(keys, values) {
|
|
17
|
+
const snapshot = Object.fromEntries(keys.map((key) => [
|
|
18
|
+
key,
|
|
19
|
+
Object.hasOwn(values, key) ? values[key] : undefined
|
|
20
|
+
]));
|
|
21
|
+
const missing = keys.filter((key) => typeof snapshot[key] !== "string" || !snapshot[key]);
|
|
22
|
+
if (missing.length) {
|
|
23
|
+
throw new SecretLoadError2("MISSING_SECRETS", `Missing required public configuration: ${missing.join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
const configured = snapshot;
|
|
26
|
+
return {
|
|
27
|
+
secret(key) {
|
|
28
|
+
if (!Object.hasOwn(configured, key)) {
|
|
29
|
+
throw new SecretLoadError2("CONFIGURATION", `Public key ${key} is not configured.`);
|
|
30
|
+
}
|
|
31
|
+
return configured[key];
|
|
32
|
+
},
|
|
33
|
+
secrets: () => ({ ...configured })
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { SecretLoadError2, readPublicConfig2 };
|
|
@@ -1006,7 +1006,7 @@ async function validateAndTransformResponse(endpoint, response, ctx) {
|
|
|
1006
1006
|
}
|
|
1007
1007
|
const transformedData = endpoint.resFormatter ? endpoint.resFormatter(responseData, responseHeaders) : responseData;
|
|
1008
1008
|
const data = await validateResponse(endpoint.resSchema, transformedData, ctx);
|
|
1009
|
-
return { data, responseSizeBytes };
|
|
1009
|
+
return { data, responseSizeBytes, headers: responseHeaders };
|
|
1010
1010
|
}
|
|
1011
1011
|
function defaultShouldRetry2(ctx) {
|
|
1012
1012
|
if (ctx.error)
|
|
@@ -1170,14 +1170,16 @@ function createApiClientImpl(apiConfig) {
|
|
|
1170
1170
|
responseSizeMb: result.validatedData.responseSizeBytes / (1024 * 1024),
|
|
1171
1171
|
responseTimeMs: elapsed(),
|
|
1172
1172
|
httpStatus: result.httpStatus,
|
|
1173
|
-
retryCount: result.retryCount
|
|
1173
|
+
retryCount: result.retryCount,
|
|
1174
|
+
headers: result.validatedData.headers
|
|
1174
1175
|
};
|
|
1175
1176
|
};
|
|
1176
1177
|
const runCheckResponse = async (data, httpStatus, attempt) => {
|
|
1177
|
-
|
|
1178
|
+
const checkResponse = endpoint.checkResponse === undefined ? apiConfig.checkResponse : endpoint.checkResponse;
|
|
1179
|
+
if (!checkResponse)
|
|
1178
1180
|
return;
|
|
1179
1181
|
try {
|
|
1180
|
-
await
|
|
1182
|
+
await checkResponse(data, {
|
|
1181
1183
|
endpoint: endpointName,
|
|
1182
1184
|
method: endpoint.method,
|
|
1183
1185
|
url: fullUrl,
|
package/dist/secrets/core.d.ts
CHANGED
|
@@ -44,4 +44,11 @@ export type SecretSet<K extends string, Parsed = Record<K, string>> = {
|
|
|
44
44
|
sources: () => Record<K, string>;
|
|
45
45
|
reload: (options?: SecretRequestOptions) => Promise<SecretSet<K, Parsed>>;
|
|
46
46
|
};
|
|
47
|
+
/** A declaration that must be loaded explicitly before its values can be read. */
|
|
48
|
+
export type LazySecretSet<K extends string, Parsed = Record<K, string>> = SecretSet<K, Parsed> & {
|
|
49
|
+
/** Initialize once. Concurrent calls share a load; use reload to refresh. */
|
|
50
|
+
load: (options?: SecretRequestOptions) => Promise<LazySecretSet<K, Parsed>>;
|
|
51
|
+
};
|
|
52
|
+
export declare function createSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: CustomLoaderDefineSecretSetOptions<Keys[number], Parsed>, environmentVariables?: EnvironmentVariables): LazySecretSet<Keys[number], Parsed>;
|
|
53
|
+
/** Compatibility API: declares and loads a complete snapshot before returning. */
|
|
47
54
|
export declare function defineSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: CustomLoaderDefineSecretSetOptions<Keys[number], Parsed>, environmentVariables?: EnvironmentVariables): Promise<SecretSet<Keys[number], Parsed>>;
|
package/dist/secrets/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CommonSecretSetOptions, type CustomLoaderDefineSecretSetOptions, type SecretSet } from './core';
|
|
1
|
+
import { type LazySecretSet, type CommonSecretSetOptions, type CustomLoaderDefineSecretSetOptions, type SecretSet } from './core';
|
|
2
2
|
import { type SecretEnvironment } from './environment';
|
|
3
3
|
import { type InfisicalAuthMode } from './infisical';
|
|
4
4
|
import { type InfisicalProjectOptions } from './infisical-config';
|
|
@@ -15,4 +15,6 @@ export type InfisicalDefineSecretSetOptions<K extends string = string, Parsed =
|
|
|
15
15
|
};
|
|
16
16
|
export type DefineSecretSetOptions<K extends string, Parsed = Record<K, string>> = InfisicalDefineSecretSetOptions<K, Parsed> | CustomLoaderDefineSecretSetOptions<K, Parsed>;
|
|
17
17
|
export declare function getSecretEnvironment(): SecretEnvironment;
|
|
18
|
+
export declare function createSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: DefineSecretSetOptions<Keys[number], Parsed>): LazySecretSet<Keys[number], Parsed>;
|
|
19
|
+
/** Compatibility API: load immediately and fail before application startup. */
|
|
18
20
|
export declare function defineSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: DefineSecretSetOptions<Keys[number], Parsed>): Promise<SecretSet<Keys[number], Parsed>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SecretSet } from './core';
|
|
2
|
+
/**
|
|
3
|
+
* Read only explicitly listed public values. No process globals, secret loader,
|
|
4
|
+
* environment writes, or async initialization; safe in frontend tooling.
|
|
5
|
+
* Validate application-specific formats with your schema after secrets().
|
|
6
|
+
*/
|
|
7
|
+
export declare function readPublicConfig<const Keys extends readonly string[]>(keys: Keys, values: Readonly<Record<string, string | undefined>>): Pick<SecretSet<Keys[number]>, 'secret' | 'secrets'>;
|
package/dist/secrets/vite.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export type ViteSecretSetOptions<K extends string> = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function getViteDefine<K extends string>(secretSet: Pick<SecretSet<K, unknown>, 'secrets'>, options?: ViteSecretSetOptions<K>): Record<string, string>;
|
|
13
13
|
export declare function viteSecretSetPlugin<K extends string>(secretSet: Pick<SecretSet<K, unknown>, 'secrets'>, options?: ViteSecretSetOptions<K>): ViteSecretSetPlugin;
|
|
14
|
+
export { readPublicConfig } from './public-config';
|
package/dist/secrets/worker.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HttpResponseError2,
|
|
3
3
|
createApiClient2
|
|
4
|
-
} from "../../index-
|
|
4
|
+
} from "../../index-zbj9s3s3.js";
|
|
5
5
|
import {
|
|
6
6
|
getViteDefine2,
|
|
7
7
|
viteSecretSetPlugin2
|
|
8
|
-
} from "../../index-
|
|
8
|
+
} from "../../index-w882zry3.js";
|
|
9
9
|
import {
|
|
10
10
|
withSecretDeadline,
|
|
11
11
|
getProcessEnvironment,
|
|
12
12
|
resolveSecretEnvironment,
|
|
13
|
-
|
|
13
|
+
createSecretSet2,
|
|
14
14
|
cloudflareWorkerEnvLoader2
|
|
15
|
-
} from "../../index-
|
|
15
|
+
} from "../../index-hyt6c56h.js";
|
|
16
16
|
import {
|
|
17
|
-
SecretLoadError2
|
|
18
|
-
|
|
17
|
+
SecretLoadError2,
|
|
18
|
+
readPublicConfig2
|
|
19
|
+
} from "../../index-ktynw3vs.js";
|
|
19
20
|
|
|
20
21
|
// src/secrets/infisical.ts
|
|
21
22
|
import { z as z2 } from "zod";
|
|
@@ -328,7 +329,7 @@ Object.assign(processEnvLoader, { source: "process.env" });
|
|
|
328
329
|
function getSecretEnvironment() {
|
|
329
330
|
return resolveSecretEnvironment(undefined, getProcessEnvironment());
|
|
330
331
|
}
|
|
331
|
-
|
|
332
|
+
function createSecretSet(keys, options) {
|
|
332
333
|
let loader;
|
|
333
334
|
if (!options.loader) {
|
|
334
335
|
validateInfisicalOrganizationId(options.organizationId);
|
|
@@ -336,7 +337,7 @@ async function defineSecretSet(keys, options) {
|
|
|
336
337
|
} else {
|
|
337
338
|
loader = options.loader;
|
|
338
339
|
}
|
|
339
|
-
return
|
|
340
|
+
return createSecretSet2(keys, { ...options, loader }, getProcessEnvironment());
|
|
340
341
|
}
|
|
341
342
|
function createDefaultInfisicalLoader(options) {
|
|
342
343
|
return (context) => loadInfisicalSecrets({
|
|
@@ -350,10 +351,14 @@ function createDefaultInfisicalLoader(options) {
|
|
|
350
351
|
clientSecretEnvKey: options.clientSecretEnvKey ?? "INFISICAL_CLIENT_SECRET"
|
|
351
352
|
});
|
|
352
353
|
}
|
|
354
|
+
async function defineSecretSet(keys, options) {
|
|
355
|
+
return createSecretSet(keys, options).load();
|
|
356
|
+
}
|
|
353
357
|
export {
|
|
354
358
|
DEFAULT_INFISICAL_SITE_URL,
|
|
355
359
|
SecretLoadError2 as SecretLoadError,
|
|
356
360
|
cloudflareWorkerEnvLoader2 as cloudflareWorkerEnvLoader,
|
|
361
|
+
createSecretSet,
|
|
357
362
|
defineSecretSet,
|
|
358
363
|
fetchInfisicalSecrets,
|
|
359
364
|
getSecretEnvironment,
|
|
@@ -361,5 +366,6 @@ export {
|
|
|
361
366
|
infisicalLoader,
|
|
362
367
|
loadInfisicalSecrets,
|
|
363
368
|
processEnvLoader,
|
|
369
|
+
readPublicConfig2 as readPublicConfig,
|
|
364
370
|
viteSecretSetPlugin2 as viteSecretSetPlugin
|
|
365
371
|
};
|
package/dist/src/secrets/vite.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getViteDefine2,
|
|
3
3
|
viteSecretSetPlugin2
|
|
4
|
-
} from "../../index-
|
|
4
|
+
} from "../../index-w882zry3.js";
|
|
5
|
+
import {
|
|
6
|
+
readPublicConfig2
|
|
7
|
+
} from "../../index-ktynw3vs.js";
|
|
5
8
|
export {
|
|
6
9
|
getViteDefine2 as getViteDefine,
|
|
10
|
+
readPublicConfig2 as readPublicConfig,
|
|
7
11
|
viteSecretSetPlugin2 as viteSecretSetPlugin
|
|
8
12
|
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createSecretSet2,
|
|
2
3
|
defineSecretSet2,
|
|
3
4
|
cloudflareWorkerEnvLoader2
|
|
4
|
-
} from "../../index-
|
|
5
|
+
} from "../../index-hyt6c56h.js";
|
|
5
6
|
import {
|
|
6
|
-
SecretLoadError2
|
|
7
|
-
|
|
7
|
+
SecretLoadError2,
|
|
8
|
+
readPublicConfig2
|
|
9
|
+
} from "../../index-ktynw3vs.js";
|
|
8
10
|
export {
|
|
9
11
|
SecretLoadError2 as SecretLoadError,
|
|
10
12
|
cloudflareWorkerEnvLoader2 as cloudflareWorkerEnvLoader,
|
|
11
|
-
|
|
13
|
+
createSecretSet2 as createSecretSet,
|
|
14
|
+
defineSecretSet2 as defineSecretSet,
|
|
15
|
+
readPublicConfig2 as readPublicConfig
|
|
12
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hanzio",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A lightweight set of utility functions for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/src/index.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"src/**/*.ts",
|
|
28
|
+
"src/**/README.md",
|
|
28
29
|
"dist",
|
|
29
30
|
"!src/**/*.test.ts"
|
|
30
31
|
],
|
|
@@ -132,7 +133,8 @@
|
|
|
132
133
|
"typecheck": "tsgo --noEmit",
|
|
133
134
|
"prepare": "husky",
|
|
134
135
|
"test:secrets:runtime": "bun run build && node scripts/verify-secrets.mjs",
|
|
135
|
-
"test:exports": "bun run build && node scripts/verify-exports.mjs"
|
|
136
|
+
"test:exports": "bun run build && node scripts/verify-exports.mjs",
|
|
137
|
+
"verify:package": "node scripts/verify-package.mjs"
|
|
136
138
|
},
|
|
137
139
|
"devDependencies": {
|
|
138
140
|
"@biomejs/biome": "^2.4.6",
|
|
@@ -152,5 +154,10 @@
|
|
|
152
154
|
"zod": {
|
|
153
155
|
"optional": true
|
|
154
156
|
}
|
|
155
|
-
}
|
|
157
|
+
},
|
|
158
|
+
"homepage": "https://github.com/HansKristoffer/hanzio#readme",
|
|
159
|
+
"bugs": {
|
|
160
|
+
"url": "https://github.com/HansKristoffer/hanzio/issues"
|
|
161
|
+
},
|
|
162
|
+
"packageManager": "bun@1.4.2"
|
|
156
163
|
}
|