@twin.org/immutable-proof-service 0.0.3-next.8 → 0.9.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/README.md +1 -1
- package/dist/es/entities/immutableProof.js +3 -3
- package/dist/es/entities/immutableProof.js.map +1 -1
- package/dist/es/immutableProofRoutes.js +98 -14
- package/dist/es/immutableProofRoutes.js.map +1 -1
- package/dist/es/immutableProofService.js +78 -39
- package/dist/es/immutableProofService.js.map +1 -1
- package/dist/es/models/IImmutableProofServiceConstructorOptions.js.map +1 -1
- package/dist/es/restEntryPoints.js +3 -0
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/types/entities/immutableProof.d.ts +2 -2
- package/dist/types/immutableProofRoutes.d.ts +20 -4
- package/dist/types/immutableProofService.d.ts +20 -10
- package/dist/types/models/IImmutableProofServiceConstructorOptions.d.ts +3 -4
- package/dist/types/restEntryPoints.d.ts +3 -0
- package/docs/changelog.md +247 -45
- package/docs/examples.md +127 -1
- package/docs/open-api/spec.json +216 -692
- package/docs/reference/classes/ImmutableProof.md +11 -11
- package/docs/reference/classes/ImmutableProofService.md +57 -17
- package/docs/reference/functions/immutableProofGet.md +1 -1
- package/docs/reference/functions/immutableProofRemove.md +31 -0
- package/docs/reference/functions/immutableProofRemoveNotarization.md +31 -0
- package/docs/reference/functions/immutableProofVerify.md +1 -1
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IImmutableProofServiceConfig.md +2 -2
- package/docs/reference/interfaces/IImmutableProofServiceConstructorOptions.md +16 -22
- package/docs/reference/variables/restEntryPoints.md +2 -0
- package/locales/en.json +2 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"immutableProofService.js","sourceRoot":"","sources":["../../src/immutableProofService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EAGV,MAAM,kCAAkC,CAAC;AAC1C,OAAO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X-License-Identifier: Apache-2.0.\nimport {\n\tTaskStatus,\n\ttype IBackgroundTask,\n\ttype IBackgroundTaskComponent\n} from \"@twin.org/background-task-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper,\n\tUrn,\n\tValidation,\n\ttype IValidationFailure\n} from \"@twin.org/core\";\nimport { IntegrityAlgorithm, IntegrityHelper } from \"@twin.org/crypto\";\nimport { JsonLdHelper, JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IEventBusComponent } from \"@twin.org/event-bus-models\";\nimport { IdentityConnectorFactory, type IIdentityConnector } from \"@twin.org/identity-models\";\nimport {\n\tImmutableProofContexts,\n\tImmutableProofFailure,\n\tImmutableProofTopics,\n\tImmutableProofTypes,\n\ttype IImmutableProof,\n\ttype IImmutableProofComponent,\n\ttype IImmutableProofEventBusProofCreated,\n\ttype IImmutableProofVerification\n} from \"@twin.org/immutable-proof-models\";\nimport type {\n\tIImmutableProofTaskPayload,\n\tIImmutableProofTaskResult\n} from \"@twin.org/immutable-proof-task\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tVerifiableCredentialHelper,\n\ttype IDidVerifiableCredential,\n\ttype IProof\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVerifiableStorageConnectorFactory,\n\ttype IVerifiableStorageConnector\n} from \"@twin.org/verifiable-storage-models\";\nimport type { ImmutableProof } from \"./entities/immutableProof.js\";\nimport type { IImmutableProofServiceConfig } from \"./models/IImmutableProofServiceConfig.js\";\nimport type { IImmutableProofServiceConstructorOptions } from \"./models/IImmutableProofServiceConstructorOptions.js\";\n\n/**\n * Class for performing immutable proof operations.\n */\nexport class ImmutableProofService implements IImmutableProofComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ImmutableProofService>();\n\n\t/**\n\t * The namespace for the service.\n\t * @internal\n\t */\n\tprivate static readonly _NAMESPACE: string = \"immutable-proof\";\n\n\t/**\n\t * The configuration for the connector.\n\t * @internal\n\t */\n\tprivate readonly _config: IImmutableProofServiceConfig;\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The identity connector.\n\t * @internal\n\t */\n\tprivate readonly _identityConnector: IIdentityConnector;\n\n\t/**\n\t * The entity storage for proofs.\n\t * @internal\n\t */\n\tprivate readonly _proofStorage: IEntityStorageConnector<ImmutableProof>;\n\n\t/**\n\t * The verifiable storage for the credentials.\n\t * @internal\n\t */\n\tprivate readonly _verifiableStorage: IVerifiableStorageConnector;\n\n\t/**\n\t * The background task component.\n\t * @internal\n\t */\n\tprivate readonly _backgroundTaskComponent: IBackgroundTaskComponent;\n\n\t/**\n\t * The event bus component.\n\t * @internal\n\t */\n\tprivate readonly _eventBusComponent?: IEventBusComponent;\n\n\t/**\n\t * The verification method id to use for the proofs.\n\t * @internal\n\t */\n\tprivate readonly _verificationMethodId: string;\n\n\t/**\n\t * The identity connector type.\n\t * @internal\n\t */\n\tprivate readonly _identityConnectorType: string;\n\n\t/**\n\t * Create a new instance of ImmutableProofService.\n\t * @param options The dependencies for the immutable proof connector.\n\t */\n\tconstructor(options?: IImmutableProofServiceConstructorOptions) {\n\t\tthis._proofStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.immutableProofEntityStorageType ?? nameofKebabCase<ImmutableProof>()\n\t\t);\n\n\t\tthis._verifiableStorage = VerifiableStorageConnectorFactory.get(\n\t\t\toptions?.verifiableStorageType ?? \"verifiable-storage\"\n\t\t);\n\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\tthis._identityConnectorType = options?.identityConnectorType ?? \"identity\";\n\n\t\tthis._identityConnector = IdentityConnectorFactory.get(this._identityConnectorType);\n\n\t\tthis._backgroundTaskComponent = ComponentFactory.get(\n\t\t\toptions?.backgroundTaskComponentType ?? \"background-task\"\n\t\t);\n\n\t\tif (Is.stringValue(options?.eventBusComponentType)) {\n\t\t\tthis._eventBusComponent = ComponentFactory.get(options.eventBusComponentType);\n\t\t}\n\n\t\tthis._config = options?.config ?? {};\n\t\tthis._verificationMethodId = this._config.verificationMethodId ?? \"immutable-proof-assertion\";\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn ImmutableProofService.CLASS_NAME;\n\t}\n\n\t/**\n\t * The component needs to be started when the node is initialized.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns Nothing.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tawait this._backgroundTaskComponent.registerHandler<\n\t\t\tIImmutableProofTaskPayload,\n\t\t\tIImmutableProofTaskResult\n\t\t>(\"immutable-proof\", \"@twin.org/immutable-proof-task\", \"processProofTask\", async task => {\n\t\t\tawait this.finaliseTask(task);\n\t\t});\n\t}\n\n\t/**\n\t * Create a new proof.\n\t * @param document The document to create the proof for.\n\t * @returns The id of the new proof.\n\t */\n\tpublic async create(document: IJsonLdNodeObject): Promise<string> {\n\t\tGuards.object<IJsonLdNodeObject>(ImmutableProofService.CLASS_NAME, nameof(document), document);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\ttry {\n\t\t\tconst validationFailures: IValidationFailure[] = [];\n\t\t\tawait JsonLdHelper.validate(document, validationFailures);\n\t\t\tValidation.asValidationError(\n\t\t\t\tImmutableProofService.CLASS_NAME,\n\t\t\t\tnameof(document),\n\t\t\t\tvalidationFailures\n\t\t\t);\n\n\t\t\tconst id = RandomHelper.generateUuidV7(\"compact\");\n\n\t\t\tconst dateCreated = new Date(Date.now()).toISOString();\n\n\t\t\tconst proofObjectId = ObjectHelper.extractProperty<string>(document, [\"@id\", \"id\"], false);\n\n\t\t\t// We don't want to store the whole document in the immutable proof, as this could be large\n\t\t\t// and also reveal information that should not be stored in the proof so we hash the document\n\t\t\t// and store the hash\n\t\t\tconst proofObjectIntegrity = IntegrityHelper.generate(\n\t\t\t\tIntegrityAlgorithm.Sha256,\n\t\t\t\tObjectHelper.toBytes(JsonHelper.canonicalize(document))\n\t\t\t);\n\n\t\t\tconst credentialSubject: IImmutableProof = {\n\t\t\t\t\"@context\": [ImmutableProofContexts.Context, ImmutableProofContexts.ContextCommon],\n\t\t\t\ttype: ImmutableProofTypes.ImmutableProof,\n\t\t\t\tid: proofObjectId,\n\t\t\t\tproofIntegrity: proofObjectIntegrity\n\t\t\t};\n\n\t\t\tconst proofEntity: ImmutableProof = {\n\t\t\t\tid,\n\t\t\t\torganizationId: contextIds[ContextIdKeys.Organization],\n\t\t\t\tdateCreated,\n\t\t\t\tproofObjectId,\n\t\t\t\tproofObjectIntegrity\n\t\t\t};\n\t\t\tawait this._proofStorage.set(proofEntity);\n\n\t\t\tconst fullId = new Urn(ImmutableProofService._NAMESPACE, id).toString();\n\n\t\t\tconst proofTaskPayload: IImmutableProofTaskPayload = {\n\t\t\t\tproofId: fullId,\n\t\t\t\tidentity: contextIds[ContextIdKeys.Organization],\n\t\t\t\tidentityConnectorType: this._identityConnectorType,\n\t\t\t\tverificationMethodId: this._verificationMethodId,\n\t\t\t\tcredentialSubject\n\t\t\t};\n\n\t\t\tawait this._backgroundTaskComponent.create(\"immutable-proof\", proofTaskPayload, {\n\t\t\t\tretainFor: 5000\n\t\t\t});\n\n\t\t\treturn fullId;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"createFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get a proof.\n\t * @param id The id of the proof to get.\n\t * @returns The proof.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async get(id: string): Promise<IDidVerifiableCredential> {\n\t\tGuards.stringValue(ImmutableProofService.CLASS_NAME, nameof(id), id);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceIdentifier() !== ImmutableProofService._NAMESPACE) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: ImmutableProofService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst { verifiableCredential } = await this.internalGet(id, false);\n\n\t\t\tconst result = await JsonLdProcessor.compact(\n\t\t\t\tverifiableCredential,\n\t\t\t\tverifiableCredential[\"@context\"]\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Verify a proof.\n\t * @param id The id of the proof to verify.\n\t * @returns The result of the verification and any failures.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async verify(id: string): Promise<IImmutableProofVerification> {\n\t\tGuards.stringValue(ImmutableProofService.CLASS_NAME, nameof(id), id);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceIdentifier() !== ImmutableProofService._NAMESPACE) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: ImmutableProofService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst { verified, failure } = await this.internalGet(id, true);\n\n\t\t\treturn {\n\t\t\t\t\"@context\": ImmutableProofContexts.Context,\n\t\t\t\ttype: ImmutableProofTypes.ImmutableProofVerification,\n\t\t\t\tverified,\n\t\t\t\tfailure\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"verifyFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove the verifiable storage for the proof.\n\t * @param id The id of the proof to remove the storage from.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async removeVerifiable(id: string): Promise<void> {\n\t\tGuards.stringValue(ImmutableProofService.CLASS_NAME, nameof(id), id);\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceIdentifier() !== ImmutableProofService._NAMESPACE) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: ImmutableProofService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst streamId = urnParsed.namespaceSpecific(0);\n\t\t\tconst streamEntity = await this._proofStorage.get(streamId);\n\n\t\t\tif (Is.empty(streamEntity)) {\n\t\t\t\tthrow new NotFoundError(ImmutableProofService.CLASS_NAME, \"proofNotFound\", id);\n\t\t\t}\n\n\t\t\tif (Is.stringValue(streamEntity.verifiableStorageId)) {\n\t\t\t\tawait this._verifiableStorage.remove(\n\t\t\t\t\tcontextIds[ContextIdKeys.Organization],\n\t\t\t\t\tstreamEntity.verifiableStorageId\n\t\t\t\t);\n\t\t\t\tdelete streamEntity.verifiableStorageId;\n\t\t\t\tawait this._proofStorage.set(streamEntity);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tImmutableProofService.CLASS_NAME,\n\t\t\t\t\"removeVerifiableFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process a proof.\n\t * @param proofEntity The proof entity to process.\n\t * @internal\n\t */\n\tprivate async finaliseTask(\n\t\ttask: IBackgroundTask<IImmutableProofTaskPayload, IImmutableProofTaskResult>\n\t): Promise<void> {\n\t\tif (Is.object(task.payload)) {\n\t\t\tif (task.status === TaskStatus.Success && Is.object(task.result)) {\n\t\t\t\tconst urnParsed = Urn.fromValidString(task.payload.proofId);\n\t\t\t\tconst proofId = urnParsed.namespaceSpecific(0);\n\n\t\t\t\tconst proofEntity = await this._proofStorage.get(proofId);\n\n\t\t\t\tif (Is.object(proofEntity)) {\n\t\t\t\t\t// Extract the proof from the task result vc\n\t\t\t\t\tconst proof: IProof = task.result.verifiableCredential.proof as IProof;\n\n\t\t\t\t\t// The proof context is always the last one in the generated vc contexts\n\t\t\t\t\t// as that was the last operation performed, so we can extract it and use it for the proof itself\n\t\t\t\t\tproof[\"@context\"] = task.result.verifiableCredential[\"@context\"][\n\t\t\t\t\t\ttask.result.verifiableCredential[\"@context\"].length - 1\n\t\t\t\t\t] as IProof[\"@context\"];\n\n\t\t\t\t\t// Store the proof in the verifiable storage and get the id of where it is stored so we can retrieve it later\n\t\t\t\t\tconst verifiableCreateResult = await this._verifiableStorage.create(\n\t\t\t\t\t\ttask.payload.identity,\n\t\t\t\t\t\tObjectHelper.toBytes(proof)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Update the proof entity with the verifiable storage id so we can retrieve it later\n\t\t\t\t\tproofEntity.verifiableStorageId = verifiableCreateResult.id;\n\n\t\t\t\t\t// Update the date created if we can extract it from the VC\n\t\t\t\t\tconst validFrom = VerifiableCredentialHelper.getValidFrom(\n\t\t\t\t\t\ttask.result.verifiableCredential\n\t\t\t\t\t);\n\t\t\t\t\tif (Is.stringValue(validFrom)) {\n\t\t\t\t\t\tproofEntity.dateCreated = validFrom;\n\t\t\t\t\t}\n\t\t\t\t\tproofEntity.vcContext = VerifiableCredentialHelper.getContext(\n\t\t\t\t\t\ttask.result.verifiableCredential\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this._proofStorage.set(proofEntity);\n\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tsource: ImmutableProofService.CLASS_NAME,\n\t\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"createdProof\",\n\t\t\t\t\t\tdata: { proofId: task.payload.proofId }\n\t\t\t\t\t});\n\n\t\t\t\t\tawait this._eventBusComponent?.publish<IImmutableProofEventBusProofCreated>(\n\t\t\t\t\t\tImmutableProofTopics.ProofCreated,\n\t\t\t\t\t\t{ id: new Urn(ImmutableProofService._NAMESPACE, task.payload.proofId).toString() }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (task.status === TaskStatus.Failed) {\n\t\t\t\tawait this._logging?.log({\n\t\t\t\t\tsource: ImmutableProofService.CLASS_NAME,\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"createProofFailed\",\n\t\t\t\t\terror: BaseError.fromError(task.error)\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Verify a proof.\n\t * @param id The id of the proof to verify.\n\t * @param verify Validate the proof.\n\t * @returns The result of the verification and any failures.\n\t * @throws NotFoundError if the proof is not found.\n\t * @internal\n\t */\n\tprivate async internalGet(\n\t\tid: string,\n\t\tverify: boolean\n\t): Promise<{\n\t\tverified: boolean;\n\t\tfailure?: ImmutableProofFailure;\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t}> {\n\t\tconst urnParsed = Urn.fromValidString(id);\n\t\tconst proofId = urnParsed.namespaceSpecific(0);\n\t\tconst proofEntity = await this._proofStorage.get(proofId);\n\n\t\tif (Is.empty(proofEntity)) {\n\t\t\tthrow new NotFoundError(ImmutableProofService.CLASS_NAME, \"proofNotFound\", id);\n\t\t}\n\n\t\tconst verifiableCredential: IDidVerifiableCredential = {\n\t\t\t\"@context\": [\n\t\t\t\tproofEntity.vcContext ?? DidContexts.ContextVCv1,\n\t\t\t\tImmutableProofContexts.Context,\n\t\t\t\tImmutableProofContexts.ContextCommon\n\t\t\t],\n\t\t\ttype: [DidTypes.VerifiableCredential, ImmutableProofTypes.ImmutableProof],\n\t\t\tid,\n\t\t\tissuer: proofEntity.organizationId,\n\t\t\tcredentialSubject: {\n\t\t\t\tid: proofEntity.proofObjectId,\n\t\t\t\tproofIntegrity: proofEntity.proofObjectIntegrity\n\t\t\t}\n\t\t} as IDidVerifiableCredential;\n\n\t\tVerifiableCredentialHelper.setValidFrom(verifiableCredential, proofEntity.dateCreated);\n\n\t\tlet verified = false;\n\t\tlet failure: ImmutableProofFailure | undefined = ImmutableProofFailure.NotIssued;\n\n\t\tif (Is.stringValue(proofEntity.verifiableStorageId)) {\n\t\t\tfailure = ImmutableProofFailure.ProofMissing;\n\t\t\tconst immutableResult = await this._verifiableStorage.get(proofEntity.verifiableStorageId);\n\n\t\t\tif (Is.uint8Array(immutableResult.data)) {\n\t\t\t\tconst proof = ObjectHelper.fromBytes<IProof>(immutableResult.data);\n\n\t\t\t\tconst proofWithReceipt = {\n\t\t\t\t\t...proof,\n\t\t\t\t\tverifiableStorageId: proofEntity.verifiableStorageId,\n\t\t\t\t\timmutableReceipt: immutableResult.receipt\n\t\t\t\t};\n\n\t\t\t\t// Add the proof from the verifiable storage\n\t\t\t\t// expand it with the verifiable storage id and receipt\n\t\t\t\tverifiableCredential.proof = proofWithReceipt;\n\n\t\t\t\tif (verify && Is.object<IProof>(proof)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result =\n\t\t\t\t\t\t\tawait this._identityConnector.checkVerifiableCredential(verifiableCredential);\n\t\t\t\t\t\tif (result.revoked) {\n\t\t\t\t\t\t\tverified = false;\n\t\t\t\t\t\t\tfailure = ImmutableProofFailure.Revoked;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tverified = true;\n\t\t\t\t\t\t\tfailure = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tverified = false;\n\t\t\t\t\t\tfailure = ImmutableProofFailure.VerificationFailure;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tverifiableCredential: await JsonLdProcessor.compact(\n\t\t\t\tverifiableCredential,\n\t\t\t\tJsonLdProcessor.gatherContexts(verifiableCredential)\n\t\t\t),\n\t\t\tverified,\n\t\t\tfailure\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"immutableProofService.js","sourceRoot":"","sources":["../../src/immutableProofService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EAGV,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,GAAG,EACH,UAAU,EAEV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAA2B,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EAMnB,MAAM,kCAAkC,CAAC;AAO1C,OAAO,EACN,4BAA4B,EAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,WAAW,EACX,QAAQ,EACR,0BAA0B,EAG1B,MAAM,6BAA6B,CAAC;AAKrC;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACjC;;OAEG;IACI,MAAM,CAAU,UAAU,2BAA2C;IA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AAM,IAAI,CAAC,kBAAkB,CAAC,yBAAyB,CACrE,oBAAgD,CAChD,CAAC;wBACF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;4BACpB,QAAQ,GAAG,KAAK,CAAC;4BACjB,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC;wBACzC,CAAC;6BAAM,CAAC;4BACP,QAAQ,GAAG,IAAI,CAAC;4BAChB,OAAO,GAAG,SAAS,CAAC;wBACrB,CAAC;oBACF,CAAC;oBAAC,MAAM,CAAC;wBACR,QAAQ,GAAG,KAAK,CAAC;wBACjB,OAAO,GAAG,qBAAqB,CAAC,mBAAmB,CAAC;oBACrD,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO;YACN,oBAAoB,EAAE,MAAM,eAAe,CAAC,OAAO,CAClD,oBAAoB,EACpB,eAAe,CAAC,cAAc,CAAC,oBAAoB,CAAC,CACpD;YACD,QAAQ;YACR,OAAO;SACP,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tTaskStatus,\n\ttype IBackgroundTask,\n\ttype IBackgroundTaskComponent\n} from \"@twin.org/background-task-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper,\n\tUrn,\n\tValidation,\n\ttype IValidationFailure\n} from \"@twin.org/core\";\nimport { IntegrityAlgorithm, IntegrityHelper } from \"@twin.org/crypto\";\nimport { JsonLdHelper, JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IEventBusComponent } from \"@twin.org/event-bus-models\";\nimport { IdentityConnectorFactory, type IIdentityConnector } from \"@twin.org/identity-models\";\nimport {\n\tImmutableProofContexts,\n\tImmutableProofFailure,\n\tImmutableProofTopics,\n\tImmutableProofTypes,\n\ttype IImmutableProof,\n\ttype IImmutableProofComponent,\n\ttype IImmutableProofCredential,\n\ttype IImmutableProofEventBusProofCreated,\n\ttype IImmutableProofVerification\n} from \"@twin.org/immutable-proof-models\";\nimport type {\n\tIImmutableProofTaskPayload,\n\tIImmutableProofTaskResult\n} from \"@twin.org/immutable-proof-task\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport {\n\tNotarizationConnectorFactory,\n\ttype INotarizationConnector\n} from \"@twin.org/notarization-models\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tVerifiableCredentialHelper,\n\ttype IDidVerifiableCredential,\n\ttype IProof\n} from \"@twin.org/standards-w3c-did\";\nimport type { ImmutableProof } from \"./entities/immutableProof.js\";\nimport type { IImmutableProofServiceConfig } from \"./models/IImmutableProofServiceConfig.js\";\nimport type { IImmutableProofServiceConstructorOptions } from \"./models/IImmutableProofServiceConstructorOptions.js\";\n\n/**\n * Class for performing immutable proof operations.\n */\nexport class ImmutableProofService implements IImmutableProofComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ImmutableProofService>();\n\n\t/**\n\t * The namespace for the service.\n\t * @internal\n\t */\n\tprivate static readonly _NAMESPACE: string = \"immutable-proof\";\n\n\t/**\n\t * The configuration for the connector.\n\t * @internal\n\t */\n\tprivate readonly _config: IImmutableProofServiceConfig;\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The identity connector.\n\t * @internal\n\t */\n\tprivate readonly _identityConnector: IIdentityConnector;\n\n\t/**\n\t * The entity storage for proofs.\n\t * @internal\n\t */\n\tprivate readonly _proofStorage: IEntityStorageConnector<ImmutableProof>;\n\n\t/**\n\t * The notarization connector type.\n\t * @internal\n\t */\n\tprivate readonly _notarizationConnectorType: string;\n\n\t/**\n\t * The notarization connector for the credentials.\n\t * @internal\n\t */\n\tprivate readonly _notarizationConnector: INotarizationConnector;\n\n\t/**\n\t * The background task component.\n\t * @internal\n\t */\n\tprivate readonly _backgroundTaskComponent: IBackgroundTaskComponent;\n\n\t/**\n\t * The event bus component.\n\t * @internal\n\t */\n\tprivate readonly _eventBusComponent?: IEventBusComponent;\n\n\t/**\n\t * The verification method id to use for the proofs.\n\t * @internal\n\t */\n\tprivate readonly _verificationMethodId: string;\n\n\t/**\n\t * The identity connector type.\n\t * @internal\n\t */\n\tprivate readonly _identityConnectorType: string;\n\n\t/**\n\t * Creates an instance of ImmutableProofService.\n\t * @param options The dependencies for the immutable proof connector.\n\t */\n\tconstructor(options?: IImmutableProofServiceConstructorOptions) {\n\t\tthis._proofStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.immutableProofEntityStorageType ?? nameofKebabCase<ImmutableProof>()\n\t\t);\n\n\t\tthis._notarizationConnectorType = options?.notarizationConnectorType ?? \"notarization\";\n\t\tthis._notarizationConnector = NotarizationConnectorFactory.get(this._notarizationConnectorType);\n\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(options?.loggingComponentType);\n\n\t\tthis._identityConnectorType = options?.identityConnectorType ?? \"identity\";\n\n\t\tthis._identityConnector = IdentityConnectorFactory.get(this._identityConnectorType);\n\n\t\tthis._backgroundTaskComponent = ComponentFactory.get(\n\t\t\toptions?.backgroundTaskComponentType ?? \"background-task\"\n\t\t);\n\n\t\tif (Is.stringValue(options?.eventBusComponentType)) {\n\t\t\tthis._eventBusComponent = ComponentFactory.get(options.eventBusComponentType);\n\t\t}\n\n\t\tthis._config = options?.config ?? {};\n\n\t\tthis._verificationMethodId = this._config.verificationMethodId ?? \"immutable-proof-assertion\";\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn ImmutableProofService.CLASS_NAME;\n\t}\n\n\t/**\n\t * The component needs to be started when the node is initialized.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns A promise that resolves when the background task handler has been registered.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tawait this._backgroundTaskComponent.registerHandler<\n\t\t\tIImmutableProofTaskPayload,\n\t\t\tIImmutableProofTaskResult\n\t\t>(\"immutable-proof\", \"@twin.org/immutable-proof-task\", \"processProofTask\", async task => {\n\t\t\tawait this.finaliseTask(task);\n\t\t});\n\t}\n\n\t/**\n\t * Create a new proof.\n\t * @param document The document to create the proof for.\n\t * @param options Optional settings for the proof.\n\t * @param options.deleteLock An ISO 8601 date-time string specifying when the notarization lock expires; if omitted no lock is applied.\n\t * @returns The id of the new proof.\n\t */\n\tpublic async create(\n\t\tdocument: IJsonLdNodeObject,\n\t\toptions?: { deleteLock?: string }\n\t): Promise<string> {\n\t\tGuards.object<IJsonLdNodeObject>(ImmutableProofService.CLASS_NAME, nameof(document), document);\n\n\t\tif (!Is.empty(options?.deleteLock)) {\n\t\t\tGuards.dateTimeString(\n\t\t\t\tImmutableProofService.CLASS_NAME,\n\t\t\t\tnameof(options.deleteLock),\n\t\t\t\toptions.deleteLock\n\t\t\t);\n\t\t}\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\ttry {\n\t\t\tconst validationFailures: IValidationFailure[] = [];\n\t\t\tawait JsonLdHelper.validate(document, validationFailures);\n\t\t\tValidation.asValidationError(\n\t\t\t\tImmutableProofService.CLASS_NAME,\n\t\t\t\tnameof(document),\n\t\t\t\tvalidationFailures\n\t\t\t);\n\n\t\t\tconst id = RandomHelper.generateUuidV7(\"compact\");\n\n\t\t\tconst dateCreated = new Date(Date.now()).toISOString();\n\n\t\t\tconst proofObjectId = ObjectHelper.extractProperty<string>(document, [\"@id\", \"id\"], false);\n\n\t\t\t// We don't want to store the whole document in the immutable proof, as this could be large\n\t\t\t// and also reveal information that should not be stored in the proof so we hash the document\n\t\t\t// and store the hash\n\t\t\tconst proofObjectIntegrity = IntegrityHelper.generate(\n\t\t\t\tIntegrityAlgorithm.Sha256,\n\t\t\t\tObjectHelper.toBytes(JsonHelper.canonicalize(document))\n\t\t\t);\n\n\t\t\tconst credentialSubject: IImmutableProof = {\n\t\t\t\t\"@context\": [ImmutableProofContexts.Context, ImmutableProofContexts.ContextCommon],\n\t\t\t\ttype: ImmutableProofTypes.ImmutableProof,\n\t\t\t\tid: proofObjectId,\n\t\t\t\tproofIntegrity: proofObjectIntegrity\n\t\t\t};\n\n\t\t\tconst proofEntity: ImmutableProof = {\n\t\t\t\tid,\n\t\t\t\torganizationId: contextIds[ContextIdKeys.Organization],\n\t\t\t\tdateCreated,\n\t\t\t\tproofObjectId,\n\t\t\t\tproofObjectIntegrity\n\t\t\t};\n\t\t\tawait this._proofStorage.set(proofEntity);\n\n\t\t\tconst fullId = new Urn(ImmutableProofService._NAMESPACE, id).toString();\n\n\t\t\tconst proofTaskPayload: IImmutableProofTaskPayload = {\n\t\t\t\tproofId: fullId,\n\t\t\t\tidentity: contextIds[ContextIdKeys.Organization],\n\t\t\t\tidentityConnectorType: this._identityConnectorType,\n\t\t\t\tnotarizationConnectorType: this._notarizationConnectorType,\n\t\t\t\tverificationMethodId: this._verificationMethodId,\n\t\t\t\tcredentialSubject,\n\t\t\t\tdeleteLockDateTime: options?.deleteLock\n\t\t\t};\n\n\t\t\tawait this._backgroundTaskComponent.create(\"immutable-proof\", proofTaskPayload, {\n\t\t\t\tretainFor: 5000\n\t\t\t});\n\n\t\t\treturn fullId;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"createFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get a proof.\n\t * @param id The id of the proof to get.\n\t * @returns The proof.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async get(id: string): Promise<IImmutableProofCredential> {\n\t\tGuards.stringValue(ImmutableProofService.CLASS_NAME, nameof(id), id);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceIdentifier() !== ImmutableProofService._NAMESPACE) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: ImmutableProofService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst { verifiableCredential } = await this.internalGet(id, false);\n\n\t\t\tconst result = await JsonLdProcessor.compact(\n\t\t\t\tverifiableCredential,\n\t\t\t\tverifiableCredential[\"@context\"]\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Verify a proof.\n\t * @param id The id of the proof to verify.\n\t * @returns The result of the verification and any failures.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async verify(id: string): Promise<IImmutableProofVerification> {\n\t\tGuards.stringValue(ImmutableProofService.CLASS_NAME, nameof(id), id);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceIdentifier() !== ImmutableProofService._NAMESPACE) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: ImmutableProofService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst { verified, failure } = await this.internalGet(id, true);\n\n\t\t\treturn {\n\t\t\t\t\"@context\": ImmutableProofContexts.Context,\n\t\t\t\ttype: ImmutableProofTypes.ImmutableProofVerification,\n\t\t\t\tverified,\n\t\t\t\tfailure\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"verifyFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove the proof and its notarization.\n\t * @param id The id of the proof to remove.\n\t * @returns A promise that resolves when the proof and its notarization have been removed.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async remove(id: string): Promise<void> {\n\t\tGuards.stringValue(ImmutableProofService.CLASS_NAME, nameof(id), id);\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceIdentifier() !== ImmutableProofService._NAMESPACE) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: ImmutableProofService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst proofId = urnParsed.namespaceSpecific(0);\n\t\t\tconst proofEntity = await this._proofStorage.get(proofId);\n\n\t\t\tif (Is.empty(proofEntity)) {\n\t\t\t\tthrow new NotFoundError(ImmutableProofService.CLASS_NAME, \"proofNotFound\", id);\n\t\t\t}\n\n\t\t\tif (Is.stringValue(proofEntity.notarizationId)) {\n\t\t\t\tawait this._notarizationConnector.remove(\n\t\t\t\t\tcontextIds[ContextIdKeys.Organization],\n\t\t\t\t\tproofEntity.notarizationId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._proofStorage.remove(proofId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"removeFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove only the notarization for the proof, keeping the proof entity.\n\t * @param id The id of the proof to remove the notarization from.\n\t * @returns A promise that resolves when the notarization has been removed.\n\t * @throws NotFoundError if the proof is not found.\n\t */\n\tpublic async removeNotarization(id: string): Promise<void> {\n\t\tGuards.stringValue(ImmutableProofService.CLASS_NAME, nameof(id), id);\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceIdentifier() !== ImmutableProofService._NAMESPACE) {\n\t\t\tthrow new GeneralError(ImmutableProofService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: ImmutableProofService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst proofId = urnParsed.namespaceSpecific(0);\n\t\t\tconst proofEntity = await this._proofStorage.get(proofId);\n\n\t\t\tif (Is.empty(proofEntity)) {\n\t\t\t\tthrow new NotFoundError(ImmutableProofService.CLASS_NAME, \"proofNotFound\", id);\n\t\t\t}\n\n\t\t\tif (Is.stringValue(proofEntity.notarizationId)) {\n\t\t\t\tawait this._notarizationConnector.remove(\n\t\t\t\t\tcontextIds[ContextIdKeys.Organization],\n\t\t\t\t\tproofEntity.notarizationId\n\t\t\t\t);\n\t\t\t\tdelete proofEntity.notarizationId;\n\t\t\t\tawait this._proofStorage.set(proofEntity);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tImmutableProofService.CLASS_NAME,\n\t\t\t\t\"removeNotarizationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process a proof.\n\t * @param task The background task to finalise.\n\t * @internal\n\t */\n\tprivate async finaliseTask(\n\t\ttask: IBackgroundTask<IImmutableProofTaskPayload, IImmutableProofTaskResult>\n\t): Promise<void> {\n\t\tif (Is.object(task.payload)) {\n\t\t\tif (task.status === TaskStatus.Success && Is.object(task.result)) {\n\t\t\t\tconst urnParsed = Urn.fromValidString(task.payload.proofId);\n\t\t\t\tconst proofId = urnParsed.namespaceSpecific(0);\n\n\t\t\t\tconst proofEntity = await this._proofStorage.get(proofId);\n\n\t\t\t\tif (Is.object(proofEntity)) {\n\t\t\t\t\tproofEntity.notarizationId = task.result.notarizationId;\n\n\t\t\t\t\t// Update the date created if we can extract it from the VC\n\t\t\t\t\tconst validFrom = VerifiableCredentialHelper.getValidFrom(\n\t\t\t\t\t\ttask.result.verifiableCredential\n\t\t\t\t\t);\n\t\t\t\t\tif (Is.stringValue(validFrom)) {\n\t\t\t\t\t\tproofEntity.dateCreated = validFrom;\n\t\t\t\t\t}\n\t\t\t\t\tproofEntity.vcContext = VerifiableCredentialHelper.getContext(\n\t\t\t\t\t\ttask.result.verifiableCredential\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this._proofStorage.set(proofEntity);\n\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tsource: ImmutableProofService.CLASS_NAME,\n\t\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"createdProof\",\n\t\t\t\t\t\tdata: { proofId: task.payload.proofId }\n\t\t\t\t\t});\n\n\t\t\t\t\tawait this._eventBusComponent?.publish<IImmutableProofEventBusProofCreated>(\n\t\t\t\t\t\tImmutableProofTopics.ProofCreated,\n\t\t\t\t\t\t{ id: new Urn(ImmutableProofService._NAMESPACE, task.payload.proofId).toString() }\n\t\t\t\t\t);\n\t\t\t\t} else if (Is.stringValue(task.result.notarizationId)) {\n\t\t\t\t\t// The proof was removed before the task completed; clean up the orphaned notarization.\n\t\t\t\t\tawait this._notarizationConnector.remove(\n\t\t\t\t\t\ttask.payload.identity,\n\t\t\t\t\t\ttask.result.notarizationId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (task.status === TaskStatus.Failed) {\n\t\t\t\tawait this._logging?.log({\n\t\t\t\t\tsource: ImmutableProofService.CLASS_NAME,\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"createProofFailed\",\n\t\t\t\t\terror: BaseError.fromError(task.error)\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Verify a proof.\n\t * @param id The id of the proof to verify.\n\t * @param verify Validate the proof.\n\t * @returns The result of the verification and any failures.\n\t * @throws NotFoundError if the proof is not found.\n\t * @internal\n\t */\n\tprivate async internalGet(\n\t\tid: string,\n\t\tverify: boolean\n\t): Promise<{\n\t\tverified: boolean;\n\t\tfailure?: ImmutableProofFailure;\n\t\tverifiableCredential: IImmutableProofCredential;\n\t}> {\n\t\tconst urnParsed = Urn.fromValidString(id);\n\t\tconst proofId = urnParsed.namespaceSpecific(0);\n\t\tconst proofEntity = await this._proofStorage.get(proofId);\n\n\t\tif (Is.empty(proofEntity)) {\n\t\t\tthrow new NotFoundError(ImmutableProofService.CLASS_NAME, \"proofNotFound\", id);\n\t\t}\n\n\t\tconst verifiableCredential: IImmutableProofCredential = {\n\t\t\t\"@context\": [\n\t\t\t\tproofEntity.vcContext ?? DidContexts.ContextVCv1,\n\t\t\t\tImmutableProofContexts.Context,\n\t\t\t\tImmutableProofContexts.ContextCommon\n\t\t\t],\n\t\t\ttype: [DidTypes.VerifiableCredential, ImmutableProofTypes.ImmutableProof],\n\t\t\tid,\n\t\t\tissuer: proofEntity.organizationId,\n\t\t\tcredentialSubject: {\n\t\t\t\tid: proofEntity.proofObjectId,\n\t\t\t\tproofIntegrity: proofEntity.proofObjectIntegrity\n\t\t\t}\n\t\t} as IImmutableProofCredential;\n\n\t\tVerifiableCredentialHelper.setValidFrom(\n\t\t\tverifiableCredential as IDidVerifiableCredential,\n\t\t\tproofEntity.dateCreated\n\t\t);\n\n\t\tlet verified = false;\n\t\tlet failure: ImmutableProofFailure | undefined = ImmutableProofFailure.NotIssued;\n\n\t\tif (Is.stringValue(proofEntity.notarizationId)) {\n\t\t\tfailure = ImmutableProofFailure.ProofMissing;\n\t\t\tconst notarization = await this._notarizationConnector.get(proofEntity.notarizationId);\n\n\t\t\tif (Is.uint8Array(notarization.data)) {\n\t\t\t\tconst proof = ObjectHelper.fromBytes<IProof>(notarization.data);\n\n\t\t\t\tconst proofWithReceipt = {\n\t\t\t\t\t...proof,\n\t\t\t\t\tverificationMethod: `${proofEntity.organizationId}#${this._verificationMethodId}`,\n\t\t\t\t\tnotarizationId: proofEntity.notarizationId\n\t\t\t\t};\n\n\t\t\t\tverifiableCredential.proof = proofWithReceipt;\n\n\t\t\t\tif (verify && Is.object<IProof>(proof)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this._identityConnector.checkVerifiableCredential(\n\t\t\t\t\t\t\tverifiableCredential as IDidVerifiableCredential\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (result.revoked) {\n\t\t\t\t\t\t\tverified = false;\n\t\t\t\t\t\t\tfailure = ImmutableProofFailure.Revoked;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tverified = true;\n\t\t\t\t\t\t\tfailure = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tverified = false;\n\t\t\t\t\t\tfailure = ImmutableProofFailure.VerificationFailure;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tverifiableCredential: await JsonLdProcessor.compact(\n\t\t\t\tverifiableCredential,\n\t\t\t\tJsonLdProcessor.gatherContexts(verifiableCredential)\n\t\t\t),\n\t\t\tverified,\n\t\t\tfailure\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IImmutableProofServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IImmutableProofServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IImmutableProofServiceConfig } from \"./IImmutableProofServiceConfig.js\";\n\n/**\n * Options for the immutable proof service constructor.\n */\nexport interface IImmutableProofServiceConstructorOptions {\n\t/**\n\t * The entity storage for proofs.\n\t * @default immutable-proof\n\t */\n\timmutableProofEntityStorageType?: string;\n\n\t/**\n\t * The
|
|
1
|
+
{"version":3,"file":"IImmutableProofServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IImmutableProofServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IImmutableProofServiceConfig } from \"./IImmutableProofServiceConfig.js\";\n\n/**\n * Options for the immutable proof service constructor.\n */\nexport interface IImmutableProofServiceConstructorOptions {\n\t/**\n\t * The entity storage for proofs.\n\t * @default immutable-proof\n\t */\n\timmutableProofEntityStorageType?: string;\n\n\t/**\n\t * The notarization connector type.\n\t * @default notarization\n\t */\n\tnotarizationConnectorType?: string;\n\n\t/**\n\t * The logging component type.\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The identity connector type.\n\t * @default identity\n\t */\n\tidentityConnectorType?: string;\n\n\t/**\n\t * The background task component type.\n\t * @default background-task\n\t */\n\tbackgroundTaskComponentType?: string;\n\n\t/**\n\t * The event bus component type, defaults to no event bus.\n\t */\n\teventBusComponentType?: string;\n\n\t/**\n\t * The configuration for the connector.\n\t */\n\tconfig?: IImmutableProofServiceConfig;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjG,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,iBAAiB;QACvB,gBAAgB,EAAE,iBAAiB;QACnC,IAAI,EAAE,kBAAkB;QACxB,cAAc,EAAE,gCAAgC;KAChD;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport { generateRestRoutesImmutableProof, tagsImmutableProof } from \"./immutableProofRoutes.js\";\n\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"immutable-proof\",\n\t\tdefaultBaseRoute: \"immutable-proof\",\n\t\ttags: tagsImmutableProof,\n\t\tgenerateRoutes: generateRestRoutesImmutableProof\n\t}\n];\n"]}
|
|
1
|
+
{"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjG;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,iBAAiB;QACvB,gBAAgB,EAAE,iBAAiB;QACnC,IAAI,EAAE,kBAAkB;QACxB,cAAc,EAAE,gCAAgC;KAChD;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport { generateRestRoutesImmutableProof, tagsImmutableProof } from \"./immutableProofRoutes.js\";\n\n/**\n * The REST entry points for the immutable proof service.\n */\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"immutable-proof\",\n\t\tdefaultBaseRoute: \"immutable-proof\",\n\t\ttags: tagsImmutableProof,\n\t\tgenerateRoutes: generateRestRoutesImmutableProof\n\t}\n];\n"]}
|
|
@@ -24,9 +24,9 @@ export declare class ImmutableProof {
|
|
|
24
24
|
*/
|
|
25
25
|
proofObjectIntegrity: string;
|
|
26
26
|
/**
|
|
27
|
-
* The
|
|
27
|
+
* The notarization id.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
notarizationId?: string;
|
|
30
30
|
/**
|
|
31
31
|
* The verifiable credential context.
|
|
32
32
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICreatedResponse, IHttpRequestContext, IRestRoute, ITag } from "@twin.org/api-models";
|
|
2
|
-
import { type IImmutableProofCreateRequest, type IImmutableProofGetRequest, type IImmutableProofGetResponse, type IImmutableProofVerifyRequest, type IImmutableProofVerifyResponse } from "@twin.org/immutable-proof-models";
|
|
1
|
+
import type { ICreatedResponse, IHttpRequestContext, INoContentResponse, IRestRoute, ITag } from "@twin.org/api-models";
|
|
2
|
+
import { type IImmutableProofCreateRequest, type IImmutableProofGetRequest, type IImmutableProofGetResponse, type IImmutableProofRemoveNotarizationRequest, type IImmutableProofRemoveRequest, type IImmutableProofVerifyRequest, type IImmutableProofVerifyResponse } from "@twin.org/immutable-proof-models";
|
|
3
3
|
/**
|
|
4
4
|
* The tag to associate with the routes.
|
|
5
5
|
*/
|
|
@@ -20,7 +20,7 @@ export declare function generateRestRoutesImmutableProof(baseRouteName: string,
|
|
|
20
20
|
*/
|
|
21
21
|
export declare function immutableProofCreate(httpRequestContext: IHttpRequestContext, componentName: string, request: IImmutableProofCreateRequest): Promise<ICreatedResponse>;
|
|
22
22
|
/**
|
|
23
|
-
* Get
|
|
23
|
+
* Get a proof.
|
|
24
24
|
* @param httpRequestContext The request context for the API.
|
|
25
25
|
* @param componentName The name of the component to use in the routes.
|
|
26
26
|
* @param request The request.
|
|
@@ -28,10 +28,26 @@ export declare function immutableProofCreate(httpRequestContext: IHttpRequestCon
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function immutableProofGet(httpRequestContext: IHttpRequestContext, componentName: string, request: IImmutableProofGetRequest): Promise<IImmutableProofGetResponse>;
|
|
30
30
|
/**
|
|
31
|
-
* Verify
|
|
31
|
+
* Verify a proof.
|
|
32
32
|
* @param httpRequestContext The request context for the API.
|
|
33
33
|
* @param componentName The name of the component to use in the routes.
|
|
34
34
|
* @param request The request.
|
|
35
35
|
* @returns The response object with additional http response properties.
|
|
36
36
|
*/
|
|
37
37
|
export declare function immutableProofVerify(httpRequestContext: IHttpRequestContext, componentName: string, request: IImmutableProofVerifyRequest): Promise<IImmutableProofVerifyResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Remove the proof and its notarization.
|
|
40
|
+
* @param httpRequestContext The request context for the API.
|
|
41
|
+
* @param componentName The name of the component to use in the routes.
|
|
42
|
+
* @param request The request.
|
|
43
|
+
* @returns The response object with additional http response properties.
|
|
44
|
+
*/
|
|
45
|
+
export declare function immutableProofRemove(httpRequestContext: IHttpRequestContext, componentName: string, request: IImmutableProofRemoveRequest): Promise<INoContentResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Remove the notarization for a proof, keeping the proof entity.
|
|
48
|
+
* @param httpRequestContext The request context for the API.
|
|
49
|
+
* @param componentName The name of the component to use in the routes.
|
|
50
|
+
* @param request The request.
|
|
51
|
+
* @returns The response object with additional http response properties.
|
|
52
|
+
*/
|
|
53
|
+
export declare function immutableProofRemoveNotarization(httpRequestContext: IHttpRequestContext, componentName: string, request: IImmutableProofRemoveNotarizationRequest): Promise<INoContentResponse>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
-
import { type IImmutableProofComponent, type IImmutableProofVerification } from "@twin.org/immutable-proof-models";
|
|
3
|
-
import { type IDidVerifiableCredential } from "@twin.org/standards-w3c-did";
|
|
2
|
+
import { type IImmutableProofComponent, type IImmutableProofCredential, type IImmutableProofVerification } from "@twin.org/immutable-proof-models";
|
|
4
3
|
import type { IImmutableProofServiceConstructorOptions } from "./models/IImmutableProofServiceConstructorOptions.js";
|
|
5
4
|
/**
|
|
6
5
|
* Class for performing immutable proof operations.
|
|
@@ -11,7 +10,7 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
|
|
|
11
10
|
*/
|
|
12
11
|
static readonly CLASS_NAME: string;
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Creates an instance of ImmutableProofService.
|
|
15
14
|
* @param options The dependencies for the immutable proof connector.
|
|
16
15
|
*/
|
|
17
16
|
constructor(options?: IImmutableProofServiceConstructorOptions);
|
|
@@ -23,22 +22,26 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
|
|
|
23
22
|
/**
|
|
24
23
|
* The component needs to be started when the node is initialized.
|
|
25
24
|
* @param nodeLoggingComponentType The node logging component type.
|
|
26
|
-
* @returns
|
|
25
|
+
* @returns A promise that resolves when the background task handler has been registered.
|
|
27
26
|
*/
|
|
28
27
|
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
29
28
|
/**
|
|
30
29
|
* Create a new proof.
|
|
31
30
|
* @param document The document to create the proof for.
|
|
31
|
+
* @param options Optional settings for the proof.
|
|
32
|
+
* @param options.deleteLock An ISO 8601 date-time string specifying when the notarization lock expires; if omitted no lock is applied.
|
|
32
33
|
* @returns The id of the new proof.
|
|
33
34
|
*/
|
|
34
|
-
create(document: IJsonLdNodeObject
|
|
35
|
+
create(document: IJsonLdNodeObject, options?: {
|
|
36
|
+
deleteLock?: string;
|
|
37
|
+
}): Promise<string>;
|
|
35
38
|
/**
|
|
36
39
|
* Get a proof.
|
|
37
40
|
* @param id The id of the proof to get.
|
|
38
41
|
* @returns The proof.
|
|
39
42
|
* @throws NotFoundError if the proof is not found.
|
|
40
43
|
*/
|
|
41
|
-
get(id: string): Promise<
|
|
44
|
+
get(id: string): Promise<IImmutableProofCredential>;
|
|
42
45
|
/**
|
|
43
46
|
* Verify a proof.
|
|
44
47
|
* @param id The id of the proof to verify.
|
|
@@ -47,10 +50,17 @@ export declare class ImmutableProofService implements IImmutableProofComponent {
|
|
|
47
50
|
*/
|
|
48
51
|
verify(id: string): Promise<IImmutableProofVerification>;
|
|
49
52
|
/**
|
|
50
|
-
* Remove the
|
|
51
|
-
* @param id The id of the proof to remove
|
|
52
|
-
* @returns
|
|
53
|
+
* Remove the proof and its notarization.
|
|
54
|
+
* @param id The id of the proof to remove.
|
|
55
|
+
* @returns A promise that resolves when the proof and its notarization have been removed.
|
|
53
56
|
* @throws NotFoundError if the proof is not found.
|
|
54
57
|
*/
|
|
55
|
-
|
|
58
|
+
remove(id: string): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Remove only the notarization for the proof, keeping the proof entity.
|
|
61
|
+
* @param id The id of the proof to remove the notarization from.
|
|
62
|
+
* @returns A promise that resolves when the notarization has been removed.
|
|
63
|
+
* @throws NotFoundError if the proof is not found.
|
|
64
|
+
*/
|
|
65
|
+
removeNotarization(id: string): Promise<void>;
|
|
56
66
|
}
|
|
@@ -9,13 +9,12 @@ export interface IImmutableProofServiceConstructorOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
immutableProofEntityStorageType?: string;
|
|
11
11
|
/**
|
|
12
|
-
* The
|
|
13
|
-
* @default
|
|
12
|
+
* The notarization connector type.
|
|
13
|
+
* @default notarization
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
notarizationConnectorType?: string;
|
|
16
16
|
/**
|
|
17
17
|
* The logging component type.
|
|
18
|
-
* @default logging
|
|
19
18
|
*/
|
|
20
19
|
loggingComponentType?: string;
|
|
21
20
|
/**
|