Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/empty-dolls-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@openwallet-foundation/askar-react-native": minor
"@openwallet-foundation/askar-nodejs": minor
"@openwallet-foundation/askar-shared": minor
---

chore: drop support for Node 18
5 changes: 5 additions & 0 deletions .changeset/little-rice-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openwallet-foundation/askar-nodejs": patch
---

feat: support Node.JS 24
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v5
with:
node-version: 22
node-version: 24
cache: "pnpm"

- name: Install dependencies
Expand All @@ -43,7 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
node-version: [20, 22, 24]

steps:
- name: Checkout Repo
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v5
with:
node-version: 22
node-version: 24
cache: "pnpm"

- name: Install Dependencies
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v5
with:
node-version: 20
node-version: 24
cache: "pnpm"

- name: Install Dependencies
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ packages/askar-react-native/android/.cxx
examples/askar-react-native-example/android
examples/askar-react-native-example/ios
examples/askar-react-native-example/.expo

indy_wallet_sqlite_upgraded.db
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Wrapper for Node.js and React Native around [https://github.com/openwallet-found

## Requirements

This library requires and has been tested with Node.js version `18.x`, `20.x` and `22.x`, or React Native version `0.75.x` and `0.76.x`. Newer versions might also work, but they have not been tested.
This library requires and has been tested with Node.js version `20.x`, `22.x`, and `24.x` or React Native version `0.75.x` and `0.76.x`. Newer versions might also work, but they have not been tested.

## Setup

Expand Down
8 changes: 5 additions & 3 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.3.7/schema.json",
"formatter": {
"lineWidth": 120,
"indentStyle": "space"
Expand All @@ -21,8 +21,10 @@
"allowComments": true
}
},
"organizeImports": {
"enabled": true
"assist": {
"actions": {
"source": { "organizeImports": "on" }
}
},
"linter": {
"enabled": true,
Expand Down
10 changes: 0 additions & 10 deletions lerna.json

This file was deleted.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,26 @@
"url": "https://github.com/openwallet-foundation/askar-wrapper-javascript"
},
"engines": {
"node": ">= 18"
"node": ">= 20"
},
"scripts": {
"style:check": "biome check --unsafe .",
"style:check": "biome check --unsafe",
"style:fix": "pnpm style:check --write",
"types:check": "pnpm -r types:check",
"build": "pnpm -r build",
"clean": "pnpm -r clean",
"test": "node --import tsx --test packages/**/tests/*.test.ts",
"test": "vitest",
"release": "pnpm build && pnpm changeset publish --no-git-tag",
"changeset-version": "pnpm changeset version && pnpm style:fix"
},
"devDependencies": {
"@biomejs/biome": "catalog:",
"@biomejs/biome": "^2.3.7",
"@changesets/cli": "catalog:",
"@types/node": "catalog:",
"rimraf": "catalog:",
"tsx": "catalog:",
"typescript": "catalog:"
"typescript": "catalog:",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^4.0.12"
},
"packageManager": "pnpm@9.15.3+sha256.c1da43727ccbc1ed42aff4fd6bdb4b1e91e65a818e6efff5b240fbf070ba4eaf"
}
4 changes: 2 additions & 2 deletions packages/askar-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Wrapper for Node.Js around Askar

See the [project README](https://github.com/openwallet-foundation/askar-wrapper-javascript) for version compatability between Askar and this JavaScript Wrapper.
See the [project README](https://github.com/openwallet-foundation/askar-wrapper-javascript) for version compatibility between Askar and this JavaScript Wrapper.

## Requirements

This library requires and has been tested with Node.js version `18.x`, `20.x` and `22.x`. Newer versions might also work, but they have not been tested.
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.

## Installation

Expand Down
21 changes: 13 additions & 8 deletions packages/askar-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"publishConfig": {
"access": "public"
},
"files": ["build", "scripts"],
"files": [
"build",
"scripts"
],
"scripts": {
"types:check": "pnpm compile --noEmit",
"build": "pnpm clean && pnpm compile",
Expand All @@ -24,16 +27,18 @@
"install": "node scripts/install.js"
},
"dependencies": {
"@2060.io/ffi-napi": "^4.0.9",
"@2060.io/ref-napi": "^3.0.6",
"@napi-ffi/ffi-napi": "^4.0.3",
"@napi-ffi/ref-napi": "^3.0.5",
"@openwallet-foundation/askar-shared": "workspace:*",
"ref-array-di": "^1.2.2",
"ref-struct-di": "^1.1.1"
"@napi-ffi/ref-array-di": "^1.2.2",
"@napi-ffi/ref-struct-di": "^1.1.1"
},
"devDependencies": {
"@types/node": "catalog:",
"@types/ref-array-di": "^1.2.3",
"@types/ref-struct-di": "^1.1.6",
"@types/napi-ffi__ref-array-di": "npm:@types/ref-array-di@^1.2.3",
"@types/napi-ffi__ref-struct-di": "npm:@types/ref-struct-di@^1.1.6",
"@types/napi-ffi__ffi-napi": "npm:@types/ffi-napi@^4.0.10",
"@types/napi-ffi__ref-napi": "npm:@types/ref-napi@^3.0.12",
"typescript": "catalog:"
},
"binary": {
Expand All @@ -42,6 +47,6 @@
"packageName": "library-{platform}-{arch}.tar.gz"
},
"engines": {
"node": ">= 18"
"node": ">= 20"
}
}
22 changes: 11 additions & 11 deletions packages/askar-nodejs/src/NodeJSAskar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,26 @@ import {
AeadParams,
AskarError,
EntryListHandle,
handleInvalidNullResponse,
KeyEntryListHandle,
LocalKeyHandle,
ScanHandle,
SessionHandle,
StoreHandle,
handleInvalidNullResponse,
} from '@openwallet-foundation/askar-shared'
import {
allocateAeadParams,
allocateEncryptedBuffer,
allocateInt8Buffer,
allocateInt32Buffer,
allocatePointer,
allocateSecretBuffer,
allocateStringBuffer,
allocateStringListHandle,
type ByteBufferType,
deallocateCallbackBuffer,
type EncryptedBufferType,
encryptedBufferStructToClass,
FFI_ENTRY_LIST_HANDLE,
FFI_INT8,
FFI_INT64,
Expand All @@ -106,16 +116,6 @@ import {
FFI_STRING_LIST_HANDLE,
type NativeCallback,
type NativeCallbackWithResponse,
allocateAeadParams,
allocateEncryptedBuffer,
allocateInt8Buffer,
allocateInt32Buffer,
allocatePointer,
allocateSecretBuffer,
allocateStringBuffer,
allocateStringListHandle,
deallocateCallbackBuffer,
encryptedBufferStructToClass,
secretBufferToBuffer,
serializeArguments,
toNativeCallback,
Expand Down
2 changes: 1 addition & 1 deletion packages/askar-nodejs/src/ffi/alloc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { alloc } from '@2060.io/ref-napi'
import { alloc } from '@napi-ffi/ref-napi'
import { FFI_INT8, FFI_INT32, FFI_POINTER, FFI_STRING } from './primitives'
import { AeadParamsStruct, EncryptedBufferStruct, SecretBufferStruct } from './structures'

Expand Down
4 changes: 2 additions & 2 deletions packages/askar-nodejs/src/ffi/callback.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Callback } from '@2060.io/ffi-napi'
import { refType } from '@2060.io/ref-napi'
import { Callback } from '@napi-ffi/ffi-napi'
import { refType } from '@napi-ffi/ref-napi'
import { allocateCallbackBuffer } from './alloc'
import { FFI_CALLBACK_ID, FFI_ERROR_CODE, FFI_INT32, FFI_STRING, FFI_VOID } from './primitives'

Expand Down
6 changes: 3 additions & 3 deletions packages/askar-nodejs/src/ffi/conversion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Pointer } from '@2060.io/ref-napi'
import { reinterpret } from '@2060.io/ref-napi'
import type { TypedArray } from '@napi-ffi/ref-array-di'
import type { Pointer } from '@napi-ffi/ref-napi'
import { reinterpret } from '@napi-ffi/ref-napi'
import { EncryptedBuffer } from '@openwallet-foundation/askar-shared'
import type { TypedArray } from 'ref-array-di'
import type { ByteBufferType, EncryptedBufferType } from './structures'
import { ByteBufferStruct } from './structures'

Expand Down
2 changes: 1 addition & 1 deletion packages/askar-nodejs/src/ffi/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './alloc'
export * from './callback'
export * from './conversion'
export * from './structures'
export * from './primitives'
export * from './serialize'
export * from './structures'
2 changes: 1 addition & 1 deletion packages/askar-nodejs/src/ffi/primitives.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { refType } from '@2060.io/ref-napi'
import { refType } from '@napi-ffi/ref-napi'

// Primitives

Expand Down
4 changes: 2 additions & 2 deletions packages/askar-nodejs/src/ffi/serialize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NULL } from '@2060.io/ref-napi'
import { NULL } from '@napi-ffi/ref-napi'
import { ArcHandle, Jwk, Key, ScanHandle, SessionHandle, StoreHandle } from '@openwallet-foundation/askar-shared'
import { uint8arrayToByteBufferStruct } from './conversion'
import type { ByteBufferStruct, SecretBufferStruct } from './structures'
Expand All @@ -25,7 +25,7 @@ type SerializedArgument =
| number
| Callback
| CallbackWithResponse
| ArrayBuffer
| Uint8Array
| typeof ByteBufferStruct
| typeof SecretBufferStruct
| Buffer
Expand Down
6 changes: 3 additions & 3 deletions packages/askar-nodejs/src/ffi/structures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { default as ref, refType } from '@2060.io/ref-napi'
import refArray from 'ref-array-di'
import refStruct from 'ref-struct-di'
import refArray from '@napi-ffi/ref-array-di'
import { default as ref, refType } from '@napi-ffi/ref-napi'
import refStruct from '@napi-ffi/ref-struct-di'
import { FFI_INT32, FFI_INT64, FFI_UINT8 } from './primitives'

const CStruct = refStruct(ref)
Expand Down
6 changes: 3 additions & 3 deletions packages/askar-nodejs/src/library/NativeBindingInterface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ByteBufferType, SecretBufferStruct } from '../ffi'
import type { nativeBindings } from './bindings'

import type { ByteBufferType, SecretBufferStruct } from '../ffi'
// We need a mapping from string type value => type (property 'string' maps to type string)
interface StringTypeMapping {
pointer: Buffer
Expand All @@ -25,10 +25,10 @@ type StringTypeArrayToTypes<List extends (keyof StringTypeMapping)[]> = {
: Buffer
}

// biome-ignore lint/suspicious/noExplicitAny:
// biome-ignore lint/suspicious/noExplicitAny: no-explanation
type TypedMethods<Base extends Record<string | number | symbol, [any, any[]]>> = {
[Property in keyof Base]: (
// biome-ignore lint/suspicious/noExplicitAny:
// biome-ignore lint/suspicious/noExplicitAny: no-explanation
...args: StringTypeArrayToTypes<Base[Property][1]> extends any[] ? StringTypeArrayToTypes<Base[Property][1]> : []
) => StringTypeMapping[Base[Property][0]]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/askar-nodejs/src/library/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { refType } from '@2060.io/ref-napi'
import { refType } from '@napi-ffi/ref-napi'
import {
AeadParamsStructPtr,
ByteBufferStruct,
Expand Down
2 changes: 1 addition & 1 deletion packages/askar-nodejs/src/library/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './NativeBindingInterface'
export * from './bindings'
export * from './NativeBindingInterface'
export * from './register'
14 changes: 7 additions & 7 deletions packages/askar-nodejs/src/library/register.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { Library } from '@2060.io/ffi-napi'
import type { NativeMethods } from './NativeBindingInterface'
import { Library } from '@napi-ffi/ffi-napi'
import { nativeBindings } from './bindings'
import type { NativeMethods } from './NativeBindingInterface'

// TODO(rename): when lib is changed
const LIBNAME = 'aries_askar'
Expand Down Expand Up @@ -50,25 +50,25 @@ const getLibrary = () => {
if (pathFromEnvironment) platformPaths.unshift(pathFromEnvironment)

// Create the path + file
const libaries = platformPaths.map((p) =>
const libraries = platformPaths.map((p) =>
path.join(p, `${extensions[platform].prefix ?? ''}${LIBNAME}${extensions[platform].extension}`)
)

// Gaurd so we quit if there is no valid path for the library
if (!libaries.some(doesPathExist))
throw new Error(`Could not find ${LIBNAME} with these paths: ${libaries.join(' ')}`)
if (!libraries.some((libraryPath) => doesPathExist(libraryPath)))
throw new Error(`Could not find ${LIBNAME} with these paths: ${libraries.join(' ')}`)

// Get the first valid library
// Casting here as a string because there is a guard of none of the paths
const validLibraryPath = libaries.find((l) => doesPathExist(l)) as string
const validLibraryPath = libraries.find((l) => doesPathExist(l)) as string

// TODO fix the typing conversion
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
return Library(validLibraryPath, nativeBindings)
}

let nativeAskar: NativeMethods | undefined = undefined
let nativeAskar: NativeMethods | undefined
export const getNativeAskar = () => {
if (!nativeAskar) nativeAskar = getLibrary() as unknown as NativeMethods
return nativeAskar
Expand Down
8 changes: 2 additions & 6 deletions packages/askar-nodejs/tests/cryptoBox.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { deepStrictEqual } from 'node:assert'
import { before, describe, test } from 'node:test'
import { CryptoBox, Key, KeyAlgorithm } from '@openwallet-foundation/askar-shared'
import { setup } from './utils/initialize'
import { describe, expect, test } from 'vitest'

describe('CryptoBox', () => {
before(setup)

test('seal', () => {
const x25519Key = Key.generate(KeyAlgorithm.X25519)

Expand All @@ -17,7 +13,7 @@ describe('CryptoBox', () => {
ciphertext: sealed,
})

deepStrictEqual(opened, message)
expect(opened).toEqual(message)

x25519Key.handle.free()
})
Expand Down
Loading
Loading