@noz-ele/edgca 0.3.0 → 0.4.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > [日本語](https://github.com/noz-ele/EdgCA/blob/main/docs/jp/README.md) | English
4
4
 
5
- EdgCA is a small TypeScript library that issues mTLS client certificates from a self-managed CA on Cloudflare Workers-compatible runtimes. It supports internal keygen, CSR-based enrollment (PKCS#10 + proof-of-possession), and PFX (PKCS#12) export for OS keystore import.
5
+ EdgCA is a small TypeScript library that issues mTLS client certificates and document-signing certificates from a self-managed CA on Cloudflare Workers-compatible runtimes. It supports internal keygen, CSR-based enrollment for mTLS leaves (PKCS#10 + proof-of-possession), and PFX (PKCS#12) export for OS keystore import.
6
6
 
7
7
  The scope is intentionally narrow:
8
8
 
@@ -10,6 +10,7 @@ The scope is intentionally narrow:
10
10
  - Issue an intermediate CA from a root CA.
11
11
  - Issue an mTLS client certificate and private key from an intermediate CA.
12
12
  - Issue an mTLS client certificate from a caller-provided public key (no private key returned). Pairs with the CSR helpers below.
13
+ - Issue a document-signing certificate (RFC 9336 `id-kp-documentSigning`) and private key from a CA. Used as the signer cert for CAdES / CMS / ASiC-style document signatures, which are produced by separate tooling.
13
14
  - Parse a PKCS#10 CSR (subject, requested SAN, public key, raw extensions/attributes) and verify its proof-of-possession signature.
14
15
  - Decide whether a received client certificate was issued by your own CA.
15
16
  - Encode/decode certificates as PEM/DER. Keys are exchanged as `CryptoKey` only — the library never returns or accepts string forms (PEM, JWK, etc.) of private keys.
@@ -23,6 +24,7 @@ ECDSA on **NIST P-256, P-384, and P-521** is supported throughout (signing, veri
23
24
  ## Contents
24
25
 
25
26
  - [Quick Start](#quick-start) — root → intermediate → client cert (incl. PFX bundling)
27
+ - [Issue a document-signing certificate](#issue-a-document-signing-certificate) — RFC 9336 `id-kp-documentSigning` leaf
26
28
  - [Verify on Cloudflare Worker](#verify-cloudflare-worker) — confirm a cert was issued by your CA
27
29
  - [Issue from a CSR](#issue-from-a-csr) — accept a caller-managed key via PKCS#10 + POP
28
30
  - [Subject](#subject) · [Scope](#scope) · [Key Handling](#key-handling) · [Development](#development) · [API Documentation](#api-documentation)
@@ -119,6 +121,46 @@ The implementation is environment-agnostic (WebCrypto only, no Node-specific API
119
121
 
120
122
  The `@noz-ele/edgca/pkcs12` subpath is provided so consumers that only need PFX assembly can import it without pulling in the CA / CSR / verify modules.
121
123
 
124
+ ## Issue a document-signing certificate
125
+
126
+ `issueDocumentSigningCert` issues a leaf intended for signing arbitrary documents (CAdES detached, CMS, ASiC-E containers, etc., which are produced by separate tooling — not by EdgCA). It is **not** an mTLS client certificate: the EKU is `id-kp-documentSigning` (RFC 9336), and `keyUsage` carries `digitalSignature, contentCommitment` instead of just `digitalSignature`. SAN is intentionally not accepted; the signer is identified by Subject DN.
127
+
128
+ ```ts
129
+ import {
130
+ createRootCA,
131
+ issueIntermediateCA,
132
+ issueDocumentSigningCert
133
+ } from "@noz-ele/edgca";
134
+
135
+ const root = await createRootCA({
136
+ subject: [{ type: "CN", value: "dev-root" }],
137
+ days: 3650
138
+ });
139
+
140
+ const intermediate = await issueIntermediateCA({
141
+ ca: root,
142
+ subject: [{ type: "CN", value: "dev-intermediate" }],
143
+ days: 365
144
+ });
145
+
146
+ const signer = await issueDocumentSigningCert({
147
+ ca: intermediate,
148
+ subject: [
149
+ { type: "CN", value: "Alice (Document Signer)" },
150
+ { type: "O", value: "Example" }
151
+ ],
152
+ days: 365
153
+ });
154
+
155
+ // signer.certPem — the signing certificate
156
+ // signer.certChainPem — full chain to embed alongside the signature (signer + intermediate + root)
157
+ // signer.privateKey — secret CryptoKey, used by the document-signing tool to produce the signature
158
+ ```
159
+
160
+ The returned shape is `IssuedDocumentSigningCertificate` (structurally identical to `IssuedClientCertificate`; the distinct name flags the EKU profile). The same `exportPkcs12` flow used for mTLS leaves works here too if you need to bundle the signer cert + key into a PFX for tools that consume PKCS#12.
161
+
162
+ There is no `issueDocumentSigningCertForPublicKey` (CSR variant) in v1, and EdgCA does not produce CAdES / CMS / ASiC containers itself — see [docs/en/NON_GOALS.md](https://github.com/noz-ele/EdgCA/blob/main/docs/en/NON_GOALS.md) for the rationale.
163
+
122
164
  ## Verify (Cloudflare Worker)
123
165
 
124
166
  > ⚠ **What this is — and is not**
@@ -283,6 +325,7 @@ In scope:
283
325
  - Root CA creation.
284
326
  - Intermediate CA issuance.
285
327
  - mTLS client certificate issuance (with internal key generation, or from a caller-provided public key).
328
+ - Document-signing certificate issuance with EKU `id-kp-documentSigning` (RFC 9336) and `keyUsage digitalSignature, contentCommitment` — internal key generation only, no SAN.
286
329
  - CSR (PKCS#10) parsing and proof-of-possession signature verification.
287
330
  - Identity check that a cert was issued by your own CA (`verifyClientCertificateIssuedBy`, with optional time-validity check).
288
331
  - PEM/DER helpers (certificates only — keys are exchanged as `CryptoKey`).
@@ -291,7 +334,10 @@ In scope:
291
334
 
292
335
  Intentionally out of scope:
293
336
 
294
- - Server certificate issuance.
337
+ - Server certificate issuance. Leaf scope is mTLS client certs and document-signing certs only.
338
+ - Document-signing certificate issuance from a caller-provided public key (`issueDocumentSigningCertForPublicKey`) — not in v1.
339
+ - SAN (`dnsNames` / `ipAddresses` / `emailAddresses`) on document-signing leaves.
340
+ - CAdES / CMS / PAdES / XAdES / ASiC document signing or container building. EdgCA only issues the signing certificate; producing a signed document or container is a separate concern.
295
341
  - Public chain-validation APIs.
296
342
  - Extracting time fields from a cert. `verifyClientCertificateIssuedBy`'s `validity` option performs the time check, but the `notBefore` / `notAfter` values are passed in by the caller from `cf.tlsClientAuth`.
297
343
  - CRL, OCSP, revocation databases, revocation checks.
package/dist/ca.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { CertificateAuthority, CreateRootCAOptions, ImportCertificateAuthorityOptions, IssueClientCertForPublicKeyOptions, IssueClientCertOptions, IssueIntermediateCAOptions, IssuedClientCertificate, IssuedClientCertificateForPublicKey } from "./types.js";
1
+ import type { CertificateAuthority, CreateRootCAOptions, ImportCertificateAuthorityOptions, IssueClientCertForPublicKeyOptions, IssueClientCertOptions, IssueDocumentSigningCertOptions, IssueIntermediateCAOptions, IssuedClientCertificate, IssuedClientCertificateForPublicKey, IssuedDocumentSigningCertificate } from "./types.js";
2
2
  export declare function createRootCA(options: CreateRootCAOptions): Promise<CertificateAuthority>;
3
3
  export declare function issueIntermediateCA(options: IssueIntermediateCAOptions): Promise<CertificateAuthority>;
4
4
  export declare function issueClientCert(options: IssueClientCertOptions): Promise<IssuedClientCertificate>;
5
5
  export declare function issueClientCertForPublicKey(options: IssueClientCertForPublicKeyOptions): Promise<IssuedClientCertificateForPublicKey>;
6
+ export declare function issueDocumentSigningCert(options: IssueDocumentSigningCertOptions): Promise<IssuedDocumentSigningCertificate>;
6
7
  export declare function importCertificateAuthority(options: ImportCertificateAuthorityOptions): Promise<CertificateAuthority>;
7
8
  //# sourceMappingURL=ca.d.ts.map
package/dist/ca.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ca.d.ts","sourceRoot":"","sources":["../src/ca.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,iCAAiC,EACjC,kCAAkC,EAClC,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,mCAAmC,EAEpC,MAAM,YAAY,CAAC;AAapB,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0B9F;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAgC5G;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAqBvG;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,mCAAmC,CAAC,CAkB9C;AAuDD,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAe1H"}
1
+ {"version":3,"file":"ca.d.ts","sourceRoot":"","sources":["../src/ca.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,iCAAiC,EACjC,kCAAkC,EAClC,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,uBAAuB,EACvB,mCAAmC,EACnC,gCAAgC,EAEjC,MAAM,YAAY,CAAC;AAcpB,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0B9F;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAgC5G;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAoBvG;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,mCAAmC,CAAC,CAiB9C;AAuED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,gCAAgC,CAAC,CAoB3C;AAED,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAe1H"}
package/dist/ca.js CHANGED
@@ -3,7 +3,7 @@ import { assertKeyPairMatches, curveOf, exportSpki, generateKeyPair, keyIdentifi
3
3
  import { encodeName } from "./name.js";
4
4
  import { certificateToPem, pemToDer, pemToDerWithLabel, splitPemBlocks } from "./pem.js";
5
5
  import { parseCertificateDer } from "./parser.js";
6
- import { authorityKeyIdentifierExtension, basicConstraintsCaExtension, basicConstraintsLeafExtension, buildCertificate, buildTbsCertificate, extendedKeyUsageClientAuthExtension, keyUsageExtension, subjectAltNameExtension, subjectKeyIdentifierExtension } from "./x509.js";
6
+ import { authorityKeyIdentifierExtension, basicConstraintsCaExtension, basicConstraintsLeafExtension, buildCertificate, buildTbsCertificate, extendedKeyUsageClientAuthExtension, extendedKeyUsageDocumentSigningExtension, keyUsageExtension, subjectAltNameExtension, subjectKeyIdentifierExtension } from "./x509.js";
7
7
  export async function createRootCA(options) {
8
8
  const keyPair = await resolveKeyPair(options.keyPair);
9
9
  const issuerCurve = curveOf(keyPair.privateKey);
@@ -65,14 +65,12 @@ export async function issueIntermediateCA(options) {
65
65
  }
66
66
  export async function issueClientCert(options) {
67
67
  const keyPair = await generateKeyPair();
68
- const built = await buildClientCertificate(options.ca, keyPair.publicKey, {
68
+ const built = await buildLeafCertificate(options.ca, keyPair.publicKey, {
69
69
  subject: options.subject,
70
70
  days: options.days,
71
71
  notBefore: options.notBefore,
72
- serialNumber: options.serialNumber,
73
- dnsNames: options.dnsNames,
74
- ipAddresses: options.ipAddresses
75
- });
72
+ serialNumber: options.serialNumber
73
+ }, clientCertProfileExtensions(options.dnsNames, options.ipAddresses));
76
74
  return {
77
75
  certPem: built.certPem,
78
76
  certDer: built.certDer,
@@ -82,42 +80,36 @@ export async function issueClientCert(options) {
82
80
  };
83
81
  }
84
82
  export async function issueClientCertForPublicKey(options) {
85
- const built = await buildClientCertificate(options.ca, options.publicKey, {
83
+ const built = await buildLeafCertificate(options.ca, options.publicKey, {
86
84
  subject: options.subject,
87
85
  days: options.days,
88
86
  notBefore: options.notBefore,
89
- serialNumber: options.serialNumber,
90
- dnsNames: options.dnsNames,
91
- ipAddresses: options.ipAddresses
92
- });
87
+ serialNumber: options.serialNumber
88
+ }, clientCertProfileExtensions(options.dnsNames, options.ipAddresses));
93
89
  return {
94
90
  certPem: built.certPem,
95
91
  certDer: built.certDer,
96
92
  certChainPem: built.certChainPem
97
93
  };
98
94
  }
99
- async function buildClientCertificate(ca, subjectPublicKey, content) {
95
+ async function buildLeafCertificate(ca, subjectPublicKey, identity, profileExtensions) {
100
96
  const issuer = await parseIssuer(ca);
101
97
  const issuerChainPem = ca.issuerChainPem;
102
98
  assertCanIssueCertificate(issuer);
103
99
  const issuerCurve = curveOf(ca.privateKey);
104
- const subjectNameDer = encodeName(content.subject);
100
+ const subjectNameDer = encodeName(identity.subject);
105
101
  const spki = await exportSpki(subjectPublicKey);
106
102
  const subjectKeyIdentifier = await keyIdentifierFromSpki(spki);
107
103
  const authorityKeyIdentifier = issuer.subjectKeyIdentifier ?? await keyIdentifierFromSpki(issuer.subjectPublicKeyInfoDer);
108
- const san = subjectAltNameExtension(content.dnsNames, content.ipAddresses);
109
104
  const extensions = [
110
- basicConstraintsLeafExtension(),
111
- keyUsageExtension(["digitalSignature"]),
112
- extendedKeyUsageClientAuthExtension(),
105
+ ...profileExtensions,
113
106
  subjectKeyIdentifierExtension(subjectKeyIdentifier),
114
- authorityKeyIdentifierExtension(authorityKeyIdentifier),
115
- ...(san ? [san] : [])
107
+ authorityKeyIdentifierExtension(authorityKeyIdentifier)
116
108
  ];
117
109
  const { tbsCertificateDer } = buildTbsCertificate({
118
- serialNumber: content.serialNumber,
119
- notBefore: content.notBefore,
120
- days: content.days,
110
+ serialNumber: identity.serialNumber,
111
+ notBefore: identity.notBefore,
112
+ days: identity.days,
121
113
  issuerNameDer: issuer.subjectNameDer,
122
114
  subjectNameDer,
123
115
  subjectPublicKeyInfoDer: spki,
@@ -133,6 +125,38 @@ async function buildClientCertificate(ca, subjectPublicKey, content) {
133
125
  certChainPem: joinPemChain([certPem, ca.certPem, issuerChainPem])
134
126
  };
135
127
  }
128
+ function clientCertProfileExtensions(dnsNames, ipAddresses) {
129
+ const san = subjectAltNameExtension(dnsNames, ipAddresses);
130
+ return [
131
+ basicConstraintsLeafExtension(),
132
+ keyUsageExtension(["digitalSignature"]),
133
+ extendedKeyUsageClientAuthExtension(),
134
+ ...(san ? [san] : [])
135
+ ];
136
+ }
137
+ function documentSigningProfileExtensions() {
138
+ return [
139
+ basicConstraintsLeafExtension(),
140
+ keyUsageExtension(["digitalSignature", "contentCommitment"]),
141
+ extendedKeyUsageDocumentSigningExtension()
142
+ ];
143
+ }
144
+ export async function issueDocumentSigningCert(options) {
145
+ const keyPair = await generateKeyPair();
146
+ const built = await buildLeafCertificate(options.ca, keyPair.publicKey, {
147
+ subject: options.subject,
148
+ days: options.days,
149
+ notBefore: options.notBefore,
150
+ serialNumber: options.serialNumber
151
+ }, documentSigningProfileExtensions());
152
+ return {
153
+ certPem: built.certPem,
154
+ certDer: built.certDer,
155
+ privateKey: keyPair.privateKey,
156
+ publicKey: keyPair.publicKey,
157
+ certChainPem: built.certChainPem
158
+ };
159
+ }
136
160
  export async function importCertificateAuthority(options) {
137
161
  const issuerChainPem = options.issuerChainPem ?? "";
138
162
  assertIssuerChainPem(issuerChainPem);
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { createRootCA, importCertificateAuthority, issueClientCert, issueClientCertForPublicKey, issueIntermediateCA } from "./ca.js";
1
+ export { createRootCA, importCertificateAuthority, issueClientCert, issueClientCertForPublicKey, issueDocumentSigningCert, issueIntermediateCA } from "./ca.js";
2
2
  export { parseCertificateSigningRequest, verifyCertificateSigningRequestSignature, type ParsedCertificateSigningRequest, type CertificateSigningRequestExtension, type CertificateSigningRequestAttribute } from "./csr.js";
3
3
  export { pemToDer, certificateToPem } from "./pem.js";
4
4
  export { exportPkcs12, type ExportPkcs12Input } from "./pkcs12.js";
5
5
  export { verifyClientCertificateIssuedBy, type VerifyClientCertificateIssuedByOptions, type VerifyClientCertificateValidity } from "./verify.js";
6
- export type { CertificateAuthority, CreateRootCAOptions, ImportCertificateAuthorityOptions, IssueClientCertForPublicKeyOptions, IssueClientCertOptions, IssueIntermediateCAOptions, IssuedClientCertificate, IssuedClientCertificateForPublicKey, SerialNumber, ShortSubjectAttributeType, Subject, SubjectAttribute, SubjectAttributeType } from "./types.js";
6
+ export type { CertificateAuthority, CreateRootCAOptions, ImportCertificateAuthorityOptions, IssueClientCertForPublicKeyOptions, IssueClientCertOptions, IssueDocumentSigningCertOptions, IssueIntermediateCAOptions, IssuedClientCertificate, IssuedClientCertificateForPublicKey, IssuedDocumentSigningCertificate, SerialNumber, ShortSubjectAttributeType, Subject, SubjectAttribute, SubjectAttributeType } from "./types.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,EACxC,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACxC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,+BAA+B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,+BAA+B,EACrC,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,iCAAiC,EACjC,kCAAkC,EAClC,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,mCAAmC,EACnC,YAAY,EACZ,yBAAyB,EACzB,OAAO,EACP,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,EACxC,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACxC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,+BAA+B,EAC/B,KAAK,sCAAsC,EAC3C,KAAK,+BAA+B,EACrC,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,iCAAiC,EACjC,kCAAkC,EAClC,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,uBAAuB,EACvB,mCAAmC,EACnC,gCAAgC,EAChC,YAAY,EACZ,yBAAyB,EACzB,OAAO,EACP,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { createRootCA, importCertificateAuthority, issueClientCert, issueClientCertForPublicKey, issueIntermediateCA } from "./ca.js";
1
+ export { createRootCA, importCertificateAuthority, issueClientCert, issueClientCertForPublicKey, issueDocumentSigningCert, issueIntermediateCA } from "./ca.js";
2
2
  export { parseCertificateSigningRequest, verifyCertificateSigningRequestSignature } from "./csr.js";
3
3
  export { pemToDer, certificateToPem } from "./pem.js";
4
4
  export { exportPkcs12 } from "./pkcs12.js";
package/dist/oids.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare const OID: {
14
14
  readonly subjectKeyIdentifier: "2.5.29.14";
15
15
  readonly authorityKeyIdentifier: "2.5.29.35";
16
16
  readonly clientAuth: "1.3.6.1.5.5.7.3.2";
17
+ readonly documentSigning: "1.3.6.1.5.5.7.3.36";
17
18
  readonly extensionRequest: "1.2.840.113549.1.9.14";
18
19
  readonly data: "1.2.840.113549.1.7.1";
19
20
  readonly encryptedData: "1.2.840.113549.1.7.6";
@@ -1 +1 @@
1
- {"version":3,"file":"oids.d.ts","sourceRoot":"","sources":["../src/oids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BN,CAAC;AAEX,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,yBAAyB,EAAE,MAAM,CAgB5E,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,yBAAyB,EAAE,MAAM,CAgBjF,CAAC;AAIF,eAAO,MAAM,wBAAwB,MAAM,CAAC"}
1
+ {"version":3,"file":"oids.d.ts","sourceRoot":"","sources":["../src/oids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BN,CAAC;AAEX,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,yBAAyB,EAAE,MAAM,CAgB5E,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,yBAAyB,EAAE,MAAM,CAgBjF,CAAC;AAIF,eAAO,MAAM,wBAAwB,MAAM,CAAC"}
package/dist/oids.js CHANGED
@@ -13,6 +13,7 @@ export const OID = {
13
13
  subjectKeyIdentifier: "2.5.29.14",
14
14
  authorityKeyIdentifier: "2.5.29.35",
15
15
  clientAuth: "1.3.6.1.5.5.7.3.2",
16
+ documentSigning: "1.3.6.1.5.5.7.3.36",
16
17
  extensionRequest: "1.2.840.113549.1.9.14",
17
18
  data: "1.2.840.113549.1.7.1",
18
19
  encryptedData: "1.2.840.113549.1.7.6",
package/dist/types.d.ts CHANGED
@@ -62,6 +62,20 @@ export interface IssuedClientCertificateForPublicKey {
62
62
  certDer: Uint8Array;
63
63
  certChainPem: string;
64
64
  }
65
+ export interface IssueDocumentSigningCertOptions {
66
+ ca: CertificateAuthority;
67
+ subject: Subject;
68
+ days: number;
69
+ notBefore?: Date;
70
+ serialNumber?: SerialNumber;
71
+ }
72
+ export interface IssuedDocumentSigningCertificate {
73
+ certPem: string;
74
+ certDer: Uint8Array;
75
+ privateKey: CryptoKey;
76
+ publicKey: CryptoKey;
77
+ certChainPem: string;
78
+ }
65
79
  export interface ImportCertificateAuthorityOptions {
66
80
  certPem: string;
67
81
  privateKey: CryptoKey;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GACjC,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,GAAG,GACH,GAAG,GACH,IAAI,GACJ,cAAc,GACd,QAAQ,GACR,YAAY,GACZ,OAAO,GACP,WAAW,GACX,SAAS,GACT,KAAK,CAAC;AAEV,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAEjE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,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;CAC7B;AAED,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iCAAiC;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
package/dist/x509.d.ts CHANGED
@@ -23,11 +23,13 @@ export declare function basicConstraintsCaExtension(pathLenConstraint: number):
23
23
  export declare function basicConstraintsLeafExtension(): Uint8Array;
24
24
  export declare function keyUsageExtension(usages: readonly KeyUsageBit[]): Uint8Array;
25
25
  export declare function extendedKeyUsageClientAuthExtension(): Uint8Array;
26
+ export declare function extendedKeyUsageDocumentSigningExtension(): Uint8Array;
26
27
  export declare function subjectKeyIdentifierExtension(keyIdentifier: Uint8Array): Uint8Array;
27
28
  export declare function authorityKeyIdentifierExtension(keyIdentifier: Uint8Array): Uint8Array;
28
29
  export declare function subjectAltNameExtension(dnsNames?: readonly string[], ipAddresses?: readonly string[]): Uint8Array | undefined;
29
30
  declare const KEY_USAGE_BITS: {
30
31
  readonly digitalSignature: 0;
32
+ readonly contentCommitment: 1;
31
33
  readonly keyCertSign: 5;
32
34
  readonly cRLSign: 6;
33
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"x509.d.ts","sourceRoot":"","sources":["../src/x509.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAkBjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;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AAU,CAErF;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,GAAG,SAAS,CAmC7H;AAuID,QAAA,MAAM,cAAc;;;;;CAKV,CAAC;AAEX,KAAK,WAAW,GAAG,MAAM,OAAO,cAAc,CAAC"}
package/dist/x509.js CHANGED
@@ -43,6 +43,9 @@ export function keyUsageExtension(usages) {
43
43
  export function extendedKeyUsageClientAuthExtension() {
44
44
  return extension(OID.extendedKeyUsage, false, sequence(oid(OID.clientAuth)));
45
45
  }
46
+ export function extendedKeyUsageDocumentSigningExtension() {
47
+ return extension(OID.extendedKeyUsage, false, sequence(oid(OID.documentSigning)));
48
+ }
46
49
  export function subjectKeyIdentifierExtension(keyIdentifier) {
47
50
  return extension(OID.subjectKeyIdentifier, false, octetString(keyIdentifier));
48
51
  }
@@ -192,6 +195,7 @@ function assertYearInRange(year, fieldName) {
192
195
  }
193
196
  const KEY_USAGE_BITS = {
194
197
  digitalSignature: 0,
198
+ contentCommitment: 1,
195
199
  keyCertSign: 5,
196
200
  cRLSign: 6
197
201
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noz-ele/edgca",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A small Cloudflare Workers-friendly toolkit for issuing self-managed CA and mTLS client certificates.",
5
5
  "type": "module",
6
6
  "license": "MIT",