@twin.org/immutable-proof-task 0.0.1-next.14 → 0.0.1-next.15
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/dist/cjs/index.cjs +21 -10
- package/dist/esm/index.mjs +22 -11
- package/docs/changelog.md +1 -1
- package/docs/reference/functions/processProofTask.md +6 -2
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -14,21 +14,32 @@ const CLASS_NAME = "ImmutableProofTask";
|
|
|
14
14
|
* @returns The proof.
|
|
15
15
|
*/
|
|
16
16
|
async function processProofTask(engineCloneData, payload) {
|
|
17
|
-
core.Guards.objectValue(CLASS_NAME, "engineCloneData", engineCloneData);
|
|
18
17
|
core.Guards.objectValue(CLASS_NAME, "payload", payload);
|
|
19
18
|
core.Guards.stringValue(CLASS_NAME, "payload.nodeIdentity", payload.nodeIdentity);
|
|
20
19
|
core.Guards.stringValue(CLASS_NAME, "payload.identityConnectorType", payload.identityConnectorType);
|
|
21
20
|
core.Guards.stringHex(CLASS_NAME, "payload.hashData", payload.hashData);
|
|
22
21
|
core.Guards.stringValue(CLASS_NAME, "payload.assertionMethodId", payload.assertionMethodId);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
let engine;
|
|
23
|
+
try {
|
|
24
|
+
if (!core.Is.empty(engineCloneData)) {
|
|
25
|
+
// If the clone data is not empty we use it to create a new engine as it's a new thread
|
|
26
|
+
// otherwise we assume the factories are already populated.
|
|
27
|
+
engine = new engineCore.EngineCore();
|
|
28
|
+
engine.populateClone(engineCloneData, true);
|
|
29
|
+
await engine.start();
|
|
30
|
+
}
|
|
31
|
+
const identityConnector = identityModels.IdentityConnectorFactory.get(payload.identityConnectorType);
|
|
32
|
+
const proof = await identityConnector.createProof(payload.nodeIdentity, `${payload.nodeIdentity}#${payload.assertionMethodId}`, core.Converter.hexToBytes(payload.hashData));
|
|
33
|
+
return {
|
|
34
|
+
proofId: payload.proofId,
|
|
35
|
+
proof
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
if (!core.Is.empty(engine)) {
|
|
40
|
+
await engine.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
exports.processProofTask = processProofTask;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Guards, Converter } from '@twin.org/core';
|
|
1
|
+
import { Guards, Is, Converter } from '@twin.org/core';
|
|
2
2
|
import { EngineCore } from '@twin.org/engine-core';
|
|
3
3
|
import { IdentityConnectorFactory } from '@twin.org/identity-models';
|
|
4
4
|
|
|
@@ -12,21 +12,32 @@ const CLASS_NAME = "ImmutableProofTask";
|
|
|
12
12
|
* @returns The proof.
|
|
13
13
|
*/
|
|
14
14
|
async function processProofTask(engineCloneData, payload) {
|
|
15
|
-
Guards.objectValue(CLASS_NAME, "engineCloneData", engineCloneData);
|
|
16
15
|
Guards.objectValue(CLASS_NAME, "payload", payload);
|
|
17
16
|
Guards.stringValue(CLASS_NAME, "payload.nodeIdentity", payload.nodeIdentity);
|
|
18
17
|
Guards.stringValue(CLASS_NAME, "payload.identityConnectorType", payload.identityConnectorType);
|
|
19
18
|
Guards.stringHex(CLASS_NAME, "payload.hashData", payload.hashData);
|
|
20
19
|
Guards.stringValue(CLASS_NAME, "payload.assertionMethodId", payload.assertionMethodId);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
let engine;
|
|
21
|
+
try {
|
|
22
|
+
if (!Is.empty(engineCloneData)) {
|
|
23
|
+
// If the clone data is not empty we use it to create a new engine as it's a new thread
|
|
24
|
+
// otherwise we assume the factories are already populated.
|
|
25
|
+
engine = new EngineCore();
|
|
26
|
+
engine.populateClone(engineCloneData, true);
|
|
27
|
+
await engine.start();
|
|
28
|
+
}
|
|
29
|
+
const identityConnector = IdentityConnectorFactory.get(payload.identityConnectorType);
|
|
30
|
+
const proof = await identityConnector.createProof(payload.nodeIdentity, `${payload.nodeIdentity}#${payload.assertionMethodId}`, Converter.hexToBytes(payload.hashData));
|
|
31
|
+
return {
|
|
32
|
+
proofId: payload.proofId,
|
|
33
|
+
proof
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
if (!Is.empty(engine)) {
|
|
38
|
+
await engine.stop();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
export { processProofTask };
|
package/docs/changelog.md
CHANGED
|
@@ -6,11 +6,15 @@ Process a proof.
|
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### engineCloneData
|
|
10
|
+
|
|
11
|
+
`IEngineCoreClone`
|
|
10
12
|
|
|
11
13
|
The engine clone data.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
### payload
|
|
16
|
+
|
|
17
|
+
[`IImmutableProofTaskPayload`](../interfaces/IImmutableProofTaskPayload.md)
|
|
14
18
|
|
|
15
19
|
The payload to process.
|
|
16
20
|
|