@hyperledger/anoncreds-nodejs 0.1.0 → 0.2.0-dev.10
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 +2 -3
- package/build/NodeJSAnoncreds.d.ts +91 -11
- package/build/NodeJSAnoncreds.js +208 -95
- package/build/NodeJSAnoncreds.js.map +1 -1
- package/build/ffi/alloc.js +1 -1
- package/build/ffi/alloc.js.map +1 -1
- package/build/ffi/conversion.js +1 -1
- package/build/ffi/conversion.js.map +1 -1
- package/build/ffi/index.js +5 -1
- package/build/ffi/index.js.map +1 -1
- package/build/ffi/primitives.d.ts +5 -5
- package/build/ffi/primitives.js +1 -1
- package/build/ffi/primitives.js.map +1 -1
- package/build/ffi/serialize.d.ts +5 -5
- package/build/ffi/serialize.js +3 -3
- package/build/ffi/serialize.js.map +1 -1
- package/build/ffi/structures.d.ts +36 -36
- package/build/ffi/structures.js +21 -19
- package/build/ffi/structures.js.map +1 -1
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/library/NativeBindingInterface.d.ts +5 -7
- package/build/library/bindings.d.ts +134 -56
- package/build/library/bindings.js +98 -23
- package/build/library/bindings.js.map +1 -1
- package/build/library/index.js +5 -1
- package/build/library/index.js.map +1 -1
- package/build/library/register.d.ts +14 -3
- package/build/library/register.js +5 -5
- package/build/library/register.js.map +1 -1
- package/package.json +15 -17
- package/scripts/install.js +15 -0
- package/scripts/arch.js +0 -22
- package/scripts/platform.js +0 -13
package/README.md
CHANGED
|
@@ -4,8 +4,7 @@ Wrapper for Nodejs around anoncreds-rs
|
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
|
-
This has been tested extensively with
|
|
8
|
-
Older and newer versions might also work, but they have not been tested.
|
|
7
|
+
This library requires (and has been tested extensively with) Node.js version 18.x. Newer versions might also work, but they have not been tested.
|
|
9
8
|
|
|
10
9
|
## Installation
|
|
11
10
|
|
|
@@ -24,7 +23,7 @@ const schema = Schema.create({
|
|
|
24
23
|
name: 'test',
|
|
25
24
|
version: '1.0',
|
|
26
25
|
issuerId: 'mock:uri',
|
|
27
|
-
attributeNames: ['name', 'age', 'address']
|
|
26
|
+
attributeNames: ['name', 'age', 'address']
|
|
28
27
|
})
|
|
29
28
|
|
|
30
29
|
// JSON representation
|
|
@@ -4,7 +4,7 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
4
4
|
private handleError;
|
|
5
5
|
get nativeAnoncreds(): {
|
|
6
6
|
anoncreds_buffer_free: (args_0: Buffer) => unknown;
|
|
7
|
-
anoncreds_create_credential: (args_0: number, args_1: number, args_2: number, args_3: number, args_4: Buffer, args_5: Buffer, args_6: Buffer, args_7:
|
|
7
|
+
anoncreds_create_credential: (args_0: number, args_1: number, args_2: number, args_3: number, args_4: Buffer, args_5: Buffer, args_6: Buffer, args_7: number, args_8: Buffer) => unknown;
|
|
8
8
|
anoncreds_create_credential_definition: (args_0: string, args_1: number, args_2: string, args_3: string, args_4: string, args_5: number, args_6: Buffer, args_7: Buffer, args_8: Buffer) => unknown;
|
|
9
9
|
anoncreds_create_credential_offer: (args_0: string, args_1: string, args_2: number, args_3: Buffer) => unknown;
|
|
10
10
|
anoncreds_create_credential_request: (args_0: string, args_1: string, args_2: number, args_3: string, args_4: string, args_5: number, args_6: Buffer, args_7: Buffer) => unknown;
|
|
@@ -18,6 +18,7 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
18
18
|
anoncreds_generate_nonce: (args_0: Buffer) => unknown;
|
|
19
19
|
anoncreds_get_current_error: (args_0: Buffer) => unknown;
|
|
20
20
|
anoncreds_object_free: (args_0: number) => unknown;
|
|
21
|
+
anoncreds_string_free: (args_0: Buffer) => unknown;
|
|
21
22
|
anoncreds_object_get_json: (args_0: number, args_1: Buffer) => unknown;
|
|
22
23
|
anoncreds_object_get_type_name: (args_0: number, args_1: Buffer) => unknown;
|
|
23
24
|
anoncreds_presentation_request_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
@@ -25,9 +26,9 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
25
26
|
anoncreds_revocation_registry_definition_get_attribute: (args_0: number, args_1: string, args_2: Buffer) => unknown;
|
|
26
27
|
anoncreds_set_default_logger: () => unknown;
|
|
27
28
|
anoncreds_verify_presentation: (args_0: number, args_1: number, args_2: Buffer, args_3: Buffer, args_4: Buffer, args_5: Buffer, args_6: Buffer, args_7: Buffer, args_8: Buffer, args_9: Buffer, args_10: Buffer) => unknown;
|
|
28
|
-
anoncreds_create_revocation_status_list: (args_0:
|
|
29
|
+
anoncreds_create_revocation_status_list: (args_0: number, args_1: string, args_2: number, args_3: number, args_4: string, args_5: number, args_6: number, args_7: Buffer) => unknown;
|
|
29
30
|
anoncreds_update_revocation_status_list_timestamp_only: (args_0: number, args_1: number, args_2: Buffer) => unknown;
|
|
30
|
-
anoncreds_update_revocation_status_list: (args_0: number, args_1:
|
|
31
|
+
anoncreds_update_revocation_status_list: (args_0: number, args_1: number, args_2: number, args_3: number, args_4: Buffer, args_5: Buffer, args_6: number, args_7: Buffer) => unknown;
|
|
31
32
|
anoncreds_version: () => string;
|
|
32
33
|
anoncreds_credential_request_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
33
34
|
anoncreds_credential_request_metadata_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
@@ -43,6 +44,16 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
43
44
|
anoncreds_revocation_registry_definition_private_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
44
45
|
anoncreds_key_correctness_proof_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
45
46
|
anoncreds_schema_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
47
|
+
anoncreds_create_w3c_credential: (args_0: number, args_1: number, args_2: number, args_3: number, args_4: Buffer, args_5: Buffer, args_6: number, args_7: string, args_8: Buffer) => unknown;
|
|
48
|
+
anoncreds_process_w3c_credential: (args_0: number, args_1: number, args_2: string, args_3: number, args_4: number, args_5: Buffer) => unknown;
|
|
49
|
+
anoncreds_create_w3c_presentation: (args_0: number, args_1: Buffer, args_2: Buffer, args_3: string, args_4: Buffer, args_5: Buffer, args_6: Buffer, args_7: Buffer, args_8: string, args_9: Buffer) => unknown;
|
|
50
|
+
anoncreds_verify_w3c_presentation: (args_0: number, args_1: number, args_2: Buffer, args_3: Buffer, args_4: Buffer, args_5: Buffer, args_6: Buffer, args_7: Buffer, args_8: Buffer, args_9: Buffer, args_10: Buffer) => unknown;
|
|
51
|
+
anoncreds_credential_to_w3c: (args_0: number, args_1: number, args_2: string, args_3: Buffer) => unknown;
|
|
52
|
+
anoncreds_credential_from_w3c: (args_0: number, args_1: Buffer) => unknown;
|
|
53
|
+
anoncreds_w3c_credential_get_integrity_proof_details: (args_0: number, args_1: Buffer) => unknown;
|
|
54
|
+
anoncreds_w3c_credential_proof_get_attribute: (args_0: number, args_1: string, args_2: Buffer) => unknown;
|
|
55
|
+
anoncreds_w3c_presentation_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
56
|
+
anoncreds_w3c_credential_from_json: (args_0: Buffer, args_1: Buffer) => unknown;
|
|
46
57
|
};
|
|
47
58
|
generateNonce(): string;
|
|
48
59
|
createSchema(options: {
|
|
@@ -78,13 +89,11 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
78
89
|
credentialRequest: ObjectHandle;
|
|
79
90
|
attributeRawValues: Record<string, string>;
|
|
80
91
|
attributeEncodedValues?: Record<string, string>;
|
|
81
|
-
revocationRegistryId?: string;
|
|
82
|
-
revocationStatusList?: ObjectHandle;
|
|
83
92
|
revocationConfiguration?: NativeCredentialRevocationConfig;
|
|
84
93
|
}): ObjectHandle;
|
|
85
94
|
encodeCredentialAttributes(options: {
|
|
86
|
-
attributeRawValues:
|
|
87
|
-
}):
|
|
95
|
+
attributeRawValues: string[];
|
|
96
|
+
}): string[];
|
|
88
97
|
processCredential(options: {
|
|
89
98
|
credential: ObjectHandle;
|
|
90
99
|
credentialRequestMetadata: ObjectHandle;
|
|
@@ -131,22 +140,26 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
131
140
|
nonRevokedIntervalOverrides?: NativeNonRevokedIntervalOverride[];
|
|
132
141
|
}): boolean;
|
|
133
142
|
createRevocationStatusList(options: {
|
|
143
|
+
credentialDefinition: ObjectHandle;
|
|
134
144
|
revocationRegistryDefinitionId: string;
|
|
135
145
|
revocationRegistryDefinition: ObjectHandle;
|
|
146
|
+
revocationRegistryDefinitionPrivate: ObjectHandle;
|
|
136
147
|
issuerId: string;
|
|
137
|
-
timestamp?: number;
|
|
138
148
|
issuanceByDefault: boolean;
|
|
149
|
+
timestamp?: number;
|
|
139
150
|
}): ObjectHandle;
|
|
140
151
|
updateRevocationStatusListTimestampOnly(options: {
|
|
141
152
|
timestamp: number;
|
|
142
153
|
currentRevocationStatusList: ObjectHandle;
|
|
143
154
|
}): ObjectHandle;
|
|
144
155
|
updateRevocationStatusList(options: {
|
|
145
|
-
|
|
146
|
-
issued?: number[];
|
|
147
|
-
revoked?: number[];
|
|
156
|
+
credentialDefinition: ObjectHandle;
|
|
148
157
|
revocationRegistryDefinition: ObjectHandle;
|
|
158
|
+
revocationRegistryDefinitionPrivate: ObjectHandle;
|
|
149
159
|
currentRevocationStatusList: ObjectHandle;
|
|
160
|
+
issued?: number[];
|
|
161
|
+
revoked?: number[];
|
|
162
|
+
timestamp?: number;
|
|
150
163
|
}): ObjectHandle;
|
|
151
164
|
createRevocationRegistryDefinition(options: {
|
|
152
165
|
credentialDefinition: ObjectHandle;
|
|
@@ -168,6 +181,64 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
168
181
|
oldRevocationState?: ObjectHandle;
|
|
169
182
|
oldRevocationStatusList?: ObjectHandle;
|
|
170
183
|
}): ObjectHandle;
|
|
184
|
+
createW3cCredential(options: {
|
|
185
|
+
credentialDefinition: ObjectHandle;
|
|
186
|
+
credentialDefinitionPrivate: ObjectHandle;
|
|
187
|
+
credentialOffer: ObjectHandle;
|
|
188
|
+
credentialRequest: ObjectHandle;
|
|
189
|
+
attributeRawValues: Record<string, string>;
|
|
190
|
+
revocationConfiguration?: NativeCredentialRevocationConfig;
|
|
191
|
+
w3cVersion?: string;
|
|
192
|
+
}): ObjectHandle;
|
|
193
|
+
processW3cCredential(options: {
|
|
194
|
+
credential: ObjectHandle;
|
|
195
|
+
credentialRequestMetadata: ObjectHandle;
|
|
196
|
+
linkSecret: string;
|
|
197
|
+
credentialDefinition: ObjectHandle;
|
|
198
|
+
revocationRegistryDefinition?: ObjectHandle | undefined;
|
|
199
|
+
}): ObjectHandle;
|
|
200
|
+
createW3cPresentation(options: {
|
|
201
|
+
presentationRequest: ObjectHandle;
|
|
202
|
+
credentials: NativeCredentialEntry[];
|
|
203
|
+
credentialsProve: NativeCredentialProve[];
|
|
204
|
+
linkSecret: string;
|
|
205
|
+
schemas: Record<string, ObjectHandle>;
|
|
206
|
+
credentialDefinitions: Record<string, ObjectHandle>;
|
|
207
|
+
w3cVersion?: string;
|
|
208
|
+
}): ObjectHandle;
|
|
209
|
+
verifyW3cPresentation(options: {
|
|
210
|
+
presentation: ObjectHandle;
|
|
211
|
+
presentationRequest: ObjectHandle;
|
|
212
|
+
schemas: ObjectHandle[];
|
|
213
|
+
schemaIds: string[];
|
|
214
|
+
credentialDefinitions: ObjectHandle[];
|
|
215
|
+
credentialDefinitionIds: string[];
|
|
216
|
+
revocationRegistryDefinitions?: ObjectHandle[];
|
|
217
|
+
revocationRegistryDefinitionIds?: string[];
|
|
218
|
+
revocationStatusLists?: ObjectHandle[];
|
|
219
|
+
nonRevokedIntervalOverrides?: NativeNonRevokedIntervalOverride[];
|
|
220
|
+
}): boolean;
|
|
221
|
+
credentialToW3c(options: {
|
|
222
|
+
objectHandle: ObjectHandle;
|
|
223
|
+
credentialDefinition: ObjectHandle;
|
|
224
|
+
w3cVersion?: string;
|
|
225
|
+
}): ObjectHandle;
|
|
226
|
+
credentialFromW3c(options: {
|
|
227
|
+
objectHandle: ObjectHandle;
|
|
228
|
+
}): ObjectHandle;
|
|
229
|
+
w3cCredentialGetIntegrityProofDetails(options: {
|
|
230
|
+
objectHandle: ObjectHandle;
|
|
231
|
+
}): ObjectHandle;
|
|
232
|
+
w3cCredentialProofGetAttribute(options: {
|
|
233
|
+
objectHandle: ObjectHandle;
|
|
234
|
+
name: string;
|
|
235
|
+
}): string;
|
|
236
|
+
w3cCredentialFromJson(options: {
|
|
237
|
+
json: string;
|
|
238
|
+
}): ObjectHandle;
|
|
239
|
+
w3cPresentationFromJson(options: {
|
|
240
|
+
json: string;
|
|
241
|
+
}): ObjectHandle;
|
|
171
242
|
version(): string;
|
|
172
243
|
setDefaultLogger(): void;
|
|
173
244
|
getCurrentError(): string;
|
|
@@ -226,4 +297,13 @@ export declare class NodeJSAnoncreds implements Anoncreds {
|
|
|
226
297
|
objectFree(options: {
|
|
227
298
|
objectHandle: ObjectHandle;
|
|
228
299
|
}): void;
|
|
300
|
+
private convertCredentialList;
|
|
301
|
+
private convertCredentialProves;
|
|
302
|
+
private convertSchemas;
|
|
303
|
+
private convertCredDefs;
|
|
304
|
+
private convertNonRevokedIntervalOverrides;
|
|
305
|
+
private convertAttributeNames;
|
|
306
|
+
private convertAttributeRawValues;
|
|
307
|
+
private convertAttributeEncodedValues;
|
|
308
|
+
private convertRevocationConfiguration;
|
|
229
309
|
}
|
package/build/NodeJSAnoncreds.js
CHANGED
|
@@ -5,11 +5,14 @@ const anoncreds_shared_1 = require("@hyperledger/anoncreds-shared");
|
|
|
5
5
|
const util_1 = require("util");
|
|
6
6
|
const ffi_1 = require("./ffi");
|
|
7
7
|
const library_1 = require("./library");
|
|
8
|
-
function handleReturnPointer(returnValue) {
|
|
8
|
+
function handleReturnPointer(returnValue, cleanupCallback) {
|
|
9
9
|
if (returnValue.address() === 0) {
|
|
10
10
|
throw anoncreds_shared_1.AnoncredsError.customError({ message: 'Unexpected null pointer' });
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const ret = returnValue.deref();
|
|
13
|
+
if (cleanupCallback)
|
|
14
|
+
cleanupCallback(returnValue);
|
|
15
|
+
return ret;
|
|
13
16
|
}
|
|
14
17
|
class NodeJSAnoncreds {
|
|
15
18
|
handleError() {
|
|
@@ -60,38 +63,18 @@ class NodeJSAnoncreds {
|
|
|
60
63
|
return {
|
|
61
64
|
credentialDefinition: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(credentialDefinitionPtr)),
|
|
62
65
|
credentialDefinitionPrivate: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(credentialDefinitionPrivatePtr)),
|
|
63
|
-
keyCorrectnessProof: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(keyCorrectnessProofPtr))
|
|
66
|
+
keyCorrectnessProof: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(keyCorrectnessProofPtr))
|
|
64
67
|
};
|
|
65
68
|
}
|
|
66
69
|
createCredential(options) {
|
|
67
|
-
var _a
|
|
68
|
-
const { credentialDefinition, credentialDefinitionPrivate, credentialOffer, credentialRequest
|
|
69
|
-
const attributeNames = (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const attributeRawValues = (0, ffi_1.StringListStruct)({
|
|
74
|
-
count: Object.keys(options.attributeRawValues).length,
|
|
75
|
-
data: Object.values(options.attributeRawValues),
|
|
76
|
-
});
|
|
77
|
-
const attributeEncodedValues = options.attributeEncodedValues
|
|
78
|
-
? (0, ffi_1.StringListStruct)({
|
|
79
|
-
count: Object.keys(options.attributeEncodedValues).length,
|
|
80
|
-
data: Object.values(options.attributeEncodedValues),
|
|
81
|
-
})
|
|
82
|
-
: undefined;
|
|
83
|
-
let revocationConfiguration;
|
|
84
|
-
if (options.revocationConfiguration) {
|
|
85
|
-
const { revocationRegistryDefinition: registryDefinition, revocationRegistryDefinitionPrivate: registryDefinitionPrivate, registryIndex, tailsPath, } = (0, ffi_1.serializeArguments)(options.revocationConfiguration);
|
|
86
|
-
revocationConfiguration = (0, ffi_1.CredRevInfoStruct)({
|
|
87
|
-
reg_def: registryDefinition,
|
|
88
|
-
reg_def_private: registryDefinitionPrivate,
|
|
89
|
-
reg_idx: registryIndex,
|
|
90
|
-
tails_path: tailsPath,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
70
|
+
var _a;
|
|
71
|
+
const { credentialDefinition, credentialDefinitionPrivate, credentialOffer, credentialRequest } = (0, ffi_1.serializeArguments)(options);
|
|
72
|
+
const attributeNames = this.convertAttributeNames(options.attributeRawValues);
|
|
73
|
+
const attributeRawValues = this.convertAttributeRawValues(options.attributeRawValues);
|
|
74
|
+
const attributeEncodedValues = this.convertAttributeEncodedValues(options.attributeEncodedValues);
|
|
75
|
+
const revocationConfiguration = this.convertRevocationConfiguration(options.revocationConfiguration);
|
|
93
76
|
const credentialPtr = (0, ffi_1.allocatePointer)();
|
|
94
|
-
this.nativeAnoncreds.anoncreds_create_credential(credentialDefinition, credentialDefinitionPrivate, credentialOffer, credentialRequest, attributeNames, attributeRawValues, attributeEncodedValues,
|
|
77
|
+
this.nativeAnoncreds.anoncreds_create_credential(credentialDefinition, credentialDefinitionPrivate, credentialOffer, credentialRequest, attributeNames, attributeRawValues, attributeEncodedValues, (_a = revocationConfiguration === null || revocationConfiguration === void 0 ? void 0 : revocationConfiguration.ref().address()) !== null && _a !== void 0 ? _a : 0, credentialPtr);
|
|
95
78
|
this.handleError();
|
|
96
79
|
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(credentialPtr));
|
|
97
80
|
}
|
|
@@ -126,7 +109,7 @@ class NodeJSAnoncreds {
|
|
|
126
109
|
this.handleError();
|
|
127
110
|
return {
|
|
128
111
|
credentialRequest: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(credentialRequestPtr)),
|
|
129
|
-
credentialRequestMetadata: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(credentialRequestMetadataPtr))
|
|
112
|
+
credentialRequestMetadata: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(credentialRequestMetadataPtr))
|
|
130
113
|
};
|
|
131
114
|
}
|
|
132
115
|
createLinkSecret() {
|
|
@@ -137,83 +120,35 @@ class NodeJSAnoncreds {
|
|
|
137
120
|
}
|
|
138
121
|
createPresentation(options) {
|
|
139
122
|
const { presentationRequest, linkSecret } = (0, ffi_1.serializeArguments)(options);
|
|
140
|
-
const credentialEntries = options.credentials.map((value) => {
|
|
141
|
-
var _a, _b, _c;
|
|
142
|
-
return (0, ffi_1.CredentialEntryStruct)({
|
|
143
|
-
credential: value.credential.handle,
|
|
144
|
-
timestamp: (_a = value.timestamp) !== null && _a !== void 0 ? _a : -1,
|
|
145
|
-
rev_state: (_c = (_b = value.revocationState) === null || _b === void 0 ? void 0 : _b.handle) !== null && _c !== void 0 ? _c : 0,
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
const credentialEntryList = (0, ffi_1.CredentialEntryListStruct)({
|
|
149
|
-
count: credentialEntries.length,
|
|
150
|
-
data: credentialEntries,
|
|
151
|
-
});
|
|
152
|
-
const credentialProves = options.credentialsProve.map((value) => {
|
|
153
|
-
const { entryIndex: entry_idx, isPredicate: is_predicate, reveal, referent } = (0, ffi_1.serializeArguments)(value);
|
|
154
|
-
return (0, ffi_1.CredentialProveStruct)({ entry_idx, referent, is_predicate, reveal });
|
|
155
|
-
});
|
|
156
|
-
const credentialProveList = (0, ffi_1.CredentialProveListStruct)({
|
|
157
|
-
count: credentialProves.length,
|
|
158
|
-
data: credentialProves,
|
|
159
|
-
});
|
|
160
123
|
const selfAttestNames = (0, ffi_1.StringListStruct)({
|
|
161
124
|
count: Object.keys(options.selfAttest).length,
|
|
162
|
-
data: Object.keys(options.selfAttest)
|
|
125
|
+
data: Object.keys(options.selfAttest)
|
|
163
126
|
});
|
|
164
127
|
const selfAttestValues = (0, ffi_1.StringListStruct)({
|
|
165
128
|
count: Object.values(options.selfAttest).length,
|
|
166
|
-
data: Object.values(options.selfAttest)
|
|
167
|
-
});
|
|
168
|
-
const schemaKeys = Object.keys(options.schemas);
|
|
169
|
-
const schemaIds = (0, ffi_1.StringListStruct)({
|
|
170
|
-
count: schemaKeys.length,
|
|
171
|
-
data: schemaKeys,
|
|
172
|
-
});
|
|
173
|
-
const schemaValues = Object.values(options.schemas);
|
|
174
|
-
const schemas = (0, ffi_1.ObjectHandleListStruct)({
|
|
175
|
-
count: schemaValues.length,
|
|
176
|
-
data: (0, ffi_1.ObjectHandleArray)(schemaValues.map((o) => o.handle)),
|
|
177
|
-
});
|
|
178
|
-
const credentialDefinitionKeys = Object.keys(options.credentialDefinitions);
|
|
179
|
-
const credentialDefinitionIds = (0, ffi_1.StringListStruct)({
|
|
180
|
-
count: credentialDefinitionKeys.length,
|
|
181
|
-
data: credentialDefinitionKeys,
|
|
182
|
-
});
|
|
183
|
-
const credentialDefinitionValues = Object.values(options.credentialDefinitions);
|
|
184
|
-
const credentialDefinitions = (0, ffi_1.ObjectHandleListStruct)({
|
|
185
|
-
count: credentialDefinitionValues.length,
|
|
186
|
-
data: (0, ffi_1.ObjectHandleArray)(credentialDefinitionValues.map((o) => o.handle)),
|
|
129
|
+
data: Object.values(options.selfAttest)
|
|
187
130
|
});
|
|
131
|
+
const credentialEntryList = this.convertCredentialList(options.credentials);
|
|
132
|
+
const credentialProveList = this.convertCredentialProves(options.credentialsProve);
|
|
133
|
+
const { schemaIds, schemas } = this.convertSchemas(options.schemas);
|
|
134
|
+
const { credentialDefinitionIds, credentialDefinitions } = this.convertCredDefs(options.credentialDefinitions);
|
|
188
135
|
const ret = (0, ffi_1.allocatePointer)();
|
|
189
136
|
this.nativeAnoncreds.anoncreds_create_presentation(presentationRequest, credentialEntryList, credentialProveList, selfAttestNames, selfAttestValues, linkSecret, schemas, schemaIds, credentialDefinitions, credentialDefinitionIds, ret);
|
|
190
137
|
this.handleError();
|
|
191
138
|
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
192
139
|
}
|
|
193
140
|
verifyPresentation(options) {
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
const nativeNonRevokedIntervalOverrides = (_a = options.nonRevokedIntervalOverrides) === null || _a === void 0 ? void 0 : _a.map((value) => {
|
|
197
|
-
const { requestedFromTimestamp, revocationRegistryDefinitionId, overrideRevocationStatusListTimestamp } = (0, ffi_1.serializeArguments)(value);
|
|
198
|
-
return (0, ffi_1.NonRevokedIntervalOverrideStruct)({
|
|
199
|
-
rev_reg_def_id: revocationRegistryDefinitionId,
|
|
200
|
-
requested_from_ts: requestedFromTimestamp,
|
|
201
|
-
override_rev_status_list_ts: overrideRevocationStatusListTimestamp,
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
const nonRevokedIntervalOverrideList = (0, ffi_1.NonRevokedIntervalOverrideListStruct)({
|
|
205
|
-
count: (_c = (_b = options.nonRevokedIntervalOverrides) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0,
|
|
206
|
-
data: nativeNonRevokedIntervalOverrides,
|
|
207
|
-
});
|
|
141
|
+
const { presentation, presentationRequest, schemas, credentialDefinitions, revocationRegistryDefinitions, revocationStatusLists, revocationRegistryDefinitionIds, schemaIds, credentialDefinitionIds } = (0, ffi_1.serializeArguments)(options);
|
|
142
|
+
const nonRevokedIntervalOverrideList = this.convertNonRevokedIntervalOverrides(options.nonRevokedIntervalOverrides);
|
|
208
143
|
const ret = (0, ffi_1.allocateInt8Buffer)();
|
|
209
144
|
this.nativeAnoncreds.anoncreds_verify_presentation(presentation, presentationRequest, schemas, schemaIds, credentialDefinitions, credentialDefinitionIds, revocationRegistryDefinitions, revocationRegistryDefinitionIds, revocationStatusLists, nonRevokedIntervalOverrideList, ret);
|
|
210
145
|
this.handleError();
|
|
211
146
|
return Boolean(handleReturnPointer(ret));
|
|
212
147
|
}
|
|
213
148
|
createRevocationStatusList(options) {
|
|
214
|
-
const {
|
|
149
|
+
const { credentialDefinition, revocationRegistryDefinitionId, revocationRegistryDefinition, revocationRegistryDefinitionPrivate, issuerId, issuanceByDefault, timestamp } = (0, ffi_1.serializeArguments)(options);
|
|
215
150
|
const ret = (0, ffi_1.allocatePointer)();
|
|
216
|
-
this.nativeAnoncreds.anoncreds_create_revocation_status_list(revocationRegistryDefinitionId, revocationRegistryDefinition, issuerId, timestamp !== null && timestamp !== void 0 ? timestamp : -1,
|
|
151
|
+
this.nativeAnoncreds.anoncreds_create_revocation_status_list(credentialDefinition, revocationRegistryDefinitionId, revocationRegistryDefinition, revocationRegistryDefinitionPrivate, issuerId, issuanceByDefault, timestamp !== null && timestamp !== void 0 ? timestamp : -1, ret);
|
|
217
152
|
this.handleError();
|
|
218
153
|
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
219
154
|
}
|
|
@@ -225,21 +160,21 @@ class NodeJSAnoncreds {
|
|
|
225
160
|
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
226
161
|
}
|
|
227
162
|
updateRevocationStatusList(options) {
|
|
228
|
-
const {
|
|
163
|
+
const { credentialDefinition, revocationRegistryDefinition, revocationRegistryDefinitionPrivate, currentRevocationStatusList, issued, revoked, timestamp } = (0, ffi_1.serializeArguments)(options);
|
|
229
164
|
const ret = (0, ffi_1.allocatePointer)();
|
|
230
|
-
this.nativeAnoncreds.anoncreds_update_revocation_status_list(timestamp !== null && timestamp !== void 0 ? timestamp : -1,
|
|
165
|
+
this.nativeAnoncreds.anoncreds_update_revocation_status_list(credentialDefinition, revocationRegistryDefinition, revocationRegistryDefinitionPrivate, currentRevocationStatusList, issued, revoked, timestamp !== null && timestamp !== void 0 ? timestamp : -1, ret);
|
|
231
166
|
this.handleError();
|
|
232
167
|
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
233
168
|
}
|
|
234
169
|
createRevocationRegistryDefinition(options) {
|
|
235
|
-
const { credentialDefinition, credentialDefinitionId, tag, revocationRegistryType, issuerId, maximumCredentialNumber, tailsDirectoryPath
|
|
170
|
+
const { credentialDefinition, credentialDefinitionId, tag, revocationRegistryType, issuerId, maximumCredentialNumber, tailsDirectoryPath } = (0, ffi_1.serializeArguments)(options);
|
|
236
171
|
const revocationRegistryDefinitionPtr = (0, ffi_1.allocatePointer)();
|
|
237
172
|
const revocationRegistryDefinitionPrivate = (0, ffi_1.allocatePointer)();
|
|
238
173
|
this.nativeAnoncreds.anoncreds_create_revocation_registry_def(credentialDefinition, credentialDefinitionId, issuerId, tag, revocationRegistryType, maximumCredentialNumber, tailsDirectoryPath, revocationRegistryDefinitionPtr, revocationRegistryDefinitionPrivate);
|
|
239
174
|
this.handleError();
|
|
240
175
|
return {
|
|
241
176
|
revocationRegistryDefinition: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(revocationRegistryDefinitionPtr)),
|
|
242
|
-
revocationRegistryDefinitionPrivate: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(revocationRegistryDefinitionPrivate))
|
|
177
|
+
revocationRegistryDefinitionPrivate: new anoncreds_shared_1.ObjectHandle(handleReturnPointer(revocationRegistryDefinitionPrivate))
|
|
243
178
|
};
|
|
244
179
|
}
|
|
245
180
|
createOrUpdateRevocationState(options) {
|
|
@@ -252,6 +187,78 @@ class NodeJSAnoncreds {
|
|
|
252
187
|
this.handleError();
|
|
253
188
|
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
254
189
|
}
|
|
190
|
+
createW3cCredential(options) {
|
|
191
|
+
var _a;
|
|
192
|
+
const { credentialDefinition, credentialDefinitionPrivate, credentialOffer, credentialRequest, w3cVersion } = (0, ffi_1.serializeArguments)(options);
|
|
193
|
+
const attributeNames = this.convertAttributeNames(options.attributeRawValues);
|
|
194
|
+
const attributeRawValues = this.convertAttributeRawValues(options.attributeRawValues);
|
|
195
|
+
const revocationConfiguration = this.convertRevocationConfiguration(options.revocationConfiguration);
|
|
196
|
+
const credentialPtr = (0, ffi_1.allocatePointer)();
|
|
197
|
+
this.nativeAnoncreds.anoncreds_create_w3c_credential(credentialDefinition, credentialDefinitionPrivate, credentialOffer, credentialRequest, attributeNames, attributeRawValues, (_a = revocationConfiguration === null || revocationConfiguration === void 0 ? void 0 : revocationConfiguration.ref().address()) !== null && _a !== void 0 ? _a : 0, w3cVersion, credentialPtr);
|
|
198
|
+
this.handleError();
|
|
199
|
+
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(credentialPtr));
|
|
200
|
+
}
|
|
201
|
+
processW3cCredential(options) {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
const { credential, credentialRequestMetadata, linkSecret, credentialDefinition } = (0, ffi_1.serializeArguments)(options);
|
|
204
|
+
const ret = (0, ffi_1.allocatePointer)();
|
|
205
|
+
this.nativeAnoncreds.anoncreds_process_w3c_credential(credential, credentialRequestMetadata, linkSecret, credentialDefinition, (_b = (_a = options.revocationRegistryDefinition) === null || _a === void 0 ? void 0 : _a.handle) !== null && _b !== void 0 ? _b : 0, ret);
|
|
206
|
+
this.handleError();
|
|
207
|
+
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
208
|
+
}
|
|
209
|
+
createW3cPresentation(options) {
|
|
210
|
+
const { presentationRequest, linkSecret, w3cVersion } = (0, ffi_1.serializeArguments)(options);
|
|
211
|
+
const credentialEntryList = this.convertCredentialList(options.credentials);
|
|
212
|
+
const credentialProveList = this.convertCredentialProves(options.credentialsProve);
|
|
213
|
+
const { schemaIds, schemas } = this.convertSchemas(options.schemas);
|
|
214
|
+
const { credentialDefinitionIds, credentialDefinitions } = this.convertCredDefs(options.credentialDefinitions);
|
|
215
|
+
const ret = (0, ffi_1.allocatePointer)();
|
|
216
|
+
this.nativeAnoncreds.anoncreds_create_w3c_presentation(presentationRequest, credentialEntryList, credentialProveList, linkSecret, schemas, schemaIds, credentialDefinitions, credentialDefinitionIds, w3cVersion, ret);
|
|
217
|
+
this.handleError();
|
|
218
|
+
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
219
|
+
}
|
|
220
|
+
verifyW3cPresentation(options) {
|
|
221
|
+
const { presentation, presentationRequest, schemas, credentialDefinitions, revocationRegistryDefinitions, revocationStatusLists, revocationRegistryDefinitionIds, schemaIds, credentialDefinitionIds } = (0, ffi_1.serializeArguments)(options);
|
|
222
|
+
const nonRevokedIntervalOverrideList = this.convertNonRevokedIntervalOverrides(options.nonRevokedIntervalOverrides);
|
|
223
|
+
const ret = (0, ffi_1.allocateInt8Buffer)();
|
|
224
|
+
this.nativeAnoncreds.anoncreds_verify_w3c_presentation(presentation, presentationRequest, schemas, schemaIds, credentialDefinitions, credentialDefinitionIds, revocationRegistryDefinitions, revocationRegistryDefinitionIds, revocationStatusLists, nonRevokedIntervalOverrideList, ret);
|
|
225
|
+
this.handleError();
|
|
226
|
+
return Boolean(handleReturnPointer(ret));
|
|
227
|
+
}
|
|
228
|
+
credentialToW3c(options) {
|
|
229
|
+
const { objectHandle, credentialDefinition, w3cVersion } = (0, ffi_1.serializeArguments)(options);
|
|
230
|
+
const ret = (0, ffi_1.allocatePointer)();
|
|
231
|
+
this.nativeAnoncreds.anoncreds_credential_to_w3c(objectHandle, credentialDefinition, w3cVersion, ret);
|
|
232
|
+
this.handleError();
|
|
233
|
+
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
234
|
+
}
|
|
235
|
+
credentialFromW3c(options) {
|
|
236
|
+
const { objectHandle } = (0, ffi_1.serializeArguments)(options);
|
|
237
|
+
const ret = (0, ffi_1.allocatePointer)();
|
|
238
|
+
this.nativeAnoncreds.anoncreds_credential_from_w3c(objectHandle, ret);
|
|
239
|
+
this.handleError();
|
|
240
|
+
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
241
|
+
}
|
|
242
|
+
w3cCredentialGetIntegrityProofDetails(options) {
|
|
243
|
+
const { objectHandle } = (0, ffi_1.serializeArguments)(options);
|
|
244
|
+
const ret = (0, ffi_1.allocatePointer)();
|
|
245
|
+
this.nativeAnoncreds.anoncreds_w3c_credential_get_integrity_proof_details(objectHandle, ret);
|
|
246
|
+
this.handleError();
|
|
247
|
+
return new anoncreds_shared_1.ObjectHandle(handleReturnPointer(ret));
|
|
248
|
+
}
|
|
249
|
+
w3cCredentialProofGetAttribute(options) {
|
|
250
|
+
const { objectHandle, name } = (0, ffi_1.serializeArguments)(options);
|
|
251
|
+
const ret = (0, ffi_1.allocateStringBuffer)();
|
|
252
|
+
this.nativeAnoncreds.anoncreds_w3c_credential_proof_get_attribute(objectHandle, name, ret);
|
|
253
|
+
this.handleError();
|
|
254
|
+
return handleReturnPointer(ret);
|
|
255
|
+
}
|
|
256
|
+
w3cCredentialFromJson(options) {
|
|
257
|
+
return this.objectFromJson(this.nativeAnoncreds.anoncreds_w3c_credential_from_json, options);
|
|
258
|
+
}
|
|
259
|
+
w3cPresentationFromJson(options) {
|
|
260
|
+
return this.objectFromJson(this.nativeAnoncreds.anoncreds_w3c_presentation_from_json, options);
|
|
261
|
+
}
|
|
255
262
|
version() {
|
|
256
263
|
return this.nativeAnoncreds.anoncreds_version();
|
|
257
264
|
}
|
|
@@ -324,8 +331,10 @@ class NodeJSAnoncreds {
|
|
|
324
331
|
this.nativeAnoncreds.anoncreds_object_get_json(objectHandle, ret);
|
|
325
332
|
this.handleError();
|
|
326
333
|
const returnValue = handleReturnPointer(ret);
|
|
327
|
-
const
|
|
328
|
-
|
|
334
|
+
const jsonAsArray = new Uint8Array((0, ffi_1.byteBufferToBuffer)(returnValue));
|
|
335
|
+
const output = new util_1.TextDecoder().decode(jsonAsArray);
|
|
336
|
+
this.nativeAnoncreds.anoncreds_buffer_free(returnValue.data);
|
|
337
|
+
return output;
|
|
329
338
|
}
|
|
330
339
|
getTypeName(options) {
|
|
331
340
|
const { objectHandle } = (0, ffi_1.serializeArguments)(options);
|
|
@@ -338,6 +347,110 @@ class NodeJSAnoncreds {
|
|
|
338
347
|
this.nativeAnoncreds.anoncreds_object_free(options.objectHandle.handle);
|
|
339
348
|
this.handleError();
|
|
340
349
|
}
|
|
350
|
+
convertCredentialList(credentials) {
|
|
351
|
+
const credentialEntries = credentials.map((value) => {
|
|
352
|
+
var _a, _b, _c;
|
|
353
|
+
return (0, ffi_1.CredentialEntryStruct)({
|
|
354
|
+
credential: value.credential.handle,
|
|
355
|
+
timestamp: (_a = value.timestamp) !== null && _a !== void 0 ? _a : -1,
|
|
356
|
+
rev_state: (_c = (_b = value.revocationState) === null || _b === void 0 ? void 0 : _b.handle) !== null && _c !== void 0 ? _c : 0
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
return (0, ffi_1.CredentialEntryListStruct)({
|
|
360
|
+
count: credentialEntries.length,
|
|
361
|
+
data: credentialEntries
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
convertCredentialProves(credentialsProve) {
|
|
365
|
+
const credentialProves = credentialsProve.map((value) => {
|
|
366
|
+
const { entryIndex: entry_idx, isPredicate: is_predicate, reveal, referent } = (0, ffi_1.serializeArguments)(value);
|
|
367
|
+
return (0, ffi_1.CredentialProveStruct)({ entry_idx, referent, is_predicate, reveal });
|
|
368
|
+
});
|
|
369
|
+
return (0, ffi_1.CredentialProveListStruct)({
|
|
370
|
+
count: credentialProves.length,
|
|
371
|
+
data: credentialProves
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
convertSchemas(schemas) {
|
|
375
|
+
const schemaKeys = Object.keys(schemas);
|
|
376
|
+
const schemaIds = (0, ffi_1.StringListStruct)({
|
|
377
|
+
count: schemaKeys.length,
|
|
378
|
+
data: schemaKeys
|
|
379
|
+
});
|
|
380
|
+
const schemaValues = Object.values(schemas);
|
|
381
|
+
const schemasList = (0, ffi_1.ObjectHandleListStruct)({
|
|
382
|
+
count: schemaValues.length,
|
|
383
|
+
data: (0, ffi_1.ObjectHandleArray)(schemaValues.map((o) => o.handle))
|
|
384
|
+
});
|
|
385
|
+
return {
|
|
386
|
+
schemaIds,
|
|
387
|
+
schemas: schemasList
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
convertCredDefs(credentialDefinitions) {
|
|
391
|
+
const credentialDefinitionKeys = Object.keys(credentialDefinitions);
|
|
392
|
+
const credentialDefinitionIds = (0, ffi_1.StringListStruct)({
|
|
393
|
+
count: credentialDefinitionKeys.length,
|
|
394
|
+
data: credentialDefinitionKeys
|
|
395
|
+
});
|
|
396
|
+
const credentialDefinitionValues = Object.values(credentialDefinitions);
|
|
397
|
+
const credentialDefinitionsList = (0, ffi_1.ObjectHandleListStruct)({
|
|
398
|
+
count: credentialDefinitionValues.length,
|
|
399
|
+
data: (0, ffi_1.ObjectHandleArray)(credentialDefinitionValues.map((o) => o.handle))
|
|
400
|
+
});
|
|
401
|
+
return {
|
|
402
|
+
credentialDefinitionIds,
|
|
403
|
+
credentialDefinitions: credentialDefinitionsList
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
convertNonRevokedIntervalOverrides(nonRevokedIntervalOverrides) {
|
|
407
|
+
var _a;
|
|
408
|
+
const nativeNonRevokedIntervalOverrides = nonRevokedIntervalOverrides === null || nonRevokedIntervalOverrides === void 0 ? void 0 : nonRevokedIntervalOverrides.map((value) => {
|
|
409
|
+
const { requestedFromTimestamp, revocationRegistryDefinitionId, overrideRevocationStatusListTimestamp } = (0, ffi_1.serializeArguments)(value);
|
|
410
|
+
return (0, ffi_1.NonRevokedIntervalOverrideStruct)({
|
|
411
|
+
rev_reg_def_id: revocationRegistryDefinitionId,
|
|
412
|
+
requested_from_ts: requestedFromTimestamp,
|
|
413
|
+
override_rev_status_list_ts: overrideRevocationStatusListTimestamp
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
return (0, ffi_1.NonRevokedIntervalOverrideListStruct)({
|
|
417
|
+
count: (_a = nonRevokedIntervalOverrides === null || nonRevokedIntervalOverrides === void 0 ? void 0 : nonRevokedIntervalOverrides.length) !== null && _a !== void 0 ? _a : 0,
|
|
418
|
+
data: nativeNonRevokedIntervalOverrides
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
convertAttributeNames(attributeRawValues) {
|
|
422
|
+
return (0, ffi_1.StringListStruct)({
|
|
423
|
+
count: Object.keys(attributeRawValues).length,
|
|
424
|
+
data: Object.keys(attributeRawValues)
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
convertAttributeRawValues(attributeRawValues) {
|
|
428
|
+
return (0, ffi_1.StringListStruct)({
|
|
429
|
+
count: Object.keys(attributeRawValues).length,
|
|
430
|
+
data: Object.values(attributeRawValues)
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
convertAttributeEncodedValues(attributeEncodedValues) {
|
|
434
|
+
return attributeEncodedValues
|
|
435
|
+
? (0, ffi_1.StringListStruct)({
|
|
436
|
+
count: Object.keys(attributeEncodedValues).length,
|
|
437
|
+
data: Object.values(attributeEncodedValues)
|
|
438
|
+
})
|
|
439
|
+
: undefined;
|
|
440
|
+
}
|
|
441
|
+
convertRevocationConfiguration(revocationConfiguration) {
|
|
442
|
+
let credRevInfo;
|
|
443
|
+
if (revocationConfiguration) {
|
|
444
|
+
const { revocationRegistryDefinition, revocationRegistryDefinitionPrivate, revocationStatusList, registryIndex } = (0, ffi_1.serializeArguments)(revocationConfiguration);
|
|
445
|
+
credRevInfo = (0, ffi_1.CredRevInfoStruct)({
|
|
446
|
+
reg_def: revocationRegistryDefinition,
|
|
447
|
+
reg_def_private: revocationRegistryDefinitionPrivate,
|
|
448
|
+
status_list: revocationStatusList,
|
|
449
|
+
reg_idx: registryIndex
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return credRevInfo;
|
|
453
|
+
}
|
|
341
454
|
}
|
|
342
455
|
exports.NodeJSAnoncreds = NodeJSAnoncreds;
|
|
343
456
|
//# sourceMappingURL=NodeJSAnoncreds.js.map
|