@equs-ai/equs-credentials-sdk-askar-storage 1.0.1
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 +44 -0
- package/binary.d.ts +351 -0
- package/binary.js +322 -0
- package/index.d.ts +1 -0
- package/index.js +17 -0
- package/package.json +64 -0
- package/tsconfig.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Askar Storage wrapper for Node.js
|
|
2
|
+
|
|
3
|
+
Node.js bindings for the example KMS and Vault in [`plugins/askar`](../..), built as a native
|
|
4
|
+
addon with [NAPI-RS](https://napi.rs).
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
- Node.js and npm — see `engines` in [`package.json`](package.json)
|
|
9
|
+
- A Rust toolchain — see `rust-version` in [`Cargo.toml`](../../../../Cargo.toml)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
The wrapper is published as `@equs-ai/equs-credentials-sdk-askar-storage`; the native binary for your platform
|
|
14
|
+
comes from a companion `@equs-ai/equs-credentials-sdk-askar-storage-<os>-<arch>` package. Both are on npmjs:
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
npm i @equs-ai/equs-credentials-sdk-askar-storage
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
The package can be imported with both ES module and CommonJS syntax.
|
|
23
|
+
|
|
24
|
+
## Publishing
|
|
25
|
+
|
|
26
|
+
Each platform binary is published as its own npm package, then the
|
|
27
|
+
`@equs-ai/equs-credentials-sdk-askar-storage` package that depends on them is published on top. Both steps run from
|
|
28
|
+
[`publish-askar-nodejs.yml`](../../../../.github/workflows/publish-askar-nodejs.yml) on an `askar-nodejs/vX.Y.Z` tag — see
|
|
29
|
+
[Publish a New Release](../../../../docs/guidelines/release.md).
|
|
30
|
+
|
|
31
|
+
The two scripts the pipeline calls, for a manual run:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
REGISTRY_URL_NPM=<registry-url> NPM_TOKEN=<token> TARGET=<target> ALIAS=<alias> ENVIRONMENT=production scripts/build_and_publish_target.sh
|
|
35
|
+
REGISTRY_URL_NPM=<registry-url> NPM_TOKEN=<token> ENVIRONMENT=production scripts/build_and_publish_wrapper.sh
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Both scripts pack the package and publish the resulting `.tgz`, which the release manifest hashes.
|
|
39
|
+
Neither writes an `.npmrc`: `NPM_TOKEN` is unset before the build and passed to
|
|
40
|
+
`npm publish` alone as `npm_config_//<registry>/:_authToken`. In CI, `REGISTRY_URL_NPM` is `https://registry.npmjs.org/` and `NPM_TOKEN` comes
|
|
41
|
+
from the `NPM_TOKEN` repo secret.
|
|
42
|
+
|
|
43
|
+
The target list is `napi.triples.additional` in [`package.json`](package.json); `defaults` is off, so
|
|
44
|
+
`napi prepublish` lists only those three platforms in `optionalDependencies`.
|
package/binary.d.ts
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { Credential, CredentialMetadata, CredentialEntry, KeyType, Alg } from "@equs-ai/equs-credentials-sdk";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
export const enum InnerVCFormat {
|
|
8
|
+
JwtVcJson = 0,
|
|
9
|
+
JwtVcJsonLD = 1,
|
|
10
|
+
LdpVc = 2,
|
|
11
|
+
SdJwtVc = 3,
|
|
12
|
+
MsoMdoc = 4
|
|
13
|
+
}
|
|
14
|
+
export interface InnerCredential {
|
|
15
|
+
format: InnerVCFormat
|
|
16
|
+
payload: string
|
|
17
|
+
}
|
|
18
|
+
export interface InnerCredentialMetadata {
|
|
19
|
+
type: string
|
|
20
|
+
format: InnerVCFormat
|
|
21
|
+
kid: string
|
|
22
|
+
alg?: Alg
|
|
23
|
+
fields: Array<string>
|
|
24
|
+
}
|
|
25
|
+
export interface InnerCredentialEntry {
|
|
26
|
+
credential: InnerCredential
|
|
27
|
+
kid: string
|
|
28
|
+
id: string
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* An interface for pagination in Vault
|
|
32
|
+
*
|
|
33
|
+
* @property {offset} offset - amount of items to skip
|
|
34
|
+
* @property {limit} limit - maximum amount of items to get
|
|
35
|
+
*/
|
|
36
|
+
export interface InnerVaultPagination {
|
|
37
|
+
offset?: number
|
|
38
|
+
limit?: number
|
|
39
|
+
}
|
|
40
|
+
export interface AskarVaultFetchOptions {
|
|
41
|
+
limit?: number
|
|
42
|
+
offset?: number
|
|
43
|
+
sortBy?: AskarVaultSortBy
|
|
44
|
+
sortOrder?: AskarVaultParamsSortOrder
|
|
45
|
+
}
|
|
46
|
+
export const enum AskarVaultSortBy {
|
|
47
|
+
Id = 0
|
|
48
|
+
}
|
|
49
|
+
export const enum AskarVaultParamsSortOrder {
|
|
50
|
+
Ascending = 0,
|
|
51
|
+
Descending = 1
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `Askar Storage Configuration`
|
|
55
|
+
*
|
|
56
|
+
* Configuration options for initializing Askar storage.
|
|
57
|
+
*
|
|
58
|
+
* Provides necessary parameters to establish a connection to an Askar database.
|
|
59
|
+
*
|
|
60
|
+
* @property db_url - Database URL for Askar storage
|
|
61
|
+
* @property key_method - Method used for key protection {@link KeyMethod}
|
|
62
|
+
* @property pass_key - Passphrase or raw key material used with the specified key method
|
|
63
|
+
* @property profile - Name of the profile/namespace within the storage
|
|
64
|
+
*/
|
|
65
|
+
export interface AskarStorageConfig {
|
|
66
|
+
dbUrl: string
|
|
67
|
+
keyMethod: KeyMethod
|
|
68
|
+
passKey: string
|
|
69
|
+
profile: string
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `Key Protection Method`
|
|
73
|
+
*
|
|
74
|
+
* Specifies how encryption keys for the Askar storage are protected.
|
|
75
|
+
*
|
|
76
|
+
* Determines how the pass_key value is processed when opening or creating storage.
|
|
77
|
+
*
|
|
78
|
+
* @value DeriveKey - Derives encryption key from the provided passphrase
|
|
79
|
+
* @value RawKey - Uses the provided key material directly
|
|
80
|
+
* @value Unprotected - Minimal key protection, suitable for testing environments only
|
|
81
|
+
*/
|
|
82
|
+
export const enum KeyMethod {
|
|
83
|
+
DeriveKey = 0,
|
|
84
|
+
RawKey = 1,
|
|
85
|
+
Unprotected = 2
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* `Askar Kms`
|
|
89
|
+
*
|
|
90
|
+
* @method {(kt: KeyType) => Promise<string>} create - Create and store a key in {@link Kms}.
|
|
91
|
+
* @method {(kid: string) => Promise<KeyHandle>} get - Returns {@link KeyHandle} for the provided `KID`
|
|
92
|
+
* @method {(pk: Uint8Array) => Promise<KeyHandle>} getByPublicKey - Returns {@link KeyHandle} for the provided `Public Key`
|
|
93
|
+
* @method {(jwe: string) => Promise<Buffer>} decryptToBuffer - Decrypts a compact JWE token and returns raw plaintext bytes.
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
export declare class AskarKms {
|
|
97
|
+
constructor(storage: AskarStorage, profile: string)
|
|
98
|
+
/**
|
|
99
|
+
* Create and store a key in `Askar Kms`.
|
|
100
|
+
*
|
|
101
|
+
* @param {KeyType} kt - a {@link KeyType} for the key.
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise<string>} - A `KeyId` for the created key on success.
|
|
104
|
+
*/
|
|
105
|
+
create(kt: KeyType): Promise<string>
|
|
106
|
+
/**
|
|
107
|
+
* Returns {@link KeyHandle} for the provided `KID`.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} kid - a `KeyId` of the requested key.
|
|
110
|
+
*
|
|
111
|
+
* @returns {Promise<KeyHandle>} - A {@link KeyHandle} supporting basic crypto primitives on success.
|
|
112
|
+
*/
|
|
113
|
+
get(kid: string): Promise<AskarKeyHandle>
|
|
114
|
+
/**
|
|
115
|
+
* Returns {@link KeyHandle} for the provided public key.
|
|
116
|
+
*
|
|
117
|
+
* @param {Uint8Array} publicKey - a public key for the requested key.
|
|
118
|
+
*
|
|
119
|
+
* @returns {Promise<KeyHandle>} - A {@link KeyHandle} supporting basic crypto primitives on success.
|
|
120
|
+
*/
|
|
121
|
+
getByPublicKey(publicKey: Uint8Array): Promise<AskarKeyHandle>
|
|
122
|
+
/**
|
|
123
|
+
* Decrypts a compact JWE token using the private key stored in Askar KMS.
|
|
124
|
+
*
|
|
125
|
+
* The recipient key is resolved by the supplied `kid` rather than the one
|
|
126
|
+
* embedded in the JWE protected header, so callers can pass the raw key id
|
|
127
|
+
* after decoding any application-level prefix.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} jwe - A compact serialisation JWE token.
|
|
130
|
+
* @param {string} kid - The `KeyId` of the recipient key stored in this KMS instance.
|
|
131
|
+
*
|
|
132
|
+
* @returns {Promise<Buffer>} - Raw plaintext bytes on success.
|
|
133
|
+
*/
|
|
134
|
+
decryptToBuffer(jwe: string, kid: string): Promise<Uint8Array>
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* `Askar Key Handle`
|
|
138
|
+
*
|
|
139
|
+
* @property pubKey - {@link AskarKeyHandle.pubKey}
|
|
140
|
+
* @property jwk - {@link AskarKeyHandle.jwk}
|
|
141
|
+
* @property alg - {@link AskarKeyHandle.alg}
|
|
142
|
+
* @method sign - {@link AskarKeyHandle.sign}
|
|
143
|
+
* @method verify - {@link AskarKeyHandle.verify}
|
|
144
|
+
*/
|
|
145
|
+
export declare class AskarKeyHandle {
|
|
146
|
+
/**
|
|
147
|
+
* The public key in JWK form if it's supported.
|
|
148
|
+
*
|
|
149
|
+
* * string jwk if the public key can be represented as JWK
|
|
150
|
+
* * `undefined` if the JWK-form is not supported.
|
|
151
|
+
*/
|
|
152
|
+
jwk?: string
|
|
153
|
+
/**
|
|
154
|
+
* Returns the public key for the corresponding handle.
|
|
155
|
+
*
|
|
156
|
+
* @returns {Array<number>} - Public key bytes.
|
|
157
|
+
*/
|
|
158
|
+
get pubKey(): Array<number>
|
|
159
|
+
/**
|
|
160
|
+
* Returns algorithm of the signer.
|
|
161
|
+
*
|
|
162
|
+
* @returns {Alg} - An {@link Alg} enum value.
|
|
163
|
+
*/
|
|
164
|
+
get alg(): Alg
|
|
165
|
+
/**
|
|
166
|
+
* Sign the provided binary payload.
|
|
167
|
+
*
|
|
168
|
+
* @param {Uint8Array} payload - an array of bytes to be signed.
|
|
169
|
+
*
|
|
170
|
+
* @returns {Uint8Array} signed `payload` on success.
|
|
171
|
+
*/
|
|
172
|
+
sign(payload: Uint8Array): Promise<Uint8Array>
|
|
173
|
+
/**
|
|
174
|
+
* Verifies a cryptographic signature for given binary data.
|
|
175
|
+
*
|
|
176
|
+
* @param {Uint8Array} data - the original binary data that was signed.
|
|
177
|
+
* @param {Uint8Array} signature - the corresponding signature.
|
|
178
|
+
*
|
|
179
|
+
* @returns {void}
|
|
180
|
+
*/
|
|
181
|
+
verify(data: Uint8Array, signature: Uint8Array): Promise<void>
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* `Askar Vault`
|
|
185
|
+
*
|
|
186
|
+
* An async `Vault` interface for managing Verifiable Credentials.
|
|
187
|
+
*
|
|
188
|
+
* Should be implemented to be used with `Askar`.
|
|
189
|
+
*
|
|
190
|
+
* Supports storing, retrieving, deleting, and finding {@link Credential}.
|
|
191
|
+
* Supports closing {@link Vault}
|
|
192
|
+
*
|
|
193
|
+
* @method storeCredential - {@link AskarVault.storeCredential}
|
|
194
|
+
* @method deleteCredential - {@link AskarVault.deleteCredential}
|
|
195
|
+
* @method getCredential - {@link AskarVault.getCredential}
|
|
196
|
+
* @method getCredentials - {@link AskarVault.getCredentials}
|
|
197
|
+
* @method findCredentials - {@link AskarVault.findCredentials}
|
|
198
|
+
* @method closeVault - {@link AskarVault.closeVault}
|
|
199
|
+
*/
|
|
200
|
+
export declare class AskarVault {
|
|
201
|
+
constructor(storage: AskarStorage, profile: string)
|
|
202
|
+
/**
|
|
203
|
+
* Stores the {@link Credential} in {@link Vault}.
|
|
204
|
+
*
|
|
205
|
+
* @param {Credential} credential - the {@link Credential} to store
|
|
206
|
+
* @param {CredentialMetadata} metadata - the corresponding {@link CredentialMetadata}
|
|
207
|
+
*
|
|
208
|
+
* @returns {string} An `ID` of the stored `credential` on success
|
|
209
|
+
*/
|
|
210
|
+
storeCredential(credential: Credential, metadata: CredentialMetadata): Promise<string>
|
|
211
|
+
/**
|
|
212
|
+
* Get a {@link CredentialEntry} with {@link Credential} from {@link Vault}
|
|
213
|
+
*
|
|
214
|
+
* @param {string} id - `ID` of the stored {@link CredentialEntry}
|
|
215
|
+
*
|
|
216
|
+
* @returns {CredentialEntry | null}
|
|
217
|
+
* * {@link CredentialEntry} on success
|
|
218
|
+
* * `null` if no {@link CredentialEntry} was found by `id`
|
|
219
|
+
*/
|
|
220
|
+
getCredential(id: string): Promise<CredentialEntry | null>
|
|
221
|
+
/**
|
|
222
|
+
* List all {@link CredentialEntry}s in {@link Vault}
|
|
223
|
+
*
|
|
224
|
+
* @returns {Array<CredentialEntry>}
|
|
225
|
+
* * An array of {@link CredentialEntry} on success
|
|
226
|
+
* * Empty array if there are no entries
|
|
227
|
+
*/
|
|
228
|
+
getCredentials(pagination?: InnerVaultPagination | undefined | null): Promise<Array<CredentialEntry>>
|
|
229
|
+
getWithOptions(fields: Array<string>, options: AskarVaultFetchOptions): Promise<Array<CredentialEntry>>
|
|
230
|
+
/**
|
|
231
|
+
* Delete a {@link CredentialEntry} with {@link Credential} from {@link Vault}
|
|
232
|
+
*
|
|
233
|
+
* @param {string} id - `ID` of the stored {@link CredentialEntry}
|
|
234
|
+
*
|
|
235
|
+
* @returns {void}
|
|
236
|
+
*/
|
|
237
|
+
deleteCredential(id: string): Promise<void>
|
|
238
|
+
/**
|
|
239
|
+
* Find the matching {@link CredentialEntry}s in {@link Vault}
|
|
240
|
+
*
|
|
241
|
+
* @param {Array<string>} fields - an array of fields to search for credentials.
|
|
242
|
+
*
|
|
243
|
+
* @returns {Array<CredentialEntry>}
|
|
244
|
+
* * An array of {@link CredentialEntry} matched the provided `fields` on success
|
|
245
|
+
* * An empty array if nothing meets the `fields`
|
|
246
|
+
*/
|
|
247
|
+
findCredentials(fields: Array<string>, pagination?: InnerVaultPagination | undefined | null): Promise<Array<CredentialEntry>>
|
|
248
|
+
/**
|
|
249
|
+
* Counts all credentials in the vault, optionally filtered by category
|
|
250
|
+
*
|
|
251
|
+
* @param {string} category - Optional category to filter credentials by
|
|
252
|
+
*
|
|
253
|
+
* @returns {number} Total number of credentials matching the criteria
|
|
254
|
+
* * Returns total count of all credentials if no category specified
|
|
255
|
+
* * Returns count of credentials matching the category if specified
|
|
256
|
+
*/
|
|
257
|
+
countAll(category?: string | undefined | null): Promise<number>
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* `Askar Storage`
|
|
261
|
+
*
|
|
262
|
+
* A wrapper around the native Askar storage functionality.
|
|
263
|
+
*
|
|
264
|
+
* Provides methods for creating, opening, and managing storage instances
|
|
265
|
+
* and profiles for secure credential storage.
|
|
266
|
+
*
|
|
267
|
+
* @method create - {@link AskarStorage.create}
|
|
268
|
+
* @method open - {@link AskarStorage.open}
|
|
269
|
+
* @method remove - {@link AskarStorage.remove}
|
|
270
|
+
* @method close - {@link AskarStorage.close}
|
|
271
|
+
* @method ensure_profile - {@link AskarStorage.ensure_profile}
|
|
272
|
+
* @method get_active_profile - {@link AskarStorage.get_active_profile}
|
|
273
|
+
* @method change_active_profile - {@link AskarStorage.change_active_profile}
|
|
274
|
+
* @method remove_profile - {@link AskarStorage.remove_profile}
|
|
275
|
+
*/
|
|
276
|
+
export declare class AskarStorage {
|
|
277
|
+
/**
|
|
278
|
+
* Provision a new store instance using a config
|
|
279
|
+
*
|
|
280
|
+
* Creates and initializes a new Askar storage instance with the provided configuration.
|
|
281
|
+
*
|
|
282
|
+
* @param config - Configuration for the storage instance {@link AskarStorageConfig}
|
|
283
|
+
* @param recreate - If true, recreates the storage if it already exists
|
|
284
|
+
* @returns A new AskarStorage instance
|
|
285
|
+
*/
|
|
286
|
+
static create(config: AskarStorageConfig, recreate: boolean): Promise<AskarStorage>
|
|
287
|
+
/**
|
|
288
|
+
* Open a store instance by using a config
|
|
289
|
+
*
|
|
290
|
+
* Opens an existing Askar storage instance with the provided configuration.
|
|
291
|
+
*
|
|
292
|
+
* @param config - Configuration for the storage instance {@link AskarStorageConfig}
|
|
293
|
+
* @returns An opened AskarStorage instance
|
|
294
|
+
*/
|
|
295
|
+
static open(config: AskarStorageConfig): Promise<AskarStorage>
|
|
296
|
+
/**
|
|
297
|
+
* Remove a store instance using a database URL
|
|
298
|
+
*
|
|
299
|
+
* Deletes an Askar storage instance at the specified location.
|
|
300
|
+
*
|
|
301
|
+
* @param db_url - Database URL pointing to the storage location
|
|
302
|
+
* @returns Boolean indicating whether the storage was successfully removed
|
|
303
|
+
*/
|
|
304
|
+
static remove(dbUrl: string): Promise<boolean>
|
|
305
|
+
/**
|
|
306
|
+
* Close the store instance, waiting for any shutdown procedures to complete.
|
|
307
|
+
*
|
|
308
|
+
* Safely closes the storage instance and releases any resources.
|
|
309
|
+
* This operation is unsafe as it may affect other references to the storage.
|
|
310
|
+
*
|
|
311
|
+
* @returns void if successful
|
|
312
|
+
*/
|
|
313
|
+
close(): Promise<void>
|
|
314
|
+
/**
|
|
315
|
+
* Ensure a profile with the given name exists
|
|
316
|
+
*
|
|
317
|
+
* Creates the namespace within the storage for organizing credentials, or
|
|
318
|
+
* returns the existing one if a profile of that name is already present.
|
|
319
|
+
*
|
|
320
|
+
* @param profile - Name of the profile to ensure
|
|
321
|
+
* @returns The name of the profile
|
|
322
|
+
*/
|
|
323
|
+
ensureProfile(profile: string): Promise<string>
|
|
324
|
+
/**
|
|
325
|
+
* Create an active profile to store instance
|
|
326
|
+
*
|
|
327
|
+
* Retrieves the name of the currently active profile.
|
|
328
|
+
*
|
|
329
|
+
* @returns Name of the active profile
|
|
330
|
+
*/
|
|
331
|
+
getActiveProfile(): string
|
|
332
|
+
/**
|
|
333
|
+
* Change an active profile against store instance
|
|
334
|
+
*
|
|
335
|
+
* Switches the active profile to a different existing profile.
|
|
336
|
+
* This operation is unsafe as it may affect other references to the storage.
|
|
337
|
+
*
|
|
338
|
+
* @param profile - Name of the profile to switch to
|
|
339
|
+
* @returns Nothing if successful
|
|
340
|
+
*/
|
|
341
|
+
changeActiveProfile(profile: string): Promise<void>
|
|
342
|
+
/**
|
|
343
|
+
* Remove an existing profile with the given profile name
|
|
344
|
+
*
|
|
345
|
+
* Deletes a profile and all associated data from the storage.
|
|
346
|
+
*
|
|
347
|
+
* @param profile - Name of the profile to remove
|
|
348
|
+
* @returns Boolean indicating whether the profile was successfully removed
|
|
349
|
+
*/
|
|
350
|
+
removeProfile(profile: string): Promise<boolean>
|
|
351
|
+
}
|
package/binary.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
15
|
+
|
|
16
|
+
function isMusl() {
|
|
17
|
+
// For Node 10
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
+
try {
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'equs-credentials-sdk-askar-storage.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'equs-credentials-sdk-askar-storage.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'equs-credentials-sdk-askar-storage.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'equs-credentials-sdk-askar-storage.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-darwin-arm64')
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e
|
|
145
|
+
}
|
|
146
|
+
break
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'equs-credentials-sdk-askar-storage.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
167
|
+
switch (arch) {
|
|
168
|
+
case 'x64':
|
|
169
|
+
if (isMusl()) {
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-x64-gnu')
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadError = e
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
198
|
+
if (isMusl()) {
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-arm64-gnu')
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadError = e
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
if (isMusl()) {
|
|
228
|
+
localFileExisted = existsSync(
|
|
229
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-arm-musleabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-arm-musleabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-arm-musleabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
localFileExisted = existsSync(
|
|
242
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-arm-gnueabihf.node')
|
|
243
|
+
)
|
|
244
|
+
try {
|
|
245
|
+
if (localFileExisted) {
|
|
246
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-arm-gnueabihf.node')
|
|
247
|
+
} else {
|
|
248
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-arm-gnueabihf')
|
|
249
|
+
}
|
|
250
|
+
} catch (e) {
|
|
251
|
+
loadError = e
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break
|
|
255
|
+
case 'riscv64':
|
|
256
|
+
if (isMusl()) {
|
|
257
|
+
localFileExisted = existsSync(
|
|
258
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-riscv64-musl.node')
|
|
259
|
+
)
|
|
260
|
+
try {
|
|
261
|
+
if (localFileExisted) {
|
|
262
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-riscv64-musl.node')
|
|
263
|
+
} else {
|
|
264
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-riscv64-musl')
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadError = e
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-riscv64-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-riscv64-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-riscv64-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break
|
|
284
|
+
case 's390x':
|
|
285
|
+
localFileExisted = existsSync(
|
|
286
|
+
join(__dirname, 'equs-credentials-sdk-askar-storage.linux-s390x-gnu.node')
|
|
287
|
+
)
|
|
288
|
+
try {
|
|
289
|
+
if (localFileExisted) {
|
|
290
|
+
nativeBinding = require('./equs-credentials-sdk-askar-storage.linux-s390x-gnu.node')
|
|
291
|
+
} else {
|
|
292
|
+
nativeBinding = require('@equs-ai/equs-credentials-sdk-askar-storage-linux-s390x-gnu')
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadError = e
|
|
296
|
+
}
|
|
297
|
+
break
|
|
298
|
+
default:
|
|
299
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
300
|
+
}
|
|
301
|
+
break
|
|
302
|
+
default:
|
|
303
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!nativeBinding) {
|
|
307
|
+
if (loadError) {
|
|
308
|
+
throw loadError
|
|
309
|
+
}
|
|
310
|
+
throw new Error(`Failed to load native binding`)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const { AskarKms, AskarKeyHandle, AskarVault, InnerVCFormat, AskarVaultSortBy, AskarVaultParamsSortOrder, AskarStorage, KeyMethod } = nativeBinding
|
|
314
|
+
|
|
315
|
+
module.exports.AskarKms = AskarKms
|
|
316
|
+
module.exports.AskarKeyHandle = AskarKeyHandle
|
|
317
|
+
module.exports.AskarVault = AskarVault
|
|
318
|
+
module.exports.InnerVCFormat = InnerVCFormat
|
|
319
|
+
module.exports.AskarVaultSortBy = AskarVaultSortBy
|
|
320
|
+
module.exports.AskarVaultParamsSortOrder = AskarVaultParamsSortOrder
|
|
321
|
+
module.exports.AskarStorage = AskarStorage
|
|
322
|
+
module.exports.KeyMethod = KeyMethod
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./binary";
|
package/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./binary"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@equs-ai/equs-credentials-sdk-askar-storage",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"napi": {
|
|
7
|
+
"name": "equs-credentials-sdk-askar-storage",
|
|
8
|
+
"triples": {
|
|
9
|
+
"defaults": false,
|
|
10
|
+
"additional": [
|
|
11
|
+
"aarch64-apple-darwin",
|
|
12
|
+
"x86_64-apple-darwin",
|
|
13
|
+
"x86_64-unknown-linux-gnu"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"ava": {
|
|
19
|
+
"timeout": "3m"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">= 10"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"manual_scripts": "node scripts/add-import-line.mjs",
|
|
26
|
+
"build": "CARGO_TARGET_DIR=../../target napi build --platform --release --js binary.js --dts binary.d.ts && npm run manual_scripts && rm -rf build/ && tsc",
|
|
27
|
+
"artifacts": "napi artifacts",
|
|
28
|
+
"test": "jest -w=1",
|
|
29
|
+
"universal": "napi universal",
|
|
30
|
+
"version": "napi version"
|
|
31
|
+
},
|
|
32
|
+
"packageManager": "yarn@4.6.0",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@napi-rs/cli": "^2.18.4",
|
|
35
|
+
"oauth4webapi": "^3.1.4",
|
|
36
|
+
"@equs-ai/equs-credentials-sdk": "../../../../wrappers/nodejs",
|
|
37
|
+
"jwt-decode": "^4.0.0",
|
|
38
|
+
"@types/base-64": "^1.0.2",
|
|
39
|
+
"@types/jest": "^29.5.13",
|
|
40
|
+
"@types/node-jose": "^1.1.13",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
42
|
+
"@typescript-eslint/parser": "^7.4.0",
|
|
43
|
+
"base-64": "^1.0.0",
|
|
44
|
+
"eslint": "^8.57.0",
|
|
45
|
+
"eslint-config-prettier": "^9.1.0",
|
|
46
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
47
|
+
"jest": "^29.7.0",
|
|
48
|
+
"jest-cli": "^29.7.0",
|
|
49
|
+
"mockttp": "^3.15.3",
|
|
50
|
+
"node-jose": "^2.2.0",
|
|
51
|
+
"prettier": "^3.2.5",
|
|
52
|
+
"reflect-metadata": "^0.2.1",
|
|
53
|
+
"source-map-support": "^0.5.21",
|
|
54
|
+
"ts-jest": "^29.1.2",
|
|
55
|
+
"ts-node": "^10.9.2",
|
|
56
|
+
"tsconfig-paths": "^4.2.0",
|
|
57
|
+
"typescript": "^5.6.3"
|
|
58
|
+
},
|
|
59
|
+
"optionalDependencies": {
|
|
60
|
+
"@equs-ai/equs-credentials-sdk-askar-storage-darwin-arm64": "1.0.1",
|
|
61
|
+
"@equs-ai/equs-credentials-sdk-askar-storage-darwin-x64": "1.0.1",
|
|
62
|
+
"@equs-ai/equs-credentials-sdk-askar-storage-linux-x64-gnu": "1.0.1"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"ESNext"
|
|
5
|
+
],
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"removeComments": true,
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
10
|
+
"experimentalDecorators": true,
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"emitDeclarationOnly": false,
|
|
13
|
+
"target": "ESNext",
|
|
14
|
+
"outDir": ".",
|
|
15
|
+
"baseUrl": "./"
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"index.ts"
|
|
19
|
+
],
|
|
20
|
+
"exclude": [
|
|
21
|
+
"node_modules"
|
|
22
|
+
]
|
|
23
|
+
}
|