@hot-updater/cloudflare 1.2.0-rc.8 → 1.2.0-rc.9

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.
@@ -1,45 +0,0 @@
1
- import type { S3ClientConfig } from "@aws-sdk/client-s3";
2
- import { type Lazy, resolveLazy } from "@hot-updater/plugin-core";
3
-
4
- type SdkCredentials = S3ClientConfig["credentials"];
5
-
6
- /**
7
- * Access keys whose fields may each be a function that returns them, such
8
- * as `secret("<name>")` in `hot-updater.config.ts`, called on first use.
9
- */
10
- export interface LazyAwsCredentials {
11
- readonly accessKeyId: Lazy<string>;
12
- readonly secretAccessKey: Lazy<string>;
13
- readonly sessionToken?: Lazy<string>;
14
- }
15
-
16
- /** The credentials the AWS SDK takes, or access keys with lazy fields. */
17
- export type AwsCredentialsOption = SdkCredentials | LazyAwsCredentials;
18
-
19
- /**
20
- * `credentials` as the AWS SDK takes them: access keys with a lazy field
21
- * become a provider, which the SDK calls once, on its first request.
22
- */
23
- export const toSdkCredentials = (
24
- credentials: AwsCredentialsOption | undefined,
25
- ): SdkCredentials => {
26
- if (credentials === undefined || typeof credentials === "function") {
27
- return credentials;
28
- }
29
- const { accessKeyId, secretAccessKey, sessionToken, ...rest } = credentials;
30
- if (
31
- typeof accessKeyId !== "function" &&
32
- typeof secretAccessKey !== "function" &&
33
- typeof sessionToken !== "function"
34
- ) {
35
- return credentials as SdkCredentials;
36
- }
37
- return async () => ({
38
- ...rest,
39
- accessKeyId: await resolveLazy(accessKeyId),
40
- secretAccessKey: await resolveLazy(secretAccessKey),
41
- ...(sessionToken === undefined
42
- ? {}
43
- : { sessionToken: await resolveLazy(sessionToken) }),
44
- });
45
- };