@openwallet-foundation/askar-nodejs 0.4.4-alpha-20251124153732 → 0.5.0-alpha-20251207073409
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/README.md +2 -2
- package/build/NodeJSAskar.d.ts +2 -91
- package/build/NodeJSAskar.js +110 -59
- package/build/NodeJSAskar.js.map +1 -1
- package/build/ffi/alloc.d.ts +9 -11
- package/build/ffi/alloc.js +34 -15
- package/build/ffi/alloc.js.map +1 -1
- package/build/ffi/callback.d.ts +8 -6
- package/build/ffi/callback.js +85 -13
- package/build/ffi/callback.js.map +1 -1
- package/build/ffi/conversion.d.ts +3 -16
- package/build/ffi/conversion.js +51 -17
- package/build/ffi/conversion.js.map +1 -1
- package/build/ffi/index.d.ts +1 -1
- package/build/ffi/index.js +1 -1
- package/build/ffi/index.js.map +1 -1
- package/build/ffi/primitives.d.ts +16 -16
- package/build/ffi/primitives.js +11 -12
- package/build/ffi/primitives.js.map +1 -1
- package/build/ffi/serialize.d.ts +5 -5
- package/build/ffi/serialize.js +4 -7
- package/build/ffi/serialize.js.map +1 -1
- package/build/ffi/structures.d.ts +10 -46
- package/build/ffi/structures.js +28 -27
- package/build/ffi/structures.js.map +1 -1
- package/build/library/NativeBindingInterface.d.ts +2 -25
- package/build/library/NativeBindingInterface.js +2 -0
- package/build/library/NativeBindingInterface.js.map +1 -1
- package/build/library/bindings.d.ts +88 -251
- package/build/library/bindings.js +104 -212
- package/build/library/bindings.js.map +1 -1
- package/build/library/index.d.ts +1 -1
- package/build/library/index.js +1 -1
- package/build/library/index.js.map +1 -1
- package/build/library/register.d.ts +2 -89
- package/build/library/register.js +47 -10
- package/build/library/register.js.map +1 -1
- package/package.json +6 -11
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Wrapper for Node.Js around Askar
|
|
4
4
|
|
|
5
|
-
See the [project README](https://github.com/openwallet-foundation/askar-wrapper-javascript) for version
|
|
5
|
+
See the [project README](https://github.com/openwallet-foundation/askar-wrapper-javascript) for version compatibility between Askar and this JavaScript Wrapper.
|
|
6
6
|
|
|
7
7
|
## Requirements
|
|
8
8
|
|
|
9
|
-
This library requires and has been tested with Node.js version `
|
|
9
|
+
This library requires and has been tested with Node.js version `20.x`, `22.x`, and `24.x`. Newer versions might also work, but they have not been tested.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
package/build/NodeJSAskar.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Argon2DerivePasswordOptions, Askar, AskarErrorObject, EncryptedBuffer, EntryListCountOptions, EntryListFreeOptions, EntryListGetCategoryOptions, EntryListGetNameOptions, EntryListGetTagsOptions, EntryListGetValueOptions, KeyAeadDecryptOptions, KeyAeadEncryptOptions, KeyAeadGetPaddingOptions, KeyAeadGetParamsOptions, KeyAeadRandomNonceOptions, KeyConvertOptions, KeyCryptoBoxOpenOptions, KeyCryptoBoxOptions, KeyCryptoBoxSealOpenOptions, KeyCryptoBoxSealOptions, KeyDeriveEcdh1puOptions, KeyDeriveEcdhEsOptions, KeyEntryListCountOptions, KeyEntryListFreeOptions, KeyEntryListGetAlgorithmOptions, KeyEntryListGetMetadataOptions, KeyEntryListGetNameOptions, KeyEntryListGetTagsOptions, KeyEntryListLoadLocalOptions, KeyFreeOptions, KeyFromJwkOptions, KeyFromKeyExchangeOptions, KeyFromPublicBytesOptions, KeyFromSecretBytesOptions, KeyFromSeedOptions, KeyGenerateOptions, KeyGetAlgorithmOptions, KeyGetEphemeralOptions, KeyGetJwkPublicOptions, KeyGetJwkSecretOptions, KeyGetJwkThumbprintOptions, KeyGetPublicBytesOptions, KeyGetSecretBytesOptions, KeySignMessageOptions, KeyUnwrapKeyOptions, KeyVerifySignatureOptions, KeyWrapKeyOptions, MigrateIndySdkOptions, ScanFreeOptions, ScanNextOptions, ScanStartOptions, SessionCloseOptions, SessionCountOptions, SessionFetchAllKeysOptions, SessionFetchAllOptions, SessionFetchKeyOptions, SessionFetchOptions, SessionInsertKeyOptions, SessionRemoveAllOptions, SessionRemoveKeyOptions, SessionStartOptions, SessionUpdateKeyOptions, SessionUpdateOptions, SetCustomLoggerOptions, SetMaxLogLevelOptions, StoreCloseOptions, StoreCopyProfileOptions, StoreCopyToOptions, StoreCreateProfileOptions, StoreGenerateRawKeyOptions, StoreGetDefaultProfileOptions, StoreGetProfileNameOptions, StoreListProfilesOptions, StoreOpenOptions, StoreProvisionOptions, StoreRekeyOptions, StoreRemoveOptions, StoreRemoveProfileOptions, StoreRenameProfileOptions, StoreSetDefaultProfileOptions } from '@openwallet-foundation/askar-shared';
|
|
2
2
|
import { AeadParams, EntryListHandle, KeyEntryListHandle, LocalKeyHandle, ScanHandle, SessionHandle, StoreHandle } from '@openwallet-foundation/askar-shared';
|
|
3
|
-
import { type ByteBufferType } from './ffi';
|
|
4
3
|
export declare class NodeJSAskar implements Askar {
|
|
5
4
|
private promisify;
|
|
6
5
|
private promisifyWithResponse;
|
|
@@ -16,102 +15,14 @@ export declare class NodeJSAskar implements Askar {
|
|
|
16
15
|
*/
|
|
17
16
|
private getAskarError;
|
|
18
17
|
private handleError;
|
|
19
|
-
get nativeAskar():
|
|
20
|
-
askar_version: () => string;
|
|
21
|
-
askar_get_current_error: (args_0: Buffer) => number;
|
|
22
|
-
askar_buffer_free: (args_0: Buffer | ByteBufferType) => unknown;
|
|
23
|
-
askar_clear_custom_logger: () => unknown;
|
|
24
|
-
askar_set_custom_logger: (args_0: number, args_1: Buffer, args_2: number, args_3: number, args_4: number) => number;
|
|
25
|
-
askar_set_default_logger: () => number;
|
|
26
|
-
askar_set_max_log_level: (args_0: number) => number;
|
|
27
|
-
askar_argon2_derive_password: (args_0: number, args_1: Buffer | ByteBufferType, args_2: Buffer | ByteBufferType, args_3: Buffer) => number;
|
|
28
|
-
askar_entry_list_count: (args_0: Buffer, args_1: Buffer) => number;
|
|
29
|
-
askar_entry_list_free: (args_0: Buffer) => unknown;
|
|
30
|
-
askar_entry_list_get_category: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
31
|
-
askar_entry_list_get_name: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
32
|
-
askar_entry_list_get_tags: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
33
|
-
askar_entry_list_get_value: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
34
|
-
askar_string_list_count: (args_0: Buffer, args_1: Buffer) => number;
|
|
35
|
-
askar_string_list_free: (args_0: Buffer) => unknown;
|
|
36
|
-
askar_string_list_get_item: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
37
|
-
askar_key_aead_decrypt: (args_0: Buffer, args_1: Buffer | ByteBufferType, args_2: Buffer | ByteBufferType, args_3: Buffer | ByteBufferType, args_4: Buffer | ByteBufferType, args_5: Buffer) => number;
|
|
38
|
-
askar_key_aead_encrypt: (args_0: Buffer, args_1: Buffer | ByteBufferType, args_2: Buffer | ByteBufferType, args_3: Buffer | ByteBufferType, args_4: Buffer) => number;
|
|
39
|
-
askar_key_aead_get_padding: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
40
|
-
askar_key_aead_get_params: (args_0: Buffer, args_1: Buffer) => number;
|
|
41
|
-
askar_key_aead_random_nonce: (args_0: Buffer, args_1: Buffer) => number;
|
|
42
|
-
askar_key_convert: (args_0: Buffer, args_1: string, args_2: Buffer) => number;
|
|
43
|
-
askar_key_crypto_box: (args_0: Buffer, args_1: Buffer, args_2: Buffer | ByteBufferType, args_3: Buffer | ByteBufferType, args_4: Buffer) => number;
|
|
44
|
-
askar_key_crypto_box_open: (args_0: Buffer, args_1: Buffer, args_2: Buffer | ByteBufferType, args_3: Buffer | ByteBufferType, args_4: Buffer) => number;
|
|
45
|
-
askar_key_crypto_box_random_nonce: (args_0: Buffer) => number;
|
|
46
|
-
askar_key_crypto_box_seal: (args_0: Buffer, args_1: Buffer | ByteBufferType, args_2: Buffer) => number;
|
|
47
|
-
askar_key_crypto_box_seal_open: (args_0: Buffer, args_1: Buffer | ByteBufferType, args_2: Buffer) => number;
|
|
48
|
-
askar_key_derive_ecdh_1pu: (args_0: string, args_1: Buffer, args_2: Buffer, args_3: Buffer, args_4: Buffer | ByteBufferType, args_5: Buffer | ByteBufferType, args_6: Buffer | ByteBufferType, args_7: Buffer | ByteBufferType, args_8: number, args_9: Buffer) => number;
|
|
49
|
-
askar_key_derive_ecdh_es: (args_0: string, args_1: Buffer, args_2: Buffer, args_3: Buffer | ByteBufferType, args_4: Buffer | ByteBufferType, args_5: Buffer | ByteBufferType, args_6: number, args_7: Buffer) => number;
|
|
50
|
-
askar_key_entry_list_count: (args_0: Buffer, args_1: Buffer) => number;
|
|
51
|
-
askar_key_entry_list_free: (args_0: Buffer) => unknown;
|
|
52
|
-
askar_key_entry_list_get_algorithm: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
53
|
-
askar_key_entry_list_get_metadata: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
54
|
-
askar_key_entry_list_get_name: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
55
|
-
askar_key_entry_list_get_tags: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
56
|
-
askar_key_entry_list_load_local: (args_0: Buffer, args_1: number, args_2: Buffer) => number;
|
|
57
|
-
askar_key_free: (args_0: Buffer) => unknown;
|
|
58
|
-
askar_key_from_jwk: (args_0: Buffer | ByteBufferType, args_1: Buffer) => number;
|
|
59
|
-
askar_key_from_key_exchange: (args_0: string, args_1: Buffer, args_2: Buffer, args_3: Buffer) => number;
|
|
60
|
-
askar_key_from_public_bytes: (args_0: string, args_1: Buffer | ByteBufferType, args_2: Buffer) => number;
|
|
61
|
-
askar_key_from_secret_bytes: (args_0: string, args_1: Buffer | ByteBufferType, args_2: Buffer) => number;
|
|
62
|
-
askar_key_from_seed: (args_0: string, args_1: Buffer | ByteBufferType, args_2: string, args_3: Buffer) => number;
|
|
63
|
-
askar_key_generate: (args_0: string, args_1: string, args_2: number, args_3: Buffer) => number;
|
|
64
|
-
askar_key_get_algorithm: (args_0: Buffer, args_1: Buffer) => number;
|
|
65
|
-
askar_key_get_ephemeral: (args_0: Buffer, args_1: Buffer) => number;
|
|
66
|
-
askar_key_get_jwk_public: (args_0: Buffer, args_1: string, args_2: Buffer) => number;
|
|
67
|
-
askar_key_get_jwk_secret: (args_0: Buffer, args_1: Buffer) => number;
|
|
68
|
-
askar_key_get_jwk_thumbprint: (args_0: Buffer, args_1: string, args_2: Buffer) => number;
|
|
69
|
-
askar_key_get_public_bytes: (args_0: Buffer, args_1: Buffer) => number;
|
|
70
|
-
askar_key_get_secret_bytes: (args_0: Buffer, args_1: Buffer) => number;
|
|
71
|
-
askar_key_sign_message: (args_0: Buffer, args_1: Buffer | ByteBufferType, args_2: string, args_3: Buffer) => number;
|
|
72
|
-
askar_key_unwrap_key: (args_0: Buffer, args_1: string, args_2: Buffer | ByteBufferType, args_3: Buffer | ByteBufferType, args_4: Buffer | ByteBufferType, args_5: Buffer) => number;
|
|
73
|
-
askar_key_verify_signature: (args_0: Buffer, args_1: Buffer | ByteBufferType, args_2: Buffer | ByteBufferType, args_3: string, args_4: Buffer) => number;
|
|
74
|
-
askar_key_wrap_key: (args_0: Buffer, args_1: Buffer, args_2: Buffer | ByteBufferType, args_3: Buffer) => number;
|
|
75
|
-
askar_key_get_supported_backends: (args_0: Buffer) => number;
|
|
76
|
-
askar_scan_free: (args_0: number) => number;
|
|
77
|
-
askar_scan_next: (args_0: number, args_1: Buffer, args_2: number) => number;
|
|
78
|
-
askar_scan_start: (args_0: number, args_1: string, args_2: string, args_3: string, args_4: number, args_5: number, args_6: string, args_7: number, args_8: Buffer, args_9: number) => number;
|
|
79
|
-
askar_session_close: (args_0: number, args_1: number, args_2: Buffer, args_3: number) => number;
|
|
80
|
-
askar_session_count: (args_0: number, args_1: string, args_2: string, args_3: Buffer, args_4: number) => number;
|
|
81
|
-
askar_session_fetch: (args_0: number, args_1: string, args_2: string, args_3: number, args_4: Buffer, args_5: number) => number;
|
|
82
|
-
askar_session_fetch_all: (args_0: number, args_1: string, args_2: string, args_3: number, args_4: string, args_5: number, args_6: number, args_7: Buffer, args_8: number) => number;
|
|
83
|
-
askar_session_fetch_all_keys: (args_0: number, args_1: string, args_2: string, args_3: string, args_4: number, args_5: number, args_6: Buffer, args_7: number) => number;
|
|
84
|
-
askar_session_fetch_key: (args_0: number, args_1: string, args_2: number, args_3: Buffer, args_4: number) => number;
|
|
85
|
-
askar_session_insert_key: (args_0: number, args_1: Buffer, args_2: string, args_3: string, args_4: string, args_5: number, args_6: Buffer, args_7: number) => number;
|
|
86
|
-
askar_session_remove_all: (args_0: number, args_1: string, args_2: string, args_3: Buffer, args_4: number) => number;
|
|
87
|
-
askar_session_remove_key: (args_0: number, args_1: string, args_2: Buffer, args_3: number) => number;
|
|
88
|
-
askar_session_start: (args_0: number, args_1: string, args_2: number, args_3: Buffer, args_4: number) => number;
|
|
89
|
-
askar_session_update: (args_0: number, args_1: number, args_2: string, args_3: string, args_4: Buffer | ByteBufferType, args_5: string, args_6: number, args_7: Buffer, args_8: number) => number;
|
|
90
|
-
askar_session_update_key: (args_0: number, args_1: string, args_2: string, args_3: string, args_4: number, args_5: Buffer, args_6: number) => number;
|
|
91
|
-
askar_store_close: (args_0: number, args_1: Buffer, args_2: number) => number;
|
|
92
|
-
askar_store_copy: (args_0: number, args_1: string, args_2: string, args_3: string, args_4: number, args_5: Buffer, args_6: number) => number;
|
|
93
|
-
askar_store_create_profile: (args_0: number, args_1: string, args_2: Buffer, args_3: number) => number;
|
|
94
|
-
askar_store_generate_raw_key: (args_0: Buffer | ByteBufferType, args_1: Buffer) => number;
|
|
95
|
-
askar_store_get_profile_name: (args_0: number, args_1: Buffer, args_2: number) => number;
|
|
96
|
-
askar_store_get_default_profile: (args_0: number, args_1: Buffer, args_2: number) => number;
|
|
97
|
-
askar_store_list_profiles: (args_0: number, args_1: Buffer, args_2: number) => number;
|
|
98
|
-
askar_store_open: (args_0: string, args_1: string, args_2: string, args_3: string, args_4: Buffer, args_5: number) => number;
|
|
99
|
-
askar_store_provision: (args_0: string, args_1: string, args_2: string, args_3: string, args_4: number, args_5: Buffer, args_6: number) => number;
|
|
100
|
-
askar_store_rekey: (args_0: number, args_1: string, args_2: string, args_3: Buffer, args_4: number) => number;
|
|
101
|
-
askar_store_remove: (args_0: string, args_1: Buffer, args_2: number) => number;
|
|
102
|
-
askar_store_remove_profile: (args_0: number, args_1: string, args_2: Buffer, args_3: number) => number;
|
|
103
|
-
askar_store_set_default_profile: (args_0: number, args_1: string, args_2: Buffer, args_3: number) => number;
|
|
104
|
-
askar_store_rename_profile: (args_0: number, args_1: string, args_2: string, args_3: Buffer, args_4: number) => number;
|
|
105
|
-
askar_store_copy_profile: (args_0: number, args_1: number, args_2: string, args_3: string, args_4: Buffer, args_5: number) => number;
|
|
106
|
-
askar_migrate_indy_sdk: (args_0: string, args_1: string, args_2: string, args_3: string, args_4: Buffer, args_5: number) => number;
|
|
107
|
-
};
|
|
18
|
+
get nativeAskar(): import("./library").NativeMethods;
|
|
108
19
|
version(): string;
|
|
109
20
|
getCurrentError(): AskarErrorObject;
|
|
110
21
|
clearCustomLogger(): void;
|
|
111
22
|
setCustomLogger({ logLevel, flush, enabled, logger }: SetCustomLoggerOptions): void;
|
|
112
23
|
setDefaultLogger(): void;
|
|
113
24
|
setMaxLogLevel(options: SetMaxLogLevelOptions): void;
|
|
114
|
-
argon2DerivePassword(options: Argon2DerivePasswordOptions): Uint8Array
|
|
25
|
+
argon2DerivePassword(options: Argon2DerivePasswordOptions): Uint8Array<ArrayBufferLike>;
|
|
115
26
|
entryListCount(options: EntryListCountOptions): number;
|
|
116
27
|
entryListFree(options: EntryListFreeOptions): void;
|
|
117
28
|
entryListGetCategory(options: EntryListGetCategoryOptions): string;
|
package/build/NodeJSAskar.js
CHANGED
|
@@ -4,19 +4,25 @@ exports.NodeJSAskar = void 0;
|
|
|
4
4
|
const askar_shared_1 = require("@openwallet-foundation/askar-shared");
|
|
5
5
|
const ffi_1 = require("./ffi");
|
|
6
6
|
const library_1 = require("./library");
|
|
7
|
+
// With koffi, output parameters are arrays that get filled in place
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: koffi output parameters
|
|
7
9
|
function handleNullableReturnPointer(returnValue) {
|
|
8
|
-
|
|
10
|
+
const value = returnValue[0];
|
|
11
|
+
if (value === null || value === undefined)
|
|
9
12
|
return null;
|
|
10
|
-
return
|
|
13
|
+
return value;
|
|
11
14
|
}
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: koffi output parameters
|
|
12
16
|
function handleReturnPointer(returnValue) {
|
|
13
|
-
|
|
17
|
+
const value = returnValue[0];
|
|
18
|
+
if (value === null || value === undefined) {
|
|
14
19
|
throw askar_shared_1.AskarError.customError({ message: 'Unexpected null pointer' });
|
|
15
20
|
}
|
|
16
|
-
return
|
|
21
|
+
return value;
|
|
17
22
|
}
|
|
18
23
|
class NodeJSAskar {
|
|
19
24
|
constructor() {
|
|
25
|
+
// biome-ignore lint/suspicious/noExplicitAny: koffi callback type
|
|
20
26
|
this.promisify = async (method) => {
|
|
21
27
|
return new Promise((resolve, reject) => {
|
|
22
28
|
const cb = (id, errorCode) => {
|
|
@@ -33,7 +39,9 @@ class NodeJSAskar {
|
|
|
33
39
|
method(nativeCallback, +id);
|
|
34
40
|
});
|
|
35
41
|
};
|
|
36
|
-
this.promisifyWithResponse = async (
|
|
42
|
+
this.promisifyWithResponse = async (
|
|
43
|
+
// biome-ignore lint/suspicious/noExplicitAny: koffi callback type
|
|
44
|
+
method, responseFfiType = ffi_1.FFI_STRING) => {
|
|
37
45
|
return new Promise((resolve, reject) => {
|
|
38
46
|
const cb = (id, errorCode, response) => {
|
|
39
47
|
(0, ffi_1.deallocateCallbackBuffer)(id);
|
|
@@ -54,9 +62,11 @@ class NodeJSAskar {
|
|
|
54
62
|
else if (typeof response === 'number') {
|
|
55
63
|
resolve(response);
|
|
56
64
|
}
|
|
57
|
-
else if (response
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
else if (response === null || response === undefined) {
|
|
66
|
+
resolve(null);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// For other types, try to use directly
|
|
60
70
|
resolve(response);
|
|
61
71
|
}
|
|
62
72
|
reject(askar_shared_1.AskarError.customError({ message: `could not parse return type properly (type: ${typeof response})` }));
|
|
@@ -132,9 +142,9 @@ class NodeJSAskar {
|
|
|
132
142
|
const errorCode = this.nativeAskar.askar_argon2_derive_password(parameters, password, salt, ret);
|
|
133
143
|
this.handleError(errorCode);
|
|
134
144
|
const byteBuffer = handleReturnPointer(ret);
|
|
135
|
-
const
|
|
145
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
136
146
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
137
|
-
return
|
|
147
|
+
return uint8Array;
|
|
138
148
|
}
|
|
139
149
|
entryListCount(options) {
|
|
140
150
|
const { entryListHandle } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -174,22 +184,35 @@ class NodeJSAskar {
|
|
|
174
184
|
const errorCode = this.nativeAskar.askar_entry_list_get_value(entryListHandle, index, ret);
|
|
175
185
|
this.handleError(errorCode);
|
|
176
186
|
const byteBuffer = handleReturnPointer(ret);
|
|
177
|
-
const
|
|
187
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
178
188
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
179
|
-
return
|
|
189
|
+
return uint8Array;
|
|
180
190
|
}
|
|
181
191
|
keyAeadDecrypt(options) {
|
|
182
|
-
|
|
192
|
+
var _a, _b;
|
|
193
|
+
const { ciphertext, localKeyHandle, nonce, aad, tag } = (0, ffi_1.serializeArguments)({
|
|
194
|
+
localKeyHandle: options.localKeyHandle,
|
|
195
|
+
nonce: options.nonce,
|
|
196
|
+
ciphertext: options.ciphertext,
|
|
197
|
+
tag: (_a = options.tag) !== null && _a !== void 0 ? _a : new Uint8Array(0),
|
|
198
|
+
aad: (_b = options.aad) !== null && _b !== void 0 ? _b : new Uint8Array(0),
|
|
199
|
+
});
|
|
183
200
|
const ret = (0, ffi_1.allocateSecretBuffer)();
|
|
184
201
|
const errorCode = this.nativeAskar.askar_key_aead_decrypt(localKeyHandle, ciphertext, nonce, tag, aad, ret);
|
|
185
202
|
this.handleError(errorCode);
|
|
186
203
|
const byteBuffer = handleReturnPointer(ret);
|
|
187
|
-
const
|
|
204
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
188
205
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
189
|
-
return
|
|
206
|
+
return uint8Array;
|
|
190
207
|
}
|
|
191
208
|
keyAeadEncrypt(options) {
|
|
192
|
-
|
|
209
|
+
var _a, _b;
|
|
210
|
+
const { localKeyHandle, message, nonce, aad } = (0, ffi_1.serializeArguments)({
|
|
211
|
+
localKeyHandle: options.localKeyHandle,
|
|
212
|
+
message: options.message,
|
|
213
|
+
nonce: (_a = options.nonce) !== null && _a !== void 0 ? _a : new Uint8Array(0),
|
|
214
|
+
aad: (_b = options.aad) !== null && _b !== void 0 ? _b : new Uint8Array(0),
|
|
215
|
+
});
|
|
193
216
|
const ret = (0, ffi_1.allocateEncryptedBuffer)();
|
|
194
217
|
const errorCode = this.nativeAskar.askar_key_aead_encrypt(localKeyHandle, message, nonce, aad, ret);
|
|
195
218
|
this.handleError(errorCode);
|
|
@@ -218,9 +241,9 @@ class NodeJSAskar {
|
|
|
218
241
|
const errorCode = this.nativeAskar.askar_key_aead_random_nonce(localKeyHandle, ret);
|
|
219
242
|
this.handleError(errorCode);
|
|
220
243
|
const byteBuffer = handleReturnPointer(ret);
|
|
221
|
-
const
|
|
244
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
222
245
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
223
|
-
return
|
|
246
|
+
return uint8Array;
|
|
224
247
|
}
|
|
225
248
|
keyConvert(options) {
|
|
226
249
|
const { localKeyHandle, algorithm } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -236,9 +259,9 @@ class NodeJSAskar {
|
|
|
236
259
|
const errorCode = this.nativeAskar.askar_key_crypto_box(recipientKey, senderKey, message, nonce, ret);
|
|
237
260
|
this.handleError(errorCode);
|
|
238
261
|
const byteBuffer = handleReturnPointer(ret);
|
|
239
|
-
const
|
|
262
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
240
263
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
241
|
-
return
|
|
264
|
+
return uint8Array;
|
|
242
265
|
}
|
|
243
266
|
keyCryptoBoxOpen(options) {
|
|
244
267
|
const { nonce, message, senderKey, recipientKey } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -246,18 +269,18 @@ class NodeJSAskar {
|
|
|
246
269
|
const errorCode = this.nativeAskar.askar_key_crypto_box_open(recipientKey, senderKey, message, nonce, ret);
|
|
247
270
|
this.handleError(errorCode);
|
|
248
271
|
const byteBuffer = handleReturnPointer(ret);
|
|
249
|
-
const
|
|
272
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
250
273
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
251
|
-
return
|
|
274
|
+
return uint8Array;
|
|
252
275
|
}
|
|
253
276
|
keyCryptoBoxRandomNonce() {
|
|
254
277
|
const ret = (0, ffi_1.allocateSecretBuffer)();
|
|
255
278
|
const errorCode = this.nativeAskar.askar_key_crypto_box_random_nonce(ret);
|
|
256
279
|
this.handleError(errorCode);
|
|
257
280
|
const byteBuffer = handleReturnPointer(ret);
|
|
258
|
-
const
|
|
281
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
259
282
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
260
|
-
return
|
|
283
|
+
return uint8Array;
|
|
261
284
|
}
|
|
262
285
|
keyCryptoBoxSeal(options) {
|
|
263
286
|
const { message, localKeyHandle } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -265,9 +288,9 @@ class NodeJSAskar {
|
|
|
265
288
|
const errorCode = this.nativeAskar.askar_key_crypto_box_seal(localKeyHandle, message, ret);
|
|
266
289
|
this.handleError(errorCode);
|
|
267
290
|
const byteBuffer = handleReturnPointer(ret);
|
|
268
|
-
const
|
|
291
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
269
292
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
270
|
-
return
|
|
293
|
+
return uint8Array;
|
|
271
294
|
}
|
|
272
295
|
keyCryptoBoxSealOpen(options) {
|
|
273
296
|
const { ciphertext, localKeyHandle } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -275,12 +298,23 @@ class NodeJSAskar {
|
|
|
275
298
|
const errorCode = this.nativeAskar.askar_key_crypto_box_seal_open(localKeyHandle, ciphertext, ret);
|
|
276
299
|
this.handleError(errorCode);
|
|
277
300
|
const byteBuffer = handleReturnPointer(ret);
|
|
278
|
-
const
|
|
301
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
279
302
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
280
|
-
return
|
|
303
|
+
return uint8Array;
|
|
281
304
|
}
|
|
282
305
|
keyDeriveEcdh1pu(options) {
|
|
283
|
-
|
|
306
|
+
var _a;
|
|
307
|
+
const { senderKey, recipientKey, algorithm, algId, apu, apv, ephemeralKey, receive, ccTag } = (0, ffi_1.serializeArguments)({
|
|
308
|
+
senderKey: options.senderKey,
|
|
309
|
+
recipientKey: options.recipientKey,
|
|
310
|
+
algorithm: options.algorithm,
|
|
311
|
+
algId: options.algId,
|
|
312
|
+
apu: options.apu,
|
|
313
|
+
apv: options.apv,
|
|
314
|
+
ephemeralKey: options.ephemeralKey,
|
|
315
|
+
receive: options.receive,
|
|
316
|
+
ccTag: (_a = options.ccTag) !== null && _a !== void 0 ? _a : new Uint8Array(0),
|
|
317
|
+
});
|
|
284
318
|
const ret = (0, ffi_1.allocatePointer)();
|
|
285
319
|
const errorCode = this.nativeAskar.askar_key_derive_ecdh_1pu(algorithm, ephemeralKey, senderKey, recipientKey, algId, apu, apv, ccTag, receive, ret);
|
|
286
320
|
this.handleError(errorCode);
|
|
@@ -421,9 +455,9 @@ class NodeJSAskar {
|
|
|
421
455
|
const errorCode = this.nativeAskar.askar_key_get_jwk_secret(localKeyHandle, ret);
|
|
422
456
|
this.handleError(errorCode);
|
|
423
457
|
const byteBuffer = handleReturnPointer(ret);
|
|
424
|
-
const
|
|
458
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
425
459
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
426
|
-
return
|
|
460
|
+
return uint8Array;
|
|
427
461
|
}
|
|
428
462
|
keyGetJwkThumbprint(options) {
|
|
429
463
|
const { localKeyHandle, algorithm } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -438,9 +472,9 @@ class NodeJSAskar {
|
|
|
438
472
|
const errorCode = this.nativeAskar.askar_key_get_public_bytes(localKeyHandle, ret);
|
|
439
473
|
this.handleError(errorCode);
|
|
440
474
|
const byteBuffer = handleReturnPointer(ret);
|
|
441
|
-
const
|
|
475
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
442
476
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
443
|
-
return
|
|
477
|
+
return uint8Array;
|
|
444
478
|
}
|
|
445
479
|
keyGetSecretBytes(options) {
|
|
446
480
|
const { localKeyHandle } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -448,9 +482,9 @@ class NodeJSAskar {
|
|
|
448
482
|
const errorCode = this.nativeAskar.askar_key_get_secret_bytes(localKeyHandle, ret);
|
|
449
483
|
this.handleError(errorCode);
|
|
450
484
|
const byteBuffer = handleReturnPointer(ret);
|
|
451
|
-
const
|
|
485
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
452
486
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
453
|
-
return
|
|
487
|
+
return uint8Array;
|
|
454
488
|
}
|
|
455
489
|
keySignMessage(options) {
|
|
456
490
|
const { localKeyHandle, message, sigType } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -458,12 +492,19 @@ class NodeJSAskar {
|
|
|
458
492
|
const errorCode = this.nativeAskar.askar_key_sign_message(localKeyHandle, message, sigType, ret);
|
|
459
493
|
this.handleError(errorCode);
|
|
460
494
|
const byteBuffer = handleReturnPointer(ret);
|
|
461
|
-
const
|
|
495
|
+
const uint8Array = (0, ffi_1.secretBufferToUint8Array)(byteBuffer);
|
|
462
496
|
this.nativeAskar.askar_buffer_free(byteBuffer);
|
|
463
|
-
return
|
|
497
|
+
return uint8Array;
|
|
464
498
|
}
|
|
465
499
|
keyUnwrapKey(options) {
|
|
466
|
-
|
|
500
|
+
var _a, _b;
|
|
501
|
+
const { localKeyHandle, algorithm, ciphertext, nonce, tag } = (0, ffi_1.serializeArguments)({
|
|
502
|
+
localKeyHandle: options.localKeyHandle,
|
|
503
|
+
algorithm: options.algorithm,
|
|
504
|
+
ciphertext: options.ciphertext,
|
|
505
|
+
nonce: (_a = options.nonce) !== null && _a !== void 0 ? _a : new Uint8Array(0),
|
|
506
|
+
tag: (_b = options.tag) !== null && _b !== void 0 ? _b : new Uint8Array(0),
|
|
507
|
+
});
|
|
467
508
|
const ret = (0, ffi_1.allocatePointer)();
|
|
468
509
|
const errorCode = this.nativeAskar.askar_key_unwrap_key(localKeyHandle, algorithm, ciphertext, nonce, tag, ret);
|
|
469
510
|
this.handleError(errorCode);
|
|
@@ -478,7 +519,8 @@ class NodeJSAskar {
|
|
|
478
519
|
return Boolean(handleReturnPointer(ret));
|
|
479
520
|
}
|
|
480
521
|
keyWrapKey(options) {
|
|
481
|
-
|
|
522
|
+
var _a;
|
|
523
|
+
const { localKeyHandle, nonce, other } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { nonce: (_a = options.nonce) !== null && _a !== void 0 ? _a : new Uint8Array(0) }));
|
|
482
524
|
const ret = (0, ffi_1.allocateEncryptedBuffer)();
|
|
483
525
|
const errorCode = this.nativeAskar.askar_key_wrap_key(localKeyHandle, other, nonce, ret);
|
|
484
526
|
this.handleError(errorCode);
|
|
@@ -491,17 +533,17 @@ class NodeJSAskar {
|
|
|
491
533
|
const stringListHandlePtr = (0, ffi_1.allocateStringListHandle)();
|
|
492
534
|
const keyGetSupportedBackendsErrorCode = this.nativeAskar.askar_key_get_supported_backends(stringListHandlePtr);
|
|
493
535
|
this.handleError(keyGetSupportedBackendsErrorCode);
|
|
494
|
-
const stringListHandle = stringListHandlePtr
|
|
536
|
+
const stringListHandle = stringListHandlePtr[0];
|
|
495
537
|
const listCountPtr = (0, ffi_1.allocateInt32Buffer)();
|
|
496
538
|
const stringListCountErrorCode = this.nativeAskar.askar_string_list_count(stringListHandle, listCountPtr);
|
|
497
539
|
this.handleError(stringListCountErrorCode);
|
|
498
|
-
const count = listCountPtr
|
|
540
|
+
const count = listCountPtr[0];
|
|
499
541
|
const supportedBackends = [];
|
|
500
542
|
for (let i = 0; i < count; i++) {
|
|
501
543
|
const strPtr = (0, ffi_1.allocateStringBuffer)();
|
|
502
544
|
const errorCode = this.nativeAskar.askar_string_list_get_item(stringListHandle, i, strPtr);
|
|
503
545
|
this.handleError(errorCode);
|
|
504
|
-
supportedBackends.push(strPtr
|
|
546
|
+
supportedBackends.push(strPtr[0]);
|
|
505
547
|
}
|
|
506
548
|
this.nativeAskar.askar_string_list_free(stringListHandle);
|
|
507
549
|
return supportedBackends;
|
|
@@ -517,8 +559,9 @@ class NodeJSAskar {
|
|
|
517
559
|
return askar_shared_1.EntryListHandle.fromHandle(handle);
|
|
518
560
|
}
|
|
519
561
|
async scanStart(options) {
|
|
520
|
-
|
|
521
|
-
const
|
|
562
|
+
var _a, _b, _c;
|
|
563
|
+
const { category, limit, offset, profile, storeHandle, tagFilter, orderBy, descending } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { offset: (_a = options.offset) !== null && _a !== void 0 ? _a : 0, limit: (_b = options.limit) !== null && _b !== void 0 ? _b : -1, descending: (_c = options.descending) !== null && _c !== void 0 ? _c : 0 }));
|
|
564
|
+
const handle = await this.promisifyWithResponse((cb, cbId) => this.nativeAskar.askar_scan_start(storeHandle, profile, category, tagFilter, offset, limit, orderBy, descending, cb, cbId), ffi_1.FFI_SCAN_HANDLE);
|
|
522
565
|
return askar_shared_1.ScanHandle.fromHandle(handle);
|
|
523
566
|
}
|
|
524
567
|
async sessionClose(options) {
|
|
@@ -536,13 +579,15 @@ class NodeJSAskar {
|
|
|
536
579
|
return askar_shared_1.EntryListHandle.fromHandle(handle);
|
|
537
580
|
}
|
|
538
581
|
async sessionFetchAll(options) {
|
|
539
|
-
|
|
540
|
-
const
|
|
582
|
+
var _a, _b;
|
|
583
|
+
const { forUpdate, sessionHandle, tagFilter, limit, category, orderBy, descending } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { limit: (_a = options.limit) !== null && _a !== void 0 ? _a : -1, descending: (_b = options.descending) !== null && _b !== void 0 ? _b : 0 }));
|
|
584
|
+
const handle = await this.promisifyWithResponse((cb, cbId) => this.nativeAskar.askar_session_fetch_all(sessionHandle, category, tagFilter, limit, orderBy, descending, forUpdate, cb, cbId), ffi_1.FFI_ENTRY_LIST_HANDLE);
|
|
541
585
|
return askar_shared_1.EntryListHandle.fromHandle(handle);
|
|
542
586
|
}
|
|
543
587
|
async sessionFetchAllKeys(options) {
|
|
544
|
-
|
|
545
|
-
const
|
|
588
|
+
var _a;
|
|
589
|
+
const { forUpdate, limit, tagFilter, sessionHandle, algorithm, thumbprint } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { limit: (_a = options.limit) !== null && _a !== void 0 ? _a : -1 }));
|
|
590
|
+
const handle = await this.promisifyWithResponse((cb, cbId) => this.nativeAskar.askar_session_fetch_all_keys(sessionHandle, algorithm, thumbprint, tagFilter, limit, forUpdate, cb, cbId), ffi_1.FFI_KEY_ENTRY_LIST_HANDLE);
|
|
546
591
|
return askar_shared_1.KeyEntryListHandle.fromHandle(handle);
|
|
547
592
|
}
|
|
548
593
|
async sessionFetchKey(options) {
|
|
@@ -551,8 +596,9 @@ class NodeJSAskar {
|
|
|
551
596
|
return askar_shared_1.KeyEntryListHandle.fromHandle(handle);
|
|
552
597
|
}
|
|
553
598
|
async sessionInsertKey(options) {
|
|
554
|
-
|
|
555
|
-
|
|
599
|
+
var _a;
|
|
600
|
+
const { name, sessionHandle, expiryMs, localKeyHandle, metadata, tags } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { expiryMs: (_a = options.expiryMs) !== null && _a !== void 0 ? _a : -1 }));
|
|
601
|
+
return this.promisify((cb, cbId) => this.nativeAskar.askar_session_insert_key(sessionHandle, localKeyHandle, name, metadata, tags, expiryMs, cb, cbId));
|
|
556
602
|
}
|
|
557
603
|
async sessionRemoveAll(options) {
|
|
558
604
|
const { sessionHandle, tagFilter, category } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -569,19 +615,22 @@ class NodeJSAskar {
|
|
|
569
615
|
return askar_shared_1.SessionHandle.fromHandle(handle);
|
|
570
616
|
}
|
|
571
617
|
async sessionUpdate(options) {
|
|
572
|
-
|
|
573
|
-
|
|
618
|
+
var _a, _b;
|
|
619
|
+
const { name, sessionHandle, category, expiryMs, tags, operation, value } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { expiryMs: (_a = options.expiryMs) !== null && _a !== void 0 ? _a : -1, value: (_b = options.value) !== null && _b !== void 0 ? _b : new Uint8Array(0) }));
|
|
620
|
+
return this.promisify((cb, cbId) => this.nativeAskar.askar_session_update(sessionHandle, operation, category, name, value, tags, expiryMs, cb, cbId));
|
|
574
621
|
}
|
|
575
622
|
async sessionUpdateKey(options) {
|
|
576
|
-
|
|
577
|
-
|
|
623
|
+
var _a;
|
|
624
|
+
const { expiryMs, tags, name, sessionHandle, metadata } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { expiryMs: (_a = options.expiryMs) !== null && _a !== void 0 ? _a : -1 }));
|
|
625
|
+
return this.promisify((cb, cbId) => this.nativeAskar.askar_session_update_key(sessionHandle, name, metadata, tags, expiryMs, cb, cbId));
|
|
578
626
|
}
|
|
579
627
|
storeClose(options) {
|
|
580
628
|
const { storeHandle } = (0, ffi_1.serializeArguments)(options);
|
|
581
629
|
return this.promisify((cb, cbId) => this.nativeAskar.askar_store_close(storeHandle, cb, cbId));
|
|
582
630
|
}
|
|
583
631
|
storeCopyTo(options) {
|
|
584
|
-
|
|
632
|
+
var _a;
|
|
633
|
+
const { storeHandle, targetUri, passKey, keyMethod, recreate } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { recreate: (_a = options.recreate) !== null && _a !== void 0 ? _a : 0 }));
|
|
585
634
|
return this.promisify((cb, cbId) => this.nativeAskar.askar_store_copy(storeHandle, targetUri, keyMethod, passKey, recreate, cb, cbId));
|
|
586
635
|
}
|
|
587
636
|
async storeCreateProfile(options) {
|
|
@@ -590,11 +639,12 @@ class NodeJSAskar {
|
|
|
590
639
|
return (0, askar_shared_1.handleInvalidNullResponse)(response);
|
|
591
640
|
}
|
|
592
641
|
storeGenerateRawKey(options) {
|
|
593
|
-
|
|
642
|
+
var _a;
|
|
643
|
+
const { seed } = (0, ffi_1.serializeArguments)(Object.assign(Object.assign({}, options), { seed: (_a = options.seed) !== null && _a !== void 0 ? _a : new Uint8Array(0) }));
|
|
594
644
|
const ret = (0, ffi_1.allocateStringBuffer)();
|
|
595
645
|
const errorCode = this.nativeAskar.askar_store_generate_raw_key(seed, ret);
|
|
596
646
|
this.handleError(errorCode);
|
|
597
|
-
return ret
|
|
647
|
+
return ret[0];
|
|
598
648
|
}
|
|
599
649
|
async storeGetDefaultProfile(options) {
|
|
600
650
|
const { storeHandle } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -608,6 +658,7 @@ class NodeJSAskar {
|
|
|
608
658
|
}
|
|
609
659
|
async storeListProfiles(options) {
|
|
610
660
|
const { storeHandle } = (0, ffi_1.serializeArguments)(options);
|
|
661
|
+
// biome-ignore lint/suspicious/noExplicitAny: koffi handle type
|
|
611
662
|
const listHandle = await this.promisifyWithResponse((cb, cbId) => this.nativeAskar.askar_store_list_profiles(storeHandle, cb, cbId), ffi_1.FFI_STRING_LIST_HANDLE);
|
|
612
663
|
if (listHandle === null) {
|
|
613
664
|
throw askar_shared_1.AskarError.customError({ message: 'Invalid handle' });
|
|
@@ -615,13 +666,13 @@ class NodeJSAskar {
|
|
|
615
666
|
const counti32 = (0, ffi_1.allocateInt32Buffer)();
|
|
616
667
|
const errorCode = this.nativeAskar.askar_string_list_count(listHandle, counti32);
|
|
617
668
|
this.handleError(errorCode);
|
|
618
|
-
const count = counti32
|
|
669
|
+
const count = counti32[0];
|
|
619
670
|
const ret = [];
|
|
620
671
|
const strval = (0, ffi_1.allocateStringBuffer)();
|
|
621
672
|
for (let i = 0; i < count; i++) {
|
|
622
673
|
const errorCode = this.nativeAskar.askar_string_list_get_item(listHandle, i, strval);
|
|
623
674
|
this.handleError(errorCode);
|
|
624
|
-
ret.push(strval
|
|
675
|
+
ret.push(strval[0]);
|
|
625
676
|
}
|
|
626
677
|
this.nativeAskar.askar_string_list_free(listHandle);
|
|
627
678
|
return ret;
|