Skip to content

Commit fc3c81e

Browse files
committed
Add typescript declaration
1 parent a169d4d commit fc3c81e

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
"before",
5656
"after"
5757
]
58-
}
58+
},
59+
"types": "types/index.d.ts"
5960
}

types/index.d.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
declare namespace SimpleKeystore {
2+
class KeystoreError extends Error {
3+
constructor(message: string);
4+
}
5+
6+
class PrivateKeyNotFoundError extends KeystoreError {
7+
constructor(keyId: string);
8+
}
9+
10+
class CertificateNotFoundError extends KeystoreError {
11+
constructor(keyId: string);
12+
}
13+
14+
interface PrivateKey {
15+
alg: string;
16+
key: string;
17+
passphrase: string;
18+
}
19+
20+
interface Certificate {
21+
alg: string;
22+
cert: string;
23+
}
24+
25+
interface JWK {
26+
// Key id
27+
kid: string;
28+
29+
// X.509 certificate chain
30+
x5c: string;
31+
}
32+
33+
interface Keystore {
34+
KeystoreError: new (message: string) => KeystoreError;
35+
36+
PrivateKeyNotFoundError: new (keyId: string) => PrivateKeyNotFoundError;
37+
38+
CertificateNotFoundError: new (keyId: string) => CertificateNotFoundError;
39+
40+
getCurrentSigningKeyId(): void;
41+
42+
getPrivateKey(id: string): Promise<PrivateKey>;
43+
44+
getCertificate(id: string): Promise<Certificate>;
45+
46+
getAllCertificatesAsJWKS(): JWK[]
47+
}
48+
49+
type KeyPassphrasse = string
50+
51+
type KeyPassphrasseCollection = {
52+
[key: string]: KeyPassphrasse
53+
}
54+
}
55+
56+
declare function SimpleKeystore(debugNamePrefix: string, baseDir: string, refreshIntervalMillis: number, signingKeyPassphrases: SimpleKeystore.KeyPassphrasseCollection): SimpleKeystore.Keystore;
57+
58+
export = SimpleKeystore;

0 commit comments

Comments
 (0)