@bunny.net/api-client-effect-v4-runtime 1.0.0 → 1.1.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/CHANGELOG.md +10 -0
- package/README.md +5 -4
- package/dist/src/credentials.d.ts +7 -1
- package/dist/src/credentials.js +10 -2
- package/dist/src/credentials.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @bunny.net/api-client-effect-v4-runtime
|
|
2
|
+
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1baeec8: `BunnyCredentials.fromEnv()` without a name now reads `BUNNYNET_API_KEY`. The
|
|
8
|
+
previous default, `BUNNY_API_KEY`, is still read when `BUNNYNET_API_KEY` is
|
|
9
|
+
unset, and is deprecated: the fallback goes away in the next major. A name
|
|
10
|
+
passed explicitly is read as before.
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ const program = Effect.gen(function* () {
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
const Live = BunnyCore.Default.pipe(
|
|
46
|
-
Layer.provide(BunnyCredentials.layer(process.env.
|
|
46
|
+
Layer.provide(BunnyCredentials.layer(process.env.BUNNYNET_API_KEY!)),
|
|
47
47
|
Layer.provide(FetchHttpClient.layer),
|
|
48
48
|
);
|
|
49
49
|
|
|
@@ -52,9 +52,10 @@ console.log(await Effect.runPromise(program.pipe(Effect.provide(Live))));
|
|
|
52
52
|
|
|
53
53
|
`BunnyCredentials.layer(key)` holds one key, as a string or an existing
|
|
54
54
|
`Redacted`; `BunnyCredentials.fromEnv(name)` reads it from configuration,
|
|
55
|
-
`
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
`BUNNYNET_API_KEY` by default, falling back to the deprecated `BUNNY_API_KEY`
|
|
56
|
+
when it is unset. The key is kept `Redacted`, so it never shows up through
|
|
57
|
+
`toString`, `JSON.stringify` or inspection, and it is revealed at one place
|
|
58
|
+
only: when the auth header is set on the outgoing request.
|
|
58
59
|
|
|
59
60
|
The errors are all `Data.TaggedError`, so `Effect.catchTag` narrows them:
|
|
60
61
|
|
|
@@ -14,7 +14,13 @@ declare const BunnyCredentials_base: Context.ServiceClass<BunnyCredentials, "@bu
|
|
|
14
14
|
export declare class BunnyCredentials extends BunnyCredentials_base {
|
|
15
15
|
/** A layer holding one key. Accepts a raw string (wrapped immediately) or an existing `Redacted`. */
|
|
16
16
|
static readonly layer: (accessKey: string | Redacted.Redacted<string>) => Layer.Layer<BunnyCredentials>;
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* A layer reading the key from configuration (the environment by default).
|
|
19
|
+
*
|
|
20
|
+
* With a name, it reads that name only. Without one, it reads
|
|
21
|
+
* `BUNNYNET_API_KEY`, then the deprecated `BUNNY_API_KEY` when that is
|
|
22
|
+
* unset; the fallback goes away in the next major.
|
|
23
|
+
*/
|
|
18
24
|
static readonly fromEnv: (name?: string) => Layer.Layer<BunnyCredentials, Config.ConfigError>;
|
|
19
25
|
}
|
|
20
26
|
export {};
|
package/dist/src/credentials.js
CHANGED
|
@@ -13,7 +13,15 @@ export class BunnyCredentials extends Context.Service()("@bunny.net/api-client-e
|
|
|
13
13
|
? accessKey
|
|
14
14
|
: Redacted.make(accessKey),
|
|
15
15
|
});
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* A layer reading the key from configuration (the environment by default).
|
|
18
|
+
*
|
|
19
|
+
* With a name, it reads that name only. Without one, it reads
|
|
20
|
+
* `BUNNYNET_API_KEY`, then the deprecated `BUNNY_API_KEY` when that is
|
|
21
|
+
* unset; the fallback goes away in the next major.
|
|
22
|
+
*/
|
|
23
|
+
static fromEnv = (name) => Layer.effect(BunnyCredentials, (name === undefined
|
|
24
|
+
? Config.Redacted("BUNNYNET_API_KEY").pipe(Config.orElse(() => Config.Redacted("BUNNY_API_KEY")))
|
|
25
|
+
: Config.Redacted(name)).pipe(Effect.map((accessKey) => ({ accessKey }))));
|
|
18
26
|
}
|
|
19
27
|
//# sourceMappingURL=credentials.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAOlE;;;;;;GAMG;AACH,MAAM,OAAO,gBACX,SAAQ,OAAO,CAAC,OAAO,EAA2C,CAChE,0DAA0D,CAC3D;IACD,qGAAqG;IACrG,MAAM,CAAU,KAAK,GAAG,CACtB,SAA6C,EACd,EAAE,CACjC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAC9B,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;YACvC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;KAC7B,CAAC,CAAC;IAEL
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAOlE;;;;;;GAMG;AACH,MAAM,OAAO,gBACX,SAAQ,OAAO,CAAC,OAAO,EAA2C,CAChE,0DAA0D,CAC3D;IACD,qGAAqG;IACrG,MAAM,CAAU,KAAK,GAAG,CACtB,SAA6C,EACd,EAAE,CACjC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAC9B,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;YACvC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;KAC7B,CAAC,CAAC;IAEL;;;;;;OAMG;IACH,MAAM,CAAU,OAAO,GAAG,CACxB,IAAa,EACsC,EAAE,CACrD,KAAK,CAAC,MAAM,CACV,gBAAgB,EAChB,CAAC,IAAI,KAAK,SAAS;QACjB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,IAAI,CACxC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CACtD;QACD,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAC3B,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAC3C,CACJ,CAAC","sourcesContent":["import { Config, Context, Effect, Layer, Redacted } from \"effect\";\n\n/** What a Bunny.net client needs to authenticate: the API key (or, for the Edge Storage API, the zone password). */\nexport interface BunnyCredentialsShape {\n readonly accessKey: Redacted.Redacted<string>;\n}\n\n/**\n * The credential service every generated client reads from context.\n *\n * The key is held as `Redacted` so it never appears through\n * `toString`/`JSON.stringify`/inspection; it is revealed at exactly one\n * place, when the auth header is set on the outgoing request.\n */\nexport class BunnyCredentials\n extends Context.Service<BunnyCredentials, BunnyCredentialsShape>()(\n \"@bunny.net/api-client-effect-v4-runtime/BunnyCredentials\",\n ) {\n /** A layer holding one key. Accepts a raw string (wrapped immediately) or an existing `Redacted`. */\n static readonly layer = (\n accessKey: string | Redacted.Redacted<string>,\n ): Layer.Layer<BunnyCredentials> =>\n Layer.succeed(BunnyCredentials, {\n accessKey: Redacted.isRedacted(accessKey)\n ? accessKey\n : Redacted.make(accessKey),\n });\n\n /**\n * A layer reading the key from configuration (the environment by default).\n *\n * With a name, it reads that name only. Without one, it reads\n * `BUNNYNET_API_KEY`, then the deprecated `BUNNY_API_KEY` when that is\n * unset; the fallback goes away in the next major.\n */\n static readonly fromEnv = (\n name?: string,\n ): Layer.Layer<BunnyCredentials, Config.ConfigError> =>\n Layer.effect(\n BunnyCredentials,\n (name === undefined\n ? Config.Redacted(\"BUNNYNET_API_KEY\").pipe(\n Config.orElse(() => Config.Redacted(\"BUNNY_API_KEY\")),\n )\n : Config.Redacted(name)).pipe(\n Effect.map((accessKey) => ({ accessKey })),\n ),\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunny.net/api-client-effect-v4-runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared runtime for the Bunny.net Effect 4 API clients: the BunnyCredentials service, the error taxonomy, and the operation executor over Effect's HttpClient (effect/http).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|