From 75bffcae9bb50a4755d01bb4131487b2eecfa731 Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Sat, 12 Aug 2023 17:38:42 -0300 Subject: [PATCH 1/5] fix(js): remove tailsPath from revocation config Signed-off-by: Ariel Gentile --- wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts | 2 -- wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts | 1 - wrappers/javascript/anoncreds-nodejs/test/api.test.ts | 2 -- wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts | 2 -- .../javascript/anoncreds-react-native/src/NativeBindings.ts | 1 - .../anoncreds-react-native/src/ReactNativeAnoncreds.ts | 1 - wrappers/javascript/anoncreds-shared/src/Anoncreds.ts | 1 - .../anoncreds-shared/src/api/CredentialRevocationConfig.ts | 4 ---- 8 files changed, 14 deletions(-) diff --git a/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts b/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts index 6e9965fd..bbc99e64 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts @@ -179,14 +179,12 @@ export class NodeJSAnoncreds implements Anoncreds { revocationRegistryDefinition: registryDefinition, revocationRegistryDefinitionPrivate: registryDefinitionPrivate, registryIndex, - tailsPath, } = serializeArguments(options.revocationConfiguration) revocationConfiguration = CredRevInfoStruct({ reg_def: registryDefinition, reg_def_private: registryDefinitionPrivate, reg_idx: registryIndex, - tails_path: tailsPath, }) } diff --git a/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts b/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts index e5a0bd63..43890359 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts @@ -51,7 +51,6 @@ export const CredRevInfoStruct = CStruct({ reg_def: FFI_OBJECT_HANDLE, reg_def_private: FFI_OBJECT_HANDLE, reg_idx: FFI_INT64, - tails_path: FFI_STRING, }) export const CredentialEntryStruct = CStruct({ diff --git a/wrappers/javascript/anoncreds-nodejs/test/api.test.ts b/wrappers/javascript/anoncreds-nodejs/test/api.test.ts index 22f102d6..417e5bc9 100644 --- a/wrappers/javascript/anoncreds-nodejs/test/api.test.ts +++ b/wrappers/javascript/anoncreds-nodejs/test/api.test.ts @@ -114,7 +114,6 @@ describe('API', () => { registryDefinition: revocationRegistryDefinition, registryDefinitionPrivate: revocationRegistryDefinitionPrivate, registryIndex: 9, - tailsPath, }), }) @@ -434,7 +433,6 @@ test('create and verify presentation passing only JSON objects as parameters', ( registryDefinition: revocationRegistryDefinition, registryDefinitionPrivate: revocationRegistryDefinitionPrivate, registryIndex: 9, - tailsPath, }), }) diff --git a/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts b/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts index 0fd1f819..a23b0e38 100644 --- a/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts +++ b/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts @@ -297,7 +297,6 @@ describe('bindings', () => { revocationRegistryDefinition, revocationRegistryDefinitionPrivate, registryIndex: 9, - tailsPath, }, }) @@ -434,7 +433,6 @@ describe('bindings', () => { revocationRegistryDefinition, revocationRegistryDefinitionPrivate, registryIndex: 9, - tailsPath, }, }) diff --git a/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts b/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts index e8d7b4f0..846f4a17 100644 --- a/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts +++ b/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts @@ -61,7 +61,6 @@ export interface NativeBindings { registryIndex: number revocationRegistryDefinition: number revocationRegistryDefinitionPrivate: number - tailsPath: string } }): ReturnObject encodeCredentialAttributes(options: { attributeRawValues: Array }): ReturnObject diff --git a/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts b/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts index 13d2aaeb..e87ce48e 100644 --- a/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts +++ b/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts @@ -138,7 +138,6 @@ export class ReactNativeAnoncreds implements Anoncreds { revocationRegistryDefinition: options.revocationConfiguration.revocationRegistryDefinition.handle, revocationRegistryDefinitionPrivate: options.revocationConfiguration.revocationRegistryDefinitionPrivate.handle, - tailsPath: options.revocationConfiguration.tailsPath, } : undefined, }) diff --git a/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts b/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts index e3d89322..e0042bc8 100644 --- a/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts +++ b/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts @@ -32,7 +32,6 @@ export type NativeCredentialRevocationConfig = { revocationRegistryDefinition: ObjectHandle revocationRegistryDefinitionPrivate: ObjectHandle registryIndex: number - tailsPath: string } export interface Anoncreds { diff --git a/wrappers/javascript/anoncreds-shared/src/api/CredentialRevocationConfig.ts b/wrappers/javascript/anoncreds-shared/src/api/CredentialRevocationConfig.ts index cc90539d..70914762 100644 --- a/wrappers/javascript/anoncreds-shared/src/api/CredentialRevocationConfig.ts +++ b/wrappers/javascript/anoncreds-shared/src/api/CredentialRevocationConfig.ts @@ -6,20 +6,17 @@ export type CredentialRevocationConfigOptions = { registryDefinition: RevocationRegistryDefinition registryDefinitionPrivate: RevocationRegistryDefinitionPrivate registryIndex: number - tailsPath: string } export class CredentialRevocationConfig { private registryDefinition: RevocationRegistryDefinition private registryDefinitionPrivate: RevocationRegistryDefinitionPrivate private registryIndex: number - private tailsPath: string public constructor(options: CredentialRevocationConfigOptions) { this.registryDefinition = options.registryDefinition this.registryDefinitionPrivate = options.registryDefinitionPrivate this.registryIndex = options.registryIndex - this.tailsPath = options.tailsPath } public clear() { @@ -32,7 +29,6 @@ export class CredentialRevocationConfig { revocationRegistryDefinition: this.registryDefinition.handle, revocationRegistryDefinitionPrivate: this.registryDefinitionPrivate.handle, registryIndex: this.registryIndex, - tailsPath: this.tailsPath, } } } From 25bf545a1373de2a1d51a82b2db3ab157659eab0 Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Sat, 12 Aug 2023 18:13:38 -0300 Subject: [PATCH 2/5] fix(js): update react-native bindings for #226 Signed-off-by: Ariel Gentile --- include/README.md | 22 ++++++++++++----- include/libanoncreds.h | 20 +++++++++------- .../anoncreds-nodejs/test/api.test.ts | 8 +++++-- .../anoncreds-react-native/cpp/anoncreds.cpp | 24 +++++++++++++------ .../cpp/include/libanoncreds.h | 20 +++++++++------- .../src/NativeBindings.ts | 10 +++++--- .../src/ReactNativeAnoncreds.ts | 10 +++++--- .../anoncreds-shared/src/Anoncreds.ts | 8 ++++--- .../src/api/RevocationStatusList.ts | 19 ++++++++++++++- 9 files changed, 100 insertions(+), 41 deletions(-) diff --git a/include/README.md b/include/README.md index 5eec24d1..51443d61 100644 --- a/include/README.md +++ b/include/README.md @@ -1,22 +1,32 @@ _Generating the C header:_ -1. Install [cbindgen](https://github.com/eqrion/cbindgen/) -1. Install [cargo expand](https://github.com/dtolnay/cargo-expand) -1. use `nightly` and not `stable - - `rustup default nightly` +1. use `nightly` instead of `stable` + +```sh +rustup default nightly +``` +> **Note**: If you run into _'unknown feature'_ issues by using latest nightly, force it to 1.72.0 by executing: `rustup default nightly-2023-06-15` + +2. Install [cbindgen](https://github.com/eqrion/cbindgen/) ```sh cargo install cbindgen ``` -Generate the header file: +3. Install [cargo expand](https://github.com/dtolnay/cargo-expand) + +```sh +cargo install cargo-expand +``` + +4. Generate the header file: ```sh cbindgen --config include/cbindgen.toml --crate anoncreds --output include/libanoncreds.h ``` -Copy to React Native: +5. Copy to React Native: ```sh cp include/libanoncreds.h wrappers/javascript/anoncreds-react-native/cpp/include/ diff --git a/include/libanoncreds.h b/include/libanoncreds.h index 0df8f61d..68a1626b 100644 --- a/include/libanoncreds.h +++ b/include/libanoncreds.h @@ -1,6 +1,6 @@ #pragma once -/* Generated with cbindgen:0.24.3 */ +/* Generated with cbindgen:0.24.5 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -317,7 +317,7 @@ ErrorCode anoncreds_create_presentation(ObjectHandle pres_req, ErrorCode anoncreds_create_revocation_registry_def(ObjectHandle cred_def, FfiStr cred_def_id, - FfiStr issuer_id, + FfiStr _issuer_id, FfiStr tag, FfiStr rev_reg_type, int64_t max_cred_num, @@ -325,11 +325,13 @@ ErrorCode anoncreds_create_revocation_registry_def(ObjectHandle cred_def, ObjectHandle *reg_def_p, ObjectHandle *reg_def_private_p); -ErrorCode anoncreds_create_revocation_status_list(FfiStr rev_reg_def_id, +ErrorCode anoncreds_create_revocation_status_list(ObjectHandle cred_def, + FfiStr rev_reg_def_id, ObjectHandle rev_reg_def, - FfiStr issuer_id, - int64_t timestamp, + ObjectHandle reg_rev_priv, + FfiStr _issuer_id, int8_t issuance_by_default, + int64_t timestamp, ObjectHandle *rev_status_list_p); ErrorCode anoncreds_create_schema(FfiStr schema_name, @@ -415,11 +417,13 @@ ErrorCode anoncreds_set_default_logger(void); */ void anoncreds_string_free(char *s); -ErrorCode anoncreds_update_revocation_status_list(int64_t timestamp, - struct FfiList_i32 issued, - struct FfiList_i32 revoked, +ErrorCode anoncreds_update_revocation_status_list(ObjectHandle cred_def, ObjectHandle rev_reg_def, + ObjectHandle rev_reg_priv, ObjectHandle rev_current_list, + struct FfiList_i32 issued, + struct FfiList_i32 revoked, + int64_t timestamp, ObjectHandle *new_rev_status_list_p); ErrorCode anoncreds_update_revocation_status_list_timestamp_only(int64_t timestamp, diff --git a/wrappers/javascript/anoncreds-nodejs/test/api.test.ts b/wrappers/javascript/anoncreds-nodejs/test/api.test.ts index 417e5bc9..a5a91557 100644 --- a/wrappers/javascript/anoncreds-nodejs/test/api.test.ts +++ b/wrappers/javascript/anoncreds-nodejs/test/api.test.ts @@ -390,8 +390,6 @@ test('create and verify presentation passing only JSON objects as parameters', ( maximumCredentialNumber: 10, }) - const tailsPath = revocationRegistryDefinition.getTailsLocation() - const timeCreateRevStatusList = 12 const revocationStatusList = RevocationStatusList.create({ credentialDefinition, @@ -403,6 +401,12 @@ test('create and verify presentation passing only JSON objects as parameters', ( timestamp: timeCreateRevStatusList, }) + revocationStatusList.update({ + credentialDefinition, + revocationRegistryDefinition, + revocationRegistryDefinitionPrivate, + revoked: [1], + }) const credentialOffer = CredentialOffer.fromJson({ schema_id: 'mock:uri', cred_def_id: 'mock:uri', diff --git a/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp b/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp index 76c88b2f..27cb626b 100644 --- a/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp +++ b/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp @@ -592,37 +592,47 @@ jsi::Value createOrUpdateRevocationState(jsi::Runtime &rt, }; jsi::Value createRevocationStatusList(jsi::Runtime &rt, jsi::Object options) { + auto credentialDefinition = + jsiToValue(rt, options, "credentialDefinition"); auto revocationRegistryDefinitionId = jsiToValue(rt, options, "revocationRegistryDefinitionId"); - auto issuerId = jsiToValue(rt, options, "issuerId"); auto revocationRegistryDefinition = jsiToValue(rt, options, "revocationRegistryDefinition"); + auto revocationRegistryDefinitionPrivate = + jsiToValue(rt, options, "revocationRegistryDefinitionPrivate"); + auto issuerId = jsiToValue(rt, options, "issuerId"); auto timestamp = jsiToValue(rt, options, "timestamp"); auto issuanceByDefault = jsiToValue(rt, options, "issuanceByDefault"); ObjectHandle out; ErrorCode code = anoncreds_create_revocation_status_list( - revocationRegistryDefinitionId.c_str(), revocationRegistryDefinition, + credentialDefinition, revocationRegistryDefinitionId.c_str(), + revocationRegistryDefinition, revocationRegistryDefinitionPrivate, issuerId.c_str(), timestamp, issuanceByDefault, &out); return createReturnValue(rt, code, &out); } jsi::Value updateRevocationStatusList(jsi::Runtime &rt, jsi::Object options) { - auto timestamp = jsiToValue(rt, options, "timestamp"); - auto issued = jsiToValue(rt, options, "issued"); - auto revoked = jsiToValue(rt, options, "revoked"); + auto credentialDefinition = + jsiToValue(rt, options, "credentialDefinition"); auto revocationRegistryDefinition = jsiToValue(rt, options, "revocationRegistryDefinition"); + auto revocationRegistryDefinitionPrivate = + jsiToValue(rt, options, "revocationRegistryDefinitionPrivate"); auto revocationStatusList = jsiToValue(rt, options, "revocationStatusList"); + auto issued = jsiToValue(rt, options, "issued"); + auto revoked = jsiToValue(rt, options, "revoked"); + auto timestamp = jsiToValue(rt, options, "timestamp"); ObjectHandle out; ErrorCode code = anoncreds_update_revocation_status_list( - timestamp, issued, revoked, revocationRegistryDefinition, - revocationStatusList, &out); + credentialDefinition, revocationRegistryDefinition, + revocationRegistryDefinitionPrivate, revocationStatusList, + issued, revoked, timestamp, &out); return createReturnValue(rt, code, &out); } diff --git a/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h b/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h index 0df8f61d..68a1626b 100644 --- a/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h +++ b/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h @@ -1,6 +1,6 @@ #pragma once -/* Generated with cbindgen:0.24.3 */ +/* Generated with cbindgen:0.24.5 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -317,7 +317,7 @@ ErrorCode anoncreds_create_presentation(ObjectHandle pres_req, ErrorCode anoncreds_create_revocation_registry_def(ObjectHandle cred_def, FfiStr cred_def_id, - FfiStr issuer_id, + FfiStr _issuer_id, FfiStr tag, FfiStr rev_reg_type, int64_t max_cred_num, @@ -325,11 +325,13 @@ ErrorCode anoncreds_create_revocation_registry_def(ObjectHandle cred_def, ObjectHandle *reg_def_p, ObjectHandle *reg_def_private_p); -ErrorCode anoncreds_create_revocation_status_list(FfiStr rev_reg_def_id, +ErrorCode anoncreds_create_revocation_status_list(ObjectHandle cred_def, + FfiStr rev_reg_def_id, ObjectHandle rev_reg_def, - FfiStr issuer_id, - int64_t timestamp, + ObjectHandle reg_rev_priv, + FfiStr _issuer_id, int8_t issuance_by_default, + int64_t timestamp, ObjectHandle *rev_status_list_p); ErrorCode anoncreds_create_schema(FfiStr schema_name, @@ -415,11 +417,13 @@ ErrorCode anoncreds_set_default_logger(void); */ void anoncreds_string_free(char *s); -ErrorCode anoncreds_update_revocation_status_list(int64_t timestamp, - struct FfiList_i32 issued, - struct FfiList_i32 revoked, +ErrorCode anoncreds_update_revocation_status_list(ObjectHandle cred_def, ObjectHandle rev_reg_def, + ObjectHandle rev_reg_priv, ObjectHandle rev_current_list, + struct FfiList_i32 issued, + struct FfiList_i32 revoked, + int64_t timestamp, ObjectHandle *new_rev_status_list_p); ErrorCode anoncreds_update_revocation_status_list_timestamp_only(int64_t timestamp, diff --git a/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts b/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts index 846f4a17..53a8c319 100644 --- a/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts +++ b/wrappers/javascript/anoncreds-react-native/src/NativeBindings.ts @@ -18,19 +18,23 @@ export interface NativeBindings { }): ReturnObject createRevocationStatusList(options: { + credentialDefinition: Handle revocationRegistryDefinitionId: string revocationRegistryDefinition: Handle + revocationRegistryDefinitionPrivate: Handle issuerId: string timestamp?: number issuanceByDefault: number }): ReturnObject updateRevocationStatusList(options: { - timestamp?: number - issued?: number[] - revoked?: number[] + credentialDefinition: Handle revocationRegistryDefinition: Handle + revocationRegistryDefinitionPrivate: Handle currentRevocationStatusList: Handle + issued?: number[] + revoked?: number[] + timestamp?: number }): ReturnObject updateRevocationStatusListTimestampOnly(options: { diff --git a/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts b/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts index e87ce48e..9eb8152a 100644 --- a/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts +++ b/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts @@ -29,8 +29,10 @@ export class ReactNativeAnoncreds implements Anoncreds { } public createRevocationStatusList(options: { + credentialDefinition: ObjectHandle revocationRegistryDefinitionId: string revocationRegistryDefinition: ObjectHandle + revocationRegistryDefinitionPrivate: ObjectHandle issuerId: string timestamp?: number issuanceByDefault: boolean @@ -50,11 +52,13 @@ export class ReactNativeAnoncreds implements Anoncreds { } public updateRevocationStatusList(options: { - timestamp?: number - issued?: number[] - revoked?: number[] + credentialDefinition: ObjectHandle revocationRegistryDefinition: ObjectHandle + revocationRegistryDefinitionPrivate: ObjectHandle currentRevocationStatusList: ObjectHandle + issued?: number[] + revoked?: number[] + timestamp?: number }): ObjectHandle { const handle = this.handleError(this.anoncreds.updateRevocationStatusList(serializeArguments(options))) return new ObjectHandle(handle) diff --git a/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts b/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts index e0042bc8..dbb40e27 100644 --- a/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts +++ b/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts @@ -157,11 +157,13 @@ export interface Anoncreds { }): ObjectHandle updateRevocationStatusList(options: { - timestamp?: number - issued?: Array - revoked?: Array + credentialDefinition: ObjectHandle revocationRegistryDefinition: ObjectHandle + revocationRegistryDefinitionPrivate: ObjectHandle currentRevocationStatusList: ObjectHandle + issued?: Array + revoked?: Array + timestamp?: number }): ObjectHandle credentialGetAttribute(options: { objectHandle: ObjectHandle; name: string }): string diff --git a/wrappers/javascript/anoncreds-shared/src/api/RevocationStatusList.ts b/wrappers/javascript/anoncreds-shared/src/api/RevocationStatusList.ts index d51dd853..d57119b3 100644 --- a/wrappers/javascript/anoncreds-shared/src/api/RevocationStatusList.ts +++ b/wrappers/javascript/anoncreds-shared/src/api/RevocationStatusList.ts @@ -24,10 +24,12 @@ export type UpdateRevocationStatusListTimestampOptions = { } export type UpdateRevocationStatusListOptions = { + credentialDefinition: CredentialDefinition | JsonObject revocationRegistryDefinition: RevocationRegistryDefinition | JsonObject - timestamp?: number + revocationRegistryDefinitionPrivate: RevocationRegistryDefinitionPrivate | JsonObject issued?: Array revoked?: Array + timestamp?: number } export class RevocationStatusList extends AnoncredsObject { @@ -84,6 +86,11 @@ export class RevocationStatusList extends AnoncredsObject { public update(options: UpdateRevocationStatusListOptions) { const objectHandles: ObjectHandle[] = [] try { + const credentialDefinition = + options.credentialDefinition instanceof CredentialDefinition + ? options.credentialDefinition.handle + : pushToArray(CredentialDefinition.fromJson(options.credentialDefinition).handle, objectHandles) + const revocationRegistryDefinition = options.revocationRegistryDefinition instanceof RevocationRegistryDefinition ? options.revocationRegistryDefinition.handle @@ -92,9 +99,19 @@ export class RevocationStatusList extends AnoncredsObject { objectHandles ) + const revocationRegistryDefinitionPrivate = + options.revocationRegistryDefinitionPrivate instanceof RevocationRegistryDefinitionPrivate + ? options.revocationRegistryDefinitionPrivate.handle + : pushToArray( + RevocationRegistryDefinitionPrivate.fromJson(options.revocationRegistryDefinitionPrivate).handle, + objectHandles + ) + const updatedRevocationStatusList = anoncreds.updateRevocationStatusList({ ...options, + credentialDefinition, revocationRegistryDefinition, + revocationRegistryDefinitionPrivate, currentRevocationStatusList: this.handle, }) From 44b7a5803290b3434c2e6e306637ed6fd1b05625 Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Sat, 12 Aug 2023 18:14:46 -0300 Subject: [PATCH 3/5] build(js): update required node engine to 18 Signed-off-by: Ariel Gentile --- .github/workflows/build.yml | 4 ++-- wrappers/javascript/package.json | 5 ++++- wrappers/javascript/yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b9848a0..62b589d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,10 +204,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set up Node.JS 16.x + - name: Set up Node.JS 18.x uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 18.x - name: Fetch library artifacts uses: actions/download-artifact@v3 diff --git a/wrappers/javascript/package.json b/wrappers/javascript/package.json index a44dde05..1797662a 100644 --- a/wrappers/javascript/package.json +++ b/wrappers/javascript/package.json @@ -55,7 +55,10 @@ "tsconfig-paths": "4.1.0", "typescript": "4.5.5" }, + "resolutions": { + "ref-napi": "npm:@2060.io/ref-napi" + }, "engines": { - "node": ">= 12" + "node": ">= 18" } } diff --git a/wrappers/javascript/yarn.lock b/wrappers/javascript/yarn.lock index 73772455..f44ee07c 100644 --- a/wrappers/javascript/yarn.lock +++ b/wrappers/javascript/yarn.lock @@ -8929,10 +8929,10 @@ ref-array-di@1.2.2: array-index "^1.0.0" debug "^3.1.0" -ref-napi@3.0.3, "ref-napi@^2.0.1 || ^3.0.2": - version "3.0.3" - resolved "https://registry.yarnpkg.com/ref-napi/-/ref-napi-3.0.3.tgz#e259bfc2bbafb3e169e8cd9ba49037dd00396b22" - integrity sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA== +ref-napi@3.0.3, "ref-napi@^2.0.1 || ^3.0.2", "ref-napi@npm:@2060.io/ref-napi": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@2060.io/ref-napi/-/ref-napi-3.0.4.tgz#6a78093b36e8f4ffeb750f706433869382e73eb1" + integrity sha512-Aqf699E+DKs2xANx8bSkuzXyG9gcZ2iFkAk1kUTA8KbV5BSPQtIcBJexzohSRi9QWDhP4X54NLm7xwGA0UNCdQ== dependencies: debug "^4.1.1" get-symbol-from-current-process-h "^1.0.2" From 0e4865a6d811c6070ffd16159f4609fbc13f1389 Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Sun, 13 Aug 2023 10:17:13 -0300 Subject: [PATCH 4/5] fix(js): use patched ffi-napi and ref-napi for nodejs Signed-off-by: Ariel Gentile --- .../javascript/anoncreds-nodejs/package.json | 7 +- .../anoncreds-nodejs/src/ffi/alloc.ts | 2 +- .../anoncreds-nodejs/src/ffi/conversion.ts | 2 +- .../anoncreds-nodejs/src/ffi/primitives.ts | 2 +- .../anoncreds-nodejs/src/ffi/serialize.ts | 4 +- .../anoncreds-nodejs/src/ffi/structures.ts | 2 +- .../anoncreds-nodejs/src/library/register.ts | 2 +- wrappers/javascript/package.json | 3 - wrappers/javascript/yarn.lock | 77 ++++++++++--------- 9 files changed, 50 insertions(+), 51 deletions(-) diff --git a/wrappers/javascript/anoncreds-nodejs/package.json b/wrappers/javascript/anoncreds-nodejs/package.json index 300daba7..a4db87f2 100644 --- a/wrappers/javascript/anoncreds-nodejs/package.json +++ b/wrappers/javascript/anoncreds-nodejs/package.json @@ -28,14 +28,15 @@ "dependencies": { "@hyperledger/anoncreds-shared": "0.1.0", "@mapbox/node-pre-gyp": "^1.0.10", - "ffi-napi": "4.0.3", + "@2060.io/ffi-napi": "4.0.5", + "@2060.io/ref-napi": "3.0.4", "node-cache": "5.1.2", "ref-array-di": "1.2.2", - "ref-napi": "3.0.3", "ref-struct-di": "1.1.1" }, "devDependencies": { - "@types/ffi-napi": "4.0.5", + "@types/2060.io__ffi-napi": "npm:@types/ffi-napi", + "@types/2060.io__ref-napi": "npm:@types/ref-napi", "@types/node": "17.0.31", "@types/ref-array-di": "1.2.3", "@types/ref-napi": "3.0.7", diff --git a/wrappers/javascript/anoncreds-nodejs/src/ffi/alloc.ts b/wrappers/javascript/anoncreds-nodejs/src/ffi/alloc.ts index f6ab0cfb..0fd05fff 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/ffi/alloc.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/ffi/alloc.ts @@ -1,4 +1,4 @@ -import { alloc } from 'ref-napi' +import { alloc } from '@2060.io/ref-napi' import { FFI_STRING, FFI_OBJECT_HANDLE, FFI_INT8 } from '../ffi/primitives' diff --git a/wrappers/javascript/anoncreds-nodejs/src/ffi/conversion.ts b/wrappers/javascript/anoncreds-nodejs/src/ffi/conversion.ts index 8acf0d8d..57bcc7d1 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/ffi/conversion.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/ffi/conversion.ts @@ -1,4 +1,4 @@ -import { reinterpret } from 'ref-napi' +import { reinterpret } from '@2060.io/ref-napi' export const byteBufferToBuffer = (buffer: { data: Buffer; len: number }) => reinterpret(buffer.data, buffer.len) diff --git a/wrappers/javascript/anoncreds-nodejs/src/ffi/primitives.ts b/wrappers/javascript/anoncreds-nodejs/src/ffi/primitives.ts index 85465b12..4bce9897 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/ffi/primitives.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/ffi/primitives.ts @@ -1,4 +1,4 @@ -import { types, refType } from 'ref-napi' +import { types, refType } from '@2060.io/ref-napi' // Primitives diff --git a/wrappers/javascript/anoncreds-nodejs/src/ffi/serialize.ts b/wrappers/javascript/anoncreds-nodejs/src/ffi/serialize.ts index 31c8e3b8..4c067531 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/ffi/serialize.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/ffi/serialize.ts @@ -1,10 +1,10 @@ import type { ByteBufferStruct } from './structures' +import type { Pointer } from '@2060.io/ref-napi' import type { TypedArray } from 'ref-array-di' -import type { Pointer } from 'ref-napi' import type { StructObject } from 'ref-struct-di' +import { NULL } from '@2060.io/ref-napi' import { ObjectHandle } from '@hyperledger/anoncreds-shared' -import { NULL } from 'ref-napi' import { ObjectHandleListStruct, StringListStruct, I32ListStruct, Int32Array } from './structures' diff --git a/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts b/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts index 43890359..aba0ac3a 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/ffi/structures.ts @@ -1,5 +1,5 @@ +import * as ref from '@2060.io/ref-napi' import RefArray from 'ref-array-di' -import * as ref from 'ref-napi' import RefStruct from 'ref-struct-di' import { FFI_INT64, FFI_INT8, FFI_ISIZE, FFI_OBJECT_HANDLE, FFI_STRING, FFI_INT32 } from './primitives' diff --git a/wrappers/javascript/anoncreds-nodejs/src/library/register.ts b/wrappers/javascript/anoncreds-nodejs/src/library/register.ts index 6aad188c..2fbcb399 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/library/register.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/library/register.ts @@ -1,6 +1,6 @@ import type { NativeMethods } from './NativeBindingInterface' -import { Library } from 'ffi-napi' +import { Library } from '@2060.io/ffi-napi' import fs from 'fs' import os from 'os' import path from 'path' diff --git a/wrappers/javascript/package.json b/wrappers/javascript/package.json index 1797662a..6db8c5a8 100644 --- a/wrappers/javascript/package.json +++ b/wrappers/javascript/package.json @@ -55,9 +55,6 @@ "tsconfig-paths": "4.1.0", "typescript": "4.5.5" }, - "resolutions": { - "ref-napi": "npm:@2060.io/ref-napi" - }, "engines": { "node": ">= 18" } diff --git a/wrappers/javascript/yarn.lock b/wrappers/javascript/yarn.lock index f44ee07c..bd65fa4a 100644 --- a/wrappers/javascript/yarn.lock +++ b/wrappers/javascript/yarn.lock @@ -2,6 +2,28 @@ # yarn lockfile v1 +"@2060.io/ffi-napi@4.0.5": + version "4.0.5" + resolved "https://registry.yarnpkg.com/@2060.io/ffi-napi/-/ffi-napi-4.0.5.tgz#52fd369f25cba85319eb5625e2d598925a1713ce" + integrity sha512-CdV4y/gXYI7yzSiSHWvY/JdW06Li57Gdc3ZKzNesXrCQg4IoHL0S+zIxEr6Mbr0fCNVvj1GNSh8Uz9vSQkCXYA== + dependencies: + "@2060.io/ref-napi" "3.0.4" + debug "^4.1.1" + get-uv-event-loop-napi-h "^1.0.5" + node-addon-api "^3.0.0" + node-gyp-build "^4.2.1" + ref-struct-di "^1.1.0" + +"@2060.io/ref-napi@3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@2060.io/ref-napi/-/ref-napi-3.0.4.tgz#6a78093b36e8f4ffeb750f706433869382e73eb1" + integrity sha512-Aqf699E+DKs2xANx8bSkuzXyG9gcZ2iFkAk1kUTA8KbV5BSPQtIcBJexzohSRi9QWDhP4X54NLm7xwGA0UNCdQ== + dependencies: + debug "^4.1.1" + get-symbol-from-current-process-h "^1.0.2" + node-addon-api "^3.0.0" + node-gyp-build "^4.2.1" + "@aashutoshrathi/word-wrap@^1.2.3": version "1.2.6" resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" @@ -2447,6 +2469,23 @@ resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== +"@types/2060.io__ffi-napi@npm:@types/ffi-napi": + version "4.0.5" + resolved "https://registry.yarnpkg.com/@types/ffi-napi/-/ffi-napi-4.0.5.tgz#0b2dc2d549361947a117d55156ff34fd9632c3df" + integrity sha512-WDPpCcHaPhHmP1FIw3ds/+OLt8bYQ/h3SO7o+8kH771PL21kHVzTwii7+WyMBXMQrBsR6xVU2y7w+h+9ggpaQw== + dependencies: + "@types/node" "*" + "@types/ref-napi" "*" + "@types/ref-struct-di" "*" + +"@types/2060.io__ref-napi@npm:@types/ref-napi", "@types/ref-napi@*", "@types/ref-napi@3.0.7": + name "@types/2060.io__ref-napi" + version "3.0.7" + resolved "https://registry.yarnpkg.com/@types/ref-napi/-/ref-napi-3.0.7.tgz#20adc93a7a2f9f992dfb17409fd748e6f4bf403d" + integrity sha512-CzPwr36VkezSpaJGdQX/UrczMSDsDgsWQQFEfQkS799Ft7n/s183a53lsql7RwVq+Ik4yLEgI84pRnLC0XXRlA== + dependencies: + "@types/node" "*" + "@types/babel__core@^7.1.14": version "7.20.1" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.1.tgz#916ecea274b0c776fec721e333e55762d3a9614b" @@ -2493,15 +2532,6 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.1.tgz#aa22750962f3bf0e79d753d3cc067f010c95f194" integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA== -"@types/ffi-napi@4.0.5": - version "4.0.5" - resolved "https://registry.yarnpkg.com/@types/ffi-napi/-/ffi-napi-4.0.5.tgz#0b2dc2d549361947a117d55156ff34fd9632c3df" - integrity sha512-WDPpCcHaPhHmP1FIw3ds/+OLt8bYQ/h3SO7o+8kH771PL21kHVzTwii7+WyMBXMQrBsR6xVU2y7w+h+9ggpaQw== - dependencies: - "@types/node" "*" - "@types/ref-napi" "*" - "@types/ref-struct-di" "*" - "@types/graceful-fs@^4.1.2", "@types/graceful-fs@^4.1.3": version "4.1.6" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.6.tgz#e14b2576a1c25026b7f02ede1de3b84c3a1efeae" @@ -2617,13 +2647,6 @@ dependencies: "@types/ref-napi" "*" -"@types/ref-napi@*", "@types/ref-napi@3.0.7": - version "3.0.7" - resolved "https://registry.yarnpkg.com/@types/ref-napi/-/ref-napi-3.0.7.tgz#20adc93a7a2f9f992dfb17409fd748e6f4bf403d" - integrity sha512-CzPwr36VkezSpaJGdQX/UrczMSDsDgsWQQFEfQkS799Ft7n/s183a53lsql7RwVq+Ik4yLEgI84pRnLC0XXRlA== - dependencies: - "@types/node" "*" - "@types/ref-struct-di@*": version "1.1.9" resolved "https://registry.yarnpkg.com/@types/ref-struct-di/-/ref-struct-di-1.1.9.tgz#cdca2cefbb8a907ac9eb9d6a7f19cfae00bfa092" @@ -4930,18 +4953,6 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" -ffi-napi@4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/ffi-napi/-/ffi-napi-4.0.3.tgz#27a8d42a8ea938457154895c59761fbf1a10f441" - integrity sha512-PMdLCIvDY9mS32RxZ0XGb95sonPRal8aqRhLbeEtWKZTe2A87qRFG9HjOhvG8EX2UmQw5XNRMIOT+1MYlWmdeg== - dependencies: - debug "^4.1.1" - get-uv-event-loop-napi-h "^1.0.5" - node-addon-api "^3.0.0" - node-gyp-build "^4.2.1" - ref-napi "^2.0.1 || ^3.0.2" - ref-struct-di "^1.1.0" - figures@3.2.0, figures@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" @@ -8929,16 +8940,6 @@ ref-array-di@1.2.2: array-index "^1.0.0" debug "^3.1.0" -ref-napi@3.0.3, "ref-napi@^2.0.1 || ^3.0.2", "ref-napi@npm:@2060.io/ref-napi": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@2060.io/ref-napi/-/ref-napi-3.0.4.tgz#6a78093b36e8f4ffeb750f706433869382e73eb1" - integrity sha512-Aqf699E+DKs2xANx8bSkuzXyG9gcZ2iFkAk1kUTA8KbV5BSPQtIcBJexzohSRi9QWDhP4X54NLm7xwGA0UNCdQ== - dependencies: - debug "^4.1.1" - get-symbol-from-current-process-h "^1.0.2" - node-addon-api "^3.0.0" - node-gyp-build "^4.2.1" - ref-struct-di@1.1.1, ref-struct-di@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/ref-struct-di/-/ref-struct-di-1.1.1.tgz#5827b1d3b32372058f177547093db1fe1602dc10" From 240dadc61056c7fe47c3c07df3c38b5790998218 Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Sun, 13 Aug 2023 10:55:46 -0300 Subject: [PATCH 5/5] fix(js): use separate @types/ref-napi Signed-off-by: Ariel Gentile --- wrappers/javascript/yarn.lock | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wrappers/javascript/yarn.lock b/wrappers/javascript/yarn.lock index bd65fa4a..2a3e43d9 100644 --- a/wrappers/javascript/yarn.lock +++ b/wrappers/javascript/yarn.lock @@ -2478,7 +2478,7 @@ "@types/ref-napi" "*" "@types/ref-struct-di" "*" -"@types/2060.io__ref-napi@npm:@types/ref-napi", "@types/ref-napi@*", "@types/ref-napi@3.0.7": +"@types/2060.io__ref-napi@npm:@types/ref-napi": name "@types/2060.io__ref-napi" version "3.0.7" resolved "https://registry.yarnpkg.com/@types/ref-napi/-/ref-napi-3.0.7.tgz#20adc93a7a2f9f992dfb17409fd748e6f4bf403d" @@ -2647,6 +2647,14 @@ dependencies: "@types/ref-napi" "*" +"@types/ref-napi@*", "@types/ref-napi@3.0.7": + name "@types/ref-napi" + version "3.0.7" + resolved "https://registry.yarnpkg.com/@types/ref-napi/-/ref-napi-3.0.7.tgz#20adc93a7a2f9f992dfb17409fd748e6f4bf403d" + integrity sha512-CzPwr36VkezSpaJGdQX/UrczMSDsDgsWQQFEfQkS799Ft7n/s183a53lsql7RwVq+Ik4yLEgI84pRnLC0XXRlA== + dependencies: + "@types/node" "*" + "@types/ref-struct-di@*": version "1.1.9" resolved "https://registry.yarnpkg.com/@types/ref-struct-di/-/ref-struct-di-1.1.9.tgz#cdca2cefbb8a907ac9eb9d6a7f19cfae00bfa092"