Skip to content

Commit 3763b2d

Browse files
committed
patch @peculiar/x509 for CF Workers compat
1 parent 79335b4 commit 3763b2d

File tree

3 files changed

+144
-323
lines changed

3 files changed

+144
-323
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
"better-sqlite3",
8484
"esbuild",
8585
"@parcel/watcher"
86-
]
86+
],
87+
"patchedDependencies": {
88+
"@peculiar/x509@1.14.2": "patches/@peculiar__x509@1.14.2.patch"
89+
}
8790
}
8891
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
diff --git a/build/x509.cjs.js b/build/x509.cjs.js
2+
index 9b4ad1d8c23c56dbffd1a68702f2eb828a97f25f..4a72c7a25a4ac8415d34a571542f4b1bcf5598cc 100644
3+
--- a/build/x509.cjs.js
4+
+++ b/build/x509.cjs.js
5+
@@ -24,7 +24,6 @@
6+
*/
7+
'use strict';
8+
9+
-require('reflect-metadata');
10+
var asn1Schema = require('@peculiar/asn1-schema');
11+
var asn1X509 = require('@peculiar/asn1-x509');
12+
var pvtsutils = require('pvtsutils');
13+
@@ -32,8 +31,29 @@ var tslib = require('tslib');
14+
var asn1Cms = require('@peculiar/asn1-cms');
15+
var asn1Ecc = require('@peculiar/asn1-ecc');
16+
var asn1Rsa = require('@peculiar/asn1-rsa');
17+
-var tsyringe = require('tsyringe');
18+
var asnPkcs9 = require('@peculiar/asn1-pkcs9');
19+
+
20+
+// Simple registry replacing tsyringe (for edge runtime compatibility)
21+
+var __registry = { algorithms: [], algorithmProvider: null, signatureFormatters: [] };
22+
+var tsyringe = {
23+
+ container: {
24+
+ registerSingleton: function(token, Cls) {
25+
+ if (token === "crypto.algorithmProvider") __registry.algorithmProvider = new Cls();
26+
+ else if (token === "crypto.algorithm") __registry.algorithms.push(new Cls());
27+
+ else if (token === "crypto.signatureFormatter") __registry.signatureFormatters.push(new Cls());
28+
+ },
29+
+ resolve: function(token) {
30+
+ if (token === "crypto.algorithmProvider") return __registry.algorithmProvider;
31+
+ throw new Error("Unknown token: " + token);
32+
+ },
33+
+ resolveAll: function(token) {
34+
+ if (token === "crypto.algorithm") return __registry.algorithms;
35+
+ if (token === "crypto.signatureFormatter") return __registry.signatureFormatters;
36+
+ return [];
37+
+ },
38+
+ },
39+
+ injectable: function() { return function(target) { return target; }; }
40+
+};
41+
var asn1Csr = require('@peculiar/asn1-csr');
42+
43+
function _interopNamespaceDefault(e) {
44+
diff --git a/build/x509.es.js b/build/x509.es.js
45+
index c3059f43c9241a9ff106af312ca9fa971c8c79be..56a02f88dab88e66ae5dabba61bc7ff9d1a889b6 100644
46+
--- a/build/x509.es.js
47+
+++ b/build/x509.es.js
48+
@@ -22,7 +22,6 @@
49+
* SOFTWARE.
50+
*
51+
*/
52+
-import 'reflect-metadata';
53+
import { AsnConvert, OctetString, AsnUtf8StringConverter } from '@peculiar/asn1-schema';
54+
import * as asn1X509 from '@peculiar/asn1-x509';
55+
import { AlgorithmIdentifier, Extension as Extension$1, Name as Name$1, RelativeDistinguishedName, AttributeTypeAndValue, SubjectPublicKeyInfo, BasicConstraints, id_ce_basicConstraints, KeyUsage, id_ce_keyUsage, Attribute as Attribute$1, Version, Extensions, Certificate, id_ce_invalidityDate, InvalidityDate, id_ce_cRLReasons, CRLReason, RevokedCertificate, Time, CertificateList } from '@peculiar/asn1-x509';
56+
@@ -33,8 +32,27 @@ import * as asn1Ecc from '@peculiar/asn1-ecc';
57+
import { id_ecPublicKey, ECDSASigValue } from '@peculiar/asn1-ecc';
58+
import * as asn1Rsa from '@peculiar/asn1-rsa';
59+
import { id_RSASSA_PSS, id_rsaEncryption, RSAPublicKey, id_sha512, id_sha384, id_sha256, id_sha1 } from '@peculiar/asn1-rsa';
60+
-import { container, injectable } from 'tsyringe';
61+
import * as asnPkcs9 from '@peculiar/asn1-pkcs9';
62+
+
63+
+// Simple registry replacing tsyringe (for edge runtime compatibility)
64+
+const __registry = { algorithms: [], algorithmProvider: null, signatureFormatters: [] };
65+
+const container = {
66+
+ registerSingleton: (token, Cls) => {
67+
+ if (token === "crypto.algorithmProvider") __registry.algorithmProvider = new Cls();
68+
+ else if (token === "crypto.algorithm") __registry.algorithms.push(new Cls());
69+
+ else if (token === "crypto.signatureFormatter") __registry.signatureFormatters.push(new Cls());
70+
+ },
71+
+ resolve: (token) => {
72+
+ if (token === "crypto.algorithmProvider") return __registry.algorithmProvider;
73+
+ throw new Error(`Unknown token: ${token}`);
74+
+ },
75+
+ resolveAll: (token) => {
76+
+ if (token === "crypto.algorithm") return __registry.algorithms;
77+
+ if (token === "crypto.signatureFormatter") return __registry.signatureFormatters;
78+
+ return [];
79+
+ },
80+
+};
81+
+const injectable = () => (target) => target;
82+
import { id_pkcs9_at_extensionRequest } from '@peculiar/asn1-pkcs9';
83+
import { CertificationRequest, CertificationRequestInfo } from '@peculiar/asn1-csr';
84+

0 commit comments

Comments
 (0)