@sphereon/ssi-sdk-ext.x509-utils 0.28.1-feature.esm.cjs.8 → 0.28.1-feature.oyd.cmsm.improv.16
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/dist/index.d.ts +5 -171
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -749
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -0
- package/dist/x509/crypto.d.ts +2 -0
- package/dist/x509/crypto.d.ts.map +1 -0
- package/dist/x509/crypto.js +28 -0
- package/dist/x509/crypto.js.map +1 -0
- package/dist/x509/index.d.ts +5 -0
- package/dist/x509/index.d.ts.map +1 -0
- package/dist/x509/index.js +21 -0
- package/dist/x509/index.js.map +1 -0
- package/dist/x509/rsa-key.d.ts +10 -0
- package/dist/x509/rsa-key.d.ts.map +1 -0
- package/dist/x509/rsa-key.js +102 -0
- package/dist/x509/rsa-key.js.map +1 -0
- package/dist/x509/rsa-signer.d.ts +24 -0
- package/dist/x509/rsa-signer.d.ts.map +1 -0
- package/dist/x509/rsa-signer.js +105 -0
- package/dist/x509/rsa-signer.js.map +1 -0
- package/dist/x509/x509-utils.d.ts +31 -0
- package/dist/x509/x509-utils.d.ts.map +1 -0
- package/dist/x509/x509-utils.js +215 -0
- package/dist/x509/x509-utils.js.map +1 -0
- package/dist/x509/x509-validator.d.ts +97 -0
- package/dist/x509/x509-validator.d.ts.map +1 -0
- package/dist/x509/x509-validator.js +489 -0
- package/dist/x509/x509-validator.js.map +1 -0
- package/package.json +12 -24
- package/src/x509/crypto.ts +5 -11
- package/src/x509/rsa-key.ts +2 -7
- package/src/x509/rsa-signer.ts +5 -10
- package/src/x509/x509-utils.ts +5 -9
- package/src/x509/x509-validator.ts +4 -8
- package/dist/index.cjs +0 -776
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -173
package/dist/index.d.ts
CHANGED
|
@@ -1,173 +1,7 @@
|
|
|
1
|
-
import { CryptoKey } from 'node';
|
|
2
|
-
import { JsonWebKey, JWK } from '@sphereon/ssi-types';
|
|
3
|
-
import { X509Certificate, AlgorithmProvider } from '@peculiar/x509';
|
|
4
|
-
import { Certificate } from 'pkijs';
|
|
5
|
-
import { SubjectPublicKeyInfo } from '@peculiar/asn1-x509';
|
|
6
|
-
|
|
7
|
-
declare enum JwkKeyUse {
|
|
8
|
-
Encryption = "enc",
|
|
9
|
-
Signature = "sig"
|
|
10
|
-
}
|
|
11
|
-
type HashAlgorithm = 'SHA-256' | 'SHA-512';
|
|
12
|
-
type KeyVisibility = 'public' | 'private';
|
|
13
|
-
interface X509Opts {
|
|
14
|
-
cn?: string;
|
|
15
|
-
privateKeyPEM?: string;
|
|
16
|
-
certificatePEM?: string;
|
|
17
|
-
certificateChainURL?: string;
|
|
18
|
-
certificateChainPEM?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type RSASignatureSchemes = 'RSASSA-PKCS1-V1_5' | 'RSA-PSS';
|
|
22
|
-
type RSAEncryptionSchemes = 'RSAES-PKCS-v1_5 ' | 'RSAES-OAEP';
|
|
23
|
-
declare const signAlgorithmToSchemeAndHashAlg: (signingAlg: string) => {
|
|
24
|
-
scheme: "RSASSA-PKCS1-V1_5" | "RSA-PSS";
|
|
25
|
-
hashAlgorithm: HashAlgorithm;
|
|
26
|
-
};
|
|
27
|
-
declare const cryptoSubtleImportRSAKey: (jwk: JsonWebKey, scheme: RSAEncryptionSchemes | RSASignatureSchemes, hashAlgorithm?: HashAlgorithm) => Promise<CryptoKey>;
|
|
28
|
-
declare const generateRSAKeyAsPEM: (scheme: RSAEncryptionSchemes | RSASignatureSchemes, hashAlgorithm?: HashAlgorithm, modulusLength?: number) => Promise<string>;
|
|
29
|
-
|
|
30
|
-
declare class RSASigner {
|
|
31
|
-
private readonly hashAlgorithm;
|
|
32
|
-
private readonly jwk;
|
|
33
|
-
private key;
|
|
34
|
-
private readonly scheme;
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param key Either in PEM or JWK format (no raw hex keys here!)
|
|
38
|
-
* @param opts The algorithm and signature/encryption schemes
|
|
39
|
-
*/
|
|
40
|
-
constructor(key: string | JsonWebKey, opts?: {
|
|
41
|
-
hashAlgorithm?: HashAlgorithm;
|
|
42
|
-
scheme?: RSAEncryptionSchemes | RSASignatureSchemes;
|
|
43
|
-
visibility?: KeyVisibility;
|
|
44
|
-
});
|
|
45
|
-
private getImportParams;
|
|
46
|
-
private getKey;
|
|
47
|
-
private bufferToString;
|
|
48
|
-
sign(data: Uint8Array): Promise<string>;
|
|
49
|
-
verify(data: string | Uint8Array, signature: string): Promise<boolean>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
declare function pemCertChainTox5c(cert: string, maxDepth?: number): string[];
|
|
53
|
-
declare function x5cToPemCertChain(x5c: string[], maxDepth?: number): string;
|
|
54
|
-
declare const pemOrDerToX509Certificate: (cert: string | Uint8Array | X509Certificate) => Certificate;
|
|
55
|
-
declare const areCertificatesEqual: (cert1: Certificate, cert2: Certificate) => boolean;
|
|
56
|
-
declare const toKeyObject: (PEM: string, visibility?: KeyVisibility) => {
|
|
57
|
-
pem: string;
|
|
58
|
-
jwk: JsonWebKey;
|
|
59
|
-
keyHex: string;
|
|
60
|
-
keyType: KeyVisibility;
|
|
61
|
-
};
|
|
62
|
-
declare const jwkToPEM: (jwk: JsonWebKey, visibility?: KeyVisibility) => string;
|
|
63
|
-
declare const PEMToJwk: (pem: string, visibility?: KeyVisibility) => JsonWebKey;
|
|
64
|
-
declare const privateKeyHexFromPEM: (PEM: string) => string;
|
|
65
|
-
declare const hexKeyFromPEMBasedJwk: (jwk: JsonWebKey, visibility?: KeyVisibility) => string;
|
|
66
|
-
declare const publicKeyHexFromPEM: (PEM: string) => string;
|
|
67
|
-
declare const PEMToHex: (PEM: string, headerKey?: string) => string;
|
|
68
|
-
declare function PEMToBinary(pem: string): Uint8Array;
|
|
69
1
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @
|
|
72
|
-
* @param inputEncoding
|
|
2
|
+
*
|
|
3
|
+
* @packageDocumentation
|
|
73
4
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
declare function PEMToDer(pem: string): string;
|
|
78
|
-
declare function derToPEM(cert: string, headerKey?: 'PUBLIC KEY' | 'RSA PRIVATE KEY' | 'PRIVATE KEY' | 'CERTIFICATE'): string;
|
|
79
|
-
|
|
80
|
-
type DNInfo = {
|
|
81
|
-
DN: string;
|
|
82
|
-
attributes: Record<string, string>;
|
|
83
|
-
};
|
|
84
|
-
type CertificateInfo = {
|
|
85
|
-
certificate?: any;
|
|
86
|
-
notBefore: Date;
|
|
87
|
-
notAfter: Date;
|
|
88
|
-
publicKeyJWK?: any;
|
|
89
|
-
issuer: {
|
|
90
|
-
dn: DNInfo;
|
|
91
|
-
};
|
|
92
|
-
subject: {
|
|
93
|
-
dn: DNInfo;
|
|
94
|
-
subjectAlternativeNames: SubjectAlternativeName[];
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
type X509ValidationResult = {
|
|
98
|
-
error: boolean;
|
|
99
|
-
critical: boolean;
|
|
100
|
-
message: string;
|
|
101
|
-
detailMessage?: string;
|
|
102
|
-
verificationTime: Date;
|
|
103
|
-
certificateChain?: Array<CertificateInfo>;
|
|
104
|
-
trustAnchor?: CertificateInfo;
|
|
105
|
-
client?: {
|
|
106
|
-
clientId: string;
|
|
107
|
-
clientIdScheme: ClientIdScheme;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
declare const getCertificateInfo: (certificate: Certificate, opts?: {
|
|
111
|
-
sanTypeFilter: SubjectAlternativeGeneralName | SubjectAlternativeGeneralName[];
|
|
112
|
-
}) => Promise<CertificateInfo>;
|
|
113
|
-
type X509CertificateChainValidationOpts = {
|
|
114
|
-
allowNoTrustAnchorsFound?: boolean;
|
|
115
|
-
trustRootWhenNoAnchors?: boolean;
|
|
116
|
-
allowSingleNoCAChainElement?: boolean;
|
|
117
|
-
blindlyTrustedAnchors?: string[];
|
|
118
|
-
disallowReversedChain?: boolean;
|
|
119
|
-
client?: {
|
|
120
|
-
clientId: string;
|
|
121
|
-
clientIdScheme: ClientIdScheme;
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
declare const validateX509CertificateChain: ({ chain: pemOrDerChain, trustAnchors, verificationTime, opts, }: {
|
|
125
|
-
chain: (Uint8Array | string)[];
|
|
126
|
-
trustAnchors?: string[];
|
|
127
|
-
verificationTime?: Date;
|
|
128
|
-
opts?: X509CertificateChainValidationOpts;
|
|
129
|
-
}) => Promise<X509ValidationResult>;
|
|
130
|
-
declare const getX509AlgorithmProvider: () => AlgorithmProvider;
|
|
131
|
-
type ParsedCertificate = {
|
|
132
|
-
publicKeyInfo: SubjectPublicKeyInfo;
|
|
133
|
-
publicKeyJwk?: JWK;
|
|
134
|
-
publicKeyRaw: Uint8Array;
|
|
135
|
-
publicKeyAlgorithm: Algorithm;
|
|
136
|
-
certificateInfo: CertificateInfo;
|
|
137
|
-
certificate: Certificate;
|
|
138
|
-
x509Certificate: X509Certificate;
|
|
139
|
-
};
|
|
140
|
-
declare const parseCertificate: (rawCert: string | Uint8Array) => Promise<ParsedCertificate>;
|
|
141
|
-
declare const getIssuerDN: (cert: Certificate) => DNInfo;
|
|
142
|
-
declare const getSubjectDN: (cert: Certificate) => DNInfo;
|
|
143
|
-
declare const getCertificateSubjectPublicKeyJWK: (pemOrDerCert: string | Uint8Array | Certificate) => Promise<JWK>;
|
|
144
|
-
/**
|
|
145
|
-
* otherName [0] OtherName,
|
|
146
|
-
* rfc822Name [1] IA5String,
|
|
147
|
-
* dNSName [2] IA5String,
|
|
148
|
-
* x400Address [3] ORAddress,
|
|
149
|
-
* directoryName [4] Name,
|
|
150
|
-
* ediPartyName [5] EDIPartyName,
|
|
151
|
-
* uniformResourceIdentifier [6] IA5String,
|
|
152
|
-
* iPAddress [7] OCTET STRING,
|
|
153
|
-
* registeredID [8] OBJECT IDENTIFIER }
|
|
154
|
-
*/
|
|
155
|
-
declare enum SubjectAlternativeGeneralName {
|
|
156
|
-
rfc822Name = 1,// email
|
|
157
|
-
dnsName = 2,
|
|
158
|
-
uniformResourceIdentifier = 6,
|
|
159
|
-
ipAddress = 7
|
|
160
|
-
}
|
|
161
|
-
interface SubjectAlternativeName {
|
|
162
|
-
value: string;
|
|
163
|
-
type: SubjectAlternativeGeneralName;
|
|
164
|
-
}
|
|
165
|
-
type ClientIdScheme = 'x509_san_dns' | 'x509_san_uri';
|
|
166
|
-
declare const assertCertificateMatchesClientIdScheme: (certificate: Certificate, clientId: string, clientIdScheme: ClientIdScheme) => void;
|
|
167
|
-
declare const validateCertificateChainMatchesClientIdScheme: (certificate: Certificate, clientId: string, clientIdScheme: ClientIdScheme) => Promise<X509ValidationResult>;
|
|
168
|
-
declare const getSubjectAlternativeNames: (certificate: Certificate, opts?: {
|
|
169
|
-
typeFilter?: SubjectAlternativeGeneralName | SubjectAlternativeGeneralName[];
|
|
170
|
-
clientIdSchemeFilter?: ClientIdScheme;
|
|
171
|
-
}) => SubjectAlternativeName[];
|
|
172
|
-
|
|
173
|
-
export { type CertificateInfo, type ClientIdScheme, type DNInfo, type HashAlgorithm, JwkKeyUse, type KeyVisibility, PEMToBinary, PEMToDer, PEMToHex, PEMToJwk, type ParsedCertificate, type RSAEncryptionSchemes, type RSASignatureSchemes, RSASigner, SubjectAlternativeGeneralName, type SubjectAlternativeName, type X509CertificateChainValidationOpts, type X509Opts, type X509ValidationResult, areCertificatesEqual, assertCertificateMatchesClientIdScheme, base64ToHex, cryptoSubtleImportRSAKey, derToPEM, generateRSAKeyAsPEM, getCertificateInfo, getCertificateSubjectPublicKeyJWK, getIssuerDN, getSubjectAlternativeNames, getSubjectDN, getX509AlgorithmProvider, hexKeyFromPEMBasedJwk, hexToBase64, hexToPEM, jwkToPEM, parseCertificate, pemCertChainTox5c, pemOrDerToX509Certificate, privateKeyHexFromPEM, publicKeyHexFromPEM, signAlgorithmToSchemeAndHashAlg, toKeyObject, validateCertificateChainMatchesClientIdScheme, validateX509CertificateChain, x5cToPemCertChain };
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './x509';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA"}
|