@hyperledger/anoncreds-nodejs 0.3.5-alpha-20260107085331 → 0.4.0-alpha-20260212142546
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/build/NodeJSAnoncreds.d.ts +14 -55
- package/build/NodeJSAnoncreds.js +160 -130
- package/build/NodeJSAnoncreds.js.map +1 -1
- package/build/ffi/alloc.d.ts +10 -5
- package/build/ffi/alloc.js +32 -12
- package/build/ffi/alloc.js.map +1 -1
- package/build/ffi/conversion.d.ts +16 -7
- package/build/ffi/conversion.js +36 -5
- package/build/ffi/conversion.js.map +1 -1
- package/build/ffi/primitives.d.ts +11 -14
- package/build/ffi/primitives.js +35 -18
- package/build/ffi/primitives.js.map +1 -1
- package/build/ffi/serialize.d.ts +1 -18
- package/build/ffi/serialize.js +5 -16
- package/build/ffi/serialize.js.map +1 -1
- package/build/ffi/structures.d.ts +28 -119
- package/build/ffi/structures.js +29 -84
- package/build/ffi/structures.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/library/NativeBindingInterface.d.ts +1 -24
- package/build/library/bindings.d.ts +2 -253
- package/build/library/bindings.js +242 -135
- package/build/library/bindings.js.map +1 -1
- package/build/library/register.d.ts +2 -53
- package/build/library/register.js +27 -23
- package/build/library/register.js.map +1 -1
- package/package.json +6 -10
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
exports.getNativeAnonCreds = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const koffi_1 = __importDefault(require("koffi"));
|
|
11
11
|
const bindings_1 = require("./bindings");
|
|
12
12
|
const LIBNAME = 'anoncreds';
|
|
13
13
|
const ENV_VAR = 'LIB_ANONCREDS_PATH';
|
|
@@ -22,10 +22,10 @@ const libPaths = {
|
|
|
22
22
|
win32: ['c:\\windows\\system32\\'],
|
|
23
23
|
};
|
|
24
24
|
// Alias for a simple function to check if the path exists
|
|
25
|
-
const doesPathExist =
|
|
25
|
+
const doesPathExist = node_fs_1.default.existsSync;
|
|
26
26
|
const getLibrary = () => {
|
|
27
27
|
// Detect OS; darwin, linux and windows are only supported
|
|
28
|
-
const platform =
|
|
28
|
+
const platform = node_os_1.default.platform();
|
|
29
29
|
if (platform !== 'linux' && platform !== 'win32' && platform !== 'darwin')
|
|
30
30
|
throw new Error(`Unsupported platform: ${platform}. linux, win32 and darwin are supported.`);
|
|
31
31
|
// Get a potential path from the environment variable
|
|
@@ -34,29 +34,33 @@ const getLibrary = () => {
|
|
|
34
34
|
const platformPaths = libPaths[platform];
|
|
35
35
|
// Look for the file in the native directory of the package.
|
|
36
36
|
// node-pre-gyp will download the binaries to this directory after installing the package
|
|
37
|
-
platformPaths.unshift(
|
|
37
|
+
platformPaths.unshift(node_path_1.default.join(__dirname, '../../native'));
|
|
38
38
|
// Check if the path from the environment variable is supplied and add it
|
|
39
39
|
// We use unshift here so that when we want to get a valid library path this will be the first to resolve
|
|
40
40
|
if (pathFromEnvironment)
|
|
41
41
|
platformPaths.unshift(pathFromEnvironment);
|
|
42
42
|
// Create the path + file
|
|
43
|
-
const
|
|
44
|
-
//
|
|
45
|
-
if (!
|
|
46
|
-
throw new Error(`Could not find ${LIBNAME} with these paths: ${
|
|
43
|
+
const libraries = platformPaths.map((p) => { var _a; return node_path_1.default.join(p, `${(_a = extensions[platform].prefix) !== null && _a !== void 0 ? _a : ''}${LIBNAME}${extensions[platform].extension}`); });
|
|
44
|
+
// Guard so we quit if there is no valid path for the library
|
|
45
|
+
if (!libraries.some((libraryPath) => doesPathExist(libraryPath)))
|
|
46
|
+
throw new Error(`Could not find ${LIBNAME} with these paths: ${libraries.join(' ')}`);
|
|
47
47
|
// Get the first valid library
|
|
48
48
|
// Casting here as a string because there is a guard of none of the paths
|
|
49
|
-
const validLibraryPath =
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
49
|
+
const validLibraryPath = libraries.find((l) => doesPathExist(l));
|
|
50
|
+
// Load the library using koffi
|
|
51
|
+
const lib = koffi_1.default.load(validLibraryPath);
|
|
52
|
+
// Bind all the native functions
|
|
53
|
+
const methods = {};
|
|
54
|
+
for (const [name, [returnType, argumentTypes]] of Object.entries(bindings_1.nativeBindings)) {
|
|
55
|
+
methods[name] = lib.func(name, returnType, argumentTypes);
|
|
56
|
+
}
|
|
57
|
+
return methods;
|
|
54
58
|
};
|
|
55
|
-
let
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
return
|
|
59
|
+
let nativeAnonCreds;
|
|
60
|
+
const getNativeAnonCreds = () => {
|
|
61
|
+
if (!nativeAnonCreds)
|
|
62
|
+
nativeAnonCreds = getLibrary();
|
|
63
|
+
return nativeAnonCreds;
|
|
60
64
|
};
|
|
61
|
-
exports.
|
|
65
|
+
exports.getNativeAnonCreds = getNativeAnonCreds;
|
|
62
66
|
//# sourceMappingURL=register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/library/register.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/library/register.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwB;AACxB,sDAAwB;AACxB,0DAA4B;AAC5B,kDAAyB;AAEzB,yCAA2C;AAE3C,MAAM,OAAO,GAAG,WAAW,CAAA;AAC3B,MAAM,OAAO,GAAG,oBAAoB,CAAA;AAMpC,MAAM,UAAU,GAAiB;IAC/B,MAAM,EAAE,EAAE,MAAM,E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-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha-20260212142546",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Nodejs wrapper for Anoncreds",
|
|
6
6
|
"main": "build/index",
|
|
@@ -20,17 +20,13 @@
|
|
|
20
20
|
"scripts"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"@
|
|
25
|
-
"ref-array-di": "1.2.2",
|
|
26
|
-
"ref-struct-di": "1.1.1",
|
|
27
|
-
"@hyperledger/anoncreds-shared": "0.3.5-alpha-20260107085331"
|
|
23
|
+
"koffi": "^2.15.1",
|
|
24
|
+
"@hyperledger/anoncreds-shared": "0.4.0-alpha-20260212142546"
|
|
28
25
|
},
|
|
29
26
|
"devDependencies": {
|
|
30
27
|
"@types/node": "^20.12.11",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"typescript": "~5.4.5"
|
|
28
|
+
"typescript": "~5.4.5",
|
|
29
|
+
"vitest": "^4.0.12"
|
|
34
30
|
},
|
|
35
31
|
"binary": {
|
|
36
32
|
"version": "v0.2.3",
|
|
@@ -38,7 +34,7 @@
|
|
|
38
34
|
"packageName": "library-{platform}-{arch}.tar.gz"
|
|
39
35
|
},
|
|
40
36
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
37
|
+
"node": ">= 20"
|
|
42
38
|
},
|
|
43
39
|
"scripts": {
|
|
44
40
|
"check-types": "pnpm compile --noEmit",
|