@koralabs/kora-labs-common 4.0.5 → 4.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koralabs/kora-labs-common",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "description": "Kora Labs Common Utilities",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -3,6 +3,7 @@ export interface IOAuthRepo {
3
3
  getGrant(handle?: string | null, clientId?: string | null): Promise<AuthGrant>;
4
4
  setGrant(grant?: AuthGrant): Promise<void>;
5
5
  getPermissions(): Promise<FriendlyPermissions>;
6
+ validateAccessToken(clientId: string, handle: string, accessToken: string): Promise<boolean>;
6
7
  }
7
8
  export interface AuthClient {
8
9
  clientId: string;
@@ -1,157 +1,4 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- export declare const getNativeCrypto: () => Promise<Crypto | {
6
- default: typeof import("crypto");
7
- createHash(algorithm: string, options?: import("crypto").HashOptions | undefined): import("crypto").Hash;
8
- createHmac(algorithm: string, key: import("crypto").KeyObject | import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Hmac;
9
- createCipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
10
- createCipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
11
- createCipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
12
- createCipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").CipherCCM;
13
- createCipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").CipherOCB;
14
- createCipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").CipherGCM;
15
- createCipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Cipher;
16
- createDecipher(algorithm: import("crypto").CipherCCMTypes, password: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
17
- createDecipher(algorithm: import("crypto").CipherGCMTypes, password: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
18
- createDecipher(algorithm: string, password: import("crypto").BinaryLike, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
19
- createDecipheriv(algorithm: import("crypto").CipherCCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherCCMOptions): import("crypto").DecipherCCM;
20
- createDecipheriv(algorithm: import("crypto").CipherOCBTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options: import("crypto").CipherOCBOptions): import("crypto").DecipherOCB;
21
- createDecipheriv(algorithm: import("crypto").CipherGCMTypes, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike, options?: import("crypto").CipherGCMOptions | undefined): import("crypto").DecipherGCM;
22
- createDecipheriv(algorithm: string, key: import("crypto").CipherKey, iv: import("crypto").BinaryLike | null, options?: import("stream").TransformOptions | undefined): import("crypto").Decipher;
23
- generateKey(type: "hmac" | "aes", options: {
24
- length: number;
25
- }, callback: (err: Error | null, key: import("crypto").KeyObject) => void): void;
26
- generateKeySync(type: "hmac" | "aes", options: {
27
- length: number;
28
- }): import("crypto").KeyObject;
29
- createPrivateKey(key: string | Buffer | import("crypto").PrivateKeyInput | import("crypto").JsonWebKeyInput): import("crypto").KeyObject;
30
- createPublicKey(key: string | Buffer | import("crypto").KeyObject | import("crypto").JsonWebKeyInput | import("crypto").PublicKeyInput): import("crypto").KeyObject;
31
- createSecretKey(key: NodeJS.ArrayBufferView): import("crypto").KeyObject;
32
- createSecretKey(key: string, encoding: BufferEncoding): import("crypto").KeyObject;
33
- createSign(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Sign;
34
- createVerify(algorithm: string, options?: import("stream").WritableOptions | undefined): import("crypto").Verify;
35
- createDiffieHellman(primeLength: number, generator?: number | undefined): import("crypto").DiffieHellman;
36
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
37
- createDiffieHellman(prime: ArrayBuffer | NodeJS.ArrayBufferView, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
38
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator?: number | ArrayBuffer | NodeJS.ArrayBufferView | undefined): import("crypto").DiffieHellman;
39
- createDiffieHellman(prime: string, primeEncoding: import("crypto").BinaryToTextEncoding, generator: string, generatorEncoding: import("crypto").BinaryToTextEncoding): import("crypto").DiffieHellman;
40
- getDiffieHellman(groupName: string): import("crypto").DiffieHellmanGroup;
41
- createDiffieHellmanGroup(name: string): import("crypto").DiffieHellmanGroup;
42
- pbkdf2(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey: Buffer) => void): void;
43
- pbkdf2Sync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
44
- randomBytes(size: number): Buffer;
45
- randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
46
- pseudoRandomBytes(size: number): Buffer;
47
- pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
48
- randomInt(max: number): number;
49
- randomInt(min: number, max: number): number;
50
- randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
51
- randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
52
- randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | undefined, size?: number | undefined): T;
53
- randomFill<T_1 extends NodeJS.ArrayBufferView>(buffer: T_1, callback: (err: Error | null, buf: T_1) => void): void;
54
- randomFill<T_2 extends NodeJS.ArrayBufferView>(buffer: T_2, offset: number, callback: (err: Error | null, buf: T_2) => void): void;
55
- randomFill<T_3 extends NodeJS.ArrayBufferView>(buffer: T_3, offset: number, size: number, callback: (err: Error | null, buf: T_3) => void): void;
56
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
57
- scrypt(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options: import("crypto").ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
58
- scryptSync(password: import("crypto").BinaryLike, salt: import("crypto").BinaryLike, keylen: number, options?: import("crypto").ScryptOptions | undefined): Buffer;
59
- publicEncrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
60
- publicDecrypt(key: import("crypto").RsaPublicKey | import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
61
- privateDecrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
62
- privateEncrypt(privateKey: import("crypto").RsaPrivateKey | import("crypto").KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
63
- getCiphers(): string[];
64
- getCurves(): string[];
65
- getFips(): 0 | 1;
66
- setFips(bool: boolean): void;
67
- getHashes(): string[];
68
- createECDH(curveName: string): import("crypto").ECDH;
69
- timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
70
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
71
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
72
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
73
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
74
- generateKeyPairSync(type: "rsa", options: import("crypto").RSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
75
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
76
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
77
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
78
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
79
- generateKeyPairSync(type: "rsa-pss", options: import("crypto").RSAPSSKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
80
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
81
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
82
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
83
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
84
- generateKeyPairSync(type: "dsa", options: import("crypto").DSAKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
85
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
86
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
87
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
88
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
89
- generateKeyPairSync(type: "ec", options: import("crypto").ECKeyPairKeyObjectOptions): import("crypto").KeyPairKeyObjectResult;
90
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
91
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
92
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
93
- generateKeyPairSync(type: "ed25519", options: import("crypto").ED25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
94
- generateKeyPairSync(type: "ed25519", options?: import("crypto").ED25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
95
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
96
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
97
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
98
- generateKeyPairSync(type: "ed448", options: import("crypto").ED448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
99
- generateKeyPairSync(type: "ed448", options?: import("crypto").ED448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
100
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
101
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
102
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
103
- generateKeyPairSync(type: "x25519", options: import("crypto").X25519KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
104
- generateKeyPairSync(type: "x25519", options?: import("crypto").X25519KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
105
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "pem">): import("crypto").KeyPairSyncResult<string, string>;
106
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"pem", "der">): import("crypto").KeyPairSyncResult<string, Buffer>;
107
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "pem">): import("crypto").KeyPairSyncResult<Buffer, string>;
108
- generateKeyPairSync(type: "x448", options: import("crypto").X448KeyPairOptions<"der", "der">): import("crypto").KeyPairSyncResult<Buffer, Buffer>;
109
- generateKeyPairSync(type: "x448", options?: import("crypto").X448KeyPairKeyObjectOptions | undefined): import("crypto").KeyPairKeyObjectResult;
110
- generateKeyPair: typeof import("crypto").generateKeyPair;
111
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput): Buffer;
112
- sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").SignKeyObjectInput | import("crypto").SignPrivateKeyInput, callback: (error: Error | null, data: Buffer) => void): void;
113
- verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").VerifyKeyObjectInput | import("crypto").VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
114
- verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: import("crypto").KeyLike | import("crypto").VerifyKeyObjectInput | import("crypto").VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView, callback: (error: Error | null, result: boolean) => void): void;
115
- diffieHellman(options: {
116
- privateKey: import("crypto").KeyObject;
117
- publicKey: import("crypto").KeyObject;
118
- }): Buffer;
119
- getCipherInfo(nameOrNid: string | number, options?: import("crypto").CipherInfoOptions | undefined): import("crypto").CipherInfo | undefined;
120
- hkdf(digest: string, irm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => void): void;
121
- hkdfSync(digest: string, ikm: import("crypto").KeyObject | import("crypto").BinaryLike, salt: import("crypto").BinaryLike, info: import("crypto").BinaryLike, keylen: number): ArrayBuffer;
122
- secureHeapUsed(): import("crypto").SecureHeapUsage;
123
- randomUUID(options?: import("crypto").RandomUUIDOptions | undefined): string;
124
- generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
125
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
126
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
127
- generatePrime(size: number, options: import("crypto").GeneratePrimeOptions, callback: (err: Error | null, prime: bigint | ArrayBuffer) => void): void;
128
- generatePrimeSync(size: number): ArrayBuffer;
129
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsBigInt): bigint;
130
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
131
- generatePrimeSync(size: number, options: import("crypto").GeneratePrimeOptions): bigint | ArrayBuffer;
132
- checkPrime(value: import("crypto").LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
133
- checkPrime(value: import("crypto").LargeNumberLike, options: import("crypto").CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
134
- checkPrimeSync(candidate: import("crypto").LargeNumberLike, options?: import("crypto").CheckPrimeOptions | undefined): boolean;
135
- setEngine(engine: string, flags?: number | undefined): void;
136
- getRandomValues<T_4 extends import("crypto").webcrypto.BufferSource>(typedArray: T_4): T_4;
137
- Certificate: typeof import("crypto").Certificate;
138
- constants: typeof import("crypto").constants;
139
- fips: boolean;
140
- Hash: typeof import("crypto").Hash;
141
- Hmac: typeof import("crypto").Hmac;
142
- KeyObject: typeof import("crypto").KeyObject;
143
- Cipher: typeof import("crypto").Cipher;
144
- Decipher: typeof import("crypto").Decipher;
145
- Sign: typeof import("crypto").Sign;
146
- Verify: typeof import("crypto").Verify;
147
- DiffieHellman: typeof import("crypto").DiffieHellman;
148
- DiffieHellmanGroup: import("crypto").DiffieHellmanGroupConstructor;
149
- ECDH: typeof import("crypto").ECDH;
150
- DEFAULT_ENCODING: BufferEncoding;
151
- X509Certificate: typeof import("crypto").X509Certificate;
152
- subtle: import("crypto").webcrypto.SubtleCrypto;
153
- webcrypto: import("crypto").webcrypto.Crypto;
154
- }>;
1
+ export declare const getNativeCrypto: () => Promise<any>;
155
2
  export declare function dec2hex(dec: number): string;
156
3
  export declare function getRandomCodeVerifier(length: number): Promise<string>;
157
4
  export declare const sha256: (plain: string) => Promise<ArrayBuffer>;
@@ -41,7 +41,6 @@ exports.dec2hex = dec2hex;
41
41
  async function getRandomCodeVerifier(length) {
42
42
  const crypto = await (0, exports.getNativeCrypto)();
43
43
  const array = new Uint32Array(length / 2);
44
- // @ts-expect-error -> getRandomValues is indeed callable
45
44
  crypto.getRandomValues(array);
46
45
  return Array.from(array, dec2hex).join('');
47
46
  }