@distilled.cloud/acme 1.0.0-rc.14 → 1.0.0-rc.16

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/lib/traits.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * ACME SDK trait surface — hand-written.
2
+ * ACME SDK trait surface -- hand-written.
3
3
  *
4
4
  * Re-exports the generic protocol traits from core so generated operations
5
5
  * import everything from one place (`import * as T from "../traits.ts"`).
6
6
  * ACME is JWS-signed JSON, so
7
- * there are no ACME-specific traits — the REST-protocol traits
7
+ * there are no ACME-specific traits -- the REST-protocol traits
8
8
  * (`SensitiveValue` / `RawResponse` / `RawResponseRoot`) come from
9
9
  * `core/protocol-rest`.
10
10
  */
package/lib/traits.js CHANGED
@@ -1,13 +1,13 @@
1
- /**
2
- * ACME SDK trait surface — hand-written.
3
- *
4
- * Re-exports the generic protocol traits from core so generated operations
5
- * import everything from one place (`import * as T from "../traits.ts"`).
6
- * ACME is JWS-signed JSON, so
7
- * there are no ACME-specific traits — the REST-protocol traits
8
- * (`SensitiveValue` / `RawResponse` / `RawResponseRoot`) come from
9
- * `core/protocol-rest`.
10
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
11
  export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
12
12
  export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
13
13
  //# sourceMappingURL=traits.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/acme",
3
- "version": "1.0.0-rc.14",
3
+ "version": "1.0.0-rc.16",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,24 +65,24 @@
65
65
  }
66
66
  },
67
67
  "dependencies": {
68
- "@distilled.cloud/core": "1.0.0-rc.14"
68
+ "@distilled.cloud/core": "1.0.0-rc.16"
69
69
  },
70
70
  "devDependencies": {
71
- "@types/node": "26.2.0"
71
+ "@types/node": "26.6.5"
72
72
  },
73
73
  "peerDependencies": {
74
- "effect": "^4.0.0"
74
+ "effect": "^4.0.5"
75
75
  },
76
76
  "distilled": {
77
- "generatedAt": "2026-10-08",
77
+ "generatedAt": "2026-10-09",
78
78
  "specUpdatedAt": "2026-10-08"
79
79
  },
80
80
  "scripts": {
81
- "build": "tsc -b",
81
+ "build": "tsrs -b",
82
82
  "convert": "node --conditions=bun scripts/convert.ts",
83
83
  "generate": "node --conditions=bun scripts/generate.ts",
84
84
  "specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-acme",
85
85
  "specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-acme",
86
- "typecheck": "tsc -p tsconfig.json"
86
+ "typecheck": "tsrs -p tsconfig.json"
87
87
  }
88
88
  }
@@ -1,5 +1,6 @@
1
+ import * as EffectConfig from "@distilled.cloud/core/config";
1
2
  /**
2
- * ACME credentials — hand-written.
3
+ * ACME credentials -- hand-written.
3
4
  *
4
5
  * An ACME "credential" is the **account key**: a private JWK that signs
5
6
  * every request. The CA is addressed by its **directory URL** (Let's
@@ -12,7 +13,6 @@
12
13
  * account URL per request.
13
14
  */
14
15
  import { ConfigError } from "@distilled.cloud/core/errors";
15
- import * as EffectConfig from "effect/Config";
16
16
  import * as Context from "effect/Context";
17
17
  import * as Effect from "effect/Effect";
18
18
  import * as Layer from "effect/Layer";
@@ -52,45 +52,50 @@ export interface Config {
52
52
  readonly externalAccountBinding?: ExternalAccountBinding | undefined;
53
53
  }
54
54
 
55
- export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
56
- "AcmeCredentials",
57
- ) {}
55
+ export class Credentials
56
+ extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config>>()("AcmeCredentials") {}
58
57
 
59
58
  /**
60
59
  * Credentials from the environment:
61
60
  *
62
61
  * - `ACME_DIRECTORY_URL` (default: Let's Encrypt production)
63
- * - `ACME_ACCOUNT_KEY` — the private JWK as JSON
64
- * - `ACME_ACCOUNT_URL` — optional, once the account exists
65
- * - `ACME_EAB_KID` / `ACME_EAB_HMAC_KEY` — optional EAB pair
62
+ * - `ACME_ACCOUNT_KEY` -- the private JWK as JSON
63
+ * - `ACME_ACCOUNT_URL` -- optional, once the account exists
64
+ * - `ACME_EAB_KID` / `ACME_EAB_HMAC_KEY` -- optional EAB pair
66
65
  */
67
- export const CredentialsFromEnv = Layer.succeed(
66
+ export const CredentialsFromEnv = /*@__PURE__*/ Layer.succeed(
68
67
  Credentials,
69
- EffectConfig.all({
70
- directoryUrl: EffectConfig.String("ACME_DIRECTORY_URL").pipe(
71
- EffectConfig.withDefault(Directories.LetsEncrypt),
68
+ /*@__PURE__*/ EffectConfig.all({
69
+ directoryUrl: /*@__PURE__*/ EffectConfig.String("ACME_DIRECTORY_URL").pipe(
70
+ /*@__PURE__*/ EffectConfig.withDefault(Directories.LetsEncrypt),
71
+ ),
72
+ accountKey: /*@__PURE__*/ EffectConfig.Redacted("ACME_ACCOUNT_KEY"),
73
+ accountUrl: /*@__PURE__*/ EffectConfig.option(
74
+ /*@__PURE__*/ EffectConfig.String("ACME_ACCOUNT_URL"),
75
+ ),
76
+ eabKid: /*@__PURE__*/ EffectConfig.option(/*@__PURE__*/ EffectConfig.String("ACME_EAB_KID")),
77
+ eabHmac: /*@__PURE__*/ EffectConfig.option(
78
+ /*@__PURE__*/ EffectConfig.Redacted("ACME_EAB_HMAC_KEY"),
72
79
  ),
73
- accountKey: EffectConfig.Redacted("ACME_ACCOUNT_KEY"),
74
- accountUrl: EffectConfig.option(EffectConfig.String("ACME_ACCOUNT_URL")),
75
- eabKid: EffectConfig.option(EffectConfig.String("ACME_EAB_KID")),
76
- eabHmac: EffectConfig.option(EffectConfig.Redacted("ACME_EAB_HMAC_KEY")),
77
80
  }).pipe(
78
- Effect.mapError(
81
+ /*@__PURE__*/ Effect.mapError(
79
82
  () =>
80
83
  new ConfigError({
81
84
  message:
82
85
  "ACME_ACCOUNT_KEY (a private JWK) is required; ACME_DIRECTORY_URL, ACME_ACCOUNT_URL, ACME_EAB_KID and ACME_EAB_HMAC_KEY are optional",
83
86
  }),
84
87
  ),
85
- Effect.map(({ directoryUrl, accountKey, accountUrl, eabKid, eabHmac }): Config => ({
86
- directoryUrl,
87
- accountKey,
88
- accountUrl: Option.getOrUndefined(accountUrl),
89
- externalAccountBinding:
90
- Option.isSome(eabKid) && Option.isSome(eabHmac)
91
- ? { keyId: eabKid.value, hmacKey: eabHmac.value }
92
- : undefined,
93
- })),
88
+ /*@__PURE__*/ Effect.map(
89
+ ({ directoryUrl, accountKey, accountUrl, eabKid, eabHmac }): Config => ({
90
+ directoryUrl,
91
+ accountKey,
92
+ accountUrl: Option.getOrUndefined(accountUrl),
93
+ externalAccountBinding:
94
+ Option.isSome(eabKid) && Option.isSome(eabHmac)
95
+ ? { keyId: eabKid.value, hmacKey: eabHmac.value }
96
+ : undefined,
97
+ }),
98
+ ),
94
99
  Effect.orDie,
95
100
  ),
96
101
  );
package/src/errors.ts CHANGED
@@ -34,46 +34,47 @@ import type {
34
34
  Forbidden as CoreForbidden,
35
35
  NotFound as CoreNotFound,
36
36
  } from "@distilled.cloud/core/errors";
37
- import * as Schema from "effect/Schema";
37
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
38
38
 
39
39
  /**
40
- * Unknown ACME error — a problem document whose `type` matches no typed
40
+ * Unknown ACME error -- a problem document whose `type` matches no typed
41
41
  * class on the operation. Carries structured problem fields and a redacted
42
42
  * body. Add newly observed URNs to the authored model.
43
43
  */
44
- export class UnknownAcmeError extends Schema.TaggedError<UnknownAcmeError>()("UnknownAcmeError", {
45
- /** The problem `type` URN, when the body was a problem document. */
46
- type: Schema.optional(Schema.String),
47
- message: Schema.optional(Schema.String),
48
- status: Schema.optional(Schema.Number),
49
- detail: Schema.optional(Schema.String),
50
- subproblems: Schema.optional(Schema.Array(Schema.Unknown)),
51
- body: Schema.Unknown,
52
- }) {}
44
+ export class UnknownAcmeError
45
+ extends /*@__PURE__*/ Schema.TaggedError<UnknownAcmeError>()("UnknownAcmeError", {
46
+ /** The problem `type` URN, when the body was a problem document. */
47
+ type: /*@__PURE__*/ Schema.optional(Schema.String),
48
+ message: /*@__PURE__*/ Schema.optional(Schema.String),
49
+ status: /*@__PURE__*/ Schema.optional(Schema.Number),
50
+ detail: /*@__PURE__*/ Schema.optional(Schema.String),
51
+ subproblems: /*@__PURE__*/ Schema.optional(/*@__PURE__*/ Schema.Array(Schema.Unknown)),
52
+ body: Schema.Unknown,
53
+ }) {}
53
54
 
54
55
  /** Schema parse error wrapper. */
55
- export class AcmeParseError extends Schema.TaggedError<AcmeParseError>()("AcmeParseError", {
56
- body: Schema.Unknown,
57
- cause: Schema.Unknown,
58
- }).pipe(Category.withParseError) {}
56
+ export class AcmeParseError
57
+ extends /*@__PURE__*/ Schema.TaggedError<AcmeParseError>()("AcmeParseError", {
58
+ body: Schema.Unknown,
59
+ cause: Schema.Unknown,
60
+ }).pipe(Category.withParseError) {}
59
61
 
60
62
  /** The account key could not be parsed or used to sign (client-side). */
61
- export class JoseError extends Schema.TaggedError<JoseError>()("JoseError", {
62
- message: Schema.String,
63
- cause: Schema.optional(Schema.Unknown),
64
- }).pipe(Category.withBadRequestError) {}
63
+ export class JoseError
64
+ extends /*@__PURE__*/ Schema.TaggedError<JoseError>()("JoseError", {
65
+ message: Schema.String,
66
+ cause: /*@__PURE__*/ Schema.optional(Schema.Unknown),
67
+ }).pipe(Category.withBadRequestError) {}
65
68
 
66
69
  /**
67
70
  * The directory has no URL for the requested resource (a CA without
68
71
  * `newAuthz`/`keyChange`, or a stale directory URL).
69
72
  */
70
- export class DirectoryMissingResource extends Schema.TaggedError<DirectoryMissingResource>()(
71
- "DirectoryMissingResource",
72
- {
73
+ export class DirectoryMissingResource
74
+ extends /*@__PURE__*/ Schema.TaggedError<DirectoryMissingResource>()("DirectoryMissingResource", {
73
75
  resource: Schema.String,
74
76
  directoryUrl: Schema.String,
75
- },
76
- ).pipe(Category.withBadRequestError) {}
77
+ }).pipe(Category.withBadRequestError) {}
77
78
 
78
79
  /** Errors any ACME operation may surface beyond the core HTTP defaults. */
79
80
  export type ClientErrors = UnknownAcmeError | AcmeParseError | JoseError | DirectoryMissingResource;
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @distilled.cloud/acme — ACME (RFC 8555) SDK for Effect.
2
+ * @distilled.cloud/acme -- ACME (RFC 8555) SDK for Effect.
3
3
  *
4
4
  * `./services` is generated by `scripts/generate.ts` from the Smithy model
5
5
  * `scripts/convert.ts` builds from RFC 8555 (there is no vendor spec for a
package/src/jose.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * JOSE helpers for ACME — hand-written, WebCrypto only (no native code).
2
+ * JOSE helpers for ACME -- hand-written, WebCrypto only (no native code).
3
3
  *
4
4
  * - account keys (ES256 P-256 by default, RS256 accepted)
5
5
  * - JWS in the flattened JSON serialization every ACME POST carries
@@ -23,7 +23,7 @@ export interface Jwk {
23
23
  readonly [key: string]: unknown;
24
24
  }
25
25
 
26
- const encoder = new TextEncoder();
26
+ const encoder = /*@__PURE__*/ new TextEncoder();
27
27
 
28
28
  export const base64url = (bytes: Uint8Array | ArrayBuffer): string => {
29
29
  const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
@@ -101,7 +101,7 @@ export const publicJwk = (jwk: Jwk): Jwk =>
101
101
  export const thumbprint = (jwk: Jwk): Effect.Effect<string> =>
102
102
  sha256(JSON.stringify(publicJwk(jwk))).pipe(Effect.map(base64url));
103
103
 
104
- /** `<token>.<thumbprint>` — what a challenge proves the client holds. */
104
+ /** `<token>.<thumbprint>` -- what a challenge proves the client holds. */
105
105
  export const keyAuthorization = (token: string, jwk: Jwk): Effect.Effect<string> =>
106
106
  thumbprint(jwk).pipe(Effect.map((print) => `${token}.${print}`));
107
107
 
package/src/protocol.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  import { getAnn, getProps, hasPropAnn, mapKeys } from "@distilled.cloud/core/protocol-http";
8
8
  import { unwrapRedactedDeep } from "@distilled.cloud/core/protocol-rest";
9
9
  /**
10
- * AcmeProtocol — hand-written.
10
+ * AcmeProtocol -- hand-written.
11
11
  *
12
12
  * ACME (RFC 8555) is JSON over HTTPS with two twists the generic REST
13
13
  * protocol cannot express:
@@ -32,7 +32,11 @@ import { unwrapRedactedDeep } from "@distilled.cloud/core/protocol-rest";
32
32
  * RFC 7807 problem documents matched on their `type` URN against the
33
33
  * operation's typed error classes; an unmatched URN is `UnknownAcmeError`.
34
34
  */
35
- import { isStrict, validateResponse } from "@distilled.cloud/core/response-validation";
35
+ import {
36
+ failUnlessLenient,
37
+ isValidating,
38
+ validateResponse,
39
+ } from "@distilled.cloud/core/response-validation";
36
40
  import { parseRetryAfter, parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
37
41
  import { getErrorMatchers, httpSymbol, labelSymbol } from "@distilled.cloud/core/trait";
38
42
  import * as Effect from "effect/Effect";
@@ -70,28 +74,28 @@ export type AcmeOpContext = Credentials | HttpClient.HttpClient;
70
74
  // Directory + nonce caches (per CA, process-wide)
71
75
  // =============================================================================
72
76
 
73
- const DirectorySchema = Schema.Struct({
77
+ const DirectorySchema = /*@__PURE__*/ Schema.Struct({
74
78
  newNonce: Schema.String,
75
79
  newAccount: Schema.String,
76
80
  newOrder: Schema.String,
77
81
  revokeCert: Schema.String,
78
- newAuthz: Schema.optional(Schema.String),
79
- keyChange: Schema.optional(Schema.String),
80
- meta: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
82
+ newAuthz: /*@__PURE__*/ Schema.optional(Schema.String),
83
+ keyChange: /*@__PURE__*/ Schema.optional(Schema.String),
84
+ meta: /*@__PURE__*/ Schema.optional(/*@__PURE__*/ Schema.Record(Schema.String, Schema.Unknown)),
81
85
  });
82
86
  type Directory = typeof DirectorySchema.Type;
83
87
 
84
- const directories = new Map<string, Directory>();
88
+ const directories = /*@__PURE__*/ new Map<string, Directory>();
85
89
  /** The last unused `Replay-Nonce` per directory URL. Nonces are single-use. */
86
- const nonces = new Map<string, string>();
90
+ const nonces = /*@__PURE__*/ new Map<string, string>();
87
91
 
88
92
  type SigningContext = Omit<SignOptions, "nonce"> & {
89
93
  readonly directoryUrl: string;
90
94
  };
91
95
  // HTTP request copies preserve the body identity; entries live only with a request.
92
- const signedRequests = new WeakMap<HttpBody.HttpBody, SigningContext>();
96
+ const signedRequests = /*@__PURE__*/ new WeakMap<HttpBody.HttpBody, SigningContext>();
93
97
 
94
- const resolveCredentials = Effect.gen(function* () {
98
+ const resolveCredentials = /*@__PURE__*/ Effect.gen(function* () {
95
99
  const resolve = yield* Credentials;
96
100
  return yield* resolve as Effect.Effect<Config>;
97
101
  });
@@ -193,7 +197,7 @@ const DIRECTORY_OPERATIONS: Record<string, keyof Directory> = {
193
197
  };
194
198
 
195
199
  /** Operations whose payload is the empty POST-as-GET. */
196
- const POST_AS_GET = new Set(["GetOrder", "GetAuthorization", "DownloadCertificate"]);
200
+ const POST_AS_GET = /*@__PURE__*/ new Set(["GetOrder", "GetAuthorization", "DownloadCertificate"]);
197
201
 
198
202
  const JOSE_ACCEPT = "application/json, application/pem-certificate-chain";
199
203
 
@@ -403,14 +407,12 @@ const decode = ({
403
407
  isNewNonce || (isCertificate && status < 400)
404
408
  ? undefined
405
409
  : yield* parseJson(text).pipe(
406
- // A non-JSON 2xx fails only in strict mode; lenient returns
410
+ // A non-JSON 2xx fails unless lenient; lenient returns
407
411
  // the text as read.
408
412
  Effect.catchTag("AcmeParseError", (error) =>
409
413
  status >= 400
410
414
  ? Effect.succeed(undefined)
411
- : Effect.flatMap(isStrict, (strict) =>
412
- strict ? Effect.fail(error) : Effect.succeed<unknown>(text),
413
- ),
415
+ : failUnlessLenient<unknown, typeof error>(error, text),
414
416
  ),
415
417
  );
416
418
  const problem = status >= 400 && isProblem(json) ? json : undefined;
@@ -484,14 +486,17 @@ const decode = ({
484
486
  };
485
487
  } else if (isObject(json)) {
486
488
  body = json;
489
+ // Only outputs that declare `location` get it; elsewhere strict mode
490
+ // would reject it as an unmodeled key.
487
491
  const location = headers["location"];
488
- if (location) body = { ...body, location };
492
+ if (location && getProps(outputAst).some((p) => p.name === "location"))
493
+ body = { ...body, location };
489
494
  } else {
490
495
  // Lenient mode returns a non-object body as read.
491
- if (!(yield* isStrict)) return json;
496
+ if (!(yield* isValidating)) return json;
492
497
  return yield* fail(parseError("Expected a JSON object"));
493
498
  }
494
- // Strict mode (core/response-validation) checks the output schema.
499
+ // Validating modes (core/response-validation) check the output schema.
495
500
  return yield* validateResponse(outputAst, mapKeys(outputAst, body, "decode"), () =>
496
501
  parseError("Response does not match the output schema"),
497
502
  );
@@ -515,9 +520,9 @@ const parseJson = (text: string) =>
515
520
 
516
521
  const fail = <E>(error: E) => Effect.fail(error) as Effect.Effect<never, E>;
517
522
 
518
- export const AcmeProtocol: Layer.Layer<API.Protocol> = Layer.succeed(
523
+ export const AcmeProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ Layer.succeed(
519
524
  API.Protocol,
520
- API.Protocol.of({
525
+ /*@__PURE__*/ API.Protocol.of({
521
526
  encode: (args) => encode(args) as Effect.Effect<HttpClientRequest.HttpClientRequest>,
522
527
  decode: (args) => decode(args) as Effect.Effect<unknown>,
523
528
  }),
package/src/retry.ts CHANGED
@@ -33,17 +33,19 @@ export {
33
33
  } from "@distilled.cloud/core/retry";
34
34
 
35
35
  /** Context tag for configuring retry behavior of ACME calls. */
36
- export class Retry extends Context.Service<Retry, Policy>()("AcmeRetry") {}
36
+ export class Retry extends /*@__PURE__*/ Context.Service<Retry, Policy>()("AcmeRetry") {}
37
37
 
38
38
  /** Provides a custom retry policy to every ACME call below it. */
39
39
  export const policy = (optionsOrFactory: Policy) =>
40
40
  Effect.provide(Layer.succeed(Retry, optionsOrFactory));
41
41
 
42
42
  /** Disables all automatic retries. */
43
- export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
43
+ export const none = /*@__PURE__*/ Effect.provide(
44
+ /*@__PURE__*/ Layer.succeed(Retry, { while: () => false }),
45
+ );
44
46
 
45
47
  /** Apply the throttling retry policy (retries throttling errors indefinitely). */
46
- export const throttling = policy(throttlingFactory);
48
+ export const throttling = /*@__PURE__*/ policy(throttlingFactory);
47
49
 
48
50
  /** Apply the transient retry policy (retries all transient errors indefinitely). */
49
- export const transient = policy(transientFactory);
51
+ export const transient = /*@__PURE__*/ policy(transientFactory);