@3sixty/immutable-proof-task 0.20.0-next.0 → 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.
@@ -1,3 +1,5 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
1
3
  /**
2
4
  * The source context for guards and logging in the immutable proof task.
3
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"immutableProofTask.js","sourceRoot":"","sources":["../../src/immutableProofTask.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { nameof } from \"@3sixty/nameof\";\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 = nameof<ImmutableProofTask>();\n}\n"]}
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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","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"]}
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"]}
@@ -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 \"@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"]}
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"]}
@@ -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 { 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"]}
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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"processProofTask.js","sourceRoot":"","sources":["../../src/processProofTask.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAErF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7D;;;GAGG;AACH,IAAI,MAKQ,CAAC;AAEb;;GAEG;AACH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AAI,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\";\nimport { nameof } from \"@3sixty/nameof\";\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\tnameof(payload),\n\t\tpayload\n\t);\n\tGuards.stringValue(ImmutableProofTask.CLASS_NAME, nameof(payload.identity), payload.identity);\n\tGuards.stringValue(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\tnameof(payload.identityConnectorType),\n\t\tpayload.identityConnectorType\n\t);\n\tGuards.stringValue(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\tnameof(payload.verificationMethodId),\n\t\tpayload.verificationMethodId\n\t);\n\tGuards.object<IJsonLdNodeObject>(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\tnameof(payload.credentialSubject),\n\t\tpayload.credentialSubject\n\t);\n\tGuards.stringValue(\n\t\tImmutableProofTask.CLASS_NAME,\n\t\tnameof(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"]}
1
+ {"version":3,"file":"processProofTask.js","sources":["../../src/processProofTask.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAErF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7D;;;GAGG;AACH,IAAI,MAKQ,CAAC;AAEb;;GAEG;AACH,IAAI,cAAyC,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,eAAwB,EACxB,oBAA6B;IAE7B,IAAI,KAAoB,CAAC;IACzB,cAAc,GAAG,CAAC,KAAK,IAAI,EAAE;QAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;YAC/B,OAAO;QACR,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,8EAA8E;QAC9E,sFAAsF;QACtF,KAAK,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAC1C,qBAAqB,EACrB,6BAA6B,EAC7B;YACC,QAAQ;YACR,eAAe;YACf,MAAM,cAAc,CAAC,aAAa,EAAE;YACpC;gBACC,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE;oBACN,kBAAkB;oBAClB,kBAAkB;oBAClB,mBAAmB;oBACnB,uBAAuB;oBACvB,gBAAgB;oBAChB,wBAAwB;oBACxB,mBAA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AAC,oBAAoB;YACjD,cAAc;SACd,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,+EAA+E;QAC/E,+EAA+E;QAC/E,4EAA4E;QAC5E,2EAA2E;QAC3E,MAAM,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"]}
package/docs/changelog.md CHANGED
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3sixty/immutable-proof-task",
3
- "version": "0.20.0-next.0",
3
+ "version": "0.20.0-next.1",
4
4
  "description": "Background proof processing that creates verifiable credentials from prepared payloads",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "@3sixty/core": "next",
19
19
  "@3sixty/data-json-ld": "next",
20
20
  "@3sixty/identity-models": "next",
21
- "@3sixty/immutable-proof-models": "0.20.0-next.0",
21
+ "@3sixty/immutable-proof-models": "0.20.0-next.1",
22
22
  "@3sixty/logging-models": "next",
23
23
  "@3sixty/modules": "next",
24
24
  "@3sixty/nameof": "next",