@distilled.cloud/acme 1.0.0-rc.13 → 1.0.0-rc.14
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/README.md +8 -6
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/jose.d.ts.map +1 -1
- package/lib/jose.js +4 -11
- package/lib/jose.js.map +1 -1
- package/lib/protocol.d.ts +4 -4
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +12 -18
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.test.d.ts +2 -0
- package/lib/protocol.test.d.ts.map +1 -0
- package/lib/protocol.test.js +533 -0
- package/lib/protocol.test.js.map +1 -0
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/acme.d.ts +83 -20
- package/lib/services/acme.d.ts.map +1 -1
- package/lib/services/acme.js +72 -130
- package/lib/services/acme.js.map +1 -1
- package/package.json +15 -10
- package/src/credentials.ts +13 -19
- package/src/errors.ts +15 -25
- package/src/index.ts +4 -8
- package/src/jose.ts +14 -41
- package/src/protocol.test.ts +806 -0
- package/src/protocol.ts +32 -81
- package/src/retry.ts +2 -8
- package/src/services/acme.ts +178 -222
- package/lib/response-validation.test.d.ts +0 -4
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -51
- package/lib/response-validation.test.js.map +0 -1
- package/src/response-validation.test.ts +0 -65
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAqDjD,eAAO,MAAM,oBAAoB,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,WAAW,CAAC,GACrE,IAAI,GACJ,KAAY,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import { runValidationModes } from "@distilled.cloud/core/testing";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import * as Redacted from "effect/Redacted";
|
|
5
|
-
import { layer } from "./credentials.js";
|
|
6
|
-
import { AcmeParseError } from "./errors.js";
|
|
7
|
-
import { resetProtocolCaches } from "./protocol.js";
|
|
8
|
-
import * as Retry from "./retry.js";
|
|
9
|
-
import { getDirectory } from "./services/acme.js";
|
|
10
|
-
const DIRECTORY_URL = "https://acme.test/directory";
|
|
11
|
-
// getDirectory is a plain GET of the directory URL: no nonce, no signing.
|
|
12
|
-
const TestCredentials = layer({
|
|
13
|
-
directoryUrl: DIRECTORY_URL,
|
|
14
|
-
accountKey: Redacted.make("{}"),
|
|
15
|
-
});
|
|
16
|
-
// getDirectory declares `{ newNonce: string; newAccount: string; newOrder: string; revokeCert: string; … }`.
|
|
17
|
-
const run = (body) => runValidationModes(getDirectory({}).pipe(Retry.none, Effect.provide(TestCredentials)), (request) => {
|
|
18
|
-
if (request.url !== DIRECTORY_URL) {
|
|
19
|
-
throw new Error(`unexpected request to ${request.url}`);
|
|
20
|
-
}
|
|
21
|
-
return { body };
|
|
22
|
-
});
|
|
23
|
-
beforeEach(() => resetProtocolCaches());
|
|
24
|
-
describe("ACME response validation", () => {
|
|
25
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
26
|
-
const body = {
|
|
27
|
-
newNonce: "https://acme.test/new-nonce",
|
|
28
|
-
newAccount: "https://acme.test/new-account",
|
|
29
|
-
newOrder: "https://acme.test/new-order",
|
|
30
|
-
revokeCert: "https://acme.test/revoke-cert",
|
|
31
|
-
};
|
|
32
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
33
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
34
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
35
|
-
});
|
|
36
|
-
test("a body missing required members: lenient returns it, strict fails", async () => {
|
|
37
|
-
const body = { newNonce: "https://acme.test/new-nonce" };
|
|
38
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
39
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
40
|
-
expect(strict._tag).toBe("Failure");
|
|
41
|
-
expect(strict.failure).toBeInstanceOf(AcmeParseError);
|
|
42
|
-
});
|
|
43
|
-
test("a non-JSON body: lenient returns the text, strict fails", async () => {
|
|
44
|
-
const { lenient, strict } = await run("not json");
|
|
45
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
|
|
46
|
-
expect(strict.failure).toBeInstanceOf(AcmeParseError);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
// AcmeParseError is part of every operation's declared error type.
|
|
50
|
-
export const parseErrorIsDeclared = true;
|
|
51
|
-
//# sourceMappingURL=response-validation.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-validation.test.js","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,e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ing";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import * as Redacted from "effect/Redacted";
|
|
5
|
-
import { layer } from "./credentials.ts";
|
|
6
|
-
import { AcmeParseError } from "./errors.ts";
|
|
7
|
-
import { resetProtocolCaches } from "./protocol.ts";
|
|
8
|
-
import * as Retry from "./retry.ts";
|
|
9
|
-
import { getDirectory } from "./services/acme.ts";
|
|
10
|
-
import type { AcmeOpError } from "./protocol.ts";
|
|
11
|
-
|
|
12
|
-
const DIRECTORY_URL = "https://acme.test/directory";
|
|
13
|
-
|
|
14
|
-
// getDirectory is a plain GET of the directory URL: no nonce, no signing.
|
|
15
|
-
const TestCredentials = layer({
|
|
16
|
-
directoryUrl: DIRECTORY_URL,
|
|
17
|
-
accountKey: Redacted.make("{}"),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// getDirectory declares `{ newNonce: string; newAccount: string; newOrder: string; revokeCert: string; … }`.
|
|
21
|
-
const run = (body: string) =>
|
|
22
|
-
runValidationModes(
|
|
23
|
-
getDirectory({}).pipe(Retry.none, Effect.provide(TestCredentials)),
|
|
24
|
-
(request) => {
|
|
25
|
-
if (request.url !== DIRECTORY_URL) {
|
|
26
|
-
throw new Error(`unexpected request to ${request.url}`);
|
|
27
|
-
}
|
|
28
|
-
return { body };
|
|
29
|
-
},
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
beforeEach(() => resetProtocolCaches());
|
|
33
|
-
|
|
34
|
-
describe("ACME response validation", () => {
|
|
35
|
-
test("a matching body succeeds unchanged in both modes", async () => {
|
|
36
|
-
const body = {
|
|
37
|
-
newNonce: "https://acme.test/new-nonce",
|
|
38
|
-
newAccount: "https://acme.test/new-account",
|
|
39
|
-
newOrder: "https://acme.test/new-order",
|
|
40
|
-
revokeCert: "https://acme.test/revoke-cert",
|
|
41
|
-
};
|
|
42
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
43
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
44
|
-
expect(strict).toMatchObject({ _tag: "Success", success: body });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test("a body missing required members: lenient returns it, strict fails", async () => {
|
|
48
|
-
const body = { newNonce: "https://acme.test/new-nonce" };
|
|
49
|
-
const { lenient, strict } = await run(JSON.stringify(body));
|
|
50
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: body });
|
|
51
|
-
expect(strict._tag).toBe("Failure");
|
|
52
|
-
expect((strict as any).failure).toBeInstanceOf(AcmeParseError);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("a non-JSON body: lenient returns the text, strict fails", async () => {
|
|
56
|
-
const { lenient, strict } = await run("not json");
|
|
57
|
-
expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
|
|
58
|
-
expect((strict as any).failure).toBeInstanceOf(AcmeParseError);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// AcmeParseError is part of every operation's declared error type.
|
|
63
|
-
export const parseErrorIsDeclared: [AcmeParseError] extends [AcmeOpError]
|
|
64
|
-
? true
|
|
65
|
-
: false = true;
|