@distilled.cloud/acme 1.0.0-rc.15 → 1.0.0-rc.17
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/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/_chunks/_distilled-core_errors-CS3jP5s-.js +1 -0
- package/lib/_chunks/_distilled-core_trait-BRJKEsOV.js +1 -0
- package/lib/credentials.d.ts +4 -4
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +1 -57
- package/lib/errors.d.ts +26 -26
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -49
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -23
- package/lib/jose.d.ts +2 -2
- package/lib/jose.d.ts.map +1 -1
- package/lib/jose.js +1 -120
- package/lib/jose.js.map +1 -1
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +1 -403
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -32
- package/lib/retry.js.map +1 -1
- package/lib/services/acme.d.ts +47 -82
- package/lib/services/acme.d.ts.map +1 -1
- package/lib/services/acme.js +1 -538
- package/lib/services/acme.js.map +1 -1
- package/lib/services/index.js +1 -3
- package/lib/traits.d.ts +2 -2
- package/lib/traits.js +1 -13
- package/package.json +7 -7
- package/src/credentials.ts +31 -26
- package/src/errors.ts +25 -24
- package/src/index.ts +1 -1
- package/src/jose.ts +3 -3
- package/src/protocol.ts +25 -20
- package/src/retry.ts +6 -4
- package/src/services/acme.ts +332 -289
- package/src/traits.ts +2 -2
- package/lib/credentials.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/protocol.test.d.ts +0 -2
- package/lib/protocol.test.d.ts.map +0 -1
- package/lib/protocol.test.js +0 -533
- package/lib/protocol.test.js.map +0 -1
- package/lib/services/index.js.map +0 -1
- package/lib/traits.js.map +0 -1
- package/src/protocol.test.ts +0 -806
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"../_chunks/_distilled-core_errors-CS3jP5s-.js";import{config$Redacted as t,config$String as n,config$all as r,config$option as i,config$withDefault as a}from"@distilled.cloud/core/_bundle/base";import*as o from"effect/Context";import*as s from"effect/Effect";import*as c from"effect/Layer";import*as l from"effect/Option";import"effect/Redacted";var u=Object.defineProperty;var __exportAll=(e,t)=>{let n={};for(var r in e){u(n,r,{get:e[r],enumerable:true})}if(!t){u(n,Symbol.toStringTag,{value:`Module`})}return n};const d={LetsEncrypt:`https://acme-v02.api.letsencrypt.org/directory`,LetsEncryptStaging:`https://acme-staging-v02.api.letsencrypt.org/directory`,ZeroSSL:`https://acme.zerossl.com/v2/DV90`,GoogleTrustServices:`https://dv.acme-v02.api.pki.goog/directory`,GoogleTrustServicesStaging:`https://dv.acme-v02.test-api.pki.goog/directory`};var Credentials=class extends (/*@__PURE__*/ o.Service()(`AcmeCredentials`)){};const f=/*@__PURE__*/ c.succeed(Credentials,/*@__PURE__*/ r({directoryUrl:/*@__PURE__*/ n(`ACME_DIRECTORY_URL`).pipe(/*@__PURE__*/ a(d.LetsEncrypt)),accountKey:/*@__PURE__*/ t(`ACME_ACCOUNT_KEY`),accountUrl:/*@__PURE__*/ i(/*@__PURE__*/ n(`ACME_ACCOUNT_URL`)),eabKid:/*@__PURE__*/ i(/*@__PURE__*/ n(`ACME_EAB_KID`)),eabHmac:/*@__PURE__*/ i(/*@__PURE__*/ t(`ACME_EAB_HMAC_KEY`))}).pipe(/*@__PURE__*/ s.mapError(()=>new e({message:`ACME_ACCOUNT_KEY (a private JWK) is required; ACME_DIRECTORY_URL, ACME_ACCOUNT_URL, ACME_EAB_KID and ACME_EAB_HMAC_KEY are optional`})),/*@__PURE__*/ s.map(({directoryUrl:e,accountKey:t,accountUrl:n,eabKid:r,eabHmac:i})=>({directoryUrl:e,accountKey:t,accountUrl:l.getOrUndefined(n),externalAccountBinding:l.isSome(r)&&l.isSome(i)?{keyId:r.value,hmacKey:i.value}:void 0})),s.orDie));const layer=e=>c.succeed(Credentials,s.isEffect(e)?e:s.succeed(e));export{Credentials as credentials$Credentials,f as credentials$CredentialsFromEnv,d as credentials$Directories,layer as credentials$layer,__exportAll as t};
|
|
2
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["ConfigError","Redacted","String","all","option","withDefault","Context","Effect","Layer","Option","__defProp","target","name","no_symbols","Directories","CredentialsFromEnv","accountUrl","eabKid","eabHmac","config"],"sources":["../../src/credentials.ts"],"mappings":"shBAsBA,MAAac,EAAc,CACzB,YAAa,iDACb,mBAAoB,yDACpB,QAAS,mCACT,oBAAqB,6CACrB,2BAA4B,iDAC9B,EA0BA,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CAAC,iBAAiB,EAAA,AAAE,CAAC,EAUlG,MAAaC,EAAmC,gBAAM,QACpD,YACc,gBAAiB,CAC7B,aAA4B,gBAAoB,oBAAoB,CAAC,CAAC,KACtD,gBAAyBD,EAAY,WAAW,CAChE,EACA,WAA0B,gBAAsB,kBAAkB,EAClE,WAA0B,gBACV,gBAAoB,kBAAkB,CACtD,EACA,OAAsB,gBAAkC,gBAAoB,cAAc,CAAC,EAC3F,QAAuB,gBACP,gBAAsB,mBAAmB,CACzD,CACF,CAAC,CAAC,CAAC,KACa,gBAAO,aAEjB,IAAId,EAAY,CACd,QACE,qIACJ,CAAC,CACL,EACc,gBAAO,KAClB,CAAE,eAAc,aAAY,aAAY,SAAQ,cAAuB,CACtE,eACA,aACA,WAAYS,EAAO,eAAeO,CAAU,EAC5C,uBACEP,EAAO,OAAOQ,CAAM,GAAKR,EAAO,OAAOS,CAAO,EAC1C,CAAE,MAAOD,EAAO,MAAO,QAASC,EAAQ,KAAM,EAC9C,IAAA,EACR,EACF,EACAX,EAAO,KACT,CACF,EAGA,MAAa,MAAS,GACpBC,EAAM,QAAQ,YAAaD,EAAO,SAASY,CAAM,EAAIA,EAASZ,EAAO,QAAQY,CAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{errors$API_ERRORS as e,errors$BadGateway as t,errors$BadRequest as n,errors$ConfigError as r,errors$Conflict as i,errors$DEFAULT_ERRORS as a,errors$Forbidden as o,errors$GatewayTimeout as s,errors$HTTP_STATUS_MAP as c,errors$InternalServerError as l,errors$Locked as u,errors$NotFound as d,errors$ServiceUnavailable as f,errors$TooManyRequests as p,errors$Unauthorized as m,errors$UnprocessableEntity as h}from"@distilled.cloud/core/_bundle/rest";export{i as a,s as c,u as d,d as f,h as g,m as h,r as i,c as l,p as m,t as n,a as o,f as p,n as r,o as s,e as t,l as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{trait$Body as e,trait$FormDataFile as t,trait$Header as n,trait$Http as r,trait$HttpBody as i,trait$KeyDictionary as a,trait$Label as o,trait$Query as s,trait$ResponseCode as c,trait$UnionCases as l,trait$applyErrorMatchers as u,trait$bodySymbol as d,trait$errorMatchersSymbol as f,trait$formDataFileSymbol as p,trait$getErrorMatchers as m,trait$headerSymbol as h,trait$httpBodySymbol as g,trait$httpSymbol as _,trait$keyDictionarySymbol as v,trait$labelSymbol as y,trait$querySymbol as b,trait$responseCodeSymbol as x,trait$unionCasesSymbol as S}from"@distilled.cloud/core/_bundle/base";import{protocol_rest$RawResponse as C,protocol_rest$RawResponseRoot as w,protocol_rest$SensitiveValue as T,protocol_rest$rawResponseRootSymbol as E,protocol_rest$rawResponseSymbol as D,protocol_rest$sensitiveValueSymbol as O,protocol_rest$unwrapRedactedDeep as k}from"@distilled.cloud/core/_bundle/rest";export{k as A,S as C,E as D,T as E,D as O,x as S,w as T,g as _,i as a,y as b,s as c,u as d,d as f,h as g,m as h,r as i,O as k,c as l,p as m,t as n,a as o,f as p,n as r,o as s,e as t,l as u,_ as v,C as w,b as x,v as y};
|
package/lib/credentials.d.ts
CHANGED
|
@@ -33,15 +33,15 @@ export interface Config {
|
|
|
33
33
|
readonly externalAccountBinding?: ExternalAccountBinding | undefined;
|
|
34
34
|
}
|
|
35
35
|
declare const Credentials_base: Context.ServiceClass<Credentials, "AcmeCredentials", Effect.Effect<Config, never, never>>;
|
|
36
|
-
export declare class Credentials extends Credentials_base {
|
|
36
|
+
export declare class Credentials extends /*@__PURE__*/ Credentials_base {
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Credentials from the environment:
|
|
40
40
|
*
|
|
41
41
|
* - `ACME_DIRECTORY_URL` (default: Let's Encrypt production)
|
|
42
|
-
* - `ACME_ACCOUNT_KEY`
|
|
43
|
-
* - `ACME_ACCOUNT_URL`
|
|
44
|
-
* - `ACME_EAB_KID` / `ACME_EAB_HMAC_KEY`
|
|
42
|
+
* - `ACME_ACCOUNT_KEY` -- the private JWK as JSON
|
|
43
|
+
* - `ACME_ACCOUNT_URL` -- optional, once the account exists
|
|
44
|
+
* - `ACME_EAB_KID` / `ACME_EAB_HMAC_KEY` -- optional EAB pair
|
|
45
45
|
*/
|
|
46
46
|
export declare const CredentialsFromEnv: Layer.Layer<Credentials, never, never>;
|
|
47
47
|
/** A fixed credentials layer (tests, and consumers that manage keys themselves). */
|
package/lib/credentials.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,mCAAmC;AACnC,eAAO,MAAM,WAAW;aACtB,WAAW,EAAE,gDAAgD;aAC7D,kBAAkB,EAAE,wDAAwD;aAC5E,OAAO,EAAE,kCAAkC;aAC3C,mBAAmB,EAAE,4CAA4C;aACjE,0BA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C9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,oEAAoE;IACpE,QAAQ,CAAC,sBAAsB,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACtE;;AAED,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAAwE;CAAG;AAEnG;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,wCAmC9B,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,KAAK,WAAY,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,2CAC2B,CAAC"}
|
package/lib/credentials.js
CHANGED
|
@@ -1,57 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* ACME credentials — hand-written.
|
|
3
|
-
*
|
|
4
|
-
* An ACME "credential" is the **account key**: a private JWK that signs
|
|
5
|
-
* every request. The CA is addressed by its **directory URL** (Let's
|
|
6
|
-
* Encrypt, ZeroSSL, Google Trust Services and Pebble differ only there),
|
|
7
|
-
* plus, for CAs that require it, an **External Account Binding** (key id +
|
|
8
|
-
* HMAC key from the CA's dashboard) presented once on `newAccount`.
|
|
9
|
-
*
|
|
10
|
-
* The `Credentials` service holds an *effect* that resolves the current
|
|
11
|
-
* credentials, so the protocol picks up a rotated key or a newly learned
|
|
12
|
-
* account URL per request.
|
|
13
|
-
*/
|
|
14
|
-
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
15
|
-
import * as EffectConfig from "effect/Config";
|
|
16
|
-
import * as Context from "effect/Context";
|
|
17
|
-
import * as Effect from "effect/Effect";
|
|
18
|
-
import * as Layer from "effect/Layer";
|
|
19
|
-
import * as Option from "effect/Option";
|
|
20
|
-
import * as Redacted from "effect/Redacted";
|
|
21
|
-
/** Well-known ACME directories. */
|
|
22
|
-
export const Directories = {
|
|
23
|
-
LetsEncrypt: "https://acme-v02.api.letsencrypt.org/directory",
|
|
24
|
-
LetsEncryptStaging: "https://acme-staging-v02.api.letsencrypt.org/directory",
|
|
25
|
-
ZeroSSL: "https://acme.zerossl.com/v2/DV90",
|
|
26
|
-
GoogleTrustServices: "https://dv.acme-v02.api.pki.goog/directory",
|
|
27
|
-
GoogleTrustServicesStaging: "https://dv.acme-v02.test-api.pki.goog/directory",
|
|
28
|
-
};
|
|
29
|
-
export class Credentials extends Context.Service()("AcmeCredentials") {
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Credentials from the environment:
|
|
33
|
-
*
|
|
34
|
-
* - `ACME_DIRECTORY_URL` (default: Let's Encrypt production)
|
|
35
|
-
* - `ACME_ACCOUNT_KEY` — the private JWK as JSON
|
|
36
|
-
* - `ACME_ACCOUNT_URL` — optional, once the account exists
|
|
37
|
-
* - `ACME_EAB_KID` / `ACME_EAB_HMAC_KEY` — optional EAB pair
|
|
38
|
-
*/
|
|
39
|
-
export const CredentialsFromEnv = Layer.succeed(Credentials, EffectConfig.all({
|
|
40
|
-
directoryUrl: EffectConfig.String("ACME_DIRECTORY_URL").pipe(EffectConfig.withDefault(Directories.LetsEncrypt)),
|
|
41
|
-
accountKey: EffectConfig.Redacted("ACME_ACCOUNT_KEY"),
|
|
42
|
-
accountUrl: EffectConfig.option(EffectConfig.String("ACME_ACCOUNT_URL")),
|
|
43
|
-
eabKid: EffectConfig.option(EffectConfig.String("ACME_EAB_KID")),
|
|
44
|
-
eabHmac: EffectConfig.option(EffectConfig.Redacted("ACME_EAB_HMAC_KEY")),
|
|
45
|
-
}).pipe(Effect.mapError(() => new ConfigError({
|
|
46
|
-
message: "ACME_ACCOUNT_KEY (a private JWK) is required; ACME_DIRECTORY_URL, ACME_ACCOUNT_URL, ACME_EAB_KID and ACME_EAB_HMAC_KEY are optional",
|
|
47
|
-
})), Effect.map(({ directoryUrl, accountKey, accountUrl, eabKid, eabHmac }) => ({
|
|
48
|
-
directoryUrl,
|
|
49
|
-
accountKey,
|
|
50
|
-
accountUrl: Option.getOrUndefined(accountUrl),
|
|
51
|
-
externalAccountBinding: Option.isSome(eabKid) && Option.isSome(eabHmac)
|
|
52
|
-
? { keyId: eabKid.value, hmacKey: eabHmac.value }
|
|
53
|
-
: undefined,
|
|
54
|
-
})), Effect.orDie));
|
|
55
|
-
/** A fixed credentials layer (tests, and consumers that manage keys themselves). */
|
|
56
|
-
export const layer = (config) => Layer.succeed(Credentials, Effect.isEffect(config) ? config : Effect.succeed(config));
|
|
57
|
-
//# sourceMappingURL=credentials.js.map
|
|
1
|
+
export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$Directories as Directories, credentials$layer as layer } from "./_bundle/sdk.js";
|
package/lib/errors.d.ts
CHANGED
|
@@ -10,49 +10,49 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
12
12
|
import type { BadRequest as CoreBadRequest, Conflict as CoreConflict, DefaultErrors as CoreDefaultErrors, Forbidden as CoreForbidden, NotFound as CoreNotFound } from "@distilled.cloud/core/errors";
|
|
13
|
-
import * as Schema from "
|
|
14
|
-
declare const UnknownAcmeError_base: Schema.
|
|
13
|
+
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
14
|
+
declare const UnknownAcmeError_base: Schema.TaggedErrorClass<"UnknownAcmeError", {
|
|
15
15
|
/** The problem `type` URN, when the body was a problem document. */
|
|
16
|
-
readonly type: Schema.optional<Schema.String>;
|
|
17
|
-
readonly message: Schema.optional<Schema.String>;
|
|
18
|
-
readonly status: Schema.optional<Schema.Number>;
|
|
19
|
-
readonly detail: Schema.optional<Schema.String>;
|
|
20
|
-
readonly subproblems: Schema.optional<Schema.$Array<Schema.Unknown>>;
|
|
21
|
-
readonly body: Schema.Unknown;
|
|
22
|
-
}
|
|
16
|
+
readonly type: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
17
|
+
readonly message: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
18
|
+
readonly status: import("effect/Schema").optional<import("effect/Schema").Number>;
|
|
19
|
+
readonly detail: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
20
|
+
readonly subproblems: import("effect/Schema").optional<Schema.$Array<import("effect/Schema").Unknown>>;
|
|
21
|
+
readonly body: import("effect/Schema").Unknown;
|
|
22
|
+
}>;
|
|
23
23
|
/**
|
|
24
|
-
* Unknown ACME error
|
|
24
|
+
* Unknown ACME error -- a problem document whose `type` matches no typed
|
|
25
25
|
* class on the operation. Carries structured problem fields and a redacted
|
|
26
26
|
* body. Add newly observed URNs to the authored model.
|
|
27
27
|
*/
|
|
28
|
-
export declare class UnknownAcmeError extends UnknownAcmeError_base {
|
|
28
|
+
export declare class UnknownAcmeError extends /*@__PURE__*/ UnknownAcmeError_base {
|
|
29
29
|
}
|
|
30
|
-
declare const AcmeParseError_base: Schema.
|
|
31
|
-
readonly body: Schema.Unknown;
|
|
32
|
-
readonly cause: Schema.Unknown;
|
|
33
|
-
}
|
|
30
|
+
declare const AcmeParseError_base: Schema.TaggedErrorClass<"AcmeParseError", {
|
|
31
|
+
readonly body: import("effect/Schema").Unknown;
|
|
32
|
+
readonly cause: import("effect/Schema").Unknown;
|
|
33
|
+
}> & (new (...args: any[]) => {
|
|
34
34
|
"@distilled.cloud/error/categories": {
|
|
35
35
|
ParseError: true;
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
/** Schema parse error wrapper. */
|
|
39
|
-
export declare class AcmeParseError extends AcmeParseError_base {
|
|
39
|
+
export declare class AcmeParseError extends /*@__PURE__*/ AcmeParseError_base {
|
|
40
40
|
}
|
|
41
|
-
declare const JoseError_base: Schema.
|
|
42
|
-
readonly message: Schema.String;
|
|
43
|
-
readonly cause: Schema.optional<Schema.Unknown>;
|
|
44
|
-
}
|
|
41
|
+
declare const JoseError_base: Schema.TaggedErrorClass<"JoseError", {
|
|
42
|
+
readonly message: import("effect/Schema").String;
|
|
43
|
+
readonly cause: import("effect/Schema").optional<import("effect/Schema").Unknown>;
|
|
44
|
+
}> & (new (...args: any[]) => {
|
|
45
45
|
"@distilled.cloud/error/categories": {
|
|
46
46
|
BadRequestError: true;
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
49
|
/** The account key could not be parsed or used to sign (client-side). */
|
|
50
|
-
export declare class JoseError extends JoseError_base {
|
|
50
|
+
export declare class JoseError extends /*@__PURE__*/ JoseError_base {
|
|
51
51
|
}
|
|
52
|
-
declare const DirectoryMissingResource_base: Schema.
|
|
53
|
-
readonly resource: Schema.String;
|
|
54
|
-
readonly directoryUrl: Schema.String;
|
|
55
|
-
}
|
|
52
|
+
declare const DirectoryMissingResource_base: Schema.TaggedErrorClass<"DirectoryMissingResource", {
|
|
53
|
+
readonly resource: import("effect/Schema").String;
|
|
54
|
+
readonly directoryUrl: import("effect/Schema").String;
|
|
55
|
+
}> & (new (...args: any[]) => {
|
|
56
56
|
"@distilled.cloud/error/categories": {
|
|
57
57
|
BadRequestError: true;
|
|
58
58
|
};
|
|
@@ -61,7 +61,7 @@ declare const DirectoryMissingResource_base: Schema.Class<DirectoryMissingResour
|
|
|
61
61
|
* The directory has no URL for the requested resource (a CA without
|
|
62
62
|
* `newAuthz`/`keyChange`, or a stale directory URL).
|
|
63
63
|
*/
|
|
64
|
-
export declare class DirectoryMissingResource extends DirectoryMissingResource_base {
|
|
64
|
+
export declare class DirectoryMissingResource extends /*@__PURE__*/ DirectoryMissingResource_base {
|
|
65
65
|
}
|
|
66
66
|
/** Errors any ACME operation may surface beyond the core HTTP defaults. */
|
|
67
67
|
export type ClientErrors = UnknownAcmeError | AcmeParseError | JoseError | DirectoryMissingResource;
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EACxB,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EACxB,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;IAS9D,oEAAoE;;;;;;;;AAPxE;;;;GAIG;AACH,qBAAa,gBACX,SAAQ,aAAa,CAAC,qBAQpB;CAAG;;;;;;;;;AAEP,kCAAkC;AAClC,qBAAa,cACX,SAAQ,aAAa,CAAC,mBAGU;CAAG;;;;;;;;;AAErC,yEAAyE;AACzE,qBAAa,SACX,SAAQ,aAAa,CAAC,cAGe;CAAG;;;;;;;;;AAE1C;;;GAGG;AACH,qBAAa,wBACX,SAAQ,aAAa,CAAC,6BAGe;CAAG;AAE1C,2EAA2E;AAC3E,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,cAAc,GAAG,SAAS,GAAG,wBAAwB,CAAC;AAEpG;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC"}
|
package/lib/errors.js
CHANGED
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* ACME-specific error types.
|
|
3
|
-
*
|
|
4
|
-
* ACME reports failures as RFC 7807 problem documents whose `type` is a
|
|
5
|
-
* `urn:ietf:params:acme:error:*` URN (RFC 8555 §6.7). Every URN the SDK
|
|
6
|
-
* knows is a typed class in the generated service (patched onto the
|
|
7
|
-
* operations that raise it, matched on the URN by the protocol). This
|
|
8
|
-
* module holds the shared HTTP defaults and the package's own client
|
|
9
|
-
* errors.
|
|
10
|
-
*/
|
|
11
|
-
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
12
|
-
import * as Category from "@distilled.cloud/core/category";
|
|
13
|
-
import * as Schema from "effect/Schema";
|
|
14
|
-
/**
|
|
15
|
-
* Unknown ACME error — a problem document whose `type` matches no typed
|
|
16
|
-
* class on the operation. Carries structured problem fields and a redacted
|
|
17
|
-
* body. Add newly observed URNs to the authored model.
|
|
18
|
-
*/
|
|
19
|
-
export class UnknownAcmeError extends Schema.TaggedError()("UnknownAcmeError", {
|
|
20
|
-
/** The problem `type` URN, when the body was a problem document. */
|
|
21
|
-
type: Schema.optional(Schema.String),
|
|
22
|
-
message: Schema.optional(Schema.String),
|
|
23
|
-
status: Schema.optional(Schema.Number),
|
|
24
|
-
detail: Schema.optional(Schema.String),
|
|
25
|
-
subproblems: Schema.optional(Schema.Array(Schema.Unknown)),
|
|
26
|
-
body: Schema.Unknown,
|
|
27
|
-
}) {
|
|
28
|
-
}
|
|
29
|
-
/** Schema parse error wrapper. */
|
|
30
|
-
export class AcmeParseError extends Schema.TaggedError()("AcmeParseError", {
|
|
31
|
-
body: Schema.Unknown,
|
|
32
|
-
cause: Schema.Unknown,
|
|
33
|
-
}).pipe(Category.withParseError) {
|
|
34
|
-
}
|
|
35
|
-
/** The account key could not be parsed or used to sign (client-side). */
|
|
36
|
-
export class JoseError extends Schema.TaggedError()("JoseError", {
|
|
37
|
-
message: Schema.String,
|
|
38
|
-
cause: Schema.optional(Schema.Unknown),
|
|
39
|
-
}).pipe(Category.withBadRequestError) {
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* The directory has no URL for the requested resource (a CA without
|
|
43
|
-
* `newAuthz`/`keyChange`, or a stale directory URL).
|
|
44
|
-
*/
|
|
45
|
-
export class DirectoryMissingResource extends Schema.TaggedError()("DirectoryMissingResource", {
|
|
46
|
-
resource: Schema.String,
|
|
47
|
-
directoryUrl: Schema.String,
|
|
48
|
-
}).pipe(Category.withBadRequestError) {
|
|
49
|
-
}
|
|
1
|
+
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./_chunks/_distilled-core_errors-CS3jP5s-.js";import{category$withBadRequestError as g,category$withParseError as _,category$withRetryableError as v,category$withThrottlingError as y}from"@distilled.cloud/core/_bundle/base";import*as b from"@distilled.cloud/core/schema-lite-typed";var UnknownAcmeError=class extends (/*@__PURE__*/ b.TaggedError()(`UnknownAcmeError`,{type:/*@__PURE__*/ b.optional(b.String),message:/*@__PURE__*/ b.optional(b.String),status:/*@__PURE__*/ b.optional(b.Number),detail:/*@__PURE__*/ b.optional(b.String),subproblems:/*@__PURE__*/ b.optional(/*@__PURE__*/ b.Array(b.Unknown)),body:b.Unknown})){};var AcmeParseError=class extends (/*@__PURE__*/ b.TaggedError()(`AcmeParseError`,{body:b.Unknown,cause:b.Unknown}).pipe(_)){};var JoseError=class extends (/*@__PURE__*/ b.TaggedError()(`JoseError`,{message:b.String,cause:/*@__PURE__*/ b.optional(b.Unknown)}).pipe(g)){};var DirectoryMissingResource=class extends (/*@__PURE__*/ b.TaggedError()(`DirectoryMissingResource`,{resource:b.String,directoryUrl:b.String}).pipe(g)){};export{m as API_ERRORS,AcmeParseError,l as BadGateway,f as BadRequest,o as ConfigError,e as Conflict,u as DEFAULT_ERRORS,DirectoryMissingResource,p as Forbidden,t as GatewayTimeout,s as HTTP_STATUS_MAP,h as InternalServerError,JoseError,n as Locked,r as NotFound,d as ServiceUnavailable,c as TooManyRequests,a as Unauthorized,UnknownAcmeError,i as UnprocessableEntity,y as n,v as t};
|
|
50
2
|
//# sourceMappingURL=errors.js.map
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","
|
|
1
|
+
{"version":3,"file":"errors.js","names":["Category.withParseError","Category.withBadRequestError","Conflict","GatewayTimeout","Locked","NotFound","UnprocessableEntity","Unauthorized","ConfigError","HTTP_STATUS_MAP","TooManyRequests","BadGateway","DEFAULT_ERRORS","ServiceUnavailable","BadRequest","Forbidden","API_ERRORS","InternalServerError","withBadRequestError","withParseError","withRetryableError","withThrottlingError","Schema"],"sources":["../src/errors.ts"],"mappings":"sZA2CA,IAAa,iBAAb,eACwB,gBAAO,YAA8B,CAAC,CAAC,mBAAoB,CAE/E,KAAoB,gBAAO,SAASsB,EAAO,MAAM,EACjD,QAAuB,gBAAO,SAASA,EAAO,MAAM,EACpD,OAAsB,gBAAO,SAASA,EAAO,MAAM,EACnD,OAAsB,gBAAO,SAASA,EAAO,MAAM,EACnD,YAA2B,gBAAO,SAAuB,gBAAO,MAAMA,EAAO,OAAO,CAAC,EACrF,KAAMA,EAAO,OACf,CAAC,EAAA,AAAE,CAAC,EAGN,IAAa,eAAb,eACwB,gBAAO,YAA4B,CAAC,CAAC,iBAAkB,CAC3E,KAAMA,EAAO,QACb,MAAOA,EAAO,OAChB,CAAC,CAAC,CAAC,KAAKtB,CAAuB,EAAA,AAAE,CAAC,EAGpC,IAAa,UAAb,eACwB,gBAAO,YAAuB,CAAC,CAAC,YAAa,CACjE,QAASsB,EAAO,OAChB,MAAqB,gBAAO,SAASA,EAAO,OAAO,CACrD,CAAC,CAAC,CAAC,KAAKrB,CAA4B,EAAA,AAAE,CAAC,EAMzC,IAAa,yBAAb,eACwB,gBAAO,YAAsC,CAAC,CAAC,2BAA4B,CAC/F,SAAUqB,EAAO,OACjB,aAAcA,EAAO,MACvB,CAAC,CAAC,CAAC,KAAKrB,CAA4B,EAAA,AAAE,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @distilled.cloud/acme
|
|
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/lib/index.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @distilled.cloud/acme — ACME (RFC 8555) SDK for Effect.
|
|
3
|
-
*
|
|
4
|
-
* `./services` is generated by `scripts/generate.ts` from the Smithy model
|
|
5
|
-
* `scripts/convert.ts` builds from RFC 8555 (there is no vendor spec for a
|
|
6
|
-
* protocol). Everything else in this folder is hand-written: the
|
|
7
|
-
* JWS-signing protocol, credentials (account key + directory + EAB), JOSE
|
|
8
|
-
* helpers, retry and errors.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import * as Acme from "@distilled.cloud/acme";
|
|
13
|
-
*
|
|
14
|
-
* const account = yield* Acme.acme.newAccount({
|
|
15
|
-
* contact: ["mailto:ops@example.com"],
|
|
16
|
-
* termsOfServiceAgreed: true,
|
|
17
|
-
* });
|
|
18
|
-
* const order = yield* Acme.acme.newOrder({
|
|
19
|
-
* identifiers: [{ type: "dns", value: "*.example.com" }],
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
1
|
export * from "./credentials.js";
|
|
24
2
|
export * from "./errors.js";
|
|
25
3
|
export * as Jose from "./jose.js";
|
|
@@ -27,4 +5,3 @@ export * as T from "./traits.js";
|
|
|
27
5
|
export * as Retry from "./retry.js";
|
|
28
6
|
export { AcmeProtocol } from "./protocol.js";
|
|
29
7
|
export * from "./services/index.js";
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
package/lib/jose.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JOSE helpers for ACME
|
|
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
|
|
@@ -32,7 +32,7 @@ export declare const parseJwk: (key: Redacted.Redacted<string> | string) => Effe
|
|
|
32
32
|
export declare const publicJwk: (jwk: Jwk) => Jwk;
|
|
33
33
|
/** RFC 7638 JWK thumbprint (base64url SHA-256 of the canonical public JWK). */
|
|
34
34
|
export declare const thumbprint: (jwk: Jwk) => Effect.Effect<string>;
|
|
35
|
-
/** `<token>.<thumbprint>`
|
|
35
|
+
/** `<token>.<thumbprint>` -- what a challenge proves the client holds. */
|
|
36
36
|
export declare const keyAuthorization: (token: string, jwk: Jwk) => Effect.Effect<string>;
|
|
37
37
|
/** The TXT record value for a DNS-01 challenge: base64url(SHA-256(keyAuthorization)). */
|
|
38
38
|
export declare const dnsChallengeValue: (token: string, jwk: Jwk) => Effect.Effect<string>;
|
package/lib/jose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jose.d.ts","sourceRoot":"","sources":["../src/jose.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAID,eAAO,MAAM,SAAS,UAAW,UAAU,GAAG,WAAW,KAAG,MAK3D,CAAC;AAEF,eAAO,MAAM,eAAe,SAAU,MAAM,KAAG,UAM9C,CAAC;AAUF,0CAA0C;AAC1C,eAAO,MAAM,WAAW,QAAS,GAAG,KAAG,SAAoD,CAAC;AAU5F,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,SACxB,SAAS,KACb,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAgBtC,CAAC;AAEL,8CAA8C;AAC9C,eAAO,MAAM,QAAQ,QAAS,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,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A0B,YAAa;IAClD,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CACtD,KAAG,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAmCrC,CAAC"}
|
package/lib/jose.js
CHANGED
|
@@ -1,121 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* JOSE helpers for ACME — hand-written, WebCrypto only (no native code).
|
|
3
|
-
*
|
|
4
|
-
* - account keys (ES256 P-256 by default, RS256 accepted)
|
|
5
|
-
* - JWS in the flattened JSON serialization every ACME POST carries
|
|
6
|
-
* (RFC 8555 §6.2), including the HS256 External Account Binding
|
|
7
|
-
* - RFC 7638 JWK thumbprints, key authorizations and the DNS-01 TXT value
|
|
8
|
-
*/
|
|
9
|
-
import * as Effect from "effect/Effect";
|
|
10
|
-
import * as Redacted from "effect/Redacted";
|
|
11
|
-
import { JoseError } from "./errors.js";
|
|
12
|
-
const encoder = new TextEncoder();
|
|
13
|
-
export const base64url = (bytes) => {
|
|
14
|
-
const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
15
|
-
let binary = "";
|
|
16
|
-
for (const byte of view)
|
|
17
|
-
binary += String.fromCharCode(byte);
|
|
18
|
-
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
19
|
-
};
|
|
20
|
-
export const base64urlDecode = (text) => {
|
|
21
|
-
const padded = text.replaceAll("-", "+").replaceAll("_", "/");
|
|
22
|
-
const binary = atob(padded + "=".repeat((4 - (padded.length % 4)) % 4));
|
|
23
|
-
const out = new Uint8Array(binary.length);
|
|
24
|
-
for (let i = 0; i < binary.length; i++)
|
|
25
|
-
out[i] = binary.charCodeAt(i);
|
|
26
|
-
return out;
|
|
27
|
-
};
|
|
28
|
-
const base64urlJson = (value) => base64url(encoder.encode(JSON.stringify(value)));
|
|
29
|
-
const sha256 = (data) => Effect.promise(async () => {
|
|
30
|
-
const bytes = typeof data === "string" ? encoder.encode(data) : data;
|
|
31
|
-
return new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
|
|
32
|
-
});
|
|
33
|
-
/** Detect the JWS algorithm for a JWK. */
|
|
34
|
-
export const algorithmOf = (jwk) => (jwk.kty === "RSA" ? "RS256" : "ES256");
|
|
35
|
-
const importAlgorithm = (alg) => alg === "RS256"
|
|
36
|
-
? { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }
|
|
37
|
-
: { name: "ECDSA", namedCurve: "P-256" };
|
|
38
|
-
const signAlgorithm = (alg) => alg === "RS256" ? { name: "RSASSA-PKCS1-v1_5" } : { name: "ECDSA", hash: "SHA-256" };
|
|
39
|
-
/** Generate a fresh account key as a private JWK (JSON text, Redacted). */
|
|
40
|
-
export const generateAccountKey = (alg = "ES256") => Effect.promise(async () => {
|
|
41
|
-
const pair = await crypto.subtle.generateKey(alg === "RS256"
|
|
42
|
-
? {
|
|
43
|
-
name: "RSASSA-PKCS1-v1_5",
|
|
44
|
-
modulusLength: 2048,
|
|
45
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
|
46
|
-
hash: "SHA-256",
|
|
47
|
-
}
|
|
48
|
-
: { name: "ECDSA", namedCurve: "P-256" }, true, ["sign", "verify"]);
|
|
49
|
-
const jwk = await crypto.subtle.exportKey("jwk", pair.privateKey);
|
|
50
|
-
return Redacted.make(JSON.stringify(jwk));
|
|
51
|
-
});
|
|
52
|
-
/** Parse a private JWK from its JSON text. */
|
|
53
|
-
export const parseJwk = (key) => Effect.try({
|
|
54
|
-
try: () => JSON.parse(Redacted.isRedacted(key) ? Redacted.value(key) : key),
|
|
55
|
-
catch: (cause) => new JoseError({
|
|
56
|
-
message: "The account key is not a JSON Web Key.",
|
|
57
|
-
cause,
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
/** The public half of a JWK, with members in RFC 7638 canonical order. */
|
|
61
|
-
export const publicJwk = (jwk) => jwk.kty === "RSA"
|
|
62
|
-
? { e: jwk.e, kty: "RSA", n: jwk.n }
|
|
63
|
-
: { crv: jwk.crv, kty: "EC", x: jwk.x, y: jwk.y };
|
|
64
|
-
/** RFC 7638 JWK thumbprint (base64url SHA-256 of the canonical public JWK). */
|
|
65
|
-
export const thumbprint = (jwk) => sha256(JSON.stringify(publicJwk(jwk))).pipe(Effect.map(base64url));
|
|
66
|
-
/** `<token>.<thumbprint>` — what a challenge proves the client holds. */
|
|
67
|
-
export const keyAuthorization = (token, jwk) => thumbprint(jwk).pipe(Effect.map((print) => `${token}.${print}`));
|
|
68
|
-
/** The TXT record value for a DNS-01 challenge: base64url(SHA-256(keyAuthorization)). */
|
|
69
|
-
export const dnsChallengeValue = (token, jwk) => keyAuthorization(token, jwk).pipe(Effect.flatMap(sha256), Effect.map(base64url));
|
|
70
|
-
/** Sign an ACME request body (RFC 8555 §6.2) with the account key. */
|
|
71
|
-
export const signRequest = (options) => Effect.tryPromise({
|
|
72
|
-
try: async () => {
|
|
73
|
-
const alg = algorithmOf(options.jwk);
|
|
74
|
-
const header = {
|
|
75
|
-
alg,
|
|
76
|
-
nonce: options.nonce,
|
|
77
|
-
url: options.url,
|
|
78
|
-
...(options.kid !== undefined ? { kid: options.kid } : { jwk: publicJwk(options.jwk) }),
|
|
79
|
-
};
|
|
80
|
-
const protectedB64 = base64urlJson(header);
|
|
81
|
-
const payloadB64 = options.payload === undefined ? "" : base64urlJson(options.payload);
|
|
82
|
-
const key = await crypto.subtle.importKey("jwk", options.jwk, importAlgorithm(alg), false, ["sign"]);
|
|
83
|
-
const signature = await crypto.subtle.sign(signAlgorithm(alg), key, encoder.encode(`${protectedB64}.${payloadB64}`));
|
|
84
|
-
return {
|
|
85
|
-
protected: protectedB64,
|
|
86
|
-
payload: payloadB64,
|
|
87
|
-
signature: base64url(signature),
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
catch: (cause) => new JoseError({ message: "Signing the ACME request failed.", cause }),
|
|
91
|
-
});
|
|
92
|
-
/**
|
|
93
|
-
* The External Account Binding JWS (RFC 8555 §7.3.4): HS256 over the
|
|
94
|
-
* account's public JWK, keyed by the CA-issued HMAC key, with the CA's key
|
|
95
|
-
* id as `kid`.
|
|
96
|
-
*/
|
|
97
|
-
export const signExternalAccountBinding = (options) => Effect.tryPromise({
|
|
98
|
-
try: async () => {
|
|
99
|
-
const raw = Redacted.isRedacted(options.hmacKey)
|
|
100
|
-
? Redacted.value(options.hmacKey)
|
|
101
|
-
: options.hmacKey;
|
|
102
|
-
const key = await crypto.subtle.importKey("raw", base64urlDecode(raw), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
103
|
-
const protectedB64 = base64urlJson({
|
|
104
|
-
alg: "HS256",
|
|
105
|
-
kid: options.keyId,
|
|
106
|
-
url: options.url,
|
|
107
|
-
});
|
|
108
|
-
const payloadB64 = base64urlJson(publicJwk(options.jwk));
|
|
109
|
-
const signature = await crypto.subtle.sign("HMAC", key, encoder.encode(`${protectedB64}.${payloadB64}`));
|
|
110
|
-
return {
|
|
111
|
-
protected: protectedB64,
|
|
112
|
-
payload: payloadB64,
|
|
113
|
-
signature: base64url(signature),
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
catch: (cause) => new JoseError({
|
|
117
|
-
message: "Signing the External Account Binding failed.",
|
|
118
|
-
cause,
|
|
119
|
-
}),
|
|
120
|
-
});
|
|
1
|
+
import{JoseError as e}from"./errors.js";import*as t from"effect/Effect";import*as n from"effect/Redacted";const r=/*@__PURE__*/ new TextEncoder;const base64url=e=>{const t=e instanceof Uint8Array?e:new Uint8Array(e);let n=``;for(const e of t)n+=String.fromCharCode(e);return btoa(n).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``)};const base64urlDecode=e=>{const t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`);const n=atob(t+`=`.repeat((4-t.length%4)%4));const r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r};const base64urlJson=e=>base64url(r.encode(JSON.stringify(e)));const sha256=e=>t.promise(async()=>{const t=typeof e===`string`?r.encode(e):e;return new Uint8Array(await crypto.subtle.digest(`SHA-256`,t))});const algorithmOf=e=>e.kty===`RSA`?`RS256`:`ES256`;const importAlgorithm=e=>e===`RS256`?{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`}:{name:`ECDSA`,namedCurve:`P-256`};const signAlgorithm=e=>e===`RS256`?{name:`RSASSA-PKCS1-v1_5`}:{name:`ECDSA`,hash:`SHA-256`};const generateAccountKey=(e=`ES256`)=>t.promise(async()=>{const t=await crypto.subtle.generateKey(e===`RS256`?{name:`RSASSA-PKCS1-v1_5`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`}:{name:`ECDSA`,namedCurve:`P-256`},true,[`sign`,`verify`]);const r=await crypto.subtle.exportKey(`jwk`,t.privateKey);return n.make(JSON.stringify(r))});const parseJwk=r=>t.try({try:()=>JSON.parse(n.isRedacted(r)?n.value(r):r),catch:t=>new e({message:`The account key is not a JSON Web Key.`,cause:t})});const publicJwk=e=>e.kty===`RSA`?{e:e.e,kty:`RSA`,n:e.n}:{crv:e.crv,kty:`EC`,x:e.x,y:e.y};const thumbprint=e=>sha256(JSON.stringify(publicJwk(e))).pipe(t.map(base64url));const keyAuthorization=(e,n)=>thumbprint(n).pipe(t.map(t=>`${e}.${t}`));const dnsChallengeValue=(e,n)=>keyAuthorization(e,n).pipe(t.flatMap(sha256),t.map(base64url));const signRequest=n=>t.tryPromise({try:async()=>{const e=algorithmOf(n.jwk);const t={alg:e,nonce:n.nonce,url:n.url,...n.kid!==void 0?{kid:n.kid}:{jwk:publicJwk(n.jwk)}};const i=base64urlJson(t);const a=n.payload===void 0?``:base64urlJson(n.payload);const o=await crypto.subtle.importKey(`jwk`,n.jwk,importAlgorithm(e),false,[`sign`]);const s=await crypto.subtle.sign(signAlgorithm(e),o,r.encode(`${i}.${a}`));return{protected:i,payload:a,signature:base64url(s)}},catch:t=>new e({message:`Signing the ACME request failed.`,cause:t})});const signExternalAccountBinding=i=>t.tryPromise({try:async()=>{const e=n.isRedacted(i.hmacKey)?n.value(i.hmacKey):i.hmacKey;const t=await crypto.subtle.importKey(`raw`,base64urlDecode(e),{name:`HMAC`,hash:`SHA-256`},false,[`sign`]);const a=base64urlJson({alg:`HS256`,kid:i.keyId,url:i.url});const o=base64urlJson(publicJwk(i.jwk));const s=await crypto.subtle.sign(`HMAC`,t,r.encode(`${a}.${o}`));return{protected:a,payload:o,signature:base64url(s)}},catch:t=>new e({message:`Signing the External Account Binding failed.`,cause:t})});export{algorithmOf,base64url,base64urlDecode,dnsChallengeValue,generateAccountKey,keyAuthorization,parseJwk,publicJwk,signExternalAccountBinding,signRequest,thumbprint};
|
|
121
2
|
//# sourceMappingURL=jose.js.map
|
package/lib/jose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jose.js","
|
|
1
|
+
{"version":3,"file":"jose.js","names":["Effect","Redacted","encoder","view","bytes","binary","byte","padded","text","out","i","value","data","jwk","alg","pair","key","JoseError","token","print","options","header","protectedB64","payloadB64","signature","raw"],"sources":["../src/jose.ts"],"mappings":"0GAyBA,MAAME,gBAAwB,IAAI,YAElC,MAAa,UAAa,GAA4C,CACpE,MAAMC,EAAOC,aAAiB,WAAaA,EAAQ,IAAI,WAAWA,CAAK,EACvE,IAAIC,EAAS,GACb,IAAK,MAAMC,KAAQH,EAAM,GAAU,OAAO,aAAaG,CAAI,EAC3D,OAAO,KAAKD,CAAM,CAAC,CAAC,WAAW,IAAK,GAAG,CAAC,CAAC,WAAW,IAAK,GAAG,CAAC,CAAC,QAAQ,MAAO,EAAE,CACjF,EAEA,MAAa,gBAAmB,GAA6B,CAC3D,MAAME,EAASC,EAAK,WAAW,IAAK,GAAG,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O,KACpC,cAAcV,CAAG,EACjBE,EACAd,EAAQ,OAAO,GAAGoB,EAAa,GAAGC,GAAY,CAChD,EACA,MAAO,CACL,UAAWD,EACX,QAASC,EACT,UAAW,UAAUC,CAAS,CAChC,CACF,EACA,MAAQ,GAAU,IAAIP,EAAU,CAAE,QAAS,mCAAoC,OAAM,CAAC,CACxF,CAAC,EAOH,MAAa,2BAA8B,GAMzCjB,EAAO,WAAW,CAChB,IAAK,SAAY,CACf,MAAMyB,EAAMxB,EAAS,WAAWmB,EAAQ,OAAO,EAC3CnB,EAAS,MAAMmB,EAAQ,OAAO,EAC9BA,EAAQ,QACZ,MAAMJ,EAAM,MAAM,OAAO,OAAO,UAC9B,MACA,gBAAgBS,CAAG,EACnB,CAAE,KAAM,OAAQ,KAAM,SAAU,EAChC,MACA,CAAC,MAAM,CACT,EACA,MAAMH,EAAe,cAAc,CACjC,IAAK,QACL,IAAKF,EAAQ,MACb,IAAKA,EAAQ,GACf,CAAC,EACD,MAAMG,EAAa,cAAc,UAAUH,EAAQ,GAAG,CAAC,EACvD,MAAMI,EAAY,MAAM,OAAO,OAAO,KACpC,OACAR,EACAd,EAAQ,OAAO,GAAGoB,EAAa,GAAGC,GAAY,CAChD,EACA,MAAO,CACL,UAAWD,EACX,QAASC,EACT,UAAW,UAAUC,CAAS,CAChC,CACF,EACA,MAAQ,GACN,IAAIP,EAAU,CACZ,QAAS,+CACT,OACF,CAAC,CACL,CAAC"}
|
package/lib/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAsCtC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAGpE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC;AAExF,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAochE,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAMlD,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,QAAO,IAGtC,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,SAAS;;;CAAuB,CAAC"}
|