@twin.org/immutable-proof-task 0.0.3-next.12 → 0.0.3-next.14
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/es/immutableProofTask.js +17 -2
- package/dist/es/immutableProofTask.js.map +1 -1
- package/dist/es/models/IImmutableProofTaskPayload.js.map +1 -1
- package/dist/es/models/IImmutableProofTaskResult.js.map +1 -1
- package/dist/types/models/IImmutableProofTaskPayload.d.ts +9 -0
- package/dist/types/models/IImmutableProofTaskResult.d.ts +4 -0
- package/docs/changelog.md +28 -0
- package/docs/reference/interfaces/IImmutableProofTaskPayload.md +17 -0
- package/docs/reference/interfaces/IImmutableProofTaskResult.md +8 -0
- package/package.json +3 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ContextIdStore } from "@twin.org/context";
|
|
4
|
-
import { Guards, Is } from "@twin.org/core";
|
|
4
|
+
import { Guards, Is, ObjectHelper } from "@twin.org/core";
|
|
5
5
|
import { EngineCore } from "@twin.org/engine-core";
|
|
6
6
|
import { IdentityConnectorFactory } from "@twin.org/identity-models";
|
|
7
|
+
import { NotarizationConnectorFactory, NotarizationMode } from "@twin.org/notarization-models";
|
|
7
8
|
const CLASS_NAME = "ImmutableProofTask";
|
|
8
9
|
/**
|
|
9
10
|
* Process a proof.
|
|
@@ -17,6 +18,7 @@ export async function processProofTask(engineCloneData, payload) {
|
|
|
17
18
|
Guards.stringValue(CLASS_NAME, "payload.identityConnectorType", payload.identityConnectorType);
|
|
18
19
|
Guards.stringValue(CLASS_NAME, "payload.verificationMethodId", payload.verificationMethodId);
|
|
19
20
|
Guards.object(CLASS_NAME, "payload.credentialSubject", payload.credentialSubject);
|
|
21
|
+
Guards.stringValue(CLASS_NAME, "payload.notarizationConnectorType", payload.notarizationConnectorType);
|
|
20
22
|
let engine;
|
|
21
23
|
try {
|
|
22
24
|
if (!Is.empty(engineCloneData)) {
|
|
@@ -28,9 +30,22 @@ export async function processProofTask(engineCloneData, payload) {
|
|
|
28
30
|
}
|
|
29
31
|
const identityConnector = IdentityConnectorFactory.get(payload.identityConnectorType);
|
|
30
32
|
const result = await identityConnector.createVerifiableCredential(payload.identity, `${payload.identity}#${payload.verificationMethodId}`, payload.proofId, payload.credentialSubject);
|
|
33
|
+
// The proof context is always the last one in the generated vc contexts
|
|
34
|
+
// as that was the last operation performed, so we can extract it and use it for the proof itself.
|
|
35
|
+
// Remove verificationMethod to reduce linkage to the issuing identity (reinstated on verify).
|
|
36
|
+
const proof = result.verifiableCredential.proof;
|
|
37
|
+
proof["@context"] = result.verifiableCredential["@context"][result.verifiableCredential["@context"].length - 1];
|
|
38
|
+
delete proof.verificationMethod;
|
|
39
|
+
const notarizationConnector = NotarizationConnectorFactory.get(payload.notarizationConnectorType);
|
|
40
|
+
const notarizationId = await notarizationConnector.create(payload.identity, {
|
|
41
|
+
mode: NotarizationMode.Locked,
|
|
42
|
+
data: ObjectHelper.toBytes(proof),
|
|
43
|
+
deleteLockDateTime: payload.deleteLockDateTime
|
|
44
|
+
});
|
|
31
45
|
return {
|
|
32
46
|
proofId: payload.proofId,
|
|
33
|
-
verifiableCredential: result.verifiableCredential
|
|
47
|
+
verifiableCredential: result.verifiableCredential,
|
|
48
|
+
notarizationId
|
|
34
49
|
};
|
|
35
50
|
}
|
|
36
51
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"immutableProofTask.js","sourceRoot":"","sources":["../../src/immutableProofTask.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"immutableProofTask.js","sourceRoot":"","sources":["../../src/immutableProofTask.ts"],"names":[],"mappings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ier: Apache-2.0.\nimport { ContextIdStore } from \"@twin.org/context\";\nimport { Guards, Is, ObjectHelper } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { EngineCore } from \"@twin.org/engine-core\";\nimport type { IEngineCore, IEngineCoreClone } from \"@twin.org/engine-models\";\nimport { IdentityConnectorFactory } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { NotarizationConnectorFactory, NotarizationMode } from \"@twin.org/notarization-models\";\nimport type { IProof } from \"@twin.org/standards-w3c-did\";\nimport type { IImmutableProofTaskPayload } from \"./models/IImmutableProofTaskPayload.js\";\nimport type { IImmutableProofTaskResult } from \"./models/IImmutableProofTaskResult.js\";\n\nconst CLASS_NAME = \"ImmutableProofTask\";\n\n/**\n * Process a proof.\n * @param engineCloneData The engine clone data.\n * @param payload The payload to process.\n * @returns The proof.\n */\nexport async function processProofTask(\n\tengineCloneData: IEngineCoreClone,\n\tpayload: IImmutableProofTaskPayload\n): Promise<IImmutableProofTaskResult> {\n\tGuards.objectValue<IImmutableProofTaskPayload>(CLASS_NAME, nameof(payload), payload);\n\tGuards.stringValue(CLASS_NAME, nameof(payload.identity), payload.identity);\n\tGuards.stringValue(\n\t\tCLASS_NAME,\n\t\tnameof(payload.identityConnectorType),\n\t\tpayload.identityConnectorType\n\t);\n\tGuards.stringValue(\n\t\tCLASS_NAME,\n\t\tnameof(payload.verificationMethodId),\n\t\tpayload.verificationMethodId\n\t);\n\tGuards.object<IJsonLdNodeObject>(\n\t\tCLASS_NAME,\n\t\tnameof(payload.credentialSubject),\n\t\tpayload.credentialSubject\n\t);\n\tGuards.stringValue(\n\t\tCLASS_NAME,\n\t\tnameof(payload.notarizationConnectorType),\n\t\tpayload.notarizationConnectorType\n\t);\n\n\tlet engine: IEngineCore | undefined;\n\ttry {\n\t\tif (!Is.empty(engineCloneData)) {\n\t\t\t// If the clone data is not empty we use it to create a new engine as it's a new thread\n\t\t\t// otherwise we assume the factories are already populated.\n\t\t\tengine = new EngineCore();\n\t\t\tengine.populateClone(engineCloneData, await ContextIdStore.getContextIds(), true);\n\t\t\tawait engine.start();\n\t\t}\n\n\t\tconst identityConnector = IdentityConnectorFactory.get(payload.identityConnectorType);\n\n\t\tconst result = await identityConnector.createVerifiableCredential(\n\t\t\tpayload.identity,\n\t\t\t`${payload.identity}#${payload.verificationMethodId}`,\n\t\t\tpayload.proofId,\n\t\t\tpayload.credentialSubject\n\t\t);\n\n\t\t// The proof context is always the last one in the generated vc contexts\n\t\t// as that was the last operation performed, so we can extract it and use it for the proof itself.\n\t\t// Remove verificationMethod to reduce linkage to the issuing identity (reinstated on verify).\n\t\tconst proof: IProof = result.verifiableCredential.proof as IProof;\n\t\tproof[\"@context\"] = result.verifiableCredential[\"@context\"][\n\t\t\tresult.verifiableCredential[\"@context\"].length - 1\n\t\t] as IProof[\"@context\"];\n\t\tdelete proof.verificationMethod;\n\n\t\tconst notarizationConnector = NotarizationConnectorFactory.get(\n\t\t\tpayload.notarizationConnectorType\n\t\t);\n\t\tconst notarizationId = await notarizationConnector.create(payload.identity, {\n\t\t\tmode: NotarizationMode.Locked,\n\t\t\tdata: ObjectHelper.toBytes(proof),\n\t\t\tdeleteLockDateTime: payload.deleteLockDateTime\n\t\t});\n\n\t\treturn {\n\t\t\tproofId: payload.proofId,\n\t\t\tverifiableCredential: result.verifiableCredential,\n\t\t\tnotarizationId\n\t\t};\n\t} finally {\n\t\tif (!Is.empty(engine)) {\n\t\t\tawait engine.stop();\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IImmutableProofTaskPayload.js","sourceRoot":"","sources":["../../../src/models/IImmutableProofTaskPayload.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IImmutableProof } from \"@twin.org/immutable-proof-models\";\n\n/**\n * The payload for the immutable proof task.\n */\nexport interface IImmutableProofTaskPayload {\n\t/**\n\t * The proof id.\n\t */\n\tproofId: string;\n\n\t/**\n\t * The identity to create the proof for.\n\t */\n\tidentity: string;\n\n\t/**\n\t * The identity connector type.\n\t */\n\tidentityConnectorType: string;\n\n\t/**\n\t * The assertion method id.\n\t */\n\tverificationMethodId: string;\n\n\t/**\n\t * The subject to create the proof for.\n\t */\n\tcredentialSubject: IImmutableProof;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IImmutableProofTaskPayload.js","sourceRoot":"","sources":["../../../src/models/IImmutableProofTaskPayload.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IImmutableProof } from \"@twin.org/immutable-proof-models\";\n\n/**\n * The payload for the immutable proof task.\n */\nexport interface IImmutableProofTaskPayload {\n\t/**\n\t * The proof id.\n\t */\n\tproofId: string;\n\n\t/**\n\t * The identity to create the proof for.\n\t */\n\tidentity: string;\n\n\t/**\n\t * The identity connector type.\n\t */\n\tidentityConnectorType: string;\n\n\t/**\n\t * The assertion method id.\n\t */\n\tverificationMethodId: string;\n\n\t/**\n\t * The subject to create the proof for.\n\t */\n\tcredentialSubject: IImmutableProof;\n\n\t/**\n\t * The notarization connector type.\n\t */\n\tnotarizationConnectorType: string;\n\n\t/**\n\t * An ISO 8601 date-time string specifying when the notarization lock expires.\n\t * If omitted, no deletion lock is applied.\n\t */\n\tdeleteLockDateTime?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IImmutableProofTaskResult.js","sourceRoot":"","sources":["../../../src/models/IImmutableProofTaskResult.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IDidVerifiableCredential } from \"@twin.org/standards-w3c-did\";\n\n/**\n * The result for the immutable proof task.\n */\nexport interface IImmutableProofTaskResult {\n\t/**\n\t * The proof id.\n\t */\n\tproofId: string;\n\n\t/**\n\t * The proof, we only generate a single proof, so restrict to a single proof.\n\t */\n\tverifiableCredential: IDidVerifiableCredential;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IImmutableProofTaskResult.js","sourceRoot":"","sources":["../../../src/models/IImmutableProofTaskResult.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IDidVerifiableCredential } from \"@twin.org/standards-w3c-did\";\n\n/**\n * The result for the immutable proof task.\n */\nexport interface IImmutableProofTaskResult {\n\t/**\n\t * The proof id.\n\t */\n\tproofId: string;\n\n\t/**\n\t * The proof, we only generate a single proof, so restrict to a single proof.\n\t */\n\tverifiableCredential: IDidVerifiableCredential;\n\n\t/**\n\t * The notarization id returned after storing the proof.\n\t */\n\tnotarizationId: string;\n}\n"]}
|
|
@@ -23,4 +23,13 @@ export interface IImmutableProofTaskPayload {
|
|
|
23
23
|
* The subject to create the proof for.
|
|
24
24
|
*/
|
|
25
25
|
credentialSubject: IImmutableProof;
|
|
26
|
+
/**
|
|
27
|
+
* The notarization connector type.
|
|
28
|
+
*/
|
|
29
|
+
notarizationConnectorType: string;
|
|
30
|
+
/**
|
|
31
|
+
* An ISO 8601 date-time string specifying when the notarization lock expires.
|
|
32
|
+
* If omitted, no deletion lock is applied.
|
|
33
|
+
*/
|
|
34
|
+
deleteLockDateTime?: string;
|
|
26
35
|
}
|
|
@@ -11,4 +11,8 @@ export interface IImmutableProofTaskResult {
|
|
|
11
11
|
* The proof, we only generate a single proof, so restrict to a single proof.
|
|
12
12
|
*/
|
|
13
13
|
verifiableCredential: IDidVerifiableCredential;
|
|
14
|
+
/**
|
|
15
|
+
* The notarization id returned after storing the proof.
|
|
16
|
+
*/
|
|
17
|
+
notarizationId: string;
|
|
14
18
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.14](https://github.com/iotaledger/twin-immutable-proof/compare/immutable-proof-task-v0.0.3-next.13...immutable-proof-task-v0.0.3-next.14) (2026-05-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* replace verifiable storage with notarization as immutable proof ([#41](https://github.com/iotaledger/twin-immutable-proof/issues/41)) ([54f2154](https://github.com/iotaledger/twin-immutable-proof/commit/54f215469b0bdc9ea94cad572ca13b8533144104))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/immutable-proof-models bumped from 0.0.3-next.13 to 0.0.3-next.14
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.13](https://github.com/iotaledger/twin-immutable-proof/compare/immutable-proof-task-v0.0.3-next.12...immutable-proof-task-v0.0.3-next.13) (2026-05-20)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* update dependencies ([1ec6b18](https://github.com/iotaledger/twin-immutable-proof/commit/1ec6b18e93198a8fc4935700863cdab1c3df7b64))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/immutable-proof-models bumped from 0.0.3-next.12 to 0.0.3-next.13
|
|
30
|
+
|
|
3
31
|
## [0.0.3-next.12](https://github.com/iotaledger/twin-immutable-proof/compare/immutable-proof-task-v0.0.3-next.11...immutable-proof-task-v0.0.3-next.12) (2026-05-12)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -41,3 +41,20 @@ The assertion method id.
|
|
|
41
41
|
> **credentialSubject**: `IImmutableProof`
|
|
42
42
|
|
|
43
43
|
The subject to create the proof for.
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
### notarizationConnectorType {#notarizationconnectortype}
|
|
48
|
+
|
|
49
|
+
> **notarizationConnectorType**: `string`
|
|
50
|
+
|
|
51
|
+
The notarization connector type.
|
|
52
|
+
|
|
53
|
+
***
|
|
54
|
+
|
|
55
|
+
### deleteLockDateTime? {#deletelockdatetime}
|
|
56
|
+
|
|
57
|
+
> `optional` **deleteLockDateTime?**: `string`
|
|
58
|
+
|
|
59
|
+
An ISO 8601 date-time string specifying when the notarization lock expires.
|
|
60
|
+
If omitted, no deletion lock is applied.
|
|
@@ -17,3 +17,11 @@ The proof id.
|
|
|
17
17
|
> **verifiableCredential**: `IDidVerifiableCredential`
|
|
18
18
|
|
|
19
19
|
The proof, we only generate a single proof, so restrict to a single proof.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### notarizationId {#notarizationid}
|
|
24
|
+
|
|
25
|
+
> **notarizationId**: `string`
|
|
26
|
+
|
|
27
|
+
The notarization id returned after storing the proof.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/immutable-proof-task",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.14",
|
|
4
4
|
"description": "Background proof processing that creates verifiable credentials from prepared payloads",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
"@twin.org/engine-core": "next",
|
|
21
21
|
"@twin.org/engine-models": "next",
|
|
22
22
|
"@twin.org/identity-models": "next",
|
|
23
|
-
"@twin.org/immutable-proof-models": "0.0.3-next.
|
|
23
|
+
"@twin.org/immutable-proof-models": "0.0.3-next.14",
|
|
24
24
|
"@twin.org/nameof": "next",
|
|
25
|
+
"@twin.org/notarization-models": "next",
|
|
25
26
|
"@twin.org/standards-w3c-did": "next"
|
|
26
27
|
},
|
|
27
28
|
"main": "./dist/es/index.js",
|