harperdb 4.7.0-beta.3 → 4.7.0-beta.4

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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/bin/harperdb.js +79 -79
  3. package/bin/lite.js +77 -77
  4. package/config/yaml/defaultConfig.yaml +1 -1
  5. package/json/systemSchema.json +30 -0
  6. package/launchServiceScripts/launchNatsIngestService.js +77 -77
  7. package/launchServiceScripts/launchNatsReplyService.js +77 -77
  8. package/launchServiceScripts/launchUpdateNodes4-0-0.js +77 -77
  9. package/npm-shrinkwrap.json +299 -291
  10. package/package.json +3 -1
  11. package/resources/Table.d.ts +34 -34
  12. package/resources/blob.d.ts +6 -3
  13. package/resources/openApi.d.ts +27 -0
  14. package/security/certificateVerification/certificateVerificationSource.d.ts +18 -0
  15. package/security/certificateVerification/configValidation.d.ts +14 -0
  16. package/security/certificateVerification/crlVerification.d.ts +29 -0
  17. package/security/certificateVerification/index.d.ts +31 -0
  18. package/security/certificateVerification/ocspVerification.d.ts +23 -0
  19. package/security/certificateVerification/types.d.ts +105 -0
  20. package/security/certificateVerification/verificationConfig.d.ts +29 -0
  21. package/security/certificateVerification/verificationUtils.d.ts +79 -0
  22. package/server/jobs/jobProcess.js +77 -77
  23. package/server/operationsServer.d.ts +13 -3
  24. package/server/replication/replicator.d.ts +6 -0
  25. package/server/threads/threadServer.js +77 -77
  26. package/studio/web/assets/index-BsZJSz4i.js +1 -0
  27. package/studio/web/assets/index-BwVqw4zI.js +453 -0
  28. package/studio/web/assets/index-OpljqLtb.css +4 -0
  29. package/studio/web/assets/profiler-CW5dV_9B.js +1 -0
  30. package/studio/web/assets/startRecording--YUj61DT.js +2 -0
  31. package/studio/web/index.html +2 -2
  32. package/studio/web/running.html +90 -0
  33. package/utility/hdbTerms.d.ts +22 -3
  34. package/utility/scripts/restartHdb.js +77 -77
  35. package/security/certificateVerification.d.ts +0 -87
  36. package/studio/web/assets/index-BqOgGOeU.js +0 -445
  37. package/studio/web/assets/index-C4VX60Fd.js +0 -1
  38. package/studio/web/assets/index-Dj8x6atJ.css +0 -4
  39. package/studio/web/assets/profiler-OUXA1uul.js +0 -1
  40. package/studio/web/assets/startRecording-D8PRkhto.js +0 -2
  41. /package/security/{pkijs-ed25519-patch.d.ts → certificateVerification/pkijs-ed25519-patch.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harperdb",
3
- "version": "4.7.0-beta.3",
3
+ "version": "4.7.0-beta.4",
4
4
  "description": "HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.",
5
5
  "keywords": [
6
6
  "database",
@@ -62,6 +62,7 @@
62
62
  "@turf/length": "6.5.0",
63
63
  "alasql": "4.6.6",
64
64
  "argon2": "0.43.0",
65
+ "asn1js": "3.0.6",
65
66
  "cbor-x": "1.6.0",
66
67
  "chalk": "4.1.2",
67
68
  "chokidar": "^4.0.3",
@@ -104,6 +105,7 @@
104
105
  "passport-http": "0.3.0",
105
106
  "passport-local": "1.0.0",
106
107
  "pino": "8.16.0",
108
+ "pkijs": "3.2.5",
107
109
  "prompt": "1.3.0",
108
110
  "properties-reader": "2.3.0",
109
111
  "recursive-iterator": "3.3.0",
@@ -43,12 +43,12 @@ type ResidencyDefinition = number | string[] | void;
43
43
  */
44
44
  export declare function makeTable(options: any): {
45
45
  new (identifier: Id, source: any): {
46
- #record: any;
47
- #changes: any;
48
- #version?: number;
49
- #entry?: Entry;
50
- #saveMode?: boolean;
51
- #loadedFromSource?: boolean;
46
+ "__#private@#record": any;
47
+ "__#private@#changes": any;
48
+ "__#private@#version"?: number;
49
+ "__#private@#entry"?: Entry;
50
+ "__#private@#saveMode"?: boolean;
51
+ "__#private@#loadedFromSource"?: boolean;
52
52
  getProperty: (name: string) => any;
53
53
  /**
54
54
  * This is a request to explicitly ensure that the record is loaded from source, rather than only using the local record.
@@ -98,8 +98,8 @@ export declare function makeTable(options: any): {
98
98
  getExpiresAt(): number;
99
99
  addTo(property: string, value: number | bigint): void;
100
100
  subtractFrom(property: string, value: number | bigint): void;
101
- #record: any;
102
- #changes: any;
101
+ "__#private@#record": any;
102
+ "__#private@#changes": any;
103
103
  getRecord(): any;
104
104
  setRecord(record: any): void;
105
105
  getChanges(): any;
@@ -196,9 +196,9 @@ export declare function makeTable(options: any): {
196
196
  validate(record: any, patch?: boolean): void;
197
197
  getUpdatedTime(): number;
198
198
  wasLoadedFromSource(): boolean | void;
199
- readonly #id: Id;
200
- readonly #context: Context;
201
- #isCollection: boolean;
199
+ readonly "__#private@#id": Id;
200
+ readonly "__#private@#context": Context;
201
+ "__#private@#isCollection": boolean;
202
202
  post(newRecord: any): Promise<any>;
203
203
  get isCollection(): boolean;
204
204
  connect(incomingMessages: import("./IterableEventQueue.js").IterableEventQueue, query?: {}): AsyncIterable<any>;
@@ -252,12 +252,12 @@ export declare function makeTable(options: any): {
252
252
  * @returns
253
253
  */
254
254
  getResource(id: Id, request: Context, resourceOptions?: any): Promise<{
255
- #record: any;
256
- #changes: any;
257
- #version?: number;
258
- #entry?: Entry;
259
- #saveMode?: boolean;
260
- #loadedFromSource?: boolean;
255
+ "__#private@#record": any;
256
+ "__#private@#changes": any;
257
+ "__#private@#version"?: number;
258
+ "__#private@#entry"?: Entry;
259
+ "__#private@#saveMode"?: boolean;
260
+ "__#private@#loadedFromSource"?: boolean;
261
261
  getProperty: (name: string) => any;
262
262
  /**
263
263
  * This is a request to explicitly ensure that the record is loaded from source, rather than only using the local record.
@@ -307,8 +307,8 @@ export declare function makeTable(options: any): {
307
307
  getExpiresAt(): number;
308
308
  addTo(property: string, value: number | bigint): void;
309
309
  subtractFrom(property: string, value: number | bigint): void;
310
- #record: any;
311
- #changes: any;
310
+ "__#private@#record": any;
311
+ "__#private@#changes": any;
312
312
  getRecord(): any;
313
313
  setRecord(record: any): void;
314
314
  getChanges(): any;
@@ -405,21 +405,21 @@ export declare function makeTable(options: any): {
405
405
  validate(record: any, patch?: boolean): void;
406
406
  getUpdatedTime(): number;
407
407
  wasLoadedFromSource(): boolean | void;
408
- readonly #id: Id;
409
- readonly #context: Context;
410
- #isCollection: boolean;
408
+ readonly "__#private@#id": Id;
409
+ readonly "__#private@#context": Context;
410
+ "__#private@#isCollection": boolean;
411
411
  post(newRecord: any): Promise<any>;
412
412
  get isCollection(): boolean;
413
413
  connect(incomingMessages: import("./IterableEventQueue.js").IterableEventQueue, query?: {}): AsyncIterable<any>;
414
414
  getId(): Id;
415
415
  getContext(): Context | import("./ResourceInterface.ts").SourceContext;
416
416
  }> | {
417
- #record: any;
418
- #changes: any;
419
- #version?: number;
420
- #entry?: Entry;
421
- #saveMode?: boolean;
422
- #loadedFromSource?: boolean;
417
+ "__#private@#record": any;
418
+ "__#private@#changes": any;
419
+ "__#private@#version"?: number;
420
+ "__#private@#entry"?: Entry;
421
+ "__#private@#saveMode"?: boolean;
422
+ "__#private@#loadedFromSource"?: boolean;
423
423
  getProperty: (name: string) => any;
424
424
  /**
425
425
  * This is a request to explicitly ensure that the record is loaded from source, rather than only using the local record.
@@ -469,8 +469,8 @@ export declare function makeTable(options: any): {
469
469
  getExpiresAt(): number;
470
470
  addTo(property: string, value: number | bigint): void;
471
471
  subtractFrom(property: string, value: number | bigint): void;
472
- #record: any;
473
- #changes: any;
472
+ "__#private@#record": any;
473
+ "__#private@#changes": any;
474
474
  getRecord(): any;
475
475
  setRecord(record: any): void;
476
476
  getChanges(): any;
@@ -567,9 +567,9 @@ export declare function makeTable(options: any): {
567
567
  validate(record: any, patch?: boolean): void;
568
568
  getUpdatedTime(): number;
569
569
  wasLoadedFromSource(): boolean | void;
570
- readonly #id: Id;
571
- readonly #context: Context;
572
- #isCollection: boolean;
570
+ readonly "__#private@#id": Id;
571
+ readonly "__#private@#context": Context;
572
+ "__#private@#isCollection": boolean;
573
573
  post(newRecord: any): Promise<any>;
574
574
  get isCollection(): boolean;
575
575
  connect(incomingMessages: import("./IterableEventQueue.js").IterableEventQueue, query?: {}): AsyncIterable<any>;
@@ -613,7 +613,7 @@ export declare function makeTable(options: any): {
613
613
  /**
614
614
  * Evicting a record will remove it from a caching table. This is not considered a canonical data change, and it is assumed that retrieving this record from the source will still yield the same record, this is only removing the local copy of the record.
615
615
  */
616
- evict(id: any, existingRecord: any, existingVersion: any): Promise<void>;
616
+ evict(id: any, existingRecord: any, existingVersion: any): any;
617
617
  operation(operation: any, context: any): any;
618
618
  /**
619
619
  * This is responsible for ordering and select()ing the attributes/properties from returned entries
@@ -11,6 +11,7 @@
11
11
  * - Note that for compressed data, the size is the uncompressed size, and the compressed size in the file
12
12
  */
13
13
  import type { LMDBStore } from 'lmdb';
14
+ import * as buffer from 'node:buffer';
14
15
  type StorageInfo = {
15
16
  storageIndex: number;
16
17
  fileId: string;
@@ -26,6 +27,7 @@ type StorageInfo = {
26
27
  end?: number;
27
28
  saving?: Promise<void>;
28
29
  asString?: string;
30
+ deleteOnFailure?: boolean;
29
31
  };
30
32
  export declare const Blob: {
31
33
  new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
@@ -38,7 +40,7 @@ export declare const Blob: {
38
40
  arrayBuffer(): Promise<ArrayBufferLike>;
39
41
  get size(): number;
40
42
  slice(): /*elided*/ any;
41
- bytes(): Promise<Buffer>;
43
+ bytes(): Promise<buffer.Buffer>;
42
44
  get type(): string;
43
45
  };
44
46
  };
@@ -52,7 +54,7 @@ declare namespace InstanceOfBlobWithNoConstructor {
52
54
  arrayBuffer(): Promise<ArrayBufferLike>;
53
55
  get size(): number;
54
56
  slice(): /*elided*/ any;
55
- bytes(): Promise<Buffer>;
57
+ bytes(): Promise<buffer.Buffer>;
56
58
  get type(): string;
57
59
  };
58
60
  }
@@ -81,6 +83,7 @@ declare class FileBackedBlob extends InstanceOfBlobWithNoConstructor {
81
83
  stream(): ReadableStream;
82
84
  slice(start: number, end: number, type?: string): Blob;
83
85
  save(): Promise<void>;
86
+ get written(): Promise<void>;
84
87
  }
85
88
  /**
86
89
  * Delete the file for the blob
@@ -95,7 +98,7 @@ export type BlobCreationOptions = {
95
98
  size?: number;
96
99
  saveBeforeCommit?: boolean;
97
100
  };
98
- export declare function saveBlob(blob: FileBackedBlob): StorageInfo;
101
+ export declare function saveBlob(blob: FileBackedBlob, deleteOnFailure?: boolean): StorageInfo;
99
102
  export declare function getFileId(blob: Blob): string;
100
103
  export declare function isSaving(blob: Blob): string;
101
104
  export declare function getFilePathForBlob(blob: FileBackedBlob): string;
@@ -0,0 +1,27 @@
1
+ import { Resources } from './Resources.ts';
2
+ export declare function generateJsonApi(resources: Resources, serverHttpURL: string): {
3
+ openapi: string;
4
+ info: {
5
+ title: string;
6
+ version: any;
7
+ };
8
+ servers: {
9
+ description: string;
10
+ url: string;
11
+ }[];
12
+ paths: {};
13
+ components: {
14
+ schemas: {};
15
+ securitySchemes: {
16
+ basicAuth: {
17
+ type: string;
18
+ scheme: string;
19
+ };
20
+ bearerAuth: {
21
+ type: string;
22
+ scheme: string;
23
+ bearerFormat: string;
24
+ };
25
+ };
26
+ };
27
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Certificate verification source that handles both CRL and OCSP methods
3
+ */
4
+ import { Resource } from '../../resources/Resource.ts';
5
+ import type { Query } from '../../resources/ResourceInterface.ts';
6
+ /**
7
+ * Certificate Verification Source that can handle both CRL and OCSP
8
+ */
9
+ export declare class CertificateVerificationSource extends Resource {
10
+ get(query: Query): Promise<{
11
+ certificate_id: string;
12
+ status: any;
13
+ reason: any;
14
+ checked_at: number;
15
+ expiresAt: any;
16
+ method: string;
17
+ }>;
18
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Configuration validation for certificate verification
3
+ */
4
+ import type { CertificateVerificationConfig, OCSPDefaults, CRLDefaults } from './types.ts';
5
+ export declare const DEFAULT_FAILURE_MODE = "fail-closed";
6
+ export declare const OCSP_DEFAULTS: OCSPDefaults;
7
+ export declare const CRL_DEFAULTS: CRLDefaults;
8
+ /**
9
+ * Validate and parse certificate verification configuration
10
+ * @param config - Certificate verification configuration to validate
11
+ * @returns Validated and parsed configuration object
12
+ * @throws {Error} If configuration is invalid
13
+ */
14
+ export declare function validateAndParseCertificateVerificationConfig(config: unknown): CertificateVerificationConfig;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * CRL (Certificate Revocation List) verification
3
+ */
4
+ import type { CertificateVerificationResult, CRLCheckResult, CRLConfig } from './types.ts';
5
+ /**
6
+ * Custom error for CRL signature verification failures
7
+ * This distinguishes security failures (invalid signatures) from operational failures (network, timeout)
8
+ */
9
+ export declare class CRLSignatureVerificationError extends Error {
10
+ constructor(message: string);
11
+ }
12
+ /**
13
+ * Verify CRL status of a client certificate
14
+ * @param certPem - Client certificate as Buffer (DER format)
15
+ * @param issuerPem - Issuer (CA) certificate as Buffer (DER format)
16
+ * @param config - CRL configuration
17
+ * @param crlUrls - Optional pre-extracted CRL distribution point URLs (avoids re-parsing)
18
+ * @returns Promise resolving to verification result
19
+ */
20
+ export declare function verifyCRL(certPem: Buffer, issuerPem: Buffer, config?: CRLConfig, crlUrls?: string[]): Promise<CertificateVerificationResult>;
21
+ /**
22
+ * Perform the actual CRL check by looking up the certificate in the revoked certificates table
23
+ * @param certPem - Certificate in PEM format
24
+ * @param issuerPem - Issuer certificate in PEM format
25
+ * @param config - CRL configuration
26
+ * @param crlUrls - Optional pre-extracted CRL distribution point URLs (avoids re-parsing)
27
+ * @returns CRL check result
28
+ */
29
+ export declare function performCRLCheck(certPem: string, issuerPem: string, config: CRLConfig, crlUrls?: string[]): Promise<CRLCheckResult>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Certificate verification for mTLS authentication
3
+ *
4
+ * This module provides certificate revocation checking for client certificates
5
+ * in mutual TLS (mTLS) connections. Supports both OCSP (Online Certificate
6
+ * Status Protocol) and CRL (Certificate Revocation List) verification methods
7
+ * with automatic method selection.
8
+ *
9
+ * Features:
10
+ * - OCSP verification with caching
11
+ * - CRL verification with caching
12
+ * - CRL-first with OCSP fallback for optimal performance
13
+ * - Background CRL refresh with exponential backoff
14
+ * - Graceful degradation during network outages
15
+ * - Ed25519/Ed448 certificate support
16
+ *
17
+ * Default behavior:
18
+ * - Certificate verification: disabled (must be explicitly enabled)
19
+ * - Verification approach: CRL-first (with OCSP fallback)
20
+ * - CRL timeout: 10 seconds, cache TTL: 24 hours
21
+ * - OCSP timeout: 5 seconds, cache TTL: 1 hour
22
+ * - Failure mode: fail-closed (rejects connections if verification fails)
23
+ */
24
+ import type { PeerCertificate, CertificateVerificationResult } from './types.ts';
25
+ /**
26
+ * Verify certificate revocation status using OCSP and/or CRL
27
+ * @param peerCertificate - Peer certificate object from TLS connection
28
+ * @param mtlsConfig - The mTLS configuration from the request
29
+ * @returns Promise resolving to verification result
30
+ */
31
+ export declare function verifyCertificate(peerCertificate: PeerCertificate, mtlsConfig?: boolean | Record<string, any> | null): Promise<CertificateVerificationResult>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * OCSP (Online Certificate Status Protocol) verification
3
+ */
4
+ import './pkijs-ed25519-patch.ts';
5
+ import type { CertificateVerificationResult, OCSPCheckResult, OCSPConfig } from './types.ts';
6
+ /**
7
+ * Verify OCSP status of a client certificate
8
+ * @param certPem - Client certificate as Buffer (DER format)
9
+ * @param issuerPem - Issuer (CA) certificate as Buffer (DER format)
10
+ * @param config - OCSP configuration
11
+ * @param ocspUrls - Optional pre-extracted OCSP responder URLs (avoids re-parsing)
12
+ * @returns Promise resolving to verification result
13
+ */
14
+ export declare function verifyOCSP(certPem: Buffer, issuerPem: Buffer, config?: OCSPConfig, ocspUrls?: string[]): Promise<CertificateVerificationResult>;
15
+ /**
16
+ * Perform the actual OCSP check using easy-ocsp
17
+ * @param certPem - Certificate in PEM format
18
+ * @param issuerPem - Issuer certificate in PEM format
19
+ * @param config - OCSP configuration
20
+ * @param ocspUrls - Optional pre-extracted OCSP responder URLs (avoids re-parsing)
21
+ * @returns OCSP check result
22
+ */
23
+ export declare function performOCSPCheck(certPem: string, issuerPem: string, config: any, ocspUrls?: string[]): Promise<OCSPCheckResult>;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Shared TypeScript interfaces and types for certificate verification
3
+ */
4
+ import type { Context } from '../../resources/ResourceInterface.ts';
5
+ export type CertificateStatus = 'good' | 'revoked' | 'unknown';
6
+ export type VerificationMethod = 'ocsp' | 'crl';
7
+ export type VerificationResultMethod = VerificationMethod | 'disabled';
8
+ export type FailureMode = 'fail-open' | 'fail-closed';
9
+ export interface PeerCertificate {
10
+ subject?: {
11
+ CN?: string;
12
+ [key: string]: any;
13
+ };
14
+ raw?: Buffer;
15
+ issuerCertificate?: PeerCertificate;
16
+ }
17
+ export interface CertificateVerificationResult {
18
+ valid: boolean;
19
+ status: string;
20
+ cached?: boolean;
21
+ error?: string;
22
+ method?: VerificationResultMethod;
23
+ }
24
+ export interface CertificateCacheEntry {
25
+ certificate_id: string;
26
+ status: CertificateStatus;
27
+ reason?: string;
28
+ checked_at: number;
29
+ expiresAt: number;
30
+ method: VerificationMethod;
31
+ }
32
+ export interface CRLCacheEntry {
33
+ distribution_point: string;
34
+ issuer_dn: string;
35
+ crl_blob: Buffer;
36
+ this_update: number;
37
+ next_update: number;
38
+ signature_valid: boolean;
39
+ expiresAt: number;
40
+ }
41
+ export interface RevokedCertificateEntry {
42
+ composite_id: string;
43
+ serial_number: string;
44
+ issuer_key_id: string;
45
+ revocation_date: number;
46
+ revocation_reason?: string;
47
+ crl_source: string;
48
+ crl_next_update: number;
49
+ expiresAt: number;
50
+ }
51
+ export interface CertificateChainEntry {
52
+ cert: Buffer;
53
+ issuer?: Buffer;
54
+ }
55
+ export interface OCSPCheckResult {
56
+ status: CertificateStatus;
57
+ reason?: string;
58
+ }
59
+ export interface CRLCheckResult {
60
+ status: CertificateStatus;
61
+ reason?: string;
62
+ source?: string;
63
+ }
64
+ export interface OCSPConfig {
65
+ enabled?: boolean;
66
+ timeout?: number;
67
+ cacheTtl?: number;
68
+ errorCacheTtl?: number;
69
+ failureMode?: FailureMode;
70
+ }
71
+ export interface CRLConfig {
72
+ enabled?: boolean;
73
+ timeout?: number;
74
+ cacheTtl?: number;
75
+ failureMode?: FailureMode;
76
+ gracePeriod?: number;
77
+ }
78
+ export interface CertificateVerificationConfig {
79
+ failureMode?: FailureMode;
80
+ ocsp?: OCSPConfig;
81
+ crl?: CRLConfig;
82
+ }
83
+ export interface CertificateVerificationContext extends Context {
84
+ certPem: string;
85
+ issuerPem: string;
86
+ ocspUrls?: string[];
87
+ distributionPoint?: string;
88
+ config?: CertificateVerificationConfig;
89
+ }
90
+ export interface CRLVerificationContext extends Context {
91
+ distributionPoint: string;
92
+ issuerPem: string;
93
+ config?: CRLConfig;
94
+ }
95
+ export interface VerificationDefaults {
96
+ timeout: number;
97
+ cacheTtl: number;
98
+ failureMode: FailureMode;
99
+ }
100
+ export interface OCSPDefaults extends VerificationDefaults {
101
+ errorCacheTtl: number;
102
+ }
103
+ export interface CRLDefaults extends VerificationDefaults {
104
+ gracePeriod: number;
105
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Configuration parsing and default values for certificate verification
3
+ */
4
+ import type { CertificateVerificationConfig } from './types.ts';
5
+ export declare const CRL_DEFAULT_VALIDITY_PERIOD: number;
6
+ export declare const ERROR_CACHE_TTL = 300000;
7
+ export declare const CRL_USER_AGENT: string;
8
+ /**
9
+ * Cached version of getCertificateVerificationConfig to avoid redundant parsing
10
+ * This is the recommended function to use in hot paths like certificate verification.
11
+ *
12
+ * MEMORY SAFETY:
13
+ * - Uses WeakMap for object configs to prevent memory leaks
14
+ * - Config objects can be garbage collected when no longer referenced elsewhere
15
+ * - Primitive values (boolean, null, undefined) use simple reference equality
16
+ * - No strong references held to config objects, preventing memory accumulation
17
+ *
18
+ * ERROR HANDLING:
19
+ * - Invalid config causes validation errors to be thrown on first access
20
+ * - Validation errors are logged once and then cached
21
+ * - Subsequent accesses with the same invalid config return false (disabled) to prevent
22
+ * repeated error logging and allow the application to continue running
23
+ * - This provides fail-safe behavior: invalid security config defaults to disabled
24
+ * rather than crashing on every request
25
+ *
26
+ * @param mtlsConfig - The mTLS configuration from env.get()
27
+ * @returns Configuration object or false if verification is disabled or invalid
28
+ */
29
+ export declare function getCachedCertificateVerificationConfig(mtlsConfig?: boolean | Record<string, any> | null): false | CertificateVerificationConfig;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Shared utilities for certificate verification
3
+ */
4
+ import type { PeerCertificate, CertificateChainEntry } from './types.ts';
5
+ /**
6
+ * Convert a buffer to PEM format
7
+ * @param buffer - Certificate data as buffer
8
+ * @param type - Certificate type (e.g., 'CERTIFICATE')
9
+ * @returns PEM formatted string
10
+ */
11
+ export declare function bufferToPem(buffer: Buffer, type: string): string;
12
+ /**
13
+ * Extract certificate chain from peer certificate object
14
+ * @param peerCertificate - Peer certificate object from TLS connection
15
+ * @returns Certificate chain with issuer relationships
16
+ */
17
+ export declare function extractCertificateChain(peerCertificate: PeerCertificate): CertificateChainEntry[];
18
+ /**
19
+ * Extract CRL Distribution Points from a certificate using PKI.js
20
+ * @param certPem - Certificate in PEM format
21
+ * @returns Array of CRL distribution point URLs
22
+ */
23
+ export declare function extractCRLDistributionPoints(certPem: string): string[];
24
+ /**
25
+ * Extract both CRL and OCSP URLs from a certificate in a single parse operation
26
+ * @param certPem - Certificate in PEM format
27
+ * @returns Object containing arrays of CRL and OCSP URLs
28
+ */
29
+ export declare function extractRevocationUrls(certPem: string): {
30
+ crlUrls: string[];
31
+ ocspUrls: string[];
32
+ };
33
+ /**
34
+ * Extract OCSP responder URLs from a certificate
35
+ * @param certPem - Certificate in PEM format
36
+ * @returns Array of OCSP responder URLs
37
+ */
38
+ export declare function extractOCSPUrls(certPem: string): string[];
39
+ /**
40
+ * Convert PEM string to buffer for PKI.js parsing
41
+ * @param pem - PEM formatted certificate
42
+ * @returns Buffer containing certificate data
43
+ */
44
+ export declare function pemToBuffer(pem: string): ArrayBuffer;
45
+ /**
46
+ * Create a cache key for certificate verification
47
+ * @param certPem - Certificate in PEM format
48
+ * @param issuerPem - Issuer certificate in PEM format
49
+ * @param method - Verification method (ocsp, crl)
50
+ * @param additionalData - Additional data to include in hash
51
+ * @returns Cache key string
52
+ */
53
+ export declare function createCacheKey(certPem: string, issuerPem: string, method: 'ocsp' | 'crl', additionalData?: Record<string, any>): string;
54
+ /**
55
+ * Create a cache key for CRL storage
56
+ * @param distributionPoint - CRL distribution point URL
57
+ * @returns Cache key string
58
+ */
59
+ export declare function createCRLCacheKey(distributionPoint: string): string;
60
+ /**
61
+ * Create a composite ID for revoked certificate lookup
62
+ * @param issuerKeyId - Issuer key identifier or DN hash
63
+ * @param serialNumber - Certificate serial number
64
+ * @returns Composite ID string
65
+ */
66
+ export declare function createRevokedCertificateId(issuerKeyId: string, serialNumber: string): string;
67
+ /**
68
+ * Extract serial number from a certificate
69
+ * @param certPem - Certificate in PEM format
70
+ * @returns Certificate serial number as string
71
+ */
72
+ export declare function extractSerialNumber(certPem: string): string;
73
+ /**
74
+ * Extract issuer key identifier from a certificate
75
+ * @param certPem - Certificate in PEM format
76
+ * @returns Issuer key identifier as hex string, or hash of issuer DN if not available
77
+ */
78
+ export declare function extractIssuerKeyId(certPem: string): string;
79
+ export declare function getCertificateCacheTable(): unknown;