Skip to content

Commit 2874402

Browse files
committed
add .d.ts file and point at it in package.json
1 parent f16f0cf commit 2874402

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

index.d.ts

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
declare module "ez-web-crypto" {
2+
export default class EZCrypto {
3+
private nodeEnvLoad: () => Promise<void>;
4+
private sleep: (duration: number) => Promise<void>;
5+
constructor();
6+
base64ToArray(strng: string): Uint8Array;
7+
arrayToBase64(ary: Uint8Array): string;
8+
HMAC(secret: string, data: string): Promise<string>;
9+
HASH(algo: string, data: string, len?: number): Promise<string>;
10+
PASSWORD_ENCRYPT(password: string, base64data: string): Promise<string>;
11+
PASSWORD_DECRYPT(password: string, base64data: string): Promise<string>;
12+
AESMakeKey(exportable?: boolean): Promise<string | CryptoKey>;
13+
AESImportKey(aes_key: string | CryptoKey, exportable?: boolean): Promise<CryptoKey>;
14+
AESEncrypt(
15+
base_64_key: string | CryptoKey,
16+
base_64_data: string,
17+
base_64_nonce?: boolean
18+
): Promise<{ ciphertext: string; iv: string }>;
19+
AESDecrypt(
20+
base_64_key: string | CryptoKey,
21+
base_64_nonce: string,
22+
base_64_cipher: string,
23+
returnText?: boolean
24+
): Promise<ArrayBuffer | string>;
25+
EcMakeCryptKeys(exportable?: boolean): Promise<any>;
26+
EcEncrypt(
27+
b64Private: string,
28+
b64Public: string,
29+
b64data: string
30+
): Promise<{ ciphertext: string; iv: string }>;
31+
EcDecrypt(
32+
b64Private: string,
33+
b64Public: string,
34+
b64Nonce: string,
35+
b64data: string
36+
): Promise<ArrayBuffer>;
37+
HKDFEncrypt(
38+
b64Private: string,
39+
b64Public: string,
40+
b64data: string
41+
): Promise<{ ciphertext: string; salt: string; iv: string }>;
42+
HKDFDecrypt(
43+
b64Private: string,
44+
b64Public: string,
45+
b64Salt: string,
46+
b64iv: string,
47+
b64data: string
48+
): Promise<ArrayBuffer>;
49+
EcMakeSigKeys(exportable?: boolean): Promise<{ publicKey: string; privateKey: string | CryptoKey }>;
50+
EcSignData(b64PrivateKey: string, b64data: string): Promise<string>;
51+
EcVerifySig(
52+
b64PublicKey: string,
53+
b64Signature: string,
54+
b64data: string
55+
): Promise<boolean>;
56+
EcdhConvertKey(unknown_key: any): Promise<CryptoKey>;
57+
EcdsaConvertKey(unknown_key: any): Promise<CryptoKey>;
58+
}
59+
}
60+

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
],
3232
"devDependencies": {
3333
"jest": "^29.3.1"
34-
}
34+
},
35+
"types": "index.d.ts"
3536
}

0 commit comments

Comments
 (0)