@3sixty/immutable-proof-task 0.0.0-stage → 0.20.0-next.1
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/LICENSE +201 -0
- package/README.md +24 -2
- package/dist/es/immutableProofTask.js +12 -0
- package/dist/es/immutableProofTask.js.map +1 -0
- package/dist/es/index.js +6 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IImmutableProofTaskPayload.js +2 -0
- package/dist/es/models/IImmutableProofTaskPayload.js.map +1 -0
- package/dist/es/models/IImmutableProofTaskResult.js +2 -0
- package/dist/es/models/IImmutableProofTaskResult.js.map +1 -0
- package/dist/es/processProofTask.js +220 -0
- package/dist/es/processProofTask.js.map +1 -0
- package/dist/types/immutableProofTask.d.ts +9 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/models/IImmutableProofTaskPayload.d.ts +40 -0
- package/dist/types/models/IImmutableProofTaskResult.d.ts +26 -0
- package/dist/types/processProofTask.d.ts +25 -0
- package/docs/changelog.md +16 -0
- package/docs/examples.md +54 -0
- package/docs/reference/functions/processProofTask.md +26 -0
- package/docs/reference/functions/processProofTaskEnd.md +19 -0
- package/docs/reference/functions/processProofTaskStart.md +27 -0
- package/docs/reference/index.md +12 -0
- package/docs/reference/interfaces/IImmutableProofTaskPayload.md +69 -0
- package/docs/reference/interfaces/IImmutableProofTaskResult.md +38 -0
- package/locales/en.json +19 -0
- package/package.json +55 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 IOTA Stiftung.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 3Sixty Immutable Proof Task
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package provides background processing for immutable proof generation. It accepts prepared task payloads, resolves the configured identity connector, and produces verifiable credential output for downstream storage and verification.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @3sixty/immutable-proof-task
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
Usage of the APIs is shown in the examples [docs/examples.md](docs/examples.md)
|
|
14
|
+
|
|
15
|
+
## Reference
|
|
16
|
+
|
|
17
|
+
Detailed reference documentation for the API can be found in [docs/reference/index.md](docs/reference/index.md)
|
|
18
|
+
|
|
19
|
+
## Changelog
|
|
20
|
+
|
|
21
|
+
The changes between each version can be found in [docs/changelog.md](docs/changelog.md)
|
|
22
|
+
|
|
23
|
+
## Origin
|
|
24
|
+
|
|
25
|
+
This package is derived from the original [iotaledger/twin-immutable-proof](https://github.com/iotaledger/twin-immutable-proof/tree/next/packages/immutable-proof-task) repository.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The source context for guards and logging in the immutable proof task.
|
|
5
|
+
*/
|
|
6
|
+
export class ImmutableProofTask {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static CLASS_NAME = "ImmutableProofTask";
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=immutableProofTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"immutableProofTask.js","sources":["../../src/immutableProofTask.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAGvC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B;;OAEG;IACI,MAAM,CAAU,UAAU,GAAW,oBAAoB,CAAC;CACjE","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n\n/**\n * The source context for guards and logging in the immutable proof task.\n */\nexport class ImmutableProofTask {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = \"ImmutableProofTask\";\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./models/IImmutableProofTaskPayload.js\";\nexport * from \"./models/IImmutableProofTaskResult.js\";\nexport * from \"./processProofTask.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IImmutableProofTaskPayload.js","sources":["../../../src/models/IImmutableProofTaskPayload.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IImmutableProof } from \"@3sixty/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\t/**\n\t * The logging component type to use for step logging inside the task.\n\t * If omitted, no step logging is performed.\n\t */\n\tloggingComponentType?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IImmutableProofTaskResult.js","sources":["../../../src/models/IImmutableProofTaskResult.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IError } from \"@3sixty/core\";\nimport type { IDidVerifiableCredential } from \"@3sixty/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 verifiable credential produced by the proof task.\n\t */\n\tverifiableCredential: IDidVerifiableCredential;\n\n\t/**\n\t * The notarization id returned after storing the proof.\n\t * Not set when the notarization phase failed, see notarizationError.\n\t */\n\tnotarizationId?: string;\n\n\t/**\n\t * Set when the notarization phase failed. The failure is returned in the result\n\t * instead of being thrown, because the notarization may have reached the ledger\n\t * even though the call failed, and a retry could create a duplicate on-chain object.\n\t */\n\tnotarizationError?: IError;\n}\n"]}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ContextIdStore } from "@3sixty/context";
|
|
4
|
+
import { BaseError, ComponentFactory, Guards, Is, ObjectHelper } from "@3sixty/core";
|
|
5
|
+
import { IdentityConnectorFactory } from "@3sixty/identity-models";
|
|
6
|
+
import { ModuleHelper } from "@3sixty/modules";
|
|
7
|
+
import { NotarizationConnectorFactory, NotarizationMode } from "@3sixty/notarization-models";
|
|
8
|
+
import { ImmutableProofTask } from "./immutableProofTask.js";
|
|
9
|
+
/**
|
|
10
|
+
* The worker's engine clone, reused by every processProofTask call until processProofTaskEnd
|
|
11
|
+
* tears it down.
|
|
12
|
+
*/
|
|
13
|
+
let engine;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves once the most recent processProofTaskStart call has finished.
|
|
16
|
+
*/
|
|
17
|
+
let startupPromise;
|
|
18
|
+
/**
|
|
19
|
+
* Build and start the worker's engine clone. Registered as the background task handler's
|
|
20
|
+
* initialiseMethod, so it runs once per worker instead of once per task.
|
|
21
|
+
* @param engineCloneData The engine clone data used to initialize a cloned engine instance when
|
|
22
|
+
* running in a separate thread. Empty when not running in a worker thread (e.g. in tests).
|
|
23
|
+
* @param loggingComponentType The logging component type to use for step logging, if configured.
|
|
24
|
+
* @returns A promise that resolves once the engine has started.
|
|
25
|
+
*/
|
|
26
|
+
export async function processProofTaskStart(engineCloneData, loggingComponentType) {
|
|
27
|
+
let built;
|
|
28
|
+
startupPromise = (async () => {
|
|
29
|
+
if (Is.empty(engineCloneData)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
// If the clone data is not empty we are running in a worker thread - create a
|
|
34
|
+
// cloned engine instance via dynamic import so no static engine dependency is needed.
|
|
35
|
+
built = await ModuleHelper.execModuleMethod("@3sixty/engine-core", "EngineCoreBuilder.fromClone", [
|
|
36
|
+
"engine",
|
|
37
|
+
engineCloneData,
|
|
38
|
+
await ContextIdStore.getContextIds(),
|
|
39
|
+
{
|
|
40
|
+
logLevel: "error",
|
|
41
|
+
types: [
|
|
42
|
+
"loggingComponent",
|
|
43
|
+
"loggingConnector",
|
|
44
|
+
"identityConnector",
|
|
45
|
+
"notarizationConnector",
|
|
46
|
+
"vaultConnector",
|
|
47
|
+
"entityStorageConnector",
|
|
48
|
+
"platformComponent",
|
|
49
|
+
"dltConfig"
|
|
50
|
+
],
|
|
51
|
+
entityTypes: [
|
|
52
|
+
"LogEntry",
|
|
53
|
+
"LogEntryError",
|
|
54
|
+
"IdentityDocument",
|
|
55
|
+
"Notarization",
|
|
56
|
+
"VaultKey",
|
|
57
|
+
"VaultSecret"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
]);
|
|
61
|
+
engine = built;
|
|
62
|
+
await built.start();
|
|
63
|
+
const logging = ComponentFactory.getIfExists(loggingComponentType);
|
|
64
|
+
await logging?.log({
|
|
65
|
+
level: "debug",
|
|
66
|
+
source: ImmutableProofTask.CLASS_NAME,
|
|
67
|
+
ts: Date.now(),
|
|
68
|
+
message: "taskEngineStarted",
|
|
69
|
+
data: { elapsedMs: Date.now() - startTime }
|
|
70
|
+
});
|
|
71
|
+
})();
|
|
72
|
+
try {
|
|
73
|
+
await startupPromise;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
// Release this attempt's engine before awaiting anything, so a task waiting on the same
|
|
77
|
+
// startup sees no engine and rebuilds, then stop whatever did start so it is not leaked.
|
|
78
|
+
if (engine === built) {
|
|
79
|
+
engine = undefined;
|
|
80
|
+
startupPromise = undefined;
|
|
81
|
+
}
|
|
82
|
+
if (!Is.empty(built)) {
|
|
83
|
+
await stopEngine(built, loggingComponentType);
|
|
84
|
+
}
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Stop the worker's engine clone. Registered as the background task handler's shutdownMethod.
|
|
90
|
+
* @param loggingComponentType The logging component type to use for step logging, if configured.
|
|
91
|
+
* @returns A promise that resolves once the engine has stopped, even if stopping failed.
|
|
92
|
+
*/
|
|
93
|
+
export async function processProofTaskEnd(loggingComponentType) {
|
|
94
|
+
const current = engine;
|
|
95
|
+
engine = undefined;
|
|
96
|
+
startupPromise = undefined;
|
|
97
|
+
if (!Is.empty(current)) {
|
|
98
|
+
await stopEngine(current, loggingComponentType);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Stop an engine clone, logging instead of throwing when the stop fails.
|
|
103
|
+
* @param engineToStop The engine to stop.
|
|
104
|
+
* @param loggingComponentType The logging component type to use for step logging, if configured.
|
|
105
|
+
* @returns A promise that resolves once the stop attempt has finished.
|
|
106
|
+
*/
|
|
107
|
+
async function stopEngine(engineToStop, loggingComponentType) {
|
|
108
|
+
try {
|
|
109
|
+
await engineToStop.stop();
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
// A throw here must not stop the rest of the shutdown from completing.
|
|
113
|
+
try {
|
|
114
|
+
const logging = ComponentFactory.getIfExists(loggingComponentType);
|
|
115
|
+
await logging?.log({
|
|
116
|
+
level: "warn",
|
|
117
|
+
source: ImmutableProofTask.CLASS_NAME,
|
|
118
|
+
ts: Date.now(),
|
|
119
|
+
message: "taskEngineStopFailed",
|
|
120
|
+
error: BaseError.fromError(error)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Nothing more can be done if logging also fails.
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Process a proof task by creating a verifiable credential and notarizing it. Waits for the
|
|
130
|
+
* worker's engine clone to finish starting, building it if it hasn't started yet.
|
|
131
|
+
* @param engineCloneData The engine clone data used to initialize a cloned engine instance when running in a separate thread.
|
|
132
|
+
* @param payload The payload containing the proof parameters.
|
|
133
|
+
* @returns The task result containing the verifiable credential and notarization id.
|
|
134
|
+
*/
|
|
135
|
+
export async function processProofTask(engineCloneData, payload) {
|
|
136
|
+
Guards.objectValue(ImmutableProofTask.CLASS_NAME, "payload", payload);
|
|
137
|
+
Guards.stringValue(ImmutableProofTask.CLASS_NAME, "payload.identity", payload.identity);
|
|
138
|
+
Guards.stringValue(ImmutableProofTask.CLASS_NAME, "payload.identityConnectorType", payload.identityConnectorType);
|
|
139
|
+
Guards.stringValue(ImmutableProofTask.CLASS_NAME, "payload.verificationMethodId", payload.verificationMethodId);
|
|
140
|
+
Guards.object(ImmutableProofTask.CLASS_NAME, "payload.credentialSubject", payload.credentialSubject);
|
|
141
|
+
Guards.stringValue(ImmutableProofTask.CLASS_NAME, "payload.notarizationConnectorType", payload.notarizationConnectorType);
|
|
142
|
+
if (!Is.empty(engineCloneData)) {
|
|
143
|
+
let startFailed = false;
|
|
144
|
+
if (startupPromise) {
|
|
145
|
+
try {
|
|
146
|
+
await startupPromise;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
startFailed = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (startFailed || Is.empty(engine)) {
|
|
153
|
+
await processProofTaskStart(engineCloneData, payload.loggingComponentType);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const taskStartTime = Date.now();
|
|
157
|
+
const logging = ComponentFactory.getIfExists(payload.loggingComponentType);
|
|
158
|
+
const identityConnector = IdentityConnectorFactory.get(payload.identityConnectorType);
|
|
159
|
+
const credentialStartTime = Date.now();
|
|
160
|
+
const result = await identityConnector.createVerifiableCredential(payload.identity, `${payload.identity}#${payload.verificationMethodId}`, payload.proofId, payload.credentialSubject);
|
|
161
|
+
await logging?.log({
|
|
162
|
+
level: "debug",
|
|
163
|
+
source: ImmutableProofTask.CLASS_NAME,
|
|
164
|
+
ts: Date.now(),
|
|
165
|
+
message: "taskVerifiableCredentialCreated",
|
|
166
|
+
data: { proofId: payload.proofId, elapsedMs: Date.now() - credentialStartTime }
|
|
167
|
+
});
|
|
168
|
+
// The proof context is always the last one in the generated vc contexts
|
|
169
|
+
// as that was the last operation performed, so we can extract it and use it for the proof itself.
|
|
170
|
+
// Remove verificationMethod to reduce linkage to the issuing identity (reinstated on verify).
|
|
171
|
+
const proof = result.verifiableCredential.proof;
|
|
172
|
+
proof["@context"] = result.verifiableCredential["@context"][result.verifiableCredential["@context"].length - 1];
|
|
173
|
+
delete proof.verificationMethod;
|
|
174
|
+
const notarizationConnector = NotarizationConnectorFactory.get(payload.notarizationConnectorType);
|
|
175
|
+
const notarizationStartTime = Date.now();
|
|
176
|
+
try {
|
|
177
|
+
const notarizationId = await notarizationConnector.create(payload.identity, {
|
|
178
|
+
mode: NotarizationMode.Locked,
|
|
179
|
+
data: ObjectHelper.toBytes(proof),
|
|
180
|
+
deleteLockDateTime: payload.deleteLockDateTime
|
|
181
|
+
});
|
|
182
|
+
await logging?.log({
|
|
183
|
+
level: "debug",
|
|
184
|
+
source: ImmutableProofTask.CLASS_NAME,
|
|
185
|
+
ts: Date.now(),
|
|
186
|
+
message: "taskNotarizationComplete",
|
|
187
|
+
data: {
|
|
188
|
+
proofId: payload.proofId,
|
|
189
|
+
elapsedMs: Date.now() - notarizationStartTime,
|
|
190
|
+
totalElapsedMs: Date.now() - taskStartTime
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
return {
|
|
194
|
+
proofId: payload.proofId,
|
|
195
|
+
verifiableCredential: result.verifiableCredential,
|
|
196
|
+
notarizationId
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
// The notarization may have reached the ledger even though the call failed, so
|
|
201
|
+
// retrying could create a duplicate on-chain object. Return the failure in the
|
|
202
|
+
// result instead of throwing, which prevents the task engine from retrying.
|
|
203
|
+
// Failures thrown before this point are safe for the task engine to retry.
|
|
204
|
+
const notarizationError = BaseError.fromError(error);
|
|
205
|
+
await logging?.log({
|
|
206
|
+
level: "error",
|
|
207
|
+
source: ImmutableProofTask.CLASS_NAME,
|
|
208
|
+
ts: Date.now(),
|
|
209
|
+
message: "taskNotarizationFailed",
|
|
210
|
+
error: notarizationError,
|
|
211
|
+
data: { proofId: payload.proofId, elapsedMs: Date.now() - notarizationStartTime }
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
proofId: payload.proofId,
|
|
215
|
+
verifiableCredential: result.verifiableCredential,
|
|
216
|
+
notarizationError: notarizationError.toJsonObject(true)
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=processProofTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processProofTask.js","sources":["../../src/processProofTask.ts"],"names":[],"mappings":"AAAA,gCAAgC;AA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AAM,iBAAiB,GAAG,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAErD,MAAM,OAAO,EAAE,GAAG,CAAC;YAClB,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,kBAAkB,CAAC,UAAU;YACrC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,wBAAwB;YACjC,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,qBAAqB,EAAE;SACjF,CAAC,CAAC;QAEH,OAAO;YACN,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;YACjD,iBAAiB,EAAE,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC;SACvD,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdStore } from \"@3sixty/context\";\nimport { BaseError, ComponentFactory, Guards, Is, ObjectHelper } from \"@3sixty/core\";\nimport type { IJsonLdNodeObject } from \"@3sixty/data-json-ld\";\nimport { IdentityConnectorFactory } from \"@3sixty/identity-models\";\nimport type { ILoggingComponent } from \"@3sixty/logging-models\";\nimport { ModuleHelper } from \"@3sixty/modules\";\n\nimport { NotarizationConnectorFactory, NotarizationMode } from \"@3sixty/notarization-models\";\nimport type { IProof } from \"@3sixty/standards-w3c-did\";\nimport { ImmutableProofTask } from \"./immutableProofTask.js\";\nimport type { IImmutableProofTaskPayload } from \"./models/IImmutableProofTaskPayload.js\";\nimport type { IImmutableProofTaskResult } from \"./models/IImmutableProofTaskResult.js\";\n\n/**\n * The worker's engine clone, reused by every processProofTask call until processProofTaskEnd\n * tears it down.\n */\nlet engine:\n\t| {\n\t\t\tstart: () => Promise<void>;\n\t\t\tstop: () => Promise<void>;\n\t }\n\t| undefined;\n\n/**\n * Resolves once the most recent processProofTaskStart call has finished.\n */\nlet startupPromise: Promise<void> | undefined;\n\n/**\n * Build and start the worker's engine clone. Registered as the background task handler's\n * initialiseMethod, so it runs once per worker instead of once per task.\n * @param engineCloneData The engine clone data used to initialize a cloned engine instance when\n * running in a separate thread. Empty when not running in a worker thread (e.g. in tests).\n * @param loggingComponentType The logging component type to use for step logging, if configured.\n * @returns A promise that resolves once the engine has started.\n */\nexport async function processProofTaskStart(\n\tengineCloneData: unknown,\n\tloggingComponentType?: string\n): Promise<void> {\n\tlet built: typeof engine;\n\tstartupPromise = (async () => {\n\t\tif (Is.empty(engineCloneData)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst startTime = Date.now();\n\n\t\t// If the clone data is not empty we are running in a worker thread - create a\n\t\t// cloned engine instance via dynamic import so no static engine dependency is needed.\n\t\tbuilt = await ModuleHelper.execModuleMethod<NonNullable<typeof engine>>(\n\t\t\t\"@3sixty/engine-core\",\n\t\t\t\"EngineCoreBuilder.fromClone\",\n\t\t\t[\n\t\t\t\t\"engine\",\n\t\t\t\tengineCloneData,\n\t\t\t\tawait ContextIdStore.getContextIds(),\n\t\t\t\t{\n\t\t\t\t\tlogLevel: \"error\",\n\t\t\t\t\ttypes: [\n\t\t\t\t\t\t\"loggingComponent\",\n\t\t\t\t\t\t\"loggingConnector\",\n\t\t\t\t\t\t\"identityConnector\",\n\t\t\t\t\t\t\"notarizationConnector\",\n\t\t\t\t\t\t\"vaultConnector\",\n\t\t\t\t\t\t\"entityStorageConnector\",\n\t\t\t\t\t\t\"platformComponent\",\n\t\t\t\t\t\t\"dltConfig\"\n\t\t\t\t\t],\n\t\t\t\t\tentityTypes: [\n\t\t\t\t\t\t\"LogEntry\",\n\t\t\t\t\t\t\"LogEntryError\",\n\t\t\t\t\t\t\"IdentityDocument\",\n\t\t\t\t\t\t\"Notarization\",\n\t\t\t\t\t\t\"VaultKey\",\n\t\t\t\t\t\t\"VaultSecret\"\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t);\n\t\tengine = built;\n\t\tawait built.start();\n\n\t\tconst logging = ComponentFactory.getIfExists<ILoggingComponent>(loggingComponentType);\n\t\tawait logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tsource: ImmutableProofTask.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"taskEngineStarted\",\n\t\t\tdata: { elapsedMs: Date.now() - startTime }\n\t\t});\n\t})();\n\n\ttry {\n\t\tawait startupPromise;\n\t} catch (err) {\n\t\t// Release this attempt's engine before awaiting anything, so a task waiting on the same\n\t\t// startup sees no engine and rebuilds, then stop whatever did start so it is not leaked.\n\t\tif (engine === built) {\n\t\t\tengine = undefined;\n\t\t\tstartupPromise = undefined;\n\t\t}\n\t\tif (!Is.empty(built)) {\n\t\t\tawait stopEngine(built, loggingComponentType);\n\t\t}\n\t\tthrow err;\n\t}\n}\n\n/**\n * Stop the worker's engine clone. Registered as the background task handler's shutdownMethod.\n * @param loggingComponentType The logging component type to use for step logging, if configured.\n * @returns A promise that resolves once the engine has stopped, even if stopping failed.\n */\nexport async function processProofTaskEnd(loggingComponentType?: string): Promise<void> {\n\tconst current = engine;\n\tengine = undefined;\n\tstartupPromise = undefined;\n\tif (!Is.empty(current)) {\n\t\tawait stopEngine(current, loggingComponentType);\n\t}\n}\n\n/**\n * Stop an engine clone, logging instead of throwing when the stop fails.\n * @param engineToStop The engine to stop.\n * @param loggingComponentType The logging component type to use for step logging, if configured.\n * @returns A promise that resolves once the stop attempt has finished.\n */\nasync function stopEngine(\n\tengineToStop: NonNullable<typeof engine>,\n\tloggingComponentType?: string\n): Promise<void> {\n\ttry {\n\t\tawait engineToStop.stop();\n\t} catch (error) {\n\t\t// A throw here must not stop the rest of the shutdown from completing.\n\t\ttry {\n\t\t\tconst logging = ComponentFactory.getIfExists<ILoggingComponent>(loggingComponentType);\n\t\t\tawait logging?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: ImmutableProofTask.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"taskEngineStopFailed\",\n\t\t\t\terror: BaseError.fromError(error)\n\t\t\t});\n\t\t} catch {\n\t\t\t// Nothing more can be done if logging also fails.\n\t\t}\n\t}\n}\n\n/**\n * Process a proof task by creating a verifiable credential and notarizing it. Waits for the\n * worker's engine clone to finish starting, building it if it hasn't started yet.\n * @param engineCloneData The engine clone data used to initialize a cloned engine instance when running in a separate thread.\n * @param payload The payload containing the proof parameters.\n * @returns The task result containing the verifiable credential and notarization id.\n */\nexport async function processProofTask(\n\tengineCloneData: unknown,\n\tpayload: IImmutableProofTaskPayload\n): Promise<IImmutableProofTaskResult> {\n\tGuards.objectValue<IImmutableProofTaskPayload>(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\t\"payload\",\n\t\tpayload\n\t);\n\tGuards.stringValue(ImmutableProofTask.CLASS_NAME, \"payload.identity\", payload.identity);\n\tGuards.stringValue(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\t\"payload.identityConnectorType\",\n\t\tpayload.identityConnectorType\n\t);\n\tGuards.stringValue(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\t\"payload.verificationMethodId\",\n\t\tpayload.verificationMethodId\n\t);\n\tGuards.object<IJsonLdNodeObject>(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\t\"payload.credentialSubject\",\n\t\tpayload.credentialSubject\n\t);\n\tGuards.stringValue(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\t\"payload.notarizationConnectorType\",\n\t\tpayload.notarizationConnectorType\n\t);\n\n\tif (!Is.empty(engineCloneData)) {\n\t\tlet startFailed = false;\n\t\tif (startupPromise) {\n\t\t\ttry {\n\t\t\t\tawait startupPromise;\n\t\t\t} catch {\n\t\t\t\tstartFailed = true;\n\t\t\t}\n\t\t}\n\t\tif (startFailed || Is.empty(engine)) {\n\t\t\tawait processProofTaskStart(engineCloneData, payload.loggingComponentType);\n\t\t}\n\t}\n\n\tconst taskStartTime = Date.now();\n\tconst logging = ComponentFactory.getIfExists<ILoggingComponent>(payload.loggingComponentType);\n\n\tconst identityConnector = IdentityConnectorFactory.get(payload.identityConnectorType);\n\n\tconst credentialStartTime = Date.now();\n\tconst result = await identityConnector.createVerifiableCredential(\n\t\tpayload.identity,\n\t\t`${payload.identity}#${payload.verificationMethodId}`,\n\t\tpayload.proofId,\n\t\tpayload.credentialSubject\n\t);\n\n\tawait logging?.log({\n\t\tlevel: \"debug\",\n\t\tsource: ImmutableProofTask.CLASS_NAME,\n\t\tts: Date.now(),\n\t\tmessage: \"taskVerifiableCredentialCreated\",\n\t\tdata: { proofId: payload.proofId, elapsedMs: Date.now() - credentialStartTime }\n\t});\n\n\t// The proof context is always the last one in the generated vc contexts\n\t// as that was the last operation performed, so we can extract it and use it for the proof itself.\n\t// Remove verificationMethod to reduce linkage to the issuing identity (reinstated on verify).\n\tconst proof: IProof = result.verifiableCredential.proof as IProof;\n\tproof[\"@context\"] = result.verifiableCredential[\"@context\"][\n\t\tresult.verifiableCredential[\"@context\"].length - 1\n\t] as IProof[\"@context\"];\n\tdelete proof.verificationMethod;\n\n\tconst notarizationConnector = NotarizationConnectorFactory.get(payload.notarizationConnectorType);\n\n\tconst notarizationStartTime = Date.now();\n\ttry {\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\tawait logging?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tsource: ImmutableProofTask.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"taskNotarizationComplete\",\n\t\t\tdata: {\n\t\t\t\tproofId: payload.proofId,\n\t\t\t\telapsedMs: Date.now() - notarizationStartTime,\n\t\t\t\ttotalElapsedMs: Date.now() - taskStartTime\n\t\t\t}\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} catch (error) {\n\t\t// The notarization may have reached the ledger even though the call failed, so\n\t\t// retrying could create a duplicate on-chain object. Return the failure in the\n\t\t// result instead of throwing, which prevents the task engine from retrying.\n\t\t// Failures thrown before this point are safe for the task engine to retry.\n\t\tconst notarizationError = BaseError.fromError(error);\n\n\t\tawait logging?.log({\n\t\t\tlevel: \"error\",\n\t\t\tsource: ImmutableProofTask.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"taskNotarizationFailed\",\n\t\t\terror: notarizationError,\n\t\t\tdata: { proofId: payload.proofId, elapsedMs: Date.now() - notarizationStartTime }\n\t\t});\n\n\t\treturn {\n\t\t\tproofId: payload.proofId,\n\t\t\tverifiableCredential: result.verifiableCredential,\n\t\t\tnotarizationError: notarizationError.toJsonObject(true)\n\t\t};\n\t}\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { IImmutableProof } from "@3sixty/immutable-proof-models";
|
|
2
|
+
/**
|
|
3
|
+
* The payload for the immutable proof task.
|
|
4
|
+
*/
|
|
5
|
+
export interface IImmutableProofTaskPayload {
|
|
6
|
+
/**
|
|
7
|
+
* The proof id.
|
|
8
|
+
*/
|
|
9
|
+
proofId: string;
|
|
10
|
+
/**
|
|
11
|
+
* The identity to create the proof for.
|
|
12
|
+
*/
|
|
13
|
+
identity: string;
|
|
14
|
+
/**
|
|
15
|
+
* The identity connector type.
|
|
16
|
+
*/
|
|
17
|
+
identityConnectorType: string;
|
|
18
|
+
/**
|
|
19
|
+
* The assertion method id.
|
|
20
|
+
*/
|
|
21
|
+
verificationMethodId: string;
|
|
22
|
+
/**
|
|
23
|
+
* The subject to create the proof for.
|
|
24
|
+
*/
|
|
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;
|
|
35
|
+
/**
|
|
36
|
+
* The logging component type to use for step logging inside the task.
|
|
37
|
+
* If omitted, no step logging is performed.
|
|
38
|
+
*/
|
|
39
|
+
loggingComponentType?: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IError } from "@3sixty/core";
|
|
2
|
+
import type { IDidVerifiableCredential } from "@3sixty/standards-w3c-did";
|
|
3
|
+
/**
|
|
4
|
+
* The result for the immutable proof task.
|
|
5
|
+
*/
|
|
6
|
+
export interface IImmutableProofTaskResult {
|
|
7
|
+
/**
|
|
8
|
+
* The proof id.
|
|
9
|
+
*/
|
|
10
|
+
proofId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The verifiable credential produced by the proof task.
|
|
13
|
+
*/
|
|
14
|
+
verifiableCredential: IDidVerifiableCredential;
|
|
15
|
+
/**
|
|
16
|
+
* The notarization id returned after storing the proof.
|
|
17
|
+
* Not set when the notarization phase failed, see notarizationError.
|
|
18
|
+
*/
|
|
19
|
+
notarizationId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Set when the notarization phase failed. The failure is returned in the result
|
|
22
|
+
* instead of being thrown, because the notarization may have reached the ledger
|
|
23
|
+
* even though the call failed, and a retry could create a duplicate on-chain object.
|
|
24
|
+
*/
|
|
25
|
+
notarizationError?: IError;
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IImmutableProofTaskPayload } from "./models/IImmutableProofTaskPayload.js";
|
|
2
|
+
import type { IImmutableProofTaskResult } from "./models/IImmutableProofTaskResult.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build and start the worker's engine clone. Registered as the background task handler's
|
|
5
|
+
* initialiseMethod, so it runs once per worker instead of once per task.
|
|
6
|
+
* @param engineCloneData The engine clone data used to initialize a cloned engine instance when
|
|
7
|
+
* running in a separate thread. Empty when not running in a worker thread (e.g. in tests).
|
|
8
|
+
* @param loggingComponentType The logging component type to use for step logging, if configured.
|
|
9
|
+
* @returns A promise that resolves once the engine has started.
|
|
10
|
+
*/
|
|
11
|
+
export declare function processProofTaskStart(engineCloneData: unknown, loggingComponentType?: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Stop the worker's engine clone. Registered as the background task handler's shutdownMethod.
|
|
14
|
+
* @param loggingComponentType The logging component type to use for step logging, if configured.
|
|
15
|
+
* @returns A promise that resolves once the engine has stopped, even if stopping failed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function processProofTaskEnd(loggingComponentType?: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Process a proof task by creating a verifiable credential and notarizing it. Waits for the
|
|
20
|
+
* worker's engine clone to finish starting, building it if it hasn't started yet.
|
|
21
|
+
* @param engineCloneData The engine clone data used to initialize a cloned engine instance when running in a separate thread.
|
|
22
|
+
* @param payload The payload containing the proof parameters.
|
|
23
|
+
* @returns The task result containing the verifiable credential and notarization id.
|
|
24
|
+
*/
|
|
25
|
+
export declare function processProofTask(engineCloneData: unknown, payload: IImmutableProofTaskPayload): Promise<IImmutableProofTaskResult>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.20.0-next.1](https://github.com/3sixtyglobal/immutable-proof/compare/immutable-proof-task-v0.20.0-next.0...immutable-proof-task-v0.20.0-next.1) (2026-10-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* publish packages under the [@3sixty](https://github.com/3sixty) namespace ([427b19f](https://github.com/3sixtyglobal/immutable-proof/commit/427b19fe3bd47827cd647e907b120d57415c62a5))
|
|
9
|
+
* updated ts compile ([150ff76](https://github.com/3sixtyglobal/immutable-proof/commit/150ff76ff74620219cd3fae31d152144d0c79edd))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Dependencies
|
|
13
|
+
|
|
14
|
+
* The following workspace dependencies were updated
|
|
15
|
+
* dependencies
|
|
16
|
+
* @3sixty/immutable-proof-models bumped from 0.20.0-next.0 to 0.20.0-next.1
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Immutable Proof Task Examples
|
|
2
|
+
|
|
3
|
+
These snippets show how to prepare payloads and execute background task processing for immutable proof generation.
|
|
4
|
+
|
|
5
|
+
## processProofTask
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import type { IImmutableProofTaskPayload } from '@3sixty/immutable-proof-task';
|
|
9
|
+
|
|
10
|
+
const payload: IImmutableProofTaskPayload = {
|
|
11
|
+
proofId: 'immutable-proof:01JABCDEF1234567890',
|
|
12
|
+
identity: 'did:iota:tst:issuer',
|
|
13
|
+
identityConnectorType: 'identity',
|
|
14
|
+
verificationMethodId: 'immutable-proof-assertion',
|
|
15
|
+
credentialSubject: {
|
|
16
|
+
'@context': [
|
|
17
|
+
'https://schema.3sixty.global/immutable-proof',
|
|
18
|
+
'https://schema.3sixty.global/common'
|
|
19
|
+
],
|
|
20
|
+
type: 'ImmutableProof',
|
|
21
|
+
id: 'https://example.org/documents/100',
|
|
22
|
+
proofIntegrity: 'yEr9VvYCGDh2Ww1YwQMehUy4LlW35mLhX8j8R8U6x0g='
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
console.log(payload.identity); // did:iota:tst:issuer
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { processProofTask } from '@3sixty/immutable-proof-task';
|
|
31
|
+
|
|
32
|
+
const engineCloneData = {
|
|
33
|
+
factories: {},
|
|
34
|
+
components: {}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const result = await processProofTask(engineCloneData, {
|
|
38
|
+
proofId: 'immutable-proof:01JABCDEF1234567890',
|
|
39
|
+
identity: 'did:iota:tst:issuer',
|
|
40
|
+
identityConnectorType: 'identity',
|
|
41
|
+
verificationMethodId: 'immutable-proof-assertion',
|
|
42
|
+
credentialSubject: {
|
|
43
|
+
'@context': [
|
|
44
|
+
'https://schema.3sixty.global/immutable-proof',
|
|
45
|
+
'https://schema.3sixty.global/common'
|
|
46
|
+
],
|
|
47
|
+
type: 'ImmutableProof',
|
|
48
|
+
id: 'https://example.org/documents/100',
|
|
49
|
+
proofIntegrity: 'yEr9VvYCGDh2Ww1YwQMehUy4LlW35mLhX8j8R8U6x0g='
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
console.log(result.proofId); // immutable-proof:01JABCDEF1234567890
|
|
54
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Function: processProofTask()
|
|
2
|
+
|
|
3
|
+
> **processProofTask**(`engineCloneData`, `payload`): `Promise`\<[`IImmutableProofTaskResult`](../interfaces/IImmutableProofTaskResult.md)\>
|
|
4
|
+
|
|
5
|
+
Process a proof task by creating a verifiable credential and notarizing it. Waits for the
|
|
6
|
+
worker's engine clone to finish starting, building it if it hasn't started yet.
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
### engineCloneData
|
|
11
|
+
|
|
12
|
+
`unknown`
|
|
13
|
+
|
|
14
|
+
The engine clone data used to initialize a cloned engine instance when running in a separate thread.
|
|
15
|
+
|
|
16
|
+
### payload
|
|
17
|
+
|
|
18
|
+
[`IImmutableProofTaskPayload`](../interfaces/IImmutableProofTaskPayload.md)
|
|
19
|
+
|
|
20
|
+
The payload containing the proof parameters.
|
|
21
|
+
|
|
22
|
+
## Returns
|
|
23
|
+
|
|
24
|
+
`Promise`\<[`IImmutableProofTaskResult`](../interfaces/IImmutableProofTaskResult.md)\>
|
|
25
|
+
|
|
26
|
+
The task result containing the verifiable credential and notarization id.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Function: processProofTaskEnd()
|
|
2
|
+
|
|
3
|
+
> **processProofTaskEnd**(`loggingComponentType?`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Stop the worker's engine clone. Registered as the background task handler's shutdownMethod.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### loggingComponentType?
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The logging component type to use for step logging, if configured.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
`Promise`\<`void`\>
|
|
18
|
+
|
|
19
|
+
A promise that resolves once the engine has stopped, even if stopping failed.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Function: processProofTaskStart()
|
|
2
|
+
|
|
3
|
+
> **processProofTaskStart**(`engineCloneData`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Build and start the worker's engine clone. Registered as the background task handler's
|
|
6
|
+
initialiseMethod, so it runs once per worker instead of once per task.
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
### engineCloneData
|
|
11
|
+
|
|
12
|
+
`unknown`
|
|
13
|
+
|
|
14
|
+
The engine clone data used to initialize a cloned engine instance when
|
|
15
|
+
running in a separate thread. Empty when not running in a worker thread (e.g. in tests).
|
|
16
|
+
|
|
17
|
+
### loggingComponentType?
|
|
18
|
+
|
|
19
|
+
`string`
|
|
20
|
+
|
|
21
|
+
The logging component type to use for step logging, if configured.
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`Promise`\<`void`\>
|
|
26
|
+
|
|
27
|
+
A promise that resolves once the engine has started.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @3sixty/immutable-proof-task
|
|
2
|
+
|
|
3
|
+
## Interfaces
|
|
4
|
+
|
|
5
|
+
- [IImmutableProofTaskPayload](interfaces/IImmutableProofTaskPayload.md)
|
|
6
|
+
- [IImmutableProofTaskResult](interfaces/IImmutableProofTaskResult.md)
|
|
7
|
+
|
|
8
|
+
## Functions
|
|
9
|
+
|
|
10
|
+
- [processProofTaskStart](functions/processProofTaskStart.md)
|
|
11
|
+
- [processProofTaskEnd](functions/processProofTaskEnd.md)
|
|
12
|
+
- [processProofTask](functions/processProofTask.md)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Interface: IImmutableProofTaskPayload
|
|
2
|
+
|
|
3
|
+
The payload for the immutable proof task.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### proofId {#proofid}
|
|
8
|
+
|
|
9
|
+
> **proofId**: `string`
|
|
10
|
+
|
|
11
|
+
The proof id.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### identity {#identity}
|
|
16
|
+
|
|
17
|
+
> **identity**: `string`
|
|
18
|
+
|
|
19
|
+
The identity to create the proof for.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### identityConnectorType {#identityconnectortype}
|
|
24
|
+
|
|
25
|
+
> **identityConnectorType**: `string`
|
|
26
|
+
|
|
27
|
+
The identity connector type.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### verificationMethodId {#verificationmethodid}
|
|
32
|
+
|
|
33
|
+
> **verificationMethodId**: `string`
|
|
34
|
+
|
|
35
|
+
The assertion method id.
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### credentialSubject {#credentialsubject}
|
|
40
|
+
|
|
41
|
+
> **credentialSubject**: `IImmutableProof`
|
|
42
|
+
|
|
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.
|
|
61
|
+
|
|
62
|
+
***
|
|
63
|
+
|
|
64
|
+
### loggingComponentType? {#loggingcomponenttype}
|
|
65
|
+
|
|
66
|
+
> `optional` **loggingComponentType?**: `string`
|
|
67
|
+
|
|
68
|
+
The logging component type to use for step logging inside the task.
|
|
69
|
+
If omitted, no step logging is performed.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Interface: IImmutableProofTaskResult
|
|
2
|
+
|
|
3
|
+
The result for the immutable proof task.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### proofId {#proofid}
|
|
8
|
+
|
|
9
|
+
> **proofId**: `string`
|
|
10
|
+
|
|
11
|
+
The proof id.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### verifiableCredential {#verifiablecredential}
|
|
16
|
+
|
|
17
|
+
> **verifiableCredential**: `IDidVerifiableCredential`
|
|
18
|
+
|
|
19
|
+
The verifiable credential produced by the proof task.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### notarizationId? {#notarizationid}
|
|
24
|
+
|
|
25
|
+
> `optional` **notarizationId?**: `string`
|
|
26
|
+
|
|
27
|
+
The notarization id returned after storing the proof.
|
|
28
|
+
Not set when the notarization phase failed, see notarizationError.
|
|
29
|
+
|
|
30
|
+
***
|
|
31
|
+
|
|
32
|
+
### notarizationError? {#notarizationerror}
|
|
33
|
+
|
|
34
|
+
> `optional` **notarizationError?**: `IError`
|
|
35
|
+
|
|
36
|
+
Set when the notarization phase failed. The failure is returned in the result
|
|
37
|
+
instead of being thrown, because the notarization may have reached the ledger
|
|
38
|
+
even though the call failed, and a retry could create a duplicate on-chain object.
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"debug": {
|
|
3
|
+
"immutableProofTask": {
|
|
4
|
+
"taskEngineStarted": "The proof task worker engine started in {elapsedMs}ms",
|
|
5
|
+
"taskVerifiableCredentialCreated": "The verifiable credential for proof \"{proofId}\" was created in {elapsedMs}ms",
|
|
6
|
+
"taskNotarizationComplete": "The notarization for proof \"{proofId}\" completed in {elapsedMs}ms, total task time {totalElapsedMs}ms"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"error": {
|
|
10
|
+
"immutableProofTask": {
|
|
11
|
+
"taskNotarizationFailed": "The notarization for proof \"{proofId}\" failed after {elapsedMs}ms, the task will not be retried as the notarization may already be on the ledger"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"warn": {
|
|
15
|
+
"immutableProofTask": {
|
|
16
|
+
"taskEngineStopFailed": "Stopping the proof task worker engine failed, a new engine will be started for the next task"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@3sixty/immutable-proof-task",
|
|
3
|
+
"version": "0.20.0-next.1",
|
|
4
|
+
"description": "Background proof processing that creates verifiable credentials from prepared payloads",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/3sixtyglobal/immutable-proof.git",
|
|
8
|
+
"directory": "packages/immutable-proof-task"
|
|
9
|
+
},
|
|
10
|
+
"author": "martyn.janes@iota.org",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=24.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@3sixty/context": "next",
|
|
18
|
+
"@3sixty/core": "next",
|
|
19
|
+
"@3sixty/data-json-ld": "next",
|
|
20
|
+
"@3sixty/identity-models": "next",
|
|
21
|
+
"@3sixty/immutable-proof-models": "0.20.0-next.1",
|
|
22
|
+
"@3sixty/logging-models": "next",
|
|
23
|
+
"@3sixty/modules": "next",
|
|
24
|
+
"@3sixty/nameof": "next",
|
|
25
|
+
"@3sixty/notarization-models": "next",
|
|
26
|
+
"@3sixty/standards-w3c-did": "next"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/es/index.js",
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"import": "./dist/es/index.js",
|
|
34
|
+
"default": "./dist/es/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./locales/*.json": "./locales/*.json"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist/es",
|
|
40
|
+
"dist/types",
|
|
41
|
+
"locales",
|
|
42
|
+
"docs"
|
|
43
|
+
],
|
|
44
|
+
"keywords": [
|
|
45
|
+
"twin",
|
|
46
|
+
"trade",
|
|
47
|
+
"iota",
|
|
48
|
+
"framework",
|
|
49
|
+
"blockchain",
|
|
50
|
+
"immutable-proof"
|
|
51
|
+
],
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "git+https://github.com/3sixtyglobal/immutable-proof/issues"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://3sixty.global"
|
|
56
|
+
}
|