diff --git a/packages/ion-did-provider/src/index.ts b/packages/ion-did-provider/src/index.ts index a1d600d01..0e9a6cd62 100644 --- a/packages/ion-did-provider/src/index.ts +++ b/packages/ion-did-provider/src/index.ts @@ -6,3 +6,4 @@ */ export { IonDIDProvider } from './ion-did-provider' export { getDidIonResolver } from './ion-did-resolver' +export * from './types/ion-provider-types' diff --git a/packages/ssi-sdk-core/package.json b/packages/ssi-sdk-core/package.json index f5aa3db92..8786a505b 100644 --- a/packages/ssi-sdk-core/package.json +++ b/packages/ssi-sdk-core/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "@scure/base": "^1.1.1", + "@sphereon/ssi-types": "^0.7.0", "@veramo/core": "3.1.2-next.84" }, "devDependencies": { diff --git a/packages/ssi-sdk-core/src/index.ts b/packages/ssi-sdk-core/src/index.ts index cd8960b1e..0fe700b97 100644 --- a/packages/ssi-sdk-core/src/index.ts +++ b/packages/ssi-sdk-core/src/index.ts @@ -3,15 +3,11 @@ export { VerifiablePresentationSP, UnsignedPresentationSP, VerifiableCredentialSP, - PresentationSubmission, CredentialProofSP, CredentialStatusSP, W3CVerifiableCredentialSP, W3CVerifiablePresentationSP, - ProofPurpose, UnsignedCredentialSP, - Descriptor, - IParsedDID, - SignatureTypes, + ProofOptions, } from './types' export { SuppliedSigner } from './signers' diff --git a/packages/ssi-sdk-core/src/signers/SuppliedSigner.ts b/packages/ssi-sdk-core/src/signers/SuppliedSigner.ts index 6b8b1033c..9a9ba2136 100644 --- a/packages/ssi-sdk-core/src/signers/SuppliedSigner.ts +++ b/packages/ssi-sdk-core/src/signers/SuppliedSigner.ts @@ -7,16 +7,16 @@ export function SuppliedSigner(keyRef: Pick, context: IAgentContext return await context.agent.keyManagerSign({ keyRef: keyRef.kid, algorithm, data: input }) } } -export declare type Signer = (data: string | Uint8Array) => Promise; +export declare type Signer = (data: string | Uint8Array) => Promise export declare enum KeyAlgo { - EDDSA = "EdDSA", - RS256 = "RS256", - ES256 = "ES256", - ES256K = "ES256K" + EDDSA = 'EdDSA', + RS256 = 'RS256', + ES256 = 'ES256', + ES256K = 'ES256K', } export interface EcdsaSignature { - r: string; - s: string; - recoveryParam?: number | null; + r: string + s: string + recoveryParam?: number | null } diff --git a/packages/ssi-sdk-core/src/types/IParsedDid.ts b/packages/ssi-sdk-core/src/types/IParsedDid.ts deleted file mode 100644 index 6ff367015..000000000 --- a/packages/ssi-sdk-core/src/types/IParsedDid.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface IParsedDID { - did: string - didUrl: string - method: string - id: string - path?: string - fragment?: string - query?: string - params?: { - [index: string]: string - } -} diff --git a/packages/ssi-sdk-core/src/types/index.ts b/packages/ssi-sdk-core/src/types/index.ts index b09be0545..61d97c8cf 100644 --- a/packages/ssi-sdk-core/src/types/index.ts +++ b/packages/ssi-sdk-core/src/types/index.ts @@ -1,3 +1,2 @@ export * from './vc-data-models' -export * from './presentation-exchange' -export * from './IParsedDid' +export * from './signatures' diff --git a/packages/ssi-sdk-core/src/types/signatures.ts b/packages/ssi-sdk-core/src/types/signatures.ts index f4f6a1662..9083ff5f6 100644 --- a/packages/ssi-sdk-core/src/types/signatures.ts +++ b/packages/ssi-sdk-core/src/types/signatures.ts @@ -1,10 +1,10 @@ -import { ProofPurpose, SignatureTypes } from './vc-data-models' +import { IProofPurpose, IProofType } from '@sphereon/ssi-types' export interface ProofOptions { /** * The signature type. For instance RsaSignature2018 */ - type?: SignatureTypes | string + type?: IProofType | string /** * Type supports selective disclosure? @@ -24,7 +24,7 @@ export interface ProofOptions { /** * The purpose of this proof, for instance assertionMethod or authentication, see https://www.w3.org/TR/vc-data-model/#proofs-signatures-0 */ - proofPurpose?: ProofPurpose | string + proofPurpose?: IProofPurpose | string /** * The ISO8601 date-time string for creation. You can update the Proof value later in the callback. If not supplied the current date/time will be used diff --git a/packages/ssi-sdk-core/src/types/vc-data-models.ts b/packages/ssi-sdk-core/src/types/vc-data-models.ts index 37df9cac3..e0573777a 100644 --- a/packages/ssi-sdk-core/src/types/vc-data-models.ts +++ b/packages/ssi-sdk-core/src/types/vc-data-models.ts @@ -8,34 +8,12 @@ import { ProofType, CredentialStatus, } from '@veramo/core' -import { PresentationSubmission } from './presentation-exchange' + +import { IProofPurpose, IProofType, PresentationSubmission } from '@sphereon/ssi-types' export type W3CVerifiablePresentationSP = VerifiablePresentation | VerifiablePresentationSP | CompactJWT export type W3CVerifiableCredentialSP = VerifiableCredential | VerifiableCredentialSP | CompactJWT -export enum SignatureTypes { - Ed25519Signature2018 = 'Ed25519Signature2018', - Ed25519Signature2020 = 'Ed25519Signature2020', - EcdsaSecp256k1Signature2019 = 'EcdsaSecp256k1Signature2019', - EcdsaSecp256k1RecoverySignature2020 = 'EcdsaSecp256k1RecoverySignature2020', - JsonWebSignature2020 = 'JsonWebSignature2020', - RsaSignature2018 = 'RsaSignature2018', - GpgSignature2020 = 'GpgSignature2020', - JcsEd25519Signature2020 = 'JcsEd25519Signature2020', - BbsBlsSignatureProof2020 = 'BbsBlsSignatureProof2020', - BbsBlsBoundSignatureProof2020 = 'BbsBlsBoundSignatureProof2020', -} - -export enum ProofPurpose { - verificationMethod = 'verificationMethod', - assertionMethod = 'assertionMethod', - authentication = 'authentication', - keyAgreement = 'keyAgreement', - contractAgreement = 'contactAgreement', - capabilityInvocation = 'capabilityInvocation', - capabilityDelegation = 'capabilityDelegation', -} - export interface CredentialStatusSP extends CredentialStatus { id: string type: string @@ -56,9 +34,9 @@ export interface CredentialStatusSP extends CredentialStatus { }*/ export interface CredentialProofSP extends ProofType { - type: string | SignatureTypes // The proof type + type: string | IProofType // The proof type created: string // The ISO8601 date-time string for creation - proofPurpose: ProofPurpose | string // The specific intent for the proof + proofPurpose: IProofPurpose | string // The specific intent for the proof verificationMethod: string // A set of parameters required to independently verify the proof challenge?: string // A challenge to protect against replay attacks domain?: string // A string restricting the (usage of a) proof to the domain and protects against replay attacks diff --git a/packages/ssi-sdk-core/src/utils/dids.ts b/packages/ssi-sdk-core/src/utils/dids.ts index 41100a027..550abefd1 100644 --- a/packages/ssi-sdk-core/src/utils/dids.ts +++ b/packages/ssi-sdk-core/src/utils/dids.ts @@ -1,4 +1,4 @@ -import { IParsedDID } from '../types' +import { IParsedDID } from '@sphereon/ssi-types' export const parseDid = (did: string): IParsedDID => { const parsedDid = parse(did) diff --git a/packages/ssi-sdk-core/tsconfig.json b/packages/ssi-sdk-core/tsconfig.json index f3a8aee57..9116c4295 100644 --- a/packages/ssi-sdk-core/tsconfig.json +++ b/packages/ssi-sdk-core/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "rootDir": "src", "outDir": "dist" - } + }, + "references": [{ "path": "../ssi-types" }] } diff --git a/packages/ssi-types/CHANGELOG.md b/packages/ssi-types/CHANGELOG.md new file mode 100644 index 000000000..23c4ea33e --- /dev/null +++ b/packages/ssi-types/CHANGELOG.md @@ -0,0 +1,49 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [0.7.0](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.6.0...v0.7.0) (2022-08-05) + +**Note:** Version bump only for package @sphereon/ssi-sdk-core + +# [0.6.0](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.5.1...v0.6.0) (2022-07-01) + +**Note:** Version bump only for package @sphereon/ssi-sdk-core + +# [0.5.0](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.4.0...v0.5.0) (2022-02-23) + +**Note:** Version bump only for package @sphereon/ssi-sdk-core + +# [0.4.0](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.3.4...v0.4.0) (2022-02-11) + +**Note:** Version bump only for package @sphereon/ssi-sdk-core + +## [0.3.4](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.3.3...v0.3.4) (2022-02-11) + +**Note:** Version bump only for package @sphereon/ssi-sdk-core + +## [0.3.1](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.3.0...v0.3.1) (2022-01-28) + +**Note:** Version bump only for package @sphereon/ssi-sdk-core + +# [0.3.0](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.2.0...v0.3.0) (2022-01-16) + +**Note:** Version bump only for package @sphereon/ssi-sdk-core + +# [0.2.0](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.1.0...v0.2.0) (2021-12-16) + +### Bug Fixes + +- Multibase encoding didn't include the prefix char ([1be44b7](https://github.com/Sphereon-OpenSource/ssi-sdk/commit/1be44b7f281b82370a59a321f25057bee34d58de)) + +### Features + +- Add JSON-LD Credential and Presentation handling/sign support that is compatible with React-Native ([995f55e](https://github.com/Sphereon-OpenSource/ssi-sdk/commit/995f55efd5237e3fbd76e6569e09ee3bbcbb686c)) + +# 0.1.0 (2021-11-26) + +### Features + +- Add ssi-sdk core module ([42a5b65](https://github.com/Sphereon-OpenSource/ssi-sdk/commit/42a5b65fa3795284fc16b06d2a36c4bf4ea87668)) +- Add workspace/lerna files and structures ([2c2b112](https://github.com/Sphereon-OpenSource/ssi-sdk/commit/2c2b11244c2e5e3d2d1b1db76af3d86ec300bc72)) diff --git a/packages/ssi-types/LICENSE b/packages/ssi-types/LICENSE new file mode 100644 index 000000000..ef0dcdac2 --- /dev/null +++ b/packages/ssi-types/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this fragment. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2021] [Sphereon BV] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/ssi-types/README.md b/packages/ssi-types/README.md new file mode 100644 index 000000000..3bf8c5fb4 --- /dev/null +++ b/packages/ssi-types/README.md @@ -0,0 +1,49 @@ + +

+
+ Sphereon +
SSI Common Types (Typescript) +
+

+ +--- + +**Warning: This package still is in very early development. Breaking changes without notice will happen at this point!** + +--- + +# ssi-types + +Common SSI types + +### Installation + +```shell +yarn add @sphereon/ssi-types +``` + +### Build + +```shell +yarn build +``` + +### Test + +The test command runs: + +- `prettier` +- `jest` +- `coverage` + +You can also run only a single section of these tests, using for example `yarn test:unit`. + +```shell +yarn test +``` + +### Utility scripts + +There are other utility scripts that help with development. + +- `yarn fix` - runs `eslint --fix` as well as `prettier` to fix code style. diff --git a/packages/ssi-types/api-extractor.json b/packages/ssi-types/api-extractor.json new file mode 100644 index 000000000..94c2c6a9f --- /dev/null +++ b/packages/ssi-types/api-extractor.json @@ -0,0 +1,3 @@ +{ + "extends": "../include/api-extractor-base.json" +} diff --git a/packages/ssi-types/package.json b/packages/ssi-types/package.json new file mode 100644 index 000000000..73e61a1a2 --- /dev/null +++ b/packages/ssi-types/package.json @@ -0,0 +1,27 @@ +{ + "name": "@sphereon/ssi-types", + "description": "SSI Common Types", + "version": "0.7.0", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc --build" + }, + "devDependencies": { + "typescript": "4.6.4" + }, + "files": [ + "dist/**/*", + "src/**/*", + "plugin.schema.json", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "repository": "git@github.com:Sphereon-OpenSource/ssi-sdk.git", + "author": "Sphereon ", + "license": "Apache-2.0", + "keywords": [] +} diff --git a/packages/ssi-types/src/index.ts b/packages/ssi-types/src/index.ts new file mode 100644 index 000000000..c9f6f047d --- /dev/null +++ b/packages/ssi-types/src/index.ts @@ -0,0 +1 @@ +export * from './types' diff --git a/packages/ssi-types/src/types/did.ts b/packages/ssi-types/src/types/did.ts new file mode 100644 index 000000000..0bedb7e84 --- /dev/null +++ b/packages/ssi-types/src/types/did.ts @@ -0,0 +1,35 @@ +export enum IProofPurpose { + verificationMethod = 'verificationMethod', + assertionMethod = 'assertionMethod', + authentication = 'authentication', + keyAgreement = 'keyAgreement', + contractAgreement = 'contactAgreement', + capabilityInvocation = 'capabilityInvocation', + capabilityDelegation = 'capabilityDelegation', +} + +export enum IProofType { + Ed25519Signature2018 = 'Ed25519Signature2018', + Ed25519Signature2020 = 'Ed25519Signature2020', + EcdsaSecp256k1Signature2019 = 'EcdsaSecp256k1Signature2019', + EcdsaSecp256k1RecoverySignature2020 = 'EcdsaSecp256k1RecoverySignature2020', + JsonWebSignature2020 = 'JsonWebSignature2020', + RsaSignature2018 = 'RsaSignature2018', + GpgSignature2020 = 'GpgSignature2020', + JcsEd25519Signature2020 = 'JcsEd25519Signature2020', + BbsBlsSignatureProof2020 = 'BbsBlsSignatureProof2020', + BbsBlsBoundSignatureProof2020 = 'BbsBlsBoundSignatureProof2020', +} + +export interface IParsedDID { + did: string + didUrl: string + method: string + id: string + path?: string + fragment?: string + query?: string + params?: { + [index: string]: string + } +} diff --git a/packages/ssi-types/src/types/index.ts b/packages/ssi-types/src/types/index.ts new file mode 100644 index 000000000..d80f8127b --- /dev/null +++ b/packages/ssi-types/src/types/index.ts @@ -0,0 +1,3 @@ +export * from './did' +export * from './pex' +export * from './vc' diff --git a/packages/ssi-sdk-core/src/types/presentation-exchange.ts b/packages/ssi-types/src/types/pex.ts similarity index 64% rename from packages/ssi-sdk-core/src/types/presentation-exchange.ts rename to packages/ssi-types/src/types/pex.ts index 9d65e1a7a..bd138f570 100644 --- a/packages/ssi-sdk-core/src/types/presentation-exchange.ts +++ b/packages/ssi-types/src/types/pex.ts @@ -1,3 +1,6 @@ +/** + * It express how the inputs presented as proofs to a Verifier. + */ export interface PresentationSubmission { /** * A UUID or some other unique ID to identify this Presentation Submission @@ -13,6 +16,21 @@ export interface PresentationSubmission { descriptor_map: Array } +/** + * Presentation Echange API + * Presentation Exchange API + * + * The version of the OpenAPI document: 1.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * descriptor map laying out the structure of the presentation submission. + */ export interface Descriptor { /** * ID to identify the descriptor from Presentation Definition Input Descriptor it coresponds to. diff --git a/packages/ssi-types/src/types/vc.ts b/packages/ssi-types/src/types/vc.ts new file mode 100644 index 000000000..938eb357c --- /dev/null +++ b/packages/ssi-types/src/types/vc.ts @@ -0,0 +1,145 @@ +import { PresentationSubmission } from './pex' +import { IProofPurpose, IProofType } from './did' + +export interface ICredential { + // If exp is present, the UNIX timestamp MUST be converted to an [XMLSCHEMA11-2] date-time, and MUST be used to set the value of the expirationDate property of credentialSubject of the new JSON object. + expirationDate?: string + // If iss is present, the value MUST be used to set the issuer property of the new credential JSON object or the holder property of the new presentation JSON object. + issuer: string | IIssuer + // If nbf is present, the UNIX timestamp MUST be converted to an [XMLSCHEMA11-2] date-time, and MUST be used to set the value of the issuanceDate property of the new JSON object. + issuanceDate: string + // If sub is present, the value MUST be used to set the value of the id property of credentialSubject of the new credential JSON object. + credentialSubject: ICredentialSubject + // If jti is present, the value MUST be used to set the value of the id property of the new JSON object. + id: string + '@context': ICredentialContextType[] | ICredentialContextType + credentialStatus?: ICredentialStatus + credentialSchema?: undefined | ICredentialSchemaType | ICredentialSchemaType[] + description?: string + name?: string + type: string[] + + [x: string]: unknown +} + +export interface ICredentialSubject { + id?: string + + [x: string]: unknown +} + +export type ICredentialContextType = ICredentialContext | string + +export interface ICredentialContext { + name?: string + did?: string + [x: string]: unknown +} + +export type ICredentialSchemaType = ICredentialSchema | string + +export interface ICredentialSchema { + id: string + type?: string +} + +export interface IProof { + type: IProofType | string // The proof type + created: string // The ISO8601 date-time string for creation + proofPurpose: IProofPurpose | string // The specific intent for the proof + verificationMethod: string // A set of parameters required to independently verify the proof + challenge?: string // A challenge to protect against replay attacks + domain?: string // A string restricting the (usage of a) proof to the domain and protects against replay attacks + proofValue?: string // One of any number of valid representations of proof values + jws?: string // JWS based proof + nonce?: string // Similar to challenge. A nonce to protect against replay attacks, used in some ZKP proofs + requiredRevealStatements?: string[] // The parts of the proof that must be revealed in a derived proof + + [x: string]: string | string[] | undefined +} + +export interface ICredentialStatus { + id: string + type: string +} + +export interface IIssuer { + id: string + + [x: string]: unknown +} + +export interface IHasProof { + proof: IProof | IProof[] +} + +export type IVerifiableCredential = ICredential & IHasProof + +export interface IPresentation { + '@context': ICredentialContextType | ICredentialContextType[] + type: string[] + verifiableCredential: IVerifiableCredential[] + presentation_submission?: PresentationSubmission + holder?: string +} + +export type IVerifiablePresentation = IPresentation & IHasProof + +export interface WrappedVerifiableCredential { + /** + * Original VC that we've received + */ + original: string | JwtWrappedVerifiableCredential | IVerifiableCredential + /** + * In case of JWT credential it will be the decoded version. In other cases it will be the same as original one + */ + decoded: JwtWrappedVerifiableCredential | IVerifiableCredential + /** + * Type of this credential. Supported types are json-ld and jwt + */ + type: VerifiableDataExchangeType + /** + * created based on https://www.w3.org/TR/vc-data-model/#jwt-decoding + */ + internalCredential: ICredential +} + +export interface WrappedVerifiablePresentation { + original: string | JwtWrappedVerifiablePresentation | IVerifiablePresentation + decoded: JwtWrappedVerifiablePresentation | IVerifiablePresentation + type: VerifiableDataExchangeType + internalPresentation: InternalPresentation + vcs: WrappedVerifiableCredential[] +} + +export enum VerifiableDataExchangeType { + JSONLD, + JWT_ENCODED, + JWT_DECODED, +} + +export interface InternalPresentation { + '@context': ICredentialContextType | ICredentialContextType[] + type: string[] + verifiableCredential: WrappedVerifiableCredential[] + presentation_submission?: PresentationSubmission + holder?: string +} + +export interface JwtWrappedVerifiableCredential { + vc: ICredential + exp: string + iss: string + nbf: string + sub: string + jti: string +} + +export interface JwtWrappedVerifiablePresentation { + vp: IVerifiablePresentation + exp: string + iss: string + nbf: string + sub: string + jti: string +} diff --git a/packages/ssi-types/tsconfig.json b/packages/ssi-types/tsconfig.json new file mode 100644 index 000000000..f3a8aee57 --- /dev/null +++ b/packages/ssi-types/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + } +} diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 0ab85782d..d69bfd118 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -1,6 +1,7 @@ { "files": [], "references": [ + { "path": "ssi-types" }, { "path": "ssi-sdk-core" }, { "path": "factom-did-provider" }, { "path": "lto-did-provider" }, diff --git a/packages/wellknown-did-issuer/src/agent/WellKnownDidIssuer.ts b/packages/wellknown-did-issuer/src/agent/WellKnownDidIssuer.ts index d252e61b7..c429788b9 100644 --- a/packages/wellknown-did-issuer/src/agent/WellKnownDidIssuer.ts +++ b/packages/wellknown-did-issuer/src/agent/WellKnownDidIssuer.ts @@ -46,7 +46,7 @@ export class WellKnownDidIssuer implements IAgentPlugin { private readonly didConfigurationResourceRelations = ['linkedDids'] constructor(private dbConnection: OrPromise, args?: IWellKnownDidIssuerOptionsArgs) { - this.credentialIssuances = args && args.credentialIssuances || {} + this.credentialIssuances = (args && args.credentialIssuances) || {} } /** {@inheritDoc IWellKnownDidIssuer.registerSignatureVerification} */ @@ -188,10 +188,13 @@ export class WellKnownDidIssuer implements IAgentPlugin { .didManagerGet({ did }) .catch(() => Promise.reject(Error('DID cannot be found'))) .then(async (identifier: IIdentifier) => { - if (!identifier.services || identifier.services.filter( + if ( + !identifier.services || + identifier.services.filter( // TODO we should also check for the origins in the serviceEndpoint objects when we start supporting multiple origins (service: Service) => service.type === ServiceTypesEnum.LINKED_DOMAINS && service.serviceEndpoint === args.origin - ).length === 0) { + ).length === 0 + ) { await context.agent.didManagerAddService({ did: identifier.did, service: { diff --git a/packages/wellknown-did-issuer/src/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.ts b/packages/wellknown-did-issuer/src/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.ts index b6eb63dc6..18720fbb9 100644 --- a/packages/wellknown-did-issuer/src/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.ts +++ b/packages/wellknown-did-issuer/src/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.ts @@ -7,7 +7,9 @@ export class CreateWellknownDidIssuer1661161799000 implements MigrationInterface await queryRunner.query( `CREATE TABLE "DidConfigurationResource" ("origin" varchar PRIMARY KEY NOT NULL, "context" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))` ) - await queryRunner.query(`CREATE TABLE "DidConfigurationResourceCredentials" ("didConfigurationResourceOrigin" varchar NOT NULL, "credentialHash" varchar NOT NULL)`) + await queryRunner.query( + `CREATE TABLE "DidConfigurationResourceCredentials" ("didConfigurationResourceOrigin" varchar NOT NULL, "credentialHash" varchar NOT NULL)` + ) } public async down(queryRunner: QueryRunner): Promise { diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index 28dd9cd11..2ef706969 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -1,10 +1,5 @@ import { IAgentPlugin, DIDResolutionResult } from '@veramo/core' -import { - WellKnownDidVerifier as Verifier, - IDomainLinkageValidation, - IResourceValidation, - VerifyCallback, -} from '@sphereon/wellknown-dids-client' +import { WellKnownDidVerifier as Verifier, IDomainLinkageValidation, IResourceValidation, VerifyCallback } from '@sphereon/wellknown-dids-client' import { schema } from '../index' import { IWellKnownDidVerifier, @@ -32,8 +27,8 @@ export class WellKnownDidVerifier implements IAgentPlugin { private readonly onlyVerifyServiceDids: boolean constructor(args?: IWellKnownDidVerifierOptionsArgs) { - this.signatureVerifications = args && args.signatureVerifications || {} - this.onlyVerifyServiceDids = args && args.onlyVerifyServiceDids || false + this.signatureVerifications = (args && args.signatureVerifications) || {} + this.onlyVerifyServiceDids = (args && args.onlyVerifyServiceDids) || false } /** {@inheritDoc IWellKnownDidVerifier.registerSignatureVerification} */ @@ -57,7 +52,7 @@ export class WellKnownDidVerifier implements IAgentPlugin { const signatureVerification: VerifyCallback = typeof args.signatureVerification === 'string' ? await this.getSignatureVerification(args.signatureVerification) - : args.signatureVerification as VerifyCallback + : (args.signatureVerification as VerifyCallback) return context.agent.resolveDid({ didUrl: args.did }).then((didResolutionResult: DIDResolutionResult) => { if (!didResolutionResult.didDocument) { @@ -85,7 +80,7 @@ export class WellKnownDidVerifier implements IAgentPlugin { const signatureVerification: VerifyCallback = typeof args.signatureVerification === 'string' ? await this.getSignatureVerification(args.signatureVerification) - : args.signatureVerification as VerifyCallback + : (args.signatureVerification as VerifyCallback) return new Verifier().verifyResource({ verifySignatureCallback: signatureVerification, diff --git a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts index 3660d2657..c097ff44a 100644 --- a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts @@ -1,9 +1,4 @@ -import { - IDidConfigurationResource, - IDomainLinkageValidation, - IResourceValidation, - VerifyCallback, -} from '@sphereon/wellknown-dids-client' +import { IDidConfigurationResource, IDomainLinkageValidation, IResourceValidation, VerifyCallback } from '@sphereon/wellknown-dids-client' import { IAgentContext, IPluginMethodMap, IResolver } from '@veramo/core' export interface IWellKnownDidVerifier extends IPluginMethodMap {