Skip to content
Merged
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
2 changes: 1 addition & 1 deletion libindy_vdr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "indy-vdr"
version = "0.4.0-dev.13"
version = "0.4.0-dev.14"
authors = ["Hyperledger Indy Contributors <[email protected]>"]
description = "A library for interacting with Hyperledger Indy Node, a distributed ledger for self-sovereign identity (https://www.hyperledger.org/use/hyperledger-indy)."
edition = "2021"
Expand Down
6 changes: 3 additions & 3 deletions wrappers/javascript/indy-vdr-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperledger/indy-vdr-nodejs",
"version": "0.1.0-dev.13",
"version": "0.1.0-dev.14",
"license": "Apache-2.0",
"description": "Nodejs wrapper for Indy Vdr",
"source": "src/index",
Expand Down Expand Up @@ -41,7 +41,7 @@
"typescript": "~4.9.4"
},
"dependencies": {
"@hyperledger/indy-vdr-shared": "0.1.0-dev.13",
"@hyperledger/indy-vdr-shared": "0.1.0-dev.14",
"@mapbox/node-pre-gyp": "^1.0.10",
"@types/ref-array-di": "^1.2.5",
"ffi-napi": "^4.0.3",
Expand All @@ -52,7 +52,7 @@
"binary": {
"module_name": "indy_vdr",
"module_path": "native",
"remote_path": "v0.4.0-dev.13",
"remote_path": "v0.4.0-dev.14",
"host": "https://github.com/hyperledger/indy-vdr/releases/download/",
"package_name": "library-{platform}-{arch}.tar.gz"
}
Expand Down
5 changes: 2 additions & 3 deletions wrappers/javascript/indy-vdr-nodejs/src/NodeJSIndyVdr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,13 @@ export class NodeJSIndyVdr implements IndyVdr {
this.handleError(this.nativeIndyVdr.indy_vdr_request_free(requestHandle))
}

public requestGetBody<T extends Record<string, unknown>>(options: { requestHandle: number }): T {
public requestGetBody(options: { requestHandle: number }): string {
const output = allocateString()
const { requestHandle } = serializeArguments(options)

this.handleError(this.nativeIndyVdr.indy_vdr_request_get_body(requestHandle, output))

const outputString = handleReturnPointer<string>(output)
return JSON.parse(outputString) as T
return handleReturnPointer<string>(output)
}

public requestGetSignatureInput(options: { requestHandle: number }): string {
Expand Down
2 changes: 2 additions & 0 deletions wrappers/javascript/indy-vdr-nodejs/src/ffi/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export type SerializedOptions<Type> = Required<{
? number
: Type[Property] extends Record<string, unknown>
? string
: Type[Property] extends string | Record<string, unknown>
? string
: Type[Property] extends Array<unknown>
? string
: Type[Property] extends Array<unknown> | undefined
Expand Down
16 changes: 16 additions & 0 deletions wrappers/javascript/indy-vdr-nodejs/tests/CustomRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ describe('CustomRequest', () => {
op: 'REPLY',
})
})

test('Can parse a request from string', () => {
const json = `{"endorser":"DJKobikPAaYWAu9vfhEEo5","identifier":"2GjxcxqE2XnFrVhipkWCWT","operation":{"dest":"2GjxcxqE2XnFrVhipkWCWT","raw":"{\\"endpoint\\":{\\"endpoint\\":\\"https://example.com/endpoint\\",\\"routingKeys\\":[\\"a-routing-key\\"],\\"types\\":[\\"endpoint\\",\\"did-communication\\",\\"DIDComm\\"]}}","type":"100"},"protocolVersion":2,"reqId":1680599092494999800,"signature":"3RyENWHC1szYH7FwDfZ2pKteShtsuDgYCSjGQGDPDjAYE5mipCZ6AnZKuAgCQYq6yt1LEfPPRKVS8BjBirX5s5q3","taaAcceptance":{"mechanism":"accept","taaDigest":"e546ad2a5311b2020fd80efb4d17ec75f823d26ee2424cf741ee345ede9d3ff3","time":1680566400}}`
const request = new CustomRequest({
customRequest: json,
})

request.setMultiSignature({
identifier: 'TL1EaPFCZ8Si5aUrqScBDt',
signature: Buffer.from('Hello, this is a signature'),
})

expect(request.body).toEqual(
'{"endorser":"DJKobikPAaYWAu9vfhEEo5","identifier":"2GjxcxqE2XnFrVhipkWCWT","operation":{"dest":"2GjxcxqE2XnFrVhipkWCWT","raw":"{\\"endpoint\\":{\\"endpoint\\":\\"https://example.com/endpoint\\",\\"routingKeys\\":[\\"a-routing-key\\"],\\"types\\":[\\"endpoint\\",\\"did-communication\\",\\"DIDComm\\"]}}","type":"100"},"protocolVersion":2,"reqId":1680599092494999800,"signatures":{"2GjxcxqE2XnFrVhipkWCWT":"3RyENWHC1szYH7FwDfZ2pKteShtsuDgYCSjGQGDPDjAYE5mipCZ6AnZKuAgCQYq6yt1LEfPPRKVS8BjBirX5s5q3","TL1EaPFCZ8Si5aUrqScBDt":"3DaTn63KBMjCE8pCLkDvMBFPKHefZiQXyzr8"},"taaAcceptance":{"mechanism":"accept","taaDigest":"e546ad2a5311b2020fd80efb4d17ec75f823d26ee2424cf741ee345ede9d3ff3","time":1680566400}}'
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('IndyVdrRequest', () => {
})

test('Get request body', () => {
expect(request.body).toMatchObject({
expect(typeof request.body).toEqual('string')
expect(JSON.parse(request.body)).toMatchObject({
identifier: 'LibindyDid111111111111',
operation: {
data: { name: 'MyName', version: '1.0' },
Expand Down
6 changes: 3 additions & 3 deletions wrappers/javascript/indy-vdr-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperledger/indy-vdr-react-native",
"version": "0.1.0-dev.13",
"version": "0.1.0-dev.14",
"license": "Apache-2.0",
"description": "React Native wrapper for Indy Vdr",
"source": "src/index",
Expand Down Expand Up @@ -40,7 +40,7 @@
"install": "node-pre-gyp install"
},
"dependencies": {
"@hyperledger/indy-vdr-shared": "0.1.0-dev.13",
"@hyperledger/indy-vdr-shared": "0.1.0-dev.14",
"@mapbox/node-pre-gyp": "^1.0.10"
},
"devDependencies": {
Expand All @@ -58,7 +58,7 @@
"binary": {
"module_name": "indy_vdr",
"module_path": "native",
"remote_path": "v0.4.0-dev.13",
"remote_path": "v0.4.0-dev.14",
"host": "https://github.com/hyperledger/indy-vdr/releases/download/",
"package_name": "library-ios-android.tar.gz"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,9 @@ export class ReactNativeIndyVdr implements IndyVdr {
indyVdrReactNative.requestFree(serializedOptions)
}

public requestGetBody<T extends Record<string, unknown>>(options: { requestHandle: number }): T {
public requestGetBody(options: { requestHandle: number }): string {
const serializedOptions = serializeArguments(options)
const result = handleError(indyVdrReactNative.requestGetBody(serializedOptions))
return JSON.parse(result) as T
return handleError(indyVdrReactNative.requestGetBody(serializedOptions))
}

public requestGetSignatureInput(options: { requestHandle: number }): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type SerializedOptions<Type> = {
? number
: Type[Property] extends Record<string, unknown>
? string
: Type[Property] extends string | Record<string, unknown>
? string
: Type[Property] extends Array<unknown>
? string
: Type[Property] extends Array<unknown> | undefined
Expand Down
2 changes: 1 addition & 1 deletion wrappers/javascript/indy-vdr-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperledger/indy-vdr-shared",
"version": "0.1.0-dev.13",
"version": "0.1.0-dev.14",
"license": "Apache-2.0",
"description": "Shared library for using Indy VDR with NodeJS and React Native",
"main": "build/index",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { indyVdr, IndyVdrRequest } from '../indyVdr'

// TODO: this needs some more work, but need to find a way to use it first.
export type CustomRequestOptions = {
customRequest: {
protocolVersion: 1 | 2
reqId?: number
identifier: string
operation: Record<string, unknown>
}
customRequest: string | Record<string, unknown>
}

export class CustomRequest extends IndyVdrRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class IndyVdrRequest<ResponseType extends Record<string, unknown> = Recor
return this._handle
}

public get body(): Record<string, unknown> {
public get body(): string {
return indyVdr.requestGetBody({ requestHandle: this.handle })
}

Expand Down
2 changes: 1 addition & 1 deletion wrappers/javascript/indy-vdr-shared/src/types/IndyVdr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export interface IndyVdr {

requestFree(options: { requestHandle: number }): void

requestGetBody<T extends Record<string, unknown>>(options: { requestHandle: number }): T
requestGetBody(options: { requestHandle: number }): string

requestGetSignatureInput(options: { requestHandle: number }): string

Expand Down
2 changes: 1 addition & 1 deletion wrappers/javascript/lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "0.1.0-dev.13",
"version": "0.1.0-dev.14",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
Expand Down
2 changes: 1 addition & 1 deletion wrappers/python/indy_vdr/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""indy_vdr library wrapper version."""

__version__ = "0.4.0.dev13"
__version__ = "0.4.0.dev14"