@sphereon/ssi-sdk.wellknown-did-issuer 0.36.1-feature.SSISDK.82.and.SSISDK.70.37 → 0.36.1-next.39

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 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@20.19.13__@swc+core@1.13.5_@swc_41cc8bb304d44ce0f6d8abf512e96cd0/node_modules/tsup/assets/cjs_shims.js","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/key.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/service.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/claim.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/credential.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/presentation.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/message.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/identifier.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/utils.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/identifier/did-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/identifier/key-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/private-key.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/identifier/private-key-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/data-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/data-store-orm.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/did-discovery-provider.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/entities/PreMigrationEntities.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/migrations/migration-functions.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/migrations/1.createDatabase.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/migrations/2.simplifyRelations.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/migrations/3.createPrivateKeyStorage.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/migrations/4.allowNullVPIssuanceDate.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/migrations/index.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_cc76f3d8bd9150ca5ab4ddaac3f3e569/node_modules/@veramo/data-store/src/index.ts","../plugin.schema.json","../src/index.ts","../src/entities/DidConfigurationResourceEntity.ts","../src/agent/WellKnownDidIssuer.ts","../src/types/IWellKnownDidIssuer.ts","../src/migrations/index.ts","../src/migrations/generic/index.ts","../src/migrations/generic/1-CreateWellknownDidIssuer.ts","../src/migrations/postgres/1661165115000-CreateWellknownDidIssuer.ts","../src/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import { KeyMetadata, TKeyType } from '@veramo/core'\nimport { Entity, Column, PrimaryColumn, BaseEntity, ManyToOne } from 'typeorm'\nimport { Identifier } from './identifier'\n\n/**\n * Mirrors {@link @veramo/core#TKeyType | TKeyType}\n *\n * @beta - This API may change without a BREAKING CHANGE notice.\n */\nexport type KeyType = TKeyType\n\n/**\n * Represents some properties of a {@link @veramo/core#IKey | IKey} that are stored in a TypeORM\n * database for the purpose of keeping track of the {@link @veramo/key-manager#AbstractKeyManagementSystem}\n * implementations and the keys they are able to use.\n *\n * @see {@link @veramo/data-store#KeyStore | KeyStore} for the implementation used by the\n * {@link @veramo/key-manager#KeyManager | KeyManager}.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('key')\nexport class Key extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n kid: string\n\n @Column()\n //@ts-ignore\n kms: string\n\n @Column()\n //@ts-ignore\n type: KeyType\n\n @Column()\n //@ts-ignore\n publicKeyHex: string\n\n @Column({\n type: 'simple-json',\n nullable: true,\n transformer: {\n to: (value: any): KeyMetadata | null => {\n return value\n },\n from: (value: KeyMetadata | null): object | null => {\n return value\n },\n },\n })\n meta?: KeyMetadata | null\n\n @ManyToOne((type) => Identifier, (identifier) => identifier?.keys, { onDelete: 'CASCADE' })\n //@ts-ignore\n identifier?: Identifier\n}\n","import { Entity, Column, PrimaryColumn, BaseEntity, ManyToOne } from 'typeorm'\nimport { Identifier } from './identifier'\n\n/**\n * Represents some properties of a {@link did-resolver#ServiceEndpoint | ServiceEndpoint} as it is stored in a TypeORM\n * database. This is used by {@link @veramo/data-store#DIDStore | DIDStore} to provide information to\n * {@link @veramo/did-manager#DIDManager | DIDManager} when DID management information is stored in a local TypeORM\n * database.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('service')\nexport class Service extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n id: string\n\n @Column()\n //@ts-ignore\n type: string\n\n @Column()\n //@ts-ignore\n serviceEndpoint: string\n\n @Column({ nullable: true })\n description?: string\n\n @ManyToOne((type) => Identifier, (identifier) => identifier?.services, { onDelete: 'CASCADE' })\n //@ts-ignore\n identifier?: Identifier\n}\n","import { Entity, Column, BaseEntity, ManyToOne, PrimaryColumn } from 'typeorm'\nimport { Identifier } from './identifier'\nimport { Credential } from './credential'\n\n/**\n * Represents the properties of a claim extracted from a Verifiable Credential `credentialSubject`, and stored in a\n * TypeORM database for querying.\n *\n * @see {@link @veramo/core#IDataStoreORM} for the interface defining how this can be queried.\n * @see {@link @veramo/data-store#DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('claim')\nexport class Claim extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n hash: string\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.issuedClaims, {\n eager: true,\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n issuer: Identifier\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.receivedClaims, {\n eager: true,\n nullable: true,\n })\n subject?: Identifier\n\n @ManyToOne((type) => Credential, (credential) => credential.claims, {\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n credential: Credential\n\n @Column()\n //@ts-ignore\n issuanceDate: Date\n\n @Column({ nullable: true })\n expirationDate?: Date\n\n @Column('simple-array')\n //@ts-ignore\n context: string[]\n\n @Column('simple-array')\n //@ts-ignore\n credentialType: string[]\n\n @Column()\n //@ts-ignore\n type: string\n\n @Column('text', { nullable: true })\n //@ts-ignore\n value: string | null\n\n @Column()\n //@ts-ignore\n isObj: boolean\n}\n","import { VerifiableCredential } from '@veramo/core'\nimport { BaseEntity, Column, Entity, ManyToMany, ManyToOne, OneToMany, PrimaryColumn } from 'typeorm'\nimport { Identifier } from './identifier'\nimport { Message } from './message'\nimport { Presentation } from './presentation'\nimport { Claim } from './claim'\nimport { asArray, computeEntryHash, extractIssuer } from '@veramo/utils'\n\n/**\n * Represents some common properties of a Verifiable Credential that are stored in a TypeORM database for querying.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetVerifiableCredentials | dataStoreORMGetVerifiableCredentials}\n * for the interface defining how this can be queried.\n *\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetVerifiableCredentialsByClaims | dataStoreORMGetVerifiableCredentialsByClaims} for the interface defining how to query credentials by the claims they contain.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('credential')\nexport class Credential extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n hash: string\n\n //@ts-ignore\n private _raw: VerifiableCredential\n\n set raw(raw: VerifiableCredential) {\n this._raw = raw\n this.hash = computeEntryHash(raw)\n }\n\n @Column('simple-json')\n get raw(): VerifiableCredential {\n return this._raw\n }\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.issuedCredentials, {\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n issuer: Identifier\n\n // Subject can be null https://w3c.github.io/vc-data-model/#credential-uniquely-identifies-a-subject\n @ManyToOne((type) => Identifier, (identifier) => identifier?.receivedCredentials, {\n cascade: ['insert'],\n eager: true,\n nullable: true,\n })\n subject?: Identifier\n\n @Column({ nullable: true })\n id?: string\n\n @Column()\n //@ts-ignore\n issuanceDate: Date\n\n @Column({ nullable: true })\n expirationDate?: Date\n\n @Column('simple-array')\n //@ts-ignore\n context: string[]\n\n @Column('simple-array')\n //@ts-ignore\n type: string[]\n\n @OneToMany((type) => Claim, (claim) => claim.credential, {\n cascade: ['insert'],\n })\n //@ts-ignore\n claims: Claim[]\n\n @ManyToMany((type) => Presentation, (presentation) => presentation.credentials)\n //@ts-ignore\n presentations: Presentation[]\n\n @ManyToMany((type) => Message, (message) => message.credentials)\n //@ts-ignore\n messages: Message[]\n}\n\nexport const createCredentialEntity = (vci: VerifiableCredential): Credential => {\n const vc = vci\n const credential = new Credential()\n credential.context = asArray(vc['@context'])\n credential.type = asArray(vc.type || [])\n credential.id = vc.id\n\n if (vc.issuanceDate) {\n credential.issuanceDate = new Date(vc.issuanceDate)\n }\n\n if (vc.expirationDate) {\n credential.expirationDate = new Date(vc.expirationDate)\n }\n\n const issuer = new Identifier()\n issuer.did = extractIssuer(vc)\n credential.issuer = issuer\n\n if (vc.credentialSubject.id) {\n const subject = new Identifier()\n subject.did = vc.credentialSubject.id\n credential.subject = subject\n }\n credential.claims = []\n for (const type in vc.credentialSubject) {\n if (vc.credentialSubject.hasOwnProperty(type)) {\n const value = vc.credentialSubject[type]\n\n if (type !== 'id') {\n const isObj = typeof value === 'function' || (typeof value === 'object' && !!value)\n const claim = new Claim()\n claim.hash = computeEntryHash(JSON.stringify(vc) + type)\n claim.type = type\n claim.value = isObj ? JSON.stringify(value) : value\n claim.isObj = isObj\n claim.issuer = credential.issuer\n claim.subject = credential.subject\n claim.expirationDate = credential.expirationDate\n claim.issuanceDate = credential.issuanceDate\n claim.credentialType = credential.type\n claim.context = credential.context\n credential.claims.push(claim)\n }\n }\n }\n\n credential.raw = vci\n return credential\n}\n","import { VerifiableCredential, VerifiablePresentation } from '@veramo/core'\n\nimport { BaseEntity, Column, Entity, JoinTable, ManyToMany, ManyToOne, PrimaryColumn } from 'typeorm'\nimport { Identifier } from './identifier'\nimport { Message } from './message'\nimport { createCredentialEntity, Credential } from './credential'\nimport { asArray, computeEntryHash } from '@veramo/utils'\nimport { normalizeCredential } from 'did-jwt-vc'\n\n/**\n * Represents some common properties of a Verifiable Presentation that are stored in a TypeORM database for querying.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetVerifiablePresentations | dataStoreORMGetVerifiablePresentations} for the interface defining how this can be queried.\n *\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('presentation')\nexport class Presentation extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n hash: string\n\n //@ts-ignore\n private _raw: IVerifiablePresentation\n\n set raw(raw: VerifiablePresentation) {\n this._raw = raw\n this.hash = computeEntryHash(raw)\n }\n\n @Column({ type: 'simple-json' })\n get raw(): VerifiablePresentation {\n return this._raw\n }\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.issuedPresentations, {\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n holder: Identifier\n\n @ManyToMany((type) => Identifier, (identifier) => identifier?.receivedPresentations, {\n cascade: ['insert'],\n eager: true,\n nullable: true,\n })\n @JoinTable()\n //@ts-ignore\n verifier?: Identifier[]\n\n @Column({ nullable: true })\n id?: String\n\n @Column()\n //@ts-ignore\n issuanceDate: Date\n\n @Column({ nullable: true })\n expirationDate?: Date\n\n @Column('simple-array')\n //@ts-ignore\n context: string[]\n\n @Column('simple-array')\n //@ts-ignore\n type: string[]\n\n @ManyToMany((type) => Credential, (credential) => credential.presentations, {\n cascade: true,\n })\n @JoinTable()\n //@ts-ignore\n credentials: Credential[]\n\n @ManyToMany((type) => Message, (message) => message.presentations)\n //@ts-ignore\n messages: Message[]\n}\n\nexport const createPresentationEntity = (vpi: VerifiablePresentation): Presentation => {\n const vp = vpi\n const presentation = new Presentation()\n presentation.context = asArray(vp['@context'])\n presentation.type = asArray(vp.type || [])\n presentation.id = vp.id\n\n if (vp.issuanceDate) {\n presentation.issuanceDate = new Date(vp.issuanceDate)\n }\n\n if (vp.expirationDate) {\n presentation.expirationDate = new Date(vp.expirationDate)\n }\n\n const holder = new Identifier()\n holder.did = vp.holder\n presentation.holder = holder\n\n presentation.verifier = asArray(vp.verifier || []).map((verifierDid) => {\n const id = new Identifier()\n id.did = verifierDid\n return id\n })\n\n presentation.raw = vpi\n\n presentation.credentials = (vp.verifiableCredential || [])\n .map((cred) => {\n if (typeof cred === 'string') {\n return normalizeCredential(cred)\n } else {\n return <VerifiableCredential>cred\n }\n })\n .map(createCredentialEntity)\n return presentation\n}\n","import {\n BaseEntity,\n BeforeInsert,\n BeforeUpdate,\n Column,\n Entity,\n JoinTable,\n ManyToMany,\n ManyToOne,\n PrimaryColumn,\n} from 'typeorm'\nimport { IMessage } from '@veramo/core'\nimport { Identifier } from './identifier'\nimport { createPresentationEntity, Presentation } from './presentation'\nimport { createCredentialEntity, Credential } from './credential'\nimport { computeEntryHash } from '@veramo/utils'\nimport { v4 as uuidv4 } from 'uuid'\n\n/**\n * Represents message metadata as it is stored by {@link @veramo/data-store#DataStore | DataStore}.\n *\n * This metadata is most often used by {@link @veramo/message-handler#MessageHandler | MessageHandler} and\n * {@link @veramo/core#IMessageHandler | IMessageHandler} implementations to decorate messages that are interpreted and\n * decoded, but not returned as final, as they pass through the message handler chain.\n *\n * @beta - This API may change without a BREAKING CHANGE notice.\n */\nexport interface MetaData {\n type: string\n value?: string\n}\n\n/**\n * Represents some common properties of an {@link @veramo/core#IMessage} that are stored in a TypeORM database for\n * querying.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetMessages | dataStoreORMGetMessages}\n * for the interface defining how this can be queried\n *\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('message')\nexport class Message extends BaseEntity {\n @BeforeInsert()\n setId() {\n if (!this.id) {\n this.id = computeEntryHash(this.raw || uuidv4())\n }\n }\n\n @PrimaryColumn()\n //@ts-ignore\n id: string\n\n @BeforeInsert()\n setSaveDate() {\n this.saveDate = new Date()\n this.updateDate = new Date()\n }\n\n @BeforeUpdate()\n setUpdateDate() {\n this.updateDate = new Date()\n }\n\n @Column({ select: false })\n //@ts-ignore\n saveDate: Date\n\n @Column({ select: false })\n //@ts-ignore\n updateDate: Date\n\n @Column({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n expiresAt?: Date\n\n @Column({ nullable: true })\n threadId?: string\n\n @Column()\n //@ts-ignore\n type: string\n\n @Column({ nullable: true })\n raw?: string\n\n @Column('simple-json', { nullable: true })\n data?: object | null\n\n // https://github.com/decentralized-identifier/didcomm-messaging/blob/41f35f992275dd71d459504d14eb8d70b4185533/jwm.md#jwm-profile\n\n @Column('simple-array', { nullable: true })\n replyTo?: string[]\n\n @Column({ nullable: true })\n replyUrl?: string\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.sentMessages, {\n nullable: true,\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n from?: Identifier\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.receivedMessages, {\n nullable: true,\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n to?: Identifier\n\n @Column('simple-json', { nullable: true })\n metaData?: MetaData[] | null\n\n @ManyToMany((type) => Presentation, (presentation) => presentation.messages, {\n cascade: true,\n })\n @JoinTable()\n //@ts-ignore\n presentations: Presentation[]\n\n @ManyToMany((type) => Credential, (credential) => credential.messages, { cascade: true })\n @JoinTable()\n //@ts-ignore\n credentials: Credential[]\n}\n\nexport const createMessageEntity = (args: IMessage): Message => {\n const message = new Message()\n message.id = args.id\n message.threadId = args.threadId\n message.type = args.type\n message.raw = args.raw\n message.data = args.data\n message.metaData = args.metaData\n\n if (args.replyTo) {\n message.replyTo = args.replyTo\n }\n if (args.replyUrl) {\n message.replyUrl = args.replyUrl\n }\n\n if (args.createdAt) {\n message.createdAt = new Date(args.createdAt)\n }\n\n if (args.expiresAt) {\n message.createdAt = new Date(args.expiresAt)\n }\n\n if (args.from) {\n const from = new Identifier()\n from.did = args.from\n message.from = from\n }\n\n if (args.to) {\n const to = new Identifier()\n to.did = args.to\n message.to = to\n }\n\n if (args.presentations) {\n message.presentations = args.presentations.map(createPresentationEntity)\n }\n\n if (args.credentials) {\n message.credentials = args.credentials.map(createCredentialEntity)\n }\n\n return message\n}\n\nexport const createMessage = (args: Message): IMessage => {\n const message: Partial<IMessage> = {\n id: args.id,\n type: args.type,\n raw: args.raw,\n data: args.data,\n metaData: args.metaData,\n }\n\n if (args.threadId) {\n message.threadId = args.threadId\n }\n\n if (args.replyTo) {\n message.replyTo = args.replyTo\n }\n\n if (args.replyTo) {\n message.replyUrl = args.replyUrl\n }\n\n if (args.createdAt) {\n message.createdAt = args.createdAt.toISOString()\n }\n\n if (args.expiresAt) {\n message.expiresAt = args.expiresAt.toISOString()\n }\n\n if (args.from) {\n message.from = args.from.did\n }\n\n if (args.to) {\n message.to = args.to.did\n }\n\n if (args.presentations) {\n message.presentations = args.presentations.map((vp) => vp.raw)\n }\n\n if (args.credentials) {\n message.credentials = args.credentials.map((vc) => vc.raw)\n }\n\n return message as IMessage\n}\n","import {\n Entity,\n Column,\n Connection,\n PrimaryColumn,\n BaseEntity,\n OneToMany,\n ManyToMany,\n Index,\n BeforeInsert,\n BeforeUpdate,\n} from 'typeorm'\nimport { Key } from './key'\nimport { Service } from './service'\nimport { Message } from './message'\nimport { Presentation } from './presentation'\nimport { Credential } from './credential'\nimport { Claim } from './claim'\n\n/**\n * Represents some properties and relationships of an {@link @veramo/core#IIdentifier} that are stored in a TypeORM\n * database for the purpose of keeping track of keys and services associated with a DID managed by a Veramo agent.\n *\n * @see {@link @veramo/data-store#DIDStore | DIDStore} for the implementation used by the\n * {@link @veramo/did-manager#DIDManager | DIDManager}.\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('identifier')\n@Index(['alias', 'provider'], { unique: true })\nexport class Identifier extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n did: string\n\n @Column({ nullable: true })\n //@ts-ignore\n provider?: string\n\n @Column({ nullable: true })\n //@ts-ignore\n alias?: string\n\n @BeforeInsert()\n setSaveDate() {\n this.saveDate = new Date()\n this.updateDate = new Date()\n }\n\n @BeforeUpdate()\n setUpdateDate() {\n this.updateDate = new Date()\n }\n\n @Column({ select: false })\n //@ts-ignore\n saveDate: Date\n\n @Column({ select: false })\n //@ts-ignore\n updateDate: Date\n\n @Column({ nullable: true })\n //@ts-ignore\n controllerKeyId?: string\n\n @OneToMany((type) => Key, (key) => key.identifier)\n //@ts-ignore\n keys: Key[]\n\n @OneToMany((type) => Service, (service) => service.identifier, {\n cascade: true,\n })\n //@ts-ignore\n services: Service[]\n\n @OneToMany((type) => Message, (message) => message.from)\n //@ts-ignore\n sentMessages: Message[]\n\n @OneToMany((type) => Message, (message) => message.to)\n //@ts-ignore\n receivedMessages: Message[]\n\n @OneToMany((type) => Presentation, (presentation) => presentation.holder)\n //@ts-ignore\n issuedPresentations: Presentation[]\n\n @ManyToMany((type) => Presentation, (presentation) => presentation.verifier)\n //@ts-ignore\n receivedPresentations: Presentation[]\n\n @OneToMany((type) => Credential, (credential) => credential.issuer)\n //@ts-ignore\n issuedCredentials: Credential[]\n\n @OneToMany((type) => Credential, (credential) => credential.subject)\n //@ts-ignore\n receivedCredentials: Credential[]\n\n @OneToMany((type) => Claim, (claim) => claim.issuer)\n //@ts-ignore\n issuedClaims: Claim[]\n\n @OneToMany((type) => Claim, (claim) => claim.subject)\n //@ts-ignore\n receivedClaims: Claim[]\n\n /**\n * Convenience method to get the most recent information about a subject DID as described by Verifiable Credential\n * claims.\n *\n * Example:\n * ```typescript\n * // get the latest claim value for credentials containing `credentialSubject.name` and this Identifier as subject.\n * const name = await identifier.getLatestClaimValue({type: 'name'})\n * ```\n *\n * @param where - The TypeORM `where` filter to use.\n */\n async getLatestClaimValue(\n dbConnection: Promise<Connection>,\n where: any,\n ): Promise<string | null | undefined> {\n const claim = await (await dbConnection).getRepository(Claim).findOne({\n where: {\n ...where,\n subject: this.did,\n },\n order: {\n issuanceDate: 'DESC',\n },\n })\n return claim?.value\n }\n\n shortDid() {\n return `${this.did.slice(0, 15)}...${this.did.slice(-4)}`\n }\n}\n","import { DataSource } from 'typeorm'\nimport { OrPromise } from \"@veramo/utils\";\n\n/**\n * Ensures that the provided DataSource is connected.\n *\n * @param dbConnection - a TypeORM DataSource or a Promise that resolves to a DataSource\n */\nexport async function getConnectedDb(dbConnection: OrPromise<DataSource>): Promise<DataSource> {\n if (dbConnection instanceof Promise) {\n return await dbConnection\n } else if (!dbConnection.isInitialized) {\n return await (<DataSource>dbConnection).initialize()\n } else {\n return dbConnection\n }\n}\n","import { IIdentifier, IKey } from '@veramo/core'\nimport { AbstractDIDStore } from '@veramo/did-manager'\nimport { Identifier } from '../entities/identifier'\nimport { Credential } from '../entities/credential'\nimport { Key } from '../entities/key'\nimport { Service } from '../entities/service'\nimport { DataSource, IsNull, Not } from 'typeorm'\n\nimport Debug from 'debug'\nimport { Presentation } from '../entities/presentation'\nimport { OrPromise } from \"@veramo/utils\";\nimport { getConnectedDb } from \"../utils\";\n\nconst debug = Debug('veramo:typeorm:identifier-store')\n\n/**\n * An implementation of {@link @veramo/did-manager#AbstractDIDStore | AbstractDIDStore} that uses a TypeORM database to\n * store the relationships between DIDs, their providers and controllers and their keys and services as they are known\n * and managed by a Veramo agent.\n *\n * An instance of this class can be used by {@link @veramo/did-manager#DIDManager} as the data storage layer.\n *\n * To make full use of this class, it should use the same database as the one used by\n * {@link @veramo/data-store#KeyStore | KeyStore}.\n *\n * @public\n */\nexport class DIDStore extends AbstractDIDStore {\n constructor(private dbConnection: OrPromise<DataSource>) {\n super()\n }\n\n async get({\n did,\n alias,\n provider,\n }: {\n did: string\n alias: string\n provider: string\n }): Promise<IIdentifier> {\n let where = {}\n if (did !== undefined && alias === undefined) {\n where = { did }\n } else if (did === undefined && alias !== undefined && provider !== undefined) {\n where = { alias, provider }\n } else {\n throw Error('[veramo:data-store:identifier-store] Get requires did or (alias and provider)')\n }\n\n const identifier = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).findOne({\n where,\n relations: ['keys', 'services'],\n })\n\n if (!identifier) throw Error('Identifier not found')\n const result: IIdentifier = {\n did: identifier.did,\n controllerKeyId: identifier.controllerKeyId,\n provider: identifier.provider!!,\n services: identifier.services.map((service) => {\n let endpoint = service.serviceEndpoint.toString()\n try {\n endpoint = JSON.parse(service.serviceEndpoint)\n } catch {}\n return {\n id: service.id,\n type: service.type,\n serviceEndpoint: endpoint,\n description: service.description,\n }\n }),\n keys: identifier.keys.map(\n (k) =>\n ({\n kid: k.kid,\n type: k.type,\n kms: k.kms,\n publicKeyHex: k.publicKeyHex,\n meta: k.meta,\n } as IKey),\n ),\n }\n if (identifier.alias) {\n result.alias = identifier.alias\n }\n return result\n }\n\n async delete({ did }: { did: string }) {\n const identifier = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).findOne({\n where: { did },\n relations: ['keys', 'services', 'issuedCredentials', 'issuedPresentations'],\n })\n if (!identifier || typeof identifier === 'undefined') {\n return true\n }\n // some drivers don't support cascading so we delete these manually\n\n //unlink existing keys that are no longer tied to this identifier\n let existingKeys = identifier.keys.map((key) => {\n delete key.identifier\n return key\n })\n await (await getConnectedDb(this.dbConnection)).getRepository(Key).save(existingKeys)\n\n if (identifier.issuedCredentials || typeof identifier.issuedCredentials !== 'undefined') {\n await (await getConnectedDb(this.dbConnection)).getRepository(Credential).remove(identifier.issuedCredentials)\n }\n\n if (identifier.issuedPresentations || typeof identifier.issuedPresentations !== 'undefined') {\n await (await getConnectedDb(this.dbConnection)).getRepository(Presentation).remove(identifier.issuedPresentations)\n }\n\n //delete existing services that are no longer tied to this identifier\n let oldServices = identifier.services\n const srvRepo = await (await getConnectedDb(this.dbConnection)).getRepository(Service).remove(oldServices)\n\n if (!identifier) throw Error('Identifier not found')\n debug('Deleting', did)\n await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).remove(identifier)\n\n return true\n }\n\n async import(args: IIdentifier) {\n const identifier = new Identifier()\n identifier.did = args.did\n if (args.controllerKeyId) {\n identifier.controllerKeyId = args.controllerKeyId\n }\n identifier.provider = args.provider\n if (args.alias) {\n identifier.alias = args.alias\n }\n\n identifier.keys = []\n for (const argsKey of args.keys) {\n const key = new Key()\n key.kid = argsKey.kid\n key.publicKeyHex = argsKey.publicKeyHex\n key.kms = argsKey.kms\n key.meta = argsKey.meta\n identifier.keys.push(key)\n }\n\n identifier.services = []\n for (const argsService of args.services) {\n const service = new Service()\n service.id = argsService.id\n service.type = argsService.type\n service.serviceEndpoint = (typeof argsService.serviceEndpoint === 'string') ? argsService.serviceEndpoint : JSON.stringify(argsService.serviceEndpoint)\n service.description = argsService.description\n identifier.services.push(service)\n }\n\n await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).save(identifier)\n\n debug('Saving', args.did)\n return true\n }\n\n async list(args: { alias?: string; provider?: string }): Promise<IIdentifier[]> {\n const where: any = { provider: args?.provider || Not(IsNull()) }\n if (args?.alias) {\n where['alias'] = args.alias\n }\n const identifiers = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).find({\n where,\n relations: ['keys', 'services'],\n })\n return identifiers.map((identifier) => {\n const i = identifier\n if (i.alias === null) {\n delete i.alias\n }\n return i as IIdentifier\n })\n }\n}\n","import { IKey, ManagedKeyInfo } from '@veramo/core'\nimport { AbstractKeyStore } from '@veramo/key-manager'\nimport { DataSource } from 'typeorm'\n\nimport { Key } from '../entities/key'\n\nimport Debug from 'debug'\nimport { OrPromise } from \"@veramo/utils\";\nimport { getConnectedDb } from \"../utils\";\nconst debug = Debug('veramo:typeorm:key-store')\n\n/**\n * An implementation of {@link @veramo/key-manager#AbstractKeyStore | AbstractKeyStore} that uses a TypeORM database to\n * store the relationships between keys, their IDs, aliases and\n * {@link @veramo/key-manager#AbstractKeyManagementSystem | KMS implementations}, as they are known and managed by a\n * Veramo agent.\n *\n * An instance of this class can be used by {@link @veramo/key-manager#KeyManager} as the data storage layer.\n *\n * To make full use of this class, it should use the same database as the one used by\n * {@link @veramo/data-store#DIDStore | DIDStore}.\n *\n * @public\n */\nexport class KeyStore extends AbstractKeyStore {\n constructor(private dbConnection: OrPromise<DataSource>) {\n super()\n }\n\n async get({ kid }: { kid: string }): Promise<IKey> {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(Key).findOneBy({ kid })\n if (!key) throw Error('Key not found')\n return key as IKey\n }\n\n async delete({ kid }: { kid: string }) {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(Key).findOneBy({ kid })\n if (!key) throw Error('Key not found')\n debug('Deleting key', kid)\n await (await getConnectedDb(this.dbConnection)).getRepository(Key).remove(key)\n return true\n }\n\n async import(args: IKey) {\n const key = new Key()\n key.kid = args.kid\n key.publicKeyHex = args.publicKeyHex\n key.type = args.type\n key.kms = args.kms\n key.meta = args.meta\n debug('Saving key', args.kid)\n await (await getConnectedDb(this.dbConnection)).getRepository(Key).save(key)\n return true\n }\n\n async list(args: {} = {}): Promise<ManagedKeyInfo[]> {\n const keys = await (await getConnectedDb(this.dbConnection)).getRepository(Key).find()\n const managedKeys: ManagedKeyInfo[] = keys.map((key) => {\n const { kid, publicKeyHex, type, meta, kms } = key\n return { kid, publicKeyHex, type, meta, kms } as IKey\n })\n return managedKeys\n }\n}\n","import { KeyType } from './key'\nimport { Entity, Column, PrimaryColumn, BaseEntity } from 'typeorm'\n\n/**\n * Represents some properties of a {@link @veramo/key-manager#ManagedPrivateKey | ManagedPrivateKey} that are stored in\n * a TypeORM database when using a {@link @veramo/data-store#PrivateKeyStore | PrivateKeyStore} to store private key\n * data.\n *\n * @see {@link @veramo/kms-local#KeyManagementSystem | KeyManagementSystem} for an implementation of a KMS that can\n * make use of such stored keys.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('private-key')\nexport class PrivateKey extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n alias: string\n\n @Column()\n //@ts-ignore\n type: KeyType\n\n @Column()\n //@ts-ignore\n privateKeyHex: string\n}\n","import { AbstractSecretBox, AbstractPrivateKeyStore } from '@veramo/key-manager'\nimport { DataSource } from 'typeorm'\nimport { ImportablePrivateKey, ManagedPrivateKey } from '@veramo/key-manager'\nimport { PrivateKey } from '../entities/private-key'\nimport { v4 as uuid4 } from 'uuid'\nimport Debug from 'debug'\nimport { OrPromise } from '@veramo/utils'\nimport { getConnectedDb } from '../utils'\n\nconst debug = Debug('veramo:typeorm:key-store')\n\n/**\n * An implementation of {@link @veramo/key-manager#AbstractPrivateKeyStore | AbstractPrivateKeyStore} that uses a\n * TypeORM database connection to store private key material.\n *\n * The keys can be encrypted while at rest if this class is initialized with an\n * {@link @veramo/key-manager#AbstractSecretBox | AbstractSecretBox} implementation.\n *\n * @public\n */\nexport class PrivateKeyStore extends AbstractPrivateKeyStore {\n constructor(private dbConnection: OrPromise<DataSource>, private secretBox?: AbstractSecretBox) {\n super()\n if (!secretBox) {\n console.warn('Please provide SecretBox to the KeyStore')\n }\n }\n\n async get({ alias }: { alias: string }): Promise<ManagedPrivateKey> {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).findOneBy({ alias })\n if (!key) throw Error('Key not found')\n if (this.secretBox && key.privateKeyHex) {\n key.privateKeyHex = await this.secretBox.decrypt(key.privateKeyHex)\n }\n return key as ManagedPrivateKey\n }\n\n async delete({ alias }: { alias: string }) {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).findOneBy({ alias })\n if (!key) throw Error(`not_found: Private Key data not found for alias=${alias}`)\n debug('Deleting private key data', alias)\n await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).remove(key)\n return true\n }\n\n async import(args: ImportablePrivateKey): Promise<ManagedPrivateKey> {\n const key = new PrivateKey()\n key.alias = args.alias || uuid4()\n key.privateKeyHex = args.privateKeyHex\n if (this.secretBox && key.privateKeyHex) {\n key.privateKeyHex = await this.secretBox.encrypt(key.privateKeyHex)\n }\n key.type = args.type\n debug('Saving private key data', args.alias)\n const keyRepo = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey)\n const existingKey = await keyRepo.findOneBy({ alias: key.alias })\n if (existingKey && existingKey.privateKeyHex !== key.privateKeyHex) {\n throw new Error(\n `key_already_exists: A key with this alias exists but with different data. Please use a different alias.`,\n )\n }\n await keyRepo.save(key)\n return key\n }\n\n async list(): Promise<Array<ManagedPrivateKey>> {\n const keys = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).find()\n return keys\n }\n}\n","import {\n IAgentPlugin,\n IDataStore,\n IDataStoreDeleteVerifiableCredentialArgs,\n IDataStoreGetMessageArgs,\n IDataStoreGetVerifiableCredentialArgs,\n IDataStoreGetVerifiablePresentationArgs,\n IDataStoreSaveMessageArgs,\n IDataStoreSaveVerifiableCredentialArgs,\n IDataStoreSaveVerifiablePresentationArgs,\n IMessage,\n schema,\n VerifiableCredential,\n VerifiablePresentation,\n} from '@veramo/core'\nimport { createMessage, createMessageEntity, Message } from './entities/message'\nimport { createCredentialEntity, Credential } from './entities/credential'\nimport { Claim } from './entities/claim'\nimport { createPresentationEntity, Presentation } from './entities/presentation'\nimport { DataSource } from 'typeorm'\nimport { getConnectedDb } from './utils'\nimport { OrPromise } from '@veramo/utils'\n\n/**\n * This class implements the {@link @veramo/core#IDataStore} interface using a TypeORM compatible database.\n *\n * This allows you to store and retrieve Verifiable Credentials, Presentations and Messages by their IDs.\n *\n * For more complex queries you should use {@link @veramo/data-store#DataStoreORM} which is the default way to query\n * the stored data by some common properties. These two classes MUST also share the same database connection.\n *\n * @see {@link @veramo/core#IDataStoreORM}\n * @see {@link @veramo/core#IDataStore}\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\nexport class DataStore implements IAgentPlugin {\n readonly methods: IDataStore\n readonly schema = schema.IDataStore\n private dbConnection: OrPromise<DataSource>\n\n constructor(dbConnection: OrPromise<DataSource>) {\n this.dbConnection = dbConnection\n\n this.methods = {\n dataStoreSaveMessage: this.dataStoreSaveMessage.bind(this),\n dataStoreGetMessage: this.dataStoreGetMessage.bind(this),\n dataStoreDeleteVerifiableCredential: this.dataStoreDeleteVerifiableCredential.bind(this),\n dataStoreSaveVerifiableCredential: this.dataStoreSaveVerifiableCredential.bind(this),\n dataStoreGetVerifiableCredential: this.dataStoreGetVerifiableCredential.bind(this),\n dataStoreSaveVerifiablePresentation: this.dataStoreSaveVerifiablePresentation.bind(this),\n dataStoreGetVerifiablePresentation: this.dataStoreGetVerifiablePresentation.bind(this),\n }\n }\n\n async dataStoreSaveMessage(args: IDataStoreSaveMessageArgs): Promise<string> {\n const message = await (await getConnectedDb(this.dbConnection))\n .getRepository(Message)\n .save(createMessageEntity(args.message))\n return message.id\n }\n\n async dataStoreGetMessage(args: IDataStoreGetMessageArgs): Promise<IMessage> {\n const messageEntity = await (await getConnectedDb(this.dbConnection)).getRepository(Message).findOne({\n where: { id: args.id },\n relations: ['credentials', 'presentations'],\n })\n if (!messageEntity) throw new Error('not_found: Message not found')\n\n return createMessage(messageEntity)\n }\n\n async dataStoreDeleteVerifiableCredential(\n args: IDataStoreDeleteVerifiableCredentialArgs,\n ): Promise<boolean> {\n const credentialEntity = await (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .findOneBy({ hash: args.hash })\n if (!credentialEntity) {\n return false\n }\n\n const claims = await (await getConnectedDb(this.dbConnection))\n .getRepository(Claim)\n .find({ where: { credential: { id: credentialEntity.id } } })\n\n await (await getConnectedDb(this.dbConnection)).getRepository(Claim).remove(claims)\n\n await (await getConnectedDb(this.dbConnection)).getRepository(Credential).remove(credentialEntity)\n\n return true\n }\n\n async dataStoreSaveVerifiableCredential(args: IDataStoreSaveVerifiableCredentialArgs): Promise<string> {\n const verifiableCredential = await (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .save(createCredentialEntity(args.verifiableCredential))\n return verifiableCredential.hash\n }\n\n async dataStoreGetVerifiableCredential(\n args: IDataStoreGetVerifiableCredentialArgs,\n ): Promise<VerifiableCredential> {\n const credentialEntity = await (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .findOneBy({ hash: args.hash })\n if (!credentialEntity) throw new Error('not_found: Verifiable credential not found')\n\n return credentialEntity.raw\n }\n\n async dataStoreSaveVerifiablePresentation(args: IDataStoreSaveVerifiablePresentationArgs): Promise<string> {\n const verifiablePresentation = await (await getConnectedDb(this.dbConnection))\n .getRepository(Presentation)\n .save(createPresentationEntity(args.verifiablePresentation))\n return verifiablePresentation.hash\n }\n\n async dataStoreGetVerifiablePresentation(\n args: IDataStoreGetVerifiablePresentationArgs,\n ): Promise<VerifiablePresentation> {\n const presentationEntity = await (await getConnectedDb(this.dbConnection))\n .getRepository(Presentation)\n .findOneBy({ hash: args.hash })\n if (!presentationEntity) throw new Error('not_found: Verifiable presentation not found')\n\n return presentationEntity.raw\n }\n}\n","import {\n AuthorizedDIDContext,\n FindArgs,\n IAgentPlugin,\n IDataStoreORM,\n IIdentifier,\n IMessage,\n PartialIdentifier,\n schema,\n TClaimsColumns,\n TCredentialColumns,\n TIdentifiersColumns,\n TMessageColumns,\n TPresentationColumns,\n UniqueVerifiableCredential,\n UniqueVerifiablePresentation,\n Where,\n} from '@veramo/core'\nimport { createMessage, Message } from './entities/message'\nimport { Claim } from './entities/claim'\nimport { Credential } from './entities/credential'\nimport { Presentation } from './entities/presentation'\nimport { Identifier } from './entities/identifier'\nimport {\n Any,\n Between,\n Brackets,\n DataSource,\n Equal,\n In,\n IsNull,\n LessThan,\n LessThanOrEqual,\n Like,\n MoreThan,\n MoreThanOrEqual,\n Not,\n SelectQueryBuilder,\n} from 'typeorm'\nimport { getConnectedDb } from \"./utils\";\nimport { OrPromise } from \"@veramo/utils\";\n\n/**\n * This class implements the {@link @veramo/core#IDataStoreORM} query interface using a TypeORM compatible database.\n *\n * This allows you to filter Verifiable Credentials, Presentations and Messages by some common properties that are\n * parsed and stored in database tables.\n *\n * This class is designed to work with {@link @veramo/data-store#DataStore} which is the default way to populate the\n * database with Credentials, Presentations and Messages in such a way that they can be queried by this class.\n * These two classes MUST also share the same database connection.\n *\n * @see {@link @veramo/core#IDataStoreORM}\n * @see {@link @veramo/core#IDataStore}\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\nexport class DataStoreORM implements IAgentPlugin {\n readonly methods: IDataStoreORM\n readonly schema = schema.IDataStoreORM\n private dbConnection: OrPromise<DataSource>\n\n constructor(dbConnection: OrPromise<DataSource>) {\n this.dbConnection = dbConnection\n\n this.methods = {\n dataStoreORMGetIdentifiers: this.dataStoreORMGetIdentifiers.bind(this),\n dataStoreORMGetIdentifiersCount: this.dataStoreORMGetIdentifiersCount.bind(this),\n dataStoreORMGetMessages: this.dataStoreORMGetMessages.bind(this),\n dataStoreORMGetMessagesCount: this.dataStoreORMGetMessagesCount.bind(this),\n dataStoreORMGetVerifiableCredentialsByClaims:\n this.dataStoreORMGetVerifiableCredentialsByClaims.bind(this),\n dataStoreORMGetVerifiableCredentialsByClaimsCount:\n this.dataStoreORMGetVerifiableCredentialsByClaimsCount.bind(this),\n dataStoreORMGetVerifiableCredentials: this.dataStoreORMGetVerifiableCredentials.bind(this),\n dataStoreORMGetVerifiableCredentialsCount: this.dataStoreORMGetVerifiableCredentialsCount.bind(this),\n dataStoreORMGetVerifiablePresentations: this.dataStoreORMGetVerifiablePresentations.bind(this),\n dataStoreORMGetVerifiablePresentationsCount:\n this.dataStoreORMGetVerifiablePresentationsCount.bind(this),\n }\n }\n\n // Identifiers\n\n private async identifiersQuery(\n args: FindArgs<TIdentifiersColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Identifier>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Identifier)\n .createQueryBuilder('identifier')\n .leftJoinAndSelect('identifier.keys', 'keys')\n .leftJoinAndSelect('identifier.services', 'services')\n .where(where)\n qb = decorateQB(qb, 'message', args)\n return qb\n }\n\n async dataStoreORMGetIdentifiers(\n args: FindArgs<TIdentifiersColumns>,\n context: AuthorizedDIDContext,\n ): Promise<PartialIdentifier[]> {\n const identifiers = await (await this.identifiersQuery(args, context)).getMany()\n return identifiers.map((i) => {\n const identifier: PartialIdentifier = i as PartialIdentifier\n if (identifier.controllerKeyId === null) {\n delete identifier.controllerKeyId\n }\n if (identifier.alias === null) {\n delete identifier.alias\n }\n if (identifier.provider === null) {\n delete identifier.provider\n }\n return identifier as IIdentifier\n })\n }\n\n async dataStoreORMGetIdentifiersCount(\n args: FindArgs<TIdentifiersColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return await (await this.identifiersQuery(args, context)).getCount()\n }\n\n // Messages\n\n private async messagesQuery(\n args: FindArgs<TMessageColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Message>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Message)\n .createQueryBuilder('message')\n .leftJoinAndSelect('message.from', 'from')\n .leftJoinAndSelect('message.to', 'to')\n .leftJoinAndSelect('message.credentials', 'credentials')\n .leftJoinAndSelect('message.presentations', 'presentations')\n .where(where)\n qb = decorateQB(qb, 'message', args)\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('message.to = :ident', { ident: context.authorizedDID }).orWhere('message.from = :ident', {\n ident: context.authorizedDID,\n })\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetMessages(\n args: FindArgs<TMessageColumns>,\n context: AuthorizedDIDContext,\n ): Promise<IMessage[]> {\n const messages = await (await this.messagesQuery(args, context)).getMany()\n return messages.map(createMessage)\n }\n\n async dataStoreORMGetMessagesCount(\n args: FindArgs<TMessageColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.messagesQuery(args, context)).getCount()\n }\n\n // Claims\n\n private async claimsQuery(\n args: FindArgs<TClaimsColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Claim>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Claim)\n .createQueryBuilder('claim')\n .leftJoinAndSelect('claim.issuer', 'issuer')\n .leftJoinAndSelect('claim.subject', 'subject')\n .where(where)\n qb = decorateQB(qb, 'claim', args)\n qb = qb.leftJoinAndSelect('claim.credential', 'credential')\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('claim.subject = :ident', { ident: context.authorizedDID }).orWhere(\n 'claim.issuer = :ident',\n {\n ident: context.authorizedDID,\n },\n )\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetVerifiableCredentialsByClaims(\n args: FindArgs<TClaimsColumns>,\n context: AuthorizedDIDContext,\n ): Promise<Array<UniqueVerifiableCredential>> {\n // FIXME this breaks if args has order param\n const claims = await (await this.claimsQuery(args, context)).getMany()\n return claims.map((claim) => ({\n hash: claim.credential.hash,\n verifiableCredential: claim.credential.raw,\n }))\n }\n\n async dataStoreORMGetVerifiableCredentialsByClaimsCount(\n args: FindArgs<TClaimsColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.claimsQuery(args, context)).getCount()\n }\n\n // Credentials\n\n private async credentialsQuery(\n args: FindArgs<TCredentialColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Credential>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .createQueryBuilder('credential')\n .leftJoinAndSelect('credential.issuer', 'issuer')\n .leftJoinAndSelect('credential.subject', 'subject')\n .where(where)\n qb = decorateQB(qb, 'credential', args)\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('credential.subject = :ident', { ident: context.authorizedDID }).orWhere(\n 'credential.issuer = :ident',\n {\n ident: context.authorizedDID,\n },\n )\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetVerifiableCredentials(\n args: FindArgs<TCredentialColumns>,\n context: AuthorizedDIDContext,\n ): Promise<Array<UniqueVerifiableCredential>> {\n const credentials = await (await this.credentialsQuery(args, context)).getMany()\n return credentials.map((vc) => ({\n hash: vc.hash,\n verifiableCredential: vc.raw,\n }))\n }\n\n async dataStoreORMGetVerifiableCredentialsCount(\n args: FindArgs<TCredentialColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.credentialsQuery(args, context)).getCount()\n }\n\n // Presentations\n\n private async presentationsQuery(\n args: FindArgs<TPresentationColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Presentation>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Presentation)\n .createQueryBuilder('presentation')\n .leftJoinAndSelect('presentation.holder', 'holder')\n .leftJoinAndSelect('presentation.verifier', 'verifier')\n .where(where)\n qb = decorateQB(qb, 'presentation', args)\n qb = addVerifierQuery(args, qb)\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('verifier.did = :ident', {\n ident: context.authorizedDID,\n }).orWhere('presentation.holder = :ident', { ident: context.authorizedDID })\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetVerifiablePresentations(\n args: FindArgs<TPresentationColumns>,\n context: AuthorizedDIDContext,\n ): Promise<Array<UniqueVerifiablePresentation>> {\n const presentations = await (await this.presentationsQuery(args, context)).getMany()\n return presentations.map((vp) => ({\n hash: vp.hash,\n verifiablePresentation: vp.raw,\n }))\n }\n\n async dataStoreORMGetVerifiablePresentationsCount(\n args: FindArgs<TPresentationColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.presentationsQuery(args, context)).getCount()\n }\n}\n\nfunction opToSQL(item: Where<any>): any[] {\n switch (item.op) {\n case 'IsNull':\n return ['IS NULL', '']\n case 'Like':\n if (item.value?.length != 1) throw Error('Operation Equal requires one value')\n return ['LIKE :value', item.value[0]]\n case 'Equal':\n if (item.value?.length != 1) throw Error('Operation Equal requires one value')\n return ['= :value', item.value[0]]\n case 'Any':\n case 'Between':\n case 'LessThan':\n case 'LessThanOrEqual':\n case 'MoreThan':\n case 'MoreThanOrEqual':\n throw new Error(`${item.op} not compatible with DID argument`)\n case 'In':\n default:\n return ['IN (:...value)', item.value]\n }\n}\n\nfunction addVerifierQuery(input: FindArgs<any>, qb: SelectQueryBuilder<any>): SelectQueryBuilder<any> {\n if (!input) {\n return qb\n }\n if (!Array.isArray(input.where)) {\n return qb\n }\n const verifierWhere = input.where.find((item) => item.column === 'verifier')\n if (!verifierWhere) {\n return qb\n }\n const [op, value] = opToSQL(verifierWhere)\n return qb.andWhere(`verifier.did ${op}`, { value })\n}\n\nfunction createWhereObject(\n input: FindArgs<TMessageColumns | TClaimsColumns | TCredentialColumns | TPresentationColumns | TIdentifiersColumns>,\n): any {\n const where: Record<string, any> = {}\n if (input?.where) {\n for (const item of input.where) {\n if (item.column === 'verifier') {\n continue\n }\n switch (item.op) {\n case 'Any':\n if (!Array.isArray(item.value)) throw Error('Operator Any requires value to be an array')\n where[item.column] = Any(item.value)\n break\n case 'Between':\n if (item.value?.length != 2) throw Error('Operation Between requires two values')\n where[item.column] = Between(item.value[0], item.value[1])\n break\n case 'Equal':\n if (item.value?.length != 1) throw Error('Operation Equal requires one value')\n where[item.column] = Equal(item.value[0])\n break\n case 'IsNull':\n where[item.column] = IsNull()\n break\n case 'LessThan':\n if (item.value?.length != 1) throw Error('Operation LessThan requires one value')\n where[item.column] = LessThan(item.value[0])\n break\n case 'LessThanOrEqual':\n if (item.value?.length != 1) throw Error('Operation LessThanOrEqual requires one value')\n where[item.column] = LessThanOrEqual(item.value[0])\n break\n case 'Like':\n if (item.value?.length != 1) throw Error('Operation Like requires one value')\n where[item.column] = Like(item.value[0])\n break\n case 'MoreThan':\n if (item.value?.length != 1) throw Error('Operation MoreThan requires one value')\n where[item.column] = MoreThan(item.value[0])\n break\n case 'MoreThanOrEqual':\n if (item.value?.length != 1) throw Error('Operation MoreThanOrEqual requires one value')\n where[item.column] = MoreThanOrEqual(item.value[0])\n break\n case 'In':\n default:\n if (!Array.isArray(item.value)) throw Error('Operator IN requires value to be an array')\n where[item.column] = In(item.value)\n }\n if (item.not === true) {\n where[item.column] = Not(where[item.column])\n }\n }\n }\n return where\n}\n\nfunction decorateQB(\n qb: SelectQueryBuilder<any>,\n tableName: string,\n input: FindArgs<any>,\n): SelectQueryBuilder<any> {\n if (input?.skip) qb = qb.skip(input.skip)\n if (input?.take) qb = qb.take(input.take)\n\n if (input?.order) {\n for (const item of input.order) {\n qb = qb.orderBy(\n qb.connection.driver.escape(tableName) + '.' + qb.connection.driver.escape(item.column),\n item.direction,\n )\n }\n }\n return qb\n}\n","import { IAgentContext, IDataStoreORM } from '@veramo/core'\nimport {\n AbstractDidDiscoveryProvider,\n IDIDDiscoverMatch,\n IDIDDiscoveryProviderResult,\n IDIDDiscoveryDiscoverDidArgs,\n} from '@veramo/did-discovery'\n\n/**\n * This implementation of {@link @veramo/did-discovery#AbstractDidDiscoveryProvider | AbstractDidDiscoveryProvider}\n * helps you discover DIDs based on data that is stored by a local plugin that implements\n * {@link @veramo/core#IDataStoreORM | IDataStoreORM}.\n *\n * DIDs can be discovered by partial matches of `name` from `Profile` credentials, by partial matches of `alias` of\n * managed DIDs as well as partial matches of DIDs that are issuer or subject of credentials.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\nexport class DataStoreDiscoveryProvider implements AbstractDidDiscoveryProvider {\n readonly name = 'data-store-discovery'\n\n async discoverDid(\n args: IDIDDiscoveryDiscoverDidArgs,\n context: IAgentContext<IDataStoreORM>,\n ): Promise<IDIDDiscoveryProviderResult> {\n const matches: IDIDDiscoverMatch[] = []\n\n const credentialsByName = await context.agent.dataStoreORMGetVerifiableCredentialsByClaims({\n where: [\n { column: 'type', value: ['name'] },\n { column: 'value', value: [`%${args.query}%`], op: 'Like' },\n { column: 'credentialType', value: ['VerifiableCredential,Profile'] },\n ],\n })\n\n credentialsByName.forEach((vc) => {\n matches.push({\n did: vc.verifiableCredential.credentialSubject.id as string,\n metaData: {\n verifiableCredential: vc.verifiableCredential,\n },\n })\n })\n\n const credentialsByDID = await context.agent.dataStoreORMGetVerifiableCredentialsByClaims({\n where: [\n { column: 'type', value: ['name'] },\n { column: 'subject', value: [`%${args.query}%`], op: 'Like' },\n { column: 'credentialType', value: ['VerifiableCredential,Profile'] },\n ],\n })\n\n credentialsByDID.forEach((vc) => {\n matches.push({\n did: vc.verifiableCredential.credentialSubject.id as string,\n metaData: {\n verifiableCredential: vc.verifiableCredential,\n },\n })\n })\n\n const identifiersByDID = await context.agent.dataStoreORMGetIdentifiers({\n where: [\n { column: 'did', value: [`%${args.query}%`], op: 'Like' }\n ]\n })\n\n identifiersByDID.forEach((identifier) => {\n matches.push({\n did: identifier.did as string,\n metaData: {\n alias: identifier.alias\n }\n })\n })\n\n const identifiersByAlias = await context.agent.dataStoreORMGetIdentifiers({\n where: [\n { column: 'alias', value: [`%${args.query}%`], op: 'Like' }\n ]\n })\n\n identifiersByAlias.forEach((identifier) => {\n matches.push({\n did: identifier.did as string,\n metaData: {\n alias: identifier.alias\n }\n })\n })\n\n return {\n provider: this.name,\n matches,\n }\n }\n}\n","import { Column, Entity, PrimaryColumn } from 'typeorm'\nimport { Key } from './key'\n\n/**\n * This represents the private key data of keys that were stored by {@link @veramo/data-store#KeyStore} before Veramo\n * 3.0. During database migration this key material is moved to a different table and accessible by\n * {@link @veramo/data-store#PrivateKeyStore}.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('key', )\nexport class PreMigrationKey extends Key {\n // Key contains all the other columns present needed for successful migrations\n\n @PrimaryColumn()\n //@ts-ignore\n kid: string\n\n @Column({ nullable: true })\n privateKeyHex?: string\n}\n","import { QueryRunner, Table } from 'typeorm'\n\n/**\n * Get an existing table by name. Checks against givenTableName first, and tableName next. Throws an error if not found\n *\n * @param queryRunner The query runner object to use for querying\n * @param givenName The given name of the table to search for\n *\n * @public\n */\nexport function migrationGetExistingTableByName(queryRunner: QueryRunner, givenName: string, strictClassName?: boolean): Table {\n const table = migrationGetTableByNameImpl(queryRunner, givenName, strictClassName)\n if (!table) {\n throw Error(`Could not find table with name ${givenName}`)\n }\n return table\n}\n\n/**\n * Get an existing table by name. Checks against givenTableName first, and tableName next. Returns undefined if not found\n *\n * @param queryRunner The query runner object to use for querying\n * @param givenName The given name of the table to search for\n *\n * @private\n */\nfunction migrationGetTableByNameImpl(queryRunner: QueryRunner, givenName: string, strictClassName?: boolean): Table | undefined {\n let entityMetadata = queryRunner.connection.entityMetadatas.find((meta) => !!strictClassName ? meta.name === givenName : meta.givenTableName === givenName)\n if (!entityMetadata && !strictClassName) {\n // We are doing this separately as we don't want the above filter to use an or expression potentially matching first on tableName instead of givenTableName\n entityMetadata = queryRunner.connection.entityMetadatas.find((meta) => meta.tableName === givenName)\n }\n\n return entityMetadata ? Table.create(entityMetadata, queryRunner.connection.driver) : undefined\n}\n\n/**\n * Get a table name. Checks against givenTableName first, and tableName next from existing tables. Then returns the name. If not found returns the givenName argument\n *\n * @param queryRunner The query runner object to use for querying\n * @param givenName The given name of the table to search for\n *\n * @public\n */\nexport function migrationGetTableName(queryRunner: QueryRunner, givenName: string, strictClassName?: boolean): string {\n const table = migrationGetTableByNameImpl(queryRunner, givenName, strictClassName)\n return !!table ? table.name : givenName\n}\n","import { MigrationInterface, QueryRunner, Table } from 'typeorm'\nimport Debug from 'debug'\nimport { migrationGetTableName } from './migration-functions.js'\n\nconst debug = Debug('veramo:data-store:initial-migration')\n\n/**\n * Create the database layout for Veramo 3.0\n *\n * @public\n */\nexport class CreateDatabase1447159020001 implements MigrationInterface {\n\n name = 'CreateDatabase1447159020001' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n const dateTimeType: string = queryRunner.connection.driver.mappedDataTypes.createDate as string\n\n debug(`creating identifier table`)\n // \"CREATE TABLE \\\"identifier\\\" (\\\"did\\\" varchar PRIMARY KEY NOT NULL, \\\"provider\\\" varchar, \\\"alias\\\" varchar, \\\"saveDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"updateDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"controllerKeyId\\\" varchar)\",\n // \"CREATE UNIQUE INDEX \\\"IDX_6098cca69c838d91e55ef32fe1\\\" ON \\\"identifier\\\" (\\\"alias\\\", \\\"provider\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner,'identifier'),\n columns: [\n { name: 'did', type: 'varchar', isPrimary: true },\n { name: 'provider', type: 'varchar', isNullable: true },\n { name: 'alias', type: 'varchar', isNullable: true },\n { name: 'saveDate', type: dateTimeType },\n { name: 'updateDate', type: dateTimeType },\n { name: 'controllerKeyId', type: 'varchar', isNullable: true },\n ],\n indices: [\n {\n columnNames: ['alias', 'provider'],\n isUnique: true,\n },\n ],\n }),\n true,\n )\n\n debug(`creating key table`)\n // \"CREATE TABLE \\\"key\\\" (\\\"kid\\\" varchar PRIMARY KEY NOT NULL, \\\"kms\\\" varchar NOT NULL, \\\"type\\\" varchar NOT NULL, \\\"publicKeyHex\\\" varchar NOT NULL, \\\"privateKeyHex\\\" varchar NOT NULL, \\\"meta\\\" text, \\\"identifierDid\\\" varchar, CONSTRAINT \\\"FK_3f40a9459b53adf1729dbd3b787\\\" FOREIGN KEY (\\\"identifierDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner,'key'),\n columns: [\n { name: 'kid', type: 'varchar', isPrimary: true },\n { name: 'kms', type: 'varchar' },\n { name: 'type', type: 'varchar' },\n { name: 'publicKeyHex', type: 'varchar' },\n { name: 'privateKeyHex', type: 'varchar', isNullable: true },\n { name: 'meta', type: 'text', isNullable: true },\n { name: 'identifierDid', type: 'varchar' },\n ],\n foreignKeys: [\n {\n columnNames: ['identifierDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n ],\n }),\n true,\n )\n\n debug(`creating service table`)\n // \"CREATE TABLE \\\"service\\\" (\\\"id\\\" varchar PRIMARY KEY NOT NULL, \\\"type\\\" varchar NOT NULL, \\\"serviceEndpoint\\\" varchar NOT NULL, \\\"description\\\" varchar, \\\"identifierDid\\\" varchar, CONSTRAINT \\\"FK_e16e0280d906951809f95dd09f1\\\" FOREIGN KEY (\\\"identifierDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'service'),\n columns: [\n { name: 'id', type: 'varchar', isPrimary: true },\n { name: 'type', type: 'varchar' },\n { name: 'serviceEndpoint', type: 'varchar' },\n { name: 'description', type: 'varchar', isNullable: true },\n { name: 'identifierDid', type: 'varchar' },\n ],\n foreignKeys: [\n {\n columnNames: ['identifierDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating credentials table`)\n // \"CREATE TABLE \\\"credential\\\" (\\\"hash\\\" varchar PRIMARY KEY NOT NULL, \\\"raw\\\" text NOT NULL, \\\"id\\\" varchar, \\\"issuanceDate\\\" datetime NOT NULL, \\\"expirationDate\\\" datetime, \\\"context\\\" text NOT NULL, \\\"type\\\" text NOT NULL, \\\"issuerDid\\\" varchar, \\\"subjectDid\\\" varchar, CONSTRAINT \\\"FK_123d0977e0976565ee0932c0b9e\\\" FOREIGN KEY (\\\"issuerDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_b790831f44e2fa7f9661a017b0a\\\" FOREIGN KEY (\\\"subjectDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'credential'),\n columns: [\n { name: 'hash', type: 'varchar', isPrimary: true },\n { name: 'raw', type: 'text' },\n { name: 'id', type: 'varchar', isNullable: true },\n { name: 'issuanceDate', type: dateTimeType },\n { name: 'expirationDate', type: dateTimeType, isNullable: true },\n { name: 'context', type: 'text' },\n { name: 'type', type: 'text' },\n { name: 'issuerDid', type: 'varchar' },\n { name: 'subjectDid', type: 'varchar', isNullable: true },\n ],\n foreignKeys: [\n {\n columnNames: ['issuerDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['subjectDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n ],\n }),\n true,\n )\n\n debug(`creating claims table`)\n // \"CREATE TABLE \\\"claim\\\" (\\\"hash\\\" varchar PRIMARY KEY NOT NULL, \\\"issuanceDate\\\" datetime NOT NULL, \\\"expirationDate\\\" datetime, \\\"context\\\" text NOT NULL, \\\"credentialType\\\" text NOT NULL, \\\"type\\\" varchar NOT NULL, \\\"value\\\" text, \\\"isObj\\\" boolean NOT NULL, \\\"issuerDid\\\" varchar, \\\"subjectDid\\\" varchar, \\\"credentialHash\\\" varchar, CONSTRAINT \\\"FK_d972c73d0f875c0d14c35b33baa\\\" FOREIGN KEY (\\\"issuerDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_f411679379d373424100a1c73f4\\\" FOREIGN KEY (\\\"subjectDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_3d494b79143de3d0e793883e351\\\" FOREIGN KEY (\\\"credentialHash\\\") REFERENCES \\\"credential\\\" (\\\"hash\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'claim'),\n columns: [\n { name: 'hash', type: 'varchar', isPrimary: true },\n { name: 'issuanceDate', type: dateTimeType },\n { name: 'expirationDate', type: dateTimeType, isNullable: true },\n { name: 'context', type: 'text' },\n { name: 'credentialType', type: 'text' },\n { name: 'value', type: 'text' },\n { name: 'type', type: 'varchar' },\n { name: 'isObj', type: 'boolean' },\n { name: 'issuerDid', type: 'varchar', isNullable: true },\n { name: 'subjectDid', type: 'varchar', isNullable: true },\n { name: 'credentialHash', type: 'varchar' },\n ],\n foreignKeys: [\n {\n columnNames: ['issuerDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['subjectDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n {\n columnNames: ['credentialHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'credential'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating presentations table`)\n // \"CREATE TABLE \\\"presentation\\\" (\\\"hash\\\" varchar PRIMARY KEY NOT NULL, \\\"raw\\\" text NOT NULL, \\\"id\\\" varchar, \\\"issuanceDate\\\" datetime NOT NULL, \\\"expirationDate\\\" datetime, \\\"context\\\" text NOT NULL, \\\"type\\\" text NOT NULL, \\\"holderDid\\\" varchar, CONSTRAINT \\\"FK_a5e418449d9f527776a3bd0ca61\\\" FOREIGN KEY (\\\"holderDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'presentation'),\n columns: [\n { name: 'hash', type: 'varchar', isPrimary: true },\n { name: 'raw', type: 'text' },\n { name: 'id', type: 'varchar', isNullable: true },\n { name: 'issuanceDate', type: dateTimeType },\n { name: 'expirationDate', type: dateTimeType, isNullable: true },\n { name: 'context', type: 'text' },\n { name: 'type', type: 'text' },\n { name: 'holderDid', type: 'varchar', isNullable: true },\n ],\n foreignKeys: [\n {\n columnNames: ['holderDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating message table`)\n // \"CREATE TABLE \\\"message\\\" (\\\"id\\\" varchar PRIMARY KEY NOT NULL, \\\"saveDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"updateDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"createdAt\\\" datetime, \\\"expiresAt\\\" datetime, \\\"threadId\\\" varchar, \\\"type\\\" varchar NOT NULL, \\\"raw\\\" varchar, \\\"data\\\" text, \\\"replyTo\\\" text, \\\"replyUrl\\\" varchar, \\\"metaData\\\" text, \\\"fromDid\\\" varchar, \\\"toDid\\\" varchar, CONSTRAINT \\\"FK_63bf73143b285c727bd046e6710\\\" FOREIGN KEY (\\\"fromDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_1a666b2c29bb2b68d91259f55df\\\" FOREIGN KEY (\\\"toDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'message'),\n columns: [\n { name: 'id', type: 'varchar', isPrimary: true },\n { name: 'saveDate', type: dateTimeType },\n { name: 'updateDate', type: dateTimeType },\n { name: 'createdAt', type: dateTimeType, isNullable: true },\n { name: 'expiresAt', type: dateTimeType, isNullable: true },\n { name: 'threadId', type: 'varchar', isNullable: true },\n { name: 'type', type: 'varchar', isNullable: true },\n { name: 'raw', type: 'varchar', isNullable: true },\n { name: 'data', type: 'text', isNullable: true },\n { name: 'replyTo', type: 'text', isNullable: true },\n { name: 'replyUrl', type: 'varchar', isNullable: true },\n { name: 'metaData', type: 'text', isNullable: true },\n { name: 'fromDid', type: 'varchar', isNullable: true },\n { name: 'toDid', type: 'varchar', isNullable: true },\n ],\n foreignKeys: [\n {\n columnNames: ['fromDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n {\n columnNames: ['toDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n ],\n }),\n true,\n )\n\n debug(`creating presentation_verifier_identifier many to many table`)\n // \"CREATE TABLE \\\"presentation_verifier_identifier\\\" (\\\"presentationHash\\\" varchar NOT NULL, \\\"identifierDid\\\" varchar NOT NULL, CONSTRAINT \\\"FK_05b1eda0f6f5400cb173ebbc086\\\" FOREIGN KEY (\\\"presentationHash\\\") REFERENCES \\\"presentation\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_3a460e48557bad5564504ddad90\\\" FOREIGN KEY (\\\"identifierDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"presentationHash\\\", \\\"identifierDid\\\"))\",\n // \"CREATE INDEX \\\"IDX_05b1eda0f6f5400cb173ebbc08\\\" ON \\\"presentation_verifier_identifier\\\" (\\\"presentationHash\\\")\",\n // \"CREATE INDEX \\\"IDX_3a460e48557bad5564504ddad9\\\" ON \\\"presentation_verifier_identifier\\\" (\\\"identifierDid\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'presentation_verifier_identifier'),\n columns: [\n { name: 'presentationHash', type: 'varchar', isPrimary: true },\n { name: 'identifierDid', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['presentationHash', 'identifierDid'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['presentationHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'presentation'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['identifierDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating presentation_credentials_credential many to many table`)\n // \"CREATE TABLE \\\"presentation_credentials_credential\\\" (\\\"presentationHash\\\" varchar NOT NULL, \\\"credentialHash\\\" varchar NOT NULL, CONSTRAINT \\\"FK_d796bcde5e182136266b2a6b72c\\\" FOREIGN KEY (\\\"presentationHash\\\") REFERENCES \\\"presentation\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_ef88f92988763fee884c37db63b\\\" FOREIGN KEY (\\\"credentialHash\\\") REFERENCES \\\"credential\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"presentationHash\\\", \\\"credentialHash\\\"))\",\n // \"CREATE INDEX \\\"IDX_d796bcde5e182136266b2a6b72\\\" ON \\\"presentation_credentials_credential\\\" (\\\"presentationHash\\\")\",\n // \"CREATE INDEX \\\"IDX_ef88f92988763fee884c37db63\\\" ON \\\"presentation_credentials_credential\\\" (\\\"credentialHash\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'presentation_credentials_credential'),\n columns: [\n { name: 'presentationHash', type: 'varchar', isPrimary: true },\n { name: 'credentialHash', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['presentationHash', 'credentialHash'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['presentationHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'presentation'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['credentialHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'credential'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating message_presentations_presentation many to many table`)\n // \"CREATE TABLE \\\"message_presentations_presentation\\\" (\\\"messageId\\\" varchar NOT NULL, \\\"presentationHash\\\" varchar NOT NULL, CONSTRAINT \\\"FK_7e7094f2cd6e5ec93914ac5138f\\\" FOREIGN KEY (\\\"messageId\\\") REFERENCES \\\"message\\\" (\\\"id\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_a13b5cf828c669e61faf489c182\\\" FOREIGN KEY (\\\"presentationHash\\\") REFERENCES \\\"presentation\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"messageId\\\", \\\"presentationHash\\\"))\",\n // \"CREATE INDEX \\\"IDX_7e7094f2cd6e5ec93914ac5138\\\" ON \\\"message_presentations_presentation\\\" (\\\"messageId\\\")\",\n // \"CREATE INDEX \\\"IDX_a13b5cf828c669e61faf489c18\\\" ON \\\"message_presentations_presentation\\\" (\\\"presentationHash\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'message_presentations_presentation'),\n columns: [\n { name: 'messageId', type: 'varchar', isPrimary: true },\n { name: 'presentationHash', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['messageId', 'presentationHash'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['messageId'],\n referencedColumnNames: ['id'],\n referencedTableName: migrationGetTableName(queryRunner, 'message'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['presentationHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'presentation'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating message_credentials_credential many to many table`)\n // \"CREATE TABLE \\\"message_credentials_credential\\\" (\\\"messageId\\\" varchar NOT NULL, \\\"credentialHash\\\" varchar NOT NULL, CONSTRAINT \\\"FK_1c111357e73db91a08525914b59\\\" FOREIGN KEY (\\\"messageId\\\") REFERENCES \\\"message\\\" (\\\"id\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_8ae8195a94b667b185d2c023e33\\\" FOREIGN KEY (\\\"credentialHash\\\") REFERENCES \\\"credential\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"messageId\\\", \\\"credentialHash\\\"))\",\n // \"CREATE INDEX \\\"IDX_1c111357e73db91a08525914b5\\\" ON \\\"message_credentials_credential\\\" (\\\"messageId\\\")\",\n // \"CREATE INDEX \\\"IDX_8ae8195a94b667b185d2c023e3\\\" ON \\\"message_credentials_credential\\\" (\\\"credentialHash\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'message_credentials_credential'),\n columns: [\n { name: 'messageId', type: 'varchar', isPrimary: true },\n { name: 'credentialHash', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['messageId', 'credentialHash'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['messageId'],\n referencedColumnNames: ['id'],\n referencedTableName: migrationGetTableName(queryRunner, 'message'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['credentialHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'credential'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n throw new Error('illegal_operation: cannot roll back initial migration')\n }\n}\n","import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'\nimport { migrationGetExistingTableByName } from './migration-functions'\nimport { PreMigrationKey } from '../entities/PreMigrationEntities'\n\n/**\n * Fix inconsistencies between Entity data and column data.\n *\n * @public\n */\nexport class SimplifyRelations1447159020002 implements MigrationInterface {\n\n name = 'SimplifyRelations1447159020002' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.changeColumn(\n migrationGetExistingTableByName(queryRunner, 'PreMigrationKey', true),\n 'identifierDid',\n new TableColumn({ name: 'identifierDid', type: 'varchar', isNullable: true }),\n )\n await queryRunner.changeColumn(\n migrationGetExistingTableByName(queryRunner, 'service'),\n 'identifierDid',\n new TableColumn({ name: 'identifierDid', type: 'varchar', isNullable: true }),\n )\n\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n throw new Error('illegal_operation: cannot roll back initial migration')\n }\n}\n","import { MigrationInterface, QueryRunner, Table, TableColumn } from 'typeorm'\nimport { PrivateKey } from '..'\nimport { PreMigrationKey } from '../entities/PreMigrationEntities'\nimport Debug from 'debug'\nimport { migrationGetExistingTableByName, migrationGetTableName } from './migration-functions'\n\nconst debug = Debug('veramo:data-store:migrate-private-keys')\n\n/**\n * Migration of existing private keys from Veramo 2.x to Veramo 3.x\n *\n * @public\n */\nexport class CreatePrivateKeyStorage1629293428674 implements MigrationInterface {\n\n name = 'CreatePrivateKeyStorage1629293428674' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n // 1.create new table\n debug(`creating new private-key table`)\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'private-key'),\n columns: [\n {\n name: 'alias',\n type: 'varchar',\n isPrimary: true,\n },\n {\n name: 'type',\n type: 'varchar',\n },\n {\n name: 'privateKeyHex',\n type: 'varchar',\n },\n ],\n }),\n true,\n )\n // 2. copy key data\n const keys: PreMigrationKey[] = await queryRunner.manager.find(PreMigrationKey)\n debug(`got ${keys.length} potential keys to migrate`)\n const privKeys = keys\n .filter((key) => typeof key.privateKeyHex !== 'undefined' && key.privateKeyHex !== null)\n .map((key) => ({\n alias: key.kid,\n type: key.type,\n privateKeyHex: key.privateKeyHex,\n }))\n debug(`${privKeys.length} keys need to be migrated`)\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(migrationGetTableName(queryRunner, 'private-key'))\n .values(privKeys)\n .execute()\n // 3. drop old column\n debug(`dropping privKeyHex column from old key table`)\n await queryRunner.dropColumn(migrationGetExistingTableByName(queryRunner, 'PreMigrationKey', true), 'privateKeyHex')\n //4. done\n debug(`migrated ${privKeys.length} keys to private key storage`)\n\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n\n // 1. add old column back\n debug(`adding back privateKeyHex column to key table`)\n await queryRunner.addColumn(\n 'key',\n new TableColumn({\n name: 'privateKeyHex',\n type: 'varchar',\n isNullable: true,\n }),\n )\n // 2. copy key data\n debug(`checking keys to be rolled back`)\n const keys: PrivateKey[] = await queryRunner.manager.find(PrivateKey)\n debug(`copying ${keys.length} keys`)\n for (const key of keys) {\n await queryRunner.manager\n .createQueryBuilder()\n .update(PreMigrationKey)\n .set({ privateKeyHex: key.privateKeyHex })\n .where('kid = :alias', { alias: key.alias })\n .execute()\n }\n debug(`dropping private-key table`)\n // 3. drop the new private key table\n await queryRunner.dropTable(migrationGetExistingTableByName(queryRunner, 'private-key'))\n // 4. done\n debug(`rolled back ${keys.length} keys`)\n }\n}\n","import { MigrationInterface, QueryRunner } from 'typeorm'\nimport { Presentation } from '..'\nimport Debug from 'debug'\nimport { migrationGetExistingTableByName } from './migration-functions.js'\n\nconst debug = Debug('veramo:data-store:migrate-presentation-issuance-date')\n\n/**\n * Reduce issuanceDate constraint of Presentations.\n *\n * @public\n */\nexport class AllowNullIssuanceDateForPresentations1637237492913 implements MigrationInterface {\n\n name = 'AllowNullIssuanceDateForPresentations1637237492913' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning off foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=off')\n await queryRunner.startTransaction()\n }\n\n // update issuanceDate column\n const table = migrationGetExistingTableByName(queryRunner, 'presentation')\n const oldColumn = table?.findColumnByName('issuanceDate')!\n const newColumn = oldColumn.clone()\n newColumn.isNullable = true\n debug(`updating issuanceDate for presentations to allow null`)\n await queryRunner.changeColumn(table!, oldColumn, newColumn)\n debug(`updated issuanceDate for presentations to allow null`)\n\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning on foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=on')\n await queryRunner.startTransaction()\n }\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning off foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=off')\n await queryRunner.startTransaction()\n }\n\n const table = migrationGetExistingTableByName(queryRunner, 'presentation')\n debug(`DOWN update NULL 'issuanceDate' with FAKE data for '${table.name}' table`)\n await queryRunner.manager\n .createQueryBuilder()\n .update(Presentation)\n .set({ issuanceDate: new Date(0) })\n .where('issuanceDate is NULL')\n .execute()\n // update issuanceDate column\n\n const oldColumn = table?.findColumnByName('issuanceDate')!\n const newColumn = oldColumn.clone()\n newColumn.isNullable = false\n debug(`updating issuanceDate for presentations to NOT allow null`)\n await queryRunner.changeColumn(table!, oldColumn, newColumn)\n debug(`updated issuanceDate for presentations to NOT allow null`)\n\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning on foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=on')\n await queryRunner.startTransaction()\n }\n\n debug(`DOWN updated issuanceDate for presentations to NOT allow null`)\n }\n}\n","import { CreateDatabase1447159020001 } from './1.createDatabase'\nimport { SimplifyRelations1447159020002 } from './2.simplifyRelations'\nimport { CreatePrivateKeyStorage1629293428674 } from './3.createPrivateKeyStorage'\nimport { AllowNullIssuanceDateForPresentations1637237492913 } from './4.allowNullVPIssuanceDate'\n\n\n/**\n * Allow others to use shared migration functions if they extend Veramo\n *\n * @public\n */\nexport * from './migration-functions.js'\n\n/**\n * The migrations array that SHOULD be used when initializing a TypeORM database connection.\n *\n * These ensure the correct creation of tables and the proper migrations of data when tables change between versions.\n *\n * @public\n */\n\nexport const migrations = [\n CreateDatabase1447159020001,\n SimplifyRelations1447159020002,\n CreatePrivateKeyStorage1629293428674,\n AllowNullIssuanceDateForPresentations1637237492913,\n]\n","/**\n * {@link https://typeorm.io/ | TypeORM } backed plugins. {@link @veramo/core#Agent}\n * {@link @veramo/data-store#DataStore | plugin} that implements {@link @veramo/core#IDataStore } interface.\n * {@link @veramo/core#Agent} {@link @veramo/data-store#DataStoreORM | plugin} that implements\n * {@link @veramo/core#IDataStoreORM} interface. Provides {@link @veramo/data-store#KeyStore} for\n * {@link @veramo/key-manager#KeyManager} and {@link @veramo/data-store#DIDStore} for\n * {@link @veramo/did-manager#DIDManager}\n *\n * @packageDocumentation\n */\n\nexport { DIDStore } from './identifier/did-store'\nexport { KeyStore } from './identifier/key-store'\nexport { PrivateKeyStore } from './identifier/private-key-store'\nexport { DataStore } from './data-store'\nexport { DataStoreORM } from './data-store-orm'\nexport { DataStoreDiscoveryProvider } from './did-discovery-provider'\nimport { Key, KeyType } from './entities/key'\nimport { Identifier } from './entities/identifier'\nimport { Claim } from './entities/claim'\nimport { Credential } from './entities/credential'\nimport { Presentation } from './entities/presentation'\nimport { Service } from './entities/service'\nimport { Message, MetaData } from './entities/message'\nimport { PrivateKey } from './entities/private-key'\nimport { PreMigrationKey } from './entities/PreMigrationEntities'\n\n/**\n * The TypeORM entities used by this package.\n *\n * This array SHOULD be used when creating a TypeORM connection.\n *\n * @public\n */\nexport const Entities = [\n Key,\n Identifier,\n Message,\n Claim,\n Credential,\n Presentation,\n Service,\n PrivateKey,\n PreMigrationKey,\n]\nexport {\n KeyType,\n Key,\n Identifier,\n Message,\n Claim,\n Credential,\n Presentation,\n MetaData,\n Service,\n PrivateKey,\n PreMigrationKey,\n}\nexport { migrations } from './migrations'\n\n// re-export the interfaces that were moved to core for backward compatibility\nexport { IDataStore, IDataStoreORM } from '@veramo/core'\n","{\n \"IWellKnownDidIssuer\": {\n \"components\": {\n \"schemas\": {\n \"IIssueDidConfigurationResourceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuances\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"additionalProperties\": true\n }\n }\n },\n \"credentialIssuance\": {\n \"type\": \"string\"\n },\n \"save\": {\n \"type\": \"boolean\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"issuances\", \"credentialIssuance\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.addLinkedDomainsService } \"\n },\n \"IIssueDomainLinkageCredentialArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"did\": {\n \"type\": \"string\"\n },\n \"origin\": {\n \"type\": \"string\"\n },\n \"serviceId\": {\n \"type\": \"string\"\n },\n \"issuanceDate\": {\n \"type\": \"date\"\n },\n \"expirationDate\": {\n \"type\": \"date\"\n },\n \"save\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"type\": \"object\",\n \"properties\": {\n \"additionalProperties\": true\n }\n },\n \"credentialIssuance\": {\n \"type\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"did\", \"origin\", \"expirationDate\", \"options\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.issueDomainLinkageCredential } \"\n },\n \"IGetDidConfigurationResourceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"origin\": {\n \"type\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"origin\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.getDidConfigurationResource } \"\n },\n \"IAddLinkedDomainsServiceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"did\": {\n \"type\": \"string\"\n },\n \"origin\": {\n \"type\": \"string\"\n },\n \"serviceId\": {\n \"type\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"did\", \"origin\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.addLinkedDomainsService } \"\n },\n \"ISaveDidConfigurationResourceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"origin\": {\n \"type\": \"string\"\n },\n \"didConfigurationResource\": {\n \"type\": \"object\",\n \"properties\": {\n \"additionalProperties\": true\n }\n },\n \"additionalProperties\": false\n },\n \"required\": [\"did\", \"origin\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.saveDidConfigurationResource } \"\n },\n \"IRemoveCredentialIssuanceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"origin\": {\n \"callbackName\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"callbackName\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.removeCredentialIssuance } \"\n }\n },\n \"methods\": {\n \"addLinkedDomainsService\": {\n \"description\": \"Adds a LinkedDomains service to the DID\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IAddLinkedDomainsServiceArgs\"\n }\n },\n \"getDidConfigurationResource\": {\n \"description\": \"Retrieves a DID configuration resource from the database\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IGetDidConfigurationResourceArgs\"\n },\n \"returnType\": \"object\"\n },\n \"issueDidConfigurationResource\": {\n \"description\": \"Issues a DID configuration resource\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IAddLinkedDomainsServiceArgs\"\n },\n \"returnType\": \"object\"\n },\n \"issueDomainLinkageCredential\": {\n \"description\": \"Retrieves a domain linkage credential\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IIssueDomainLinkageCredentialArgs\"\n },\n \"returnType\": \"object\"\n },\n \"removeCredentialIssuance\": {\n \"description\": \"Removes a registered callback\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IRemoveCredentialIssuanceArgs\"\n },\n \"returnType\": \"boolean\"\n },\n \"saveDidConfigurationResource\": {\n \"description\": \"Saves a DID configuration resource to the database\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/ISaveDidConfigurationResourceArgs\"\n }\n }\n }\n }\n }\n}\n","import { DidConfigurationResourceEntity } from './entities/DidConfigurationResourceEntity'\n\n/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { DidConfigurationResourceEntity } from './entities/DidConfigurationResourceEntity'\nexport { WellKnownDidIssuer } from './agent/WellKnownDidIssuer'\nexport * from './types/IWellKnownDidIssuer'\nexport const WellknownDidIssuerEntities = [DidConfigurationResourceEntity]\nexport { WellknownDidIssuerMigrations } from './migrations'\n","import { DomainLinkageCredential, IDidConfigurationResource, ISignedDomainLinkageCredential } from '@sphereon/wellknown-dids-client'\nimport { VerifiableCredential } from '@veramo/core'\nimport { Credential, Identifier, Claim } from '@veramo/data-store'\nimport { asArray, computeEntryHash, extractIssuer } from '@veramo/utils'\nimport { Entity, Column, PrimaryColumn, CreateDateColumn, UpdateDateColumn, ManyToMany, JoinTable, BaseEntity } from 'typeorm'\n\n@Entity('DidConfigurationResource')\nexport class DidConfigurationResourceEntity extends BaseEntity {\n @PrimaryColumn({ nullable: false })\n origin!: string\n\n @Column({ nullable: false })\n context!: string\n\n // TODO cascade of delete should be true when the VC is only attached to one DID configuration resource\n @ManyToMany(() => Credential, (credential: Credential) => credential.hash, { nullable: false, cascade: true, onDelete: 'NO ACTION' })\n @JoinTable({ name: 'DidConfigurationResourceCredentials' })\n linkedDids!: Array<Credential>\n\n @CreateDateColumn({ name: 'created_at', nullable: false })\n createdAt!: Date\n\n @UpdateDateColumn({ name: 'last_updated_at', nullable: false })\n lastUpdatedAt!: Date\n}\n\nexport const didConfigurationResourceFrom = (didConfigurationResource: DidConfigurationResourceEntity): IDidConfigurationResource => {\n return {\n '@context': didConfigurationResource.context,\n linked_dids: linkedDidsFrom(didConfigurationResource.linkedDids),\n }\n}\n\nconst linkedDidsFrom = (credentials: Array<Credential>): Array<DomainLinkageCredential> => {\n return credentials.map((credential: Credential) =>\n credential?.raw?.proof?.type === 'JwtProof2020' && typeof credential?.raw?.proof?.jwt === 'string'\n ? credential.raw.proof.jwt\n : (credential.raw as ISignedDomainLinkageCredential),\n )\n}\n\nexport const createCredentialEntity = (vci: VerifiableCredential): Credential => {\n const vc = vci\n const credential = new Credential()\n credential.context = asArray(vc['@context'])\n credential.type = asArray(vc.type || [])\n credential.id = vc.id\n\n if (vc.issuanceDate) {\n credential.issuanceDate = new Date(vc.issuanceDate)\n }\n\n if (vc.expirationDate) {\n credential.expirationDate = new Date(vc.expirationDate)\n }\n\n const issuer = new Identifier()\n issuer.did = extractIssuer(vc)\n credential.issuer = issuer\n\n if (vc.credentialSubject.id) {\n const subject = new Identifier()\n subject.did = vc.credentialSubject.id\n credential.subject = subject\n }\n credential.claims = []\n for (const type in vc.credentialSubject) {\n if (vc.credentialSubject.hasOwnProperty(type)) {\n const value = vc.credentialSubject[type]\n\n if (type !== 'id') {\n const isObj = typeof value === 'function' || (typeof value === 'object' && !!value)\n const claim = new Claim()\n claim.hash = computeEntryHash(JSON.stringify(vc) + type)\n claim.type = type\n claim.value = isObj ? JSON.stringify(value) : value\n claim.isObj = isObj\n claim.issuer = credential.issuer\n claim.subject = credential.subject\n claim.expirationDate = credential.expirationDate\n claim.issuanceDate = credential.issuanceDate\n claim.credentialType = credential.type\n claim.context = credential.context\n credential.claims.push(claim)\n }\n }\n }\n\n credential.raw = vci\n return credential\n}\n","import { CredentialCorrelationType, CredentialRole, DigitalCredential } from '@sphereon/ssi-sdk.credential-store'\nimport { CredentialMapper, parseDid } from '@sphereon/ssi-types'\nimport {\n DomainLinkageCredential,\n IDidConfigurationResource,\n IssuanceCallback,\n ServiceTypesEnum,\n WellKnownDidIssuer as Issuer,\n} from '@sphereon/wellknown-dids-client'\nimport { IAgentPlugin, IIdentifier, VerifiableCredential } from '@veramo/core'\nimport { OrPromise } from '@veramo/utils'\n// @ts-ignore\nimport { normalizeCredential } from 'did-jwt-vc'\n// @ts-ignore\nimport { Service } from 'did-resolver/lib/resolver'\nimport { Connection } from 'typeorm'\nimport { v4 as uuidv4 } from 'uuid'\nimport { createCredentialEntity, DidConfigurationResourceEntity, didConfigurationResourceFrom } from '../entities/DidConfigurationResourceEntity'\nimport { schema } from '../index'\nimport {\n IAddLinkedDomainsServiceArgs,\n IGetDidConfigurationResourceArgs,\n IIssueDidConfigurationResourceArgs,\n IIssueDomainLinkageCredentialArgs,\n IRegisterIssueCredentialArgs,\n IRemoveCredentialIssuanceArgs,\n ISaveDidConfigurationResourceArgs,\n IWellKnownDidIssuer,\n IWellKnownDidIssuerOptionsArgs,\n RequiredContext,\n} from '../types/IWellKnownDidIssuer'\nimport { RegulationType } from '@sphereon/ssi-sdk.data-store-types'\n\n/**\n * {@inheritDoc IWellKnownDidIssuer}\n */\nexport class WellKnownDidIssuer implements IAgentPlugin {\n readonly schema = schema.IWellKnownDidVerifier\n readonly methods: IWellKnownDidIssuer = {\n addLinkedDomainsService: this.addLinkedDomainsService.bind(this),\n getDidConfigurationResource: this.getDidConfigurationResource.bind(this),\n issueDidConfigurationResource: this.issueDidConfigurationResource.bind(this),\n issueDomainLinkageCredential: this.issueDomainLinkageCredential.bind(this),\n registerCredentialIssuance: this.registerCredentialIssuance.bind(this),\n removeCredentialIssuance: this.removeCredentialIssuance.bind(this),\n saveDidConfigurationResource: this.saveDidConfigurationResource.bind(this),\n }\n\n private readonly credentialIssuances: Record<string, IssuanceCallback>\n private readonly didConfigurationResourceRelations = ['linkedDids']\n\n constructor(\n private dbConnection: OrPromise<Connection>,\n args?: IWellKnownDidIssuerOptionsArgs,\n ) {\n this.credentialIssuances = (args && args.credentialIssuances) || {}\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.registerSignatureVerification} */\n private async registerCredentialIssuance(args: IRegisterIssueCredentialArgs, context: RequiredContext): Promise<void> {\n if (this.credentialIssuances[args.callbackName] !== undefined) {\n return Promise.reject(new Error(`Credential issuance with callbackName: ${args.callbackName} already present`))\n }\n\n this.credentialIssuances[args.callbackName] = args.credentialIssuance\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.removeSignatureVerification} */\n private async removeCredentialIssuance(args: IRemoveCredentialIssuanceArgs, context: RequiredContext): Promise<boolean> {\n return delete this.credentialIssuances[args.callbackName]\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.issueDidConfigurationResource} */\n private async issueDidConfigurationResource(\n args: IIssueDidConfigurationResourceArgs,\n context: RequiredContext,\n ): Promise<IDidConfigurationResource> {\n if (!args.issuances.every((issuance: IIssueDomainLinkageCredentialArgs) => issuance.origin === args.issuances[0].origin)) {\n return Promise.reject(Error('All verifiableCredentials should be issued for the same origin'))\n }\n\n // TODO We should combine all origins into one service when we update to Veramo 3.1.6.next-165 or higher, as then we can support multiple origins\n const addServices = args.issuances.map((issuance: IIssueDomainLinkageCredentialArgs) =>\n this.addLinkedDomainsService(\n {\n did: issuance.did,\n origin: issuance.origin,\n serviceId: issuance.serviceId,\n },\n context,\n ),\n )\n\n return Promise.all(addServices).then(async () =>\n new Issuer()\n .issueDidConfigurationResource({\n issuances: await this.mapIssuances(args.issuances),\n issueCallback:\n typeof args.credentialIssuance === 'string' ? await this.getCredentialIssuance(args.credentialIssuance) : args.credentialIssuance,\n })\n .then(async (didConfigurationResource: IDidConfigurationResource) => {\n if (args.save) {\n // TODO add support for multiple origins when we upgrade Veramo version\n await this.saveDidConfigurationResource({ origin: args.issuances[0].origin, didConfigurationResource }, context)\n }\n return didConfigurationResource\n })\n .catch((error: Error) => Promise.reject(Error(`Unable to issue DID configuration resource. Error: ${error.message}`))),\n )\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.saveDidConfigurationResource} */\n public async saveDidConfigurationResource(args: ISaveDidConfigurationResourceArgs, context: RequiredContext): Promise<void> {\n const didConfigurationEntity = {\n origin: args.origin,\n context: args.didConfigurationResource['@context'],\n linkedDids: args.didConfigurationResource.linked_dids.map((credential: DomainLinkageCredential) =>\n createCredentialEntity(this.normalizeCredential(credential)),\n ),\n }\n\n await (await this.dbConnection).getRepository(DidConfigurationResourceEntity).save(didConfigurationEntity, { transaction: true })\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.getDidConfigurationResource} */\n public async getDidConfigurationResource(args: IGetDidConfigurationResourceArgs, context: RequiredContext): Promise<IDidConfigurationResource> {\n const result = await (await this.dbConnection).getRepository(DidConfigurationResourceEntity).findOne({\n where: { origin: args.origin },\n relations: this.didConfigurationResourceRelations,\n })\n\n if (!result) {\n return Promise.reject(Error(`No DID configuration resource found for origin: ${args.origin}`))\n }\n\n return didConfigurationResourceFrom(result)\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.issueDomainLinkageCredential} */\n public async issueDomainLinkageCredential(args: IIssueDomainLinkageCredentialArgs, context: RequiredContext): Promise<DomainLinkageCredential> {\n const did: string = parseDid(args.did).did\n\n if (new URL(args.origin).origin !== args.origin) {\n return Promise.reject(Error(`Origin ${args.origin} is not valid`))\n }\n\n if (new URL(args.origin).protocol !== 'https:') {\n return Promise.reject(Error(`Origin ${args.origin} is not a https URL`))\n }\n\n if (args.issuanceDate && isNaN(Date.parse(args.issuanceDate))) {\n return Promise.reject(Error(`IssuanceDate ${args.issuanceDate} is not a valid date`))\n }\n\n if (isNaN(Date.parse(args.expirationDate))) {\n return Promise.reject(Error(`ExpirationDate ${args.expirationDate} is not a valid date`))\n }\n\n const credentialIssuance: IssuanceCallback =\n typeof args.credentialIssuance === 'string'\n ? await this.getCredentialIssuance(args.credentialIssuance)\n : (args.credentialIssuance as IssuanceCallback)\n\n return new Issuer()\n .issueDomainLinkageCredential({\n did,\n origin: args.origin,\n issuanceDate: args.issuanceDate,\n expirationDate: args.expirationDate,\n options: args.options,\n issueCallback: credentialIssuance,\n })\n .then(async (credential: DomainLinkageCredential) => {\n if (args.save) {\n await this.saveDomainLinkageCredential(credential, context)\n }\n return credential\n })\n .catch((error: Error) => Promise.reject(Error(`Unable to issue domain linkage credential for DID: ${did}. Error: ${error.message}`)))\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.addLinkedDomainsService} */\n public async addLinkedDomainsService(args: IAddLinkedDomainsServiceArgs, context: RequiredContext): Promise<void> {\n const did: string = parseDid(args.did).did\n\n if (new URL(args.origin).origin !== args.origin) {\n return Promise.reject(Error(`Origin ${args.origin} is not valid`))\n }\n\n if (new URL(args.origin).protocol !== 'https:') {\n return Promise.reject(Error(`Origin ${args.origin} is not a https URL`))\n }\n\n context.agent\n .didManagerGet({ did })\n .catch(() => Promise.reject(Error('DID cannot be found')))\n .then(async (identifier: IIdentifier) => {\n if (\n !identifier.services ||\n identifier.services.filter(\n // TODO we should also check for the origins in the serviceEndpoint objects when we start supporting multiple origins\n (service: Service) => service.type === ServiceTypesEnum.LINKED_DOMAINS && service.serviceEndpoint === args.origin,\n ).length === 0\n ) {\n await context.agent.didManagerAddService({\n did: identifier.did,\n service: {\n id: args.serviceId || uuidv4(),\n type: ServiceTypesEnum.LINKED_DOMAINS,\n // TODO We should support a serviceEndpoint object here when we update to Veramo 3.1.6.next-165 or higher, as then we can support multiple origins\n serviceEndpoint: args.origin,\n },\n })\n }\n })\n .catch((error: Error) => Promise.reject(Error(`Unable to add LinkedDomains service to DID: ${args.did}. Error: ${error.message}`)))\n }\n\n private async getCredentialIssuance(callbackName: string): Promise<IssuanceCallback> {\n if (this.credentialIssuances[callbackName] === undefined) {\n return Promise.reject(new Error(`Credential issuance not found for callbackName: ${callbackName}`))\n }\n\n return this.credentialIssuances[callbackName]\n }\n\n private async saveDomainLinkageCredential(credential: DomainLinkageCredential, context: RequiredContext): Promise<DigitalCredential> {\n const vc = this.normalizeCredential(credential)\n return context.agent.crsAddCredential({\n credential: {\n rawDocument: JSON.stringify(vc),\n credentialRole: CredentialRole.ISSUER,\n regulationType: RegulationType.NON_REGULATED, // FIXME funke\n kmsKeyRef: 'FIXME', // FIXME funke\n identifierMethod: 'did',\n issuerCorrelationId: CredentialMapper.issuerCorrelationIdFromIssuerType(vc.issuer),\n issuerCorrelationType: CredentialCorrelationType.DID,\n subjectCorrelationId: CredentialMapper.issuerCorrelationIdFromIssuerType(vc.issuer), // FIXME get separate did for subject\n subjectCorrelationType: CredentialCorrelationType.DID,\n },\n })\n }\n\n private normalizeCredential(credential: DomainLinkageCredential): VerifiableCredential {\n return typeof credential === 'string' ? normalizeCredential(credential) : credential\n }\n\n private async mapIssuances(issuances: Array<IIssueDomainLinkageCredentialArgs>): Promise<Array<IIssueDomainLinkageCredentialArgs>> {\n const promises = issuances.map(async (issuance: IIssueDomainLinkageCredentialArgs) => {\n return {\n ...issuance,\n issueCallback:\n typeof issuance.credentialIssuance === 'string'\n ? await this.getCredentialIssuance(issuance.credentialIssuance)\n : issuance.credentialIssuance,\n }\n })\n return Promise.all(promises)\n }\n}\n","import {\n DomainLinkageCredential,\n IDidConfigurationResource,\n IIssueDomainLinkageCredentialOptions,\n IssuanceCallback,\n} from '@sphereon/wellknown-dids-client'\nimport { IAgentContext, IPluginMethodMap, IDIDManager } from '@veramo/core'\nimport { ICredentialStore } from '@sphereon/ssi-sdk.credential-store'\n\nexport interface IWellKnownDidIssuer extends IPluginMethodMap {\n addLinkedDomainsService(args: IAddLinkedDomainsServiceArgs, context: RequiredContext): Promise<void>\n getDidConfigurationResource(args: IGetDidConfigurationResourceArgs, context: RequiredContext): Promise<IDidConfigurationResource>\n issueDidConfigurationResource(args: IIssueDidConfigurationResourceArgs, context: RequiredContext): Promise<IDidConfigurationResource>\n issueDomainLinkageCredential(args: IIssueDomainLinkageCredentialArgs, context: RequiredContext): Promise<DomainLinkageCredential>\n registerCredentialIssuance(args: IRegisterIssueCredentialArgs, context: RequiredContext): Promise<void>\n removeCredentialIssuance(args: IRemoveCredentialIssuanceArgs, context: RequiredContext): Promise<boolean>\n saveDidConfigurationResource(args: ISaveDidConfigurationResourceArgs, context: RequiredContext): Promise<void>\n}\n\nexport interface IWellKnownDidIssuerOptionsArgs {\n credentialIssuances?: Record<string, IssuanceCallback>\n}\n\nexport interface IRegisterIssueCredentialArgs {\n callbackName: string\n credentialIssuance: IssuanceCallback\n}\n\nexport interface IRemoveCredentialIssuanceArgs {\n callbackName: string\n}\n\nexport interface IIssueDidConfigurationResourceArgs {\n issuances: Array<IIssueDomainLinkageCredentialArgs>\n credentialIssuance?: string | IssuanceCallback\n save?: boolean\n}\n\nexport interface IIssueDomainLinkageCredentialArgs {\n did: string\n origin: string\n serviceId?: string\n issuanceDate?: string\n expirationDate: string\n save?: boolean\n options: IIssueDomainLinkageCredentialOptions\n credentialIssuance?: string | IssuanceCallback\n}\n\nexport interface IGetDidConfigurationResourceArgs {\n origin: string\n}\n\nexport interface IAddLinkedDomainsServiceArgs {\n did: string\n origin: string\n serviceId?: string\n}\n\nexport interface ISaveDidConfigurationResourceArgs {\n origin: string\n didConfigurationResource: IDidConfigurationResource\n}\n\nexport type RequiredContext = IAgentContext<IDIDManager & ICredentialStore>\n","export { WellknownDidIssuerMigrations } from './generic'\n","import { CreateWellknownDidIssuer1661162010000 } from './1-CreateWellknownDidIssuer'\n\n/**\n * The migrations array that SHOULD be used when initializing a TypeORM database connection.\n *\n * These ensure the correct creation of tables and the proper migrations of data when tables change between versions.\n *\n * @public\n */\nexport const WellknownDidIssuerMigrations = [CreateWellknownDidIssuer1661162010000]\n","import { MigrationInterface, QueryRunner } from 'typeorm'\nimport Debug from 'debug'\nimport { CreateWellknownDidIssuer1661165115000 } from '../postgres/1661165115000-CreateWellknownDidIssuer'\nimport { CreateWellknownDidIssuer1661161799000 } from '../sqlite/1661161799000-CreateWellknownDidIssuer'\n\nconst debug = Debug('sphereon:ssi-sdk:migrations')\n\nexport class CreateWellknownDidIssuer1661162010000 implements MigrationInterface {\n name = 'CreateWellknownDidIssuer1661162010000'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n debug('migration: creating well-known DID tables')\n const dbType = queryRunner.connection.driver.options.type\n if (dbType === 'postgres') {\n debug('using postgres migration file')\n const mig = new CreateWellknownDidIssuer1661165115000()\n const up = await mig.up(queryRunner)\n debug('Migration statements executed')\n return up\n } else if (dbType === 'sqlite' || dbType === 'react-native' || dbType === 'expo') {\n debug('using sqlite/react-native migration file')\n const mig = new CreateWellknownDidIssuer1661161799000()\n const up = await mig.up(queryRunner)\n debug('Migration statements executed')\n return up\n } else {\n return Promise.reject(\n `Migrations are currently only supported for sqlite, react-native, expor and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,\n )\n }\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n debug('reverting well-known DID tables')\n const dbType = queryRunner.connection.driver.options.type\n if (dbType === 'postgres') {\n debug('using postgres migration file')\n const mig = new CreateWellknownDidIssuer1661165115000()\n const down = await mig.down(queryRunner)\n debug('Migration statements executed')\n return down\n } else if (dbType === 'sqlite' || dbType === 'react-native' || dbType === 'expo') {\n debug('using sqlite/react-native migration file')\n const mig = new CreateWellknownDidIssuer1661161799000()\n const down = await mig.down(queryRunner)\n debug('Migration statements executed')\n return down\n } else {\n return Promise.reject(\n `Migrations are currently only supported for sqlite, react-native, expor and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,\n )\n }\n }\n}\n","import { MigrationInterface, QueryRunner } from 'typeorm'\n\nexport class CreateWellknownDidIssuer1661165115000 implements MigrationInterface {\n name = 'CreateWellknownDidIssuer1661165115000'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(\n `CREATE TABLE \"DidConfigurationResource\" (\"origin\" varchar NOT NULL, \"context\" varchar NOT NULL, \"created_at\" TIMESTAMP NOT NULL DEFAULT now(), \"last_updated_at\" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT \"PK_Origin\" PRIMARY KEY (\"origin\"))`,\n )\n await queryRunner.query(\n `CREATE TABLE \"DidConfigurationResourceCredentials\" (\"didConfigurationResourceOrigin\" varchar NOT NULL, \"credentialHash\" varchar NOT NULL)`,\n )\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(`DROP TABLE \"DidConfigurationResource\"`)\n await queryRunner.query(`DROP TABLE \"DidConfigurationResourceCredentials\"`)\n }\n}\n","import { MigrationInterface, QueryRunner } from 'typeorm'\n\nexport class CreateWellknownDidIssuer1661161799000 implements MigrationInterface {\n name = 'CreateWellknownDidIssuer1661161799000'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(\n `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')))`,\n )\n await queryRunner.query(\n `CREATE TABLE \"DidConfigurationResourceCredentials\" (\"didConfigurationResourceOrigin\" varchar NOT NULL, \"credentialHash\" varchar NOT NULL)`,\n )\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(`DROP TABLE \"DidConfigurationResource\"`)\n await queryRunner.query(`DROP TABLE \"DidConfigurationResourceCredentials\"`)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;ACCA,QAAA,YAAA,QAAA,SAAA;AACA,QAAA,eAAA;AAoBO,QAAM,MAAN,MAAM,YAAY,UAAA,WAAU;aAAA;;;;AACjC,eAAA;OAAC,GAAA,UAAA,eAAa;;;AAId,eAAA;OAAC,GAAA,UAAA,QAAM;;;AAIP,eAAA;OAAC,GAAA,UAAA,QAAM;;;AAIP,eAAA;OAAC,GAAA,UAAA,QAAM;;;AAIP,eAAA;OAAC,GAAA,UAAA,QAAO;QACN,MAAM;QACN,UAAU;QACV,aAAa;UACX,IAAI,wBAAC,UAAgC;AACnC,mBAAO;UACT,GAFI;UAGJ,MAAM,wBAAC,UAA0C;AAC/C,mBAAO;UACT,GAFM;;OAIT;;;AAGD,eAAA;OAAC,GAAA,UAAA,WAAU,CAAC,SAAS,aAAA,YAAY,CAAC,eAAe,eAAU,QAAV,eAAU,SAAA,SAAV,WAAY,MAAM;QAAE,UAAU;MAAS,CAAE;gCAE7E,aAAA,UAAU;;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AACN,aAAOI;IACT,OAAO;AACL,aAAOU,QAAQC,OACb,6FAA6FT,MAAAA,+GAAqH;IAEtN;EACF;EAEA,MAAaU,KAAKX,aAAyC;AACzDL,UAAM,iCAAA;AACN,UAAMM,SAASD,YAAYE,WAAWC,OAAOC,QAAQC;AACrD,QAAIJ,WAAW,YAAY;AACzBN,YAAM,+BAAA;AACN,YAAMW,MAAM,IAAIC,sCAAAA;AAChB,YAAMI,OAAO,MAAML,IAAIK,KAAKX,WAAAA;AAC5BL,YAAM,+BAAA;AACN,aAAOgB;IACT,WAAWV,WAAW,YAAYA,WAAW,kBAAkBA,WAAW,QAAQ;AAChFN,YAAM,0CAAA;AACN,YAAMW,MAAM,IAAIE,sCAAAA;AAChB,YAAMG,OAAO,MAAML,IAAIK,KAAKX,WAAAA;AAC5BL,YAAM,+BAAA;AACN,aAAOgB;IACT,OAAO;AACL,aAAOF,QAAQC,OACb,6FAA6FT,MAAAA,+GAAqH;IAEtN;EACF;AACF;;;AD5CO,IAAMW,+BAA+B;EAACC;;;;ALJ7C,IAAMC,SAASC;AAKR,IAAMC,6BAA6B;EAACC;;","names":["Claim","Credential","createCredentialEntity","Identifier","debug","debug","debug","qb","debug","debug","debug","module","DidConfigurationResourceEntity","BaseEntity","origin","context","linkedDids","createdAt","lastUpdatedAt","nullable","Credential","credential","hash","cascade","onDelete","name","didConfigurationResourceFrom","didConfigurationResource","linked_dids","linkedDidsFrom","credentials","map","raw","proof","type","jwt","createCredentialEntity","vci","vc","asArray","id","issuanceDate","Date","expirationDate","issuer","Identifier","did","extractIssuer","credentialSubject","subject","claims","hasOwnProperty","value","isObj","claim","Claim","computeEntryHash","JSON","stringify","credentialType","push","import_ssi_sdk","WellKnownDidIssuer","schema","IWellKnownDidVerifier","methods","addLinkedDomainsService","bind","getDidConfigurationResource","issueDidConfigurationResource","issueDomainLinkageCredential","registerCredentialIssuance","removeCredentialIssuance","saveDidConfigurationResource","credentialIssuances","didConfigurationResourceRelations","dbConnection","args","context","callbackName","undefined","Promise","reject","Error","credentialIssuance","issuances","every","issuance","origin","addServices","map","did","serviceId","all","then","Issuer","mapIssuances","issueCallback","getCredentialIssuance","didConfigurationResource","save","catch","error","message","didConfigurationEntity","linkedDids","linked_dids","credential","createCredentialEntity","normalizeCredential","getRepository","DidConfigurationResourceEntity","transaction","result","findOne","where","relations","didConfigurationResourceFrom","parseDid","URL","protocol","issuanceDate","isNaN","Date","parse","expirationDate","options","saveDomainLinkageCredential","agent","didManagerGet","identifier","services","filter","service","type","ServiceTypesEnum","LINKED_DOMAINS","serviceEndpoint","length","didManagerAddService","id","uuidv4","vc","crsAddCredential","rawDocument","JSON","stringify","credentialRole","CredentialRole","ISSUER","regulationType","RegulationType","NON_REGULATED","kmsKeyRef","identifierMethod","issuerCorrelationId","CredentialMapper","issuerCorrelationIdFromIssuerType","issuer","issuerCorrelationType","CredentialCorrelationType","DID","subjectCorrelationId","subjectCorrelationType","promises","CreateWellknownDidIssuer1661165115000","name","up","queryRunner","query","down","CreateWellknownDidIssuer1661161799000","name","up","queryRunner","query","down","debug","Debug","CreateWellknownDidIssuer1661162010000","name","up","queryRunner","dbType","connection","driver","options","type","mig","CreateWellknownDidIssuer1661165115000","CreateWellknownDidIssuer1661161799000","Promise","reject","down","WellknownDidIssuerMigrations","CreateWellknownDidIssuer1661162010000","schema","require","WellknownDidIssuerEntities","DidConfigurationResourceEntity"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.0_@types+node@20.19.25__@swc+core@1.15.2_@swc+_119fedc18e19d1717452bb9e989205b3/node_modules/tsup/assets/cjs_shims.js","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/key.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/service.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/claim.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/credential.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/presentation.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/message.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/identifier.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/utils.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/identifier/did-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/identifier/key-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/private-key.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/identifier/private-key-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/data-store.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/data-store-orm.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/did-discovery-provider.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/entities/PreMigrationEntities.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/migrations/migration-functions.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/migrations/1.createDatabase.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/migrations/2.simplifyRelations.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/migrations/3.createPrivateKeyStorage.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/migrations/4.allowNullVPIssuanceDate.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/migrations/index.ts","../../../node_modules/.pnpm/@veramo+data-store@4.2.0_patch_hash=25b55da53633b67af137c78afaf727c15cd0dd9f55a659a71d1_16b1082d47bace099b8c1c12369b6a86/node_modules/@veramo/data-store/src/index.ts","../plugin.schema.json","../src/index.ts","../src/entities/DidConfigurationResourceEntity.ts","../src/agent/WellKnownDidIssuer.ts","../src/types/IWellKnownDidIssuer.ts","../src/migrations/index.ts","../src/migrations/generic/index.ts","../src/migrations/generic/1-CreateWellknownDidIssuer.ts","../src/migrations/postgres/1661165115000-CreateWellknownDidIssuer.ts","../src/migrations/sqlite/1661161799000-CreateWellknownDidIssuer.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import { KeyMetadata, TKeyType } from '@veramo/core'\nimport { Entity, Column, PrimaryColumn, BaseEntity, ManyToOne } from 'typeorm'\nimport { Identifier } from './identifier'\n\n/**\n * Mirrors {@link @veramo/core#TKeyType | TKeyType}\n *\n * @beta - This API may change without a BREAKING CHANGE notice.\n */\nexport type KeyType = TKeyType\n\n/**\n * Represents some properties of a {@link @veramo/core#IKey | IKey} that are stored in a TypeORM\n * database for the purpose of keeping track of the {@link @veramo/key-manager#AbstractKeyManagementSystem}\n * implementations and the keys they are able to use.\n *\n * @see {@link @veramo/data-store#KeyStore | KeyStore} for the implementation used by the\n * {@link @veramo/key-manager#KeyManager | KeyManager}.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('key')\nexport class Key extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n kid: string\n\n @Column()\n //@ts-ignore\n kms: string\n\n @Column()\n //@ts-ignore\n type: KeyType\n\n @Column()\n //@ts-ignore\n publicKeyHex: string\n\n @Column({\n type: 'simple-json',\n nullable: true,\n transformer: {\n to: (value: any): KeyMetadata | null => {\n return value\n },\n from: (value: KeyMetadata | null): object | null => {\n return value\n },\n },\n })\n meta?: KeyMetadata | null\n\n @ManyToOne((type) => Identifier, (identifier) => identifier?.keys, { onDelete: 'CASCADE' })\n //@ts-ignore\n identifier?: Identifier\n}\n","import { Entity, Column, PrimaryColumn, BaseEntity, ManyToOne } from 'typeorm'\nimport { Identifier } from './identifier'\n\n/**\n * Represents some properties of a {@link did-resolver#ServiceEndpoint | ServiceEndpoint} as it is stored in a TypeORM\n * database. This is used by {@link @veramo/data-store#DIDStore | DIDStore} to provide information to\n * {@link @veramo/did-manager#DIDManager | DIDManager} when DID management information is stored in a local TypeORM\n * database.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('service')\nexport class Service extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n id: string\n\n @Column()\n //@ts-ignore\n type: string\n\n @Column()\n //@ts-ignore\n serviceEndpoint: string\n\n @Column({ nullable: true })\n description?: string\n\n @ManyToOne((type) => Identifier, (identifier) => identifier?.services, { onDelete: 'CASCADE' })\n //@ts-ignore\n identifier?: Identifier\n}\n","import { Entity, Column, BaseEntity, ManyToOne, PrimaryColumn } from 'typeorm'\nimport { Identifier } from './identifier'\nimport { Credential } from './credential'\n\n/**\n * Represents the properties of a claim extracted from a Verifiable Credential `credentialSubject`, and stored in a\n * TypeORM database for querying.\n *\n * @see {@link @veramo/core#IDataStoreORM} for the interface defining how this can be queried.\n * @see {@link @veramo/data-store#DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('claim')\nexport class Claim extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n hash: string\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.issuedClaims, {\n eager: true,\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n issuer: Identifier\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.receivedClaims, {\n eager: true,\n nullable: true,\n })\n subject?: Identifier\n\n @ManyToOne((type) => Credential, (credential) => credential.claims, {\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n credential: Credential\n\n @Column()\n //@ts-ignore\n issuanceDate: Date\n\n @Column({ nullable: true })\n expirationDate?: Date\n\n @Column('simple-array')\n //@ts-ignore\n context: string[]\n\n @Column('simple-array')\n //@ts-ignore\n credentialType: string[]\n\n @Column()\n //@ts-ignore\n type: string\n\n @Column('text', { nullable: true })\n //@ts-ignore\n value: string | null\n\n @Column()\n //@ts-ignore\n isObj: boolean\n}\n","import { VerifiableCredential } from '@veramo/core'\nimport { BaseEntity, Column, Entity, ManyToMany, ManyToOne, OneToMany, PrimaryColumn } from 'typeorm'\nimport { Identifier } from './identifier'\nimport { Message } from './message'\nimport { Presentation } from './presentation'\nimport { Claim } from './claim'\nimport { asArray, computeEntryHash, extractIssuer } from '@veramo/utils'\n\n/**\n * Represents some common properties of a Verifiable Credential that are stored in a TypeORM database for querying.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetVerifiableCredentials | dataStoreORMGetVerifiableCredentials}\n * for the interface defining how this can be queried.\n *\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetVerifiableCredentialsByClaims | dataStoreORMGetVerifiableCredentialsByClaims} for the interface defining how to query credentials by the claims they contain.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('credential')\nexport class Credential extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n hash: string\n\n //@ts-ignore\n private _raw: VerifiableCredential\n\n set raw(raw: VerifiableCredential) {\n this._raw = raw\n this.hash = computeEntryHash(raw)\n }\n\n @Column('simple-json')\n get raw(): VerifiableCredential {\n return this._raw\n }\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.issuedCredentials, {\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n issuer: Identifier\n\n // Subject can be null https://w3c.github.io/vc-data-model/#credential-uniquely-identifies-a-subject\n @ManyToOne((type) => Identifier, (identifier) => identifier?.receivedCredentials, {\n cascade: ['insert'],\n eager: true,\n nullable: true,\n })\n subject?: Identifier\n\n @Column({ nullable: true })\n id?: string\n\n @Column()\n //@ts-ignore\n issuanceDate: Date\n\n @Column({ nullable: true })\n expirationDate?: Date\n\n @Column('simple-array')\n //@ts-ignore\n context: string[]\n\n @Column('simple-array')\n //@ts-ignore\n type: string[]\n\n @OneToMany((type) => Claim, (claim) => claim.credential, {\n cascade: ['insert'],\n })\n //@ts-ignore\n claims: Claim[]\n\n @ManyToMany((type) => Presentation, (presentation) => presentation.credentials)\n //@ts-ignore\n presentations: Presentation[]\n\n @ManyToMany((type) => Message, (message) => message.credentials)\n //@ts-ignore\n messages: Message[]\n}\n\nexport const createCredentialEntity = (vci: VerifiableCredential): Credential => {\n const vc = vci\n const credential = new Credential()\n credential.context = asArray(vc['@context'])\n credential.type = asArray(vc.type || [])\n credential.id = vc.id\n\n if (vc.issuanceDate) {\n credential.issuanceDate = new Date(vc.issuanceDate)\n }\n\n if (vc.expirationDate) {\n credential.expirationDate = new Date(vc.expirationDate)\n }\n\n const issuer = new Identifier()\n issuer.did = extractIssuer(vc)\n credential.issuer = issuer\n\n if (vc.credentialSubject.id) {\n const subject = new Identifier()\n subject.did = vc.credentialSubject.id\n credential.subject = subject\n }\n credential.claims = []\n for (const type in vc.credentialSubject) {\n if (vc.credentialSubject.hasOwnProperty(type)) {\n const value = vc.credentialSubject[type]\n\n if (type !== 'id') {\n const isObj = typeof value === 'function' || (typeof value === 'object' && !!value)\n const claim = new Claim()\n claim.hash = computeEntryHash(JSON.stringify(vc) + type)\n claim.type = type\n claim.value = isObj ? JSON.stringify(value) : value\n claim.isObj = isObj\n claim.issuer = credential.issuer\n claim.subject = credential.subject\n claim.expirationDate = credential.expirationDate\n claim.issuanceDate = credential.issuanceDate\n claim.credentialType = credential.type\n claim.context = credential.context\n credential.claims.push(claim)\n }\n }\n }\n\n credential.raw = vci\n return credential\n}\n","import { VerifiableCredential, VerifiablePresentation } from '@veramo/core'\n\nimport { BaseEntity, Column, Entity, JoinTable, ManyToMany, ManyToOne, PrimaryColumn } from 'typeorm'\nimport { Identifier } from './identifier'\nimport { Message } from './message'\nimport { createCredentialEntity, Credential } from './credential'\nimport { asArray, computeEntryHash } from '@veramo/utils'\nimport { normalizeCredential } from 'did-jwt-vc'\n\n/**\n * Represents some common properties of a Verifiable Presentation that are stored in a TypeORM database for querying.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetVerifiablePresentations | dataStoreORMGetVerifiablePresentations} for the interface defining how this can be queried.\n *\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('presentation')\nexport class Presentation extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n hash: string\n\n //@ts-ignore\n private _raw: IVerifiablePresentation\n\n set raw(raw: VerifiablePresentation) {\n this._raw = raw\n this.hash = computeEntryHash(raw)\n }\n\n @Column({ type: 'simple-json' })\n get raw(): VerifiablePresentation {\n return this._raw\n }\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.issuedPresentations, {\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n //@ts-ignore\n holder: Identifier\n\n @ManyToMany((type) => Identifier, (identifier) => identifier?.receivedPresentations, {\n cascade: ['insert'],\n eager: true,\n nullable: true,\n })\n @JoinTable()\n //@ts-ignore\n verifier?: Identifier[]\n\n @Column({ nullable: true })\n id?: String\n\n @Column()\n //@ts-ignore\n issuanceDate: Date\n\n @Column({ nullable: true })\n expirationDate?: Date\n\n @Column('simple-array')\n //@ts-ignore\n context: string[]\n\n @Column('simple-array')\n //@ts-ignore\n type: string[]\n\n @ManyToMany((type) => Credential, (credential) => credential.presentations, {\n cascade: true,\n })\n @JoinTable()\n //@ts-ignore\n credentials: Credential[]\n\n @ManyToMany((type) => Message, (message) => message.presentations)\n //@ts-ignore\n messages: Message[]\n}\n\nexport const createPresentationEntity = (vpi: VerifiablePresentation): Presentation => {\n const vp = vpi\n const presentation = new Presentation()\n presentation.context = asArray(vp['@context'])\n presentation.type = asArray(vp.type || [])\n presentation.id = vp.id\n\n if (vp.issuanceDate) {\n presentation.issuanceDate = new Date(vp.issuanceDate)\n }\n\n if (vp.expirationDate) {\n presentation.expirationDate = new Date(vp.expirationDate)\n }\n\n const holder = new Identifier()\n holder.did = vp.holder\n presentation.holder = holder\n\n presentation.verifier = asArray(vp.verifier || []).map((verifierDid) => {\n const id = new Identifier()\n id.did = verifierDid\n return id\n })\n\n presentation.raw = vpi\n\n presentation.credentials = (vp.verifiableCredential || [])\n .map((cred) => {\n if (typeof cred === 'string') {\n return normalizeCredential(cred)\n } else {\n return <VerifiableCredential>cred\n }\n })\n .map(createCredentialEntity)\n return presentation\n}\n","import {\n BaseEntity,\n BeforeInsert,\n BeforeUpdate,\n Column,\n Entity,\n JoinTable,\n ManyToMany,\n ManyToOne,\n PrimaryColumn,\n} from 'typeorm'\nimport { IMessage } from '@veramo/core'\nimport { Identifier } from './identifier'\nimport { createPresentationEntity, Presentation } from './presentation'\nimport { createCredentialEntity, Credential } from './credential'\nimport { computeEntryHash } from '@veramo/utils'\nimport { v4 as uuidv4 } from 'uuid'\n\n/**\n * Represents message metadata as it is stored by {@link @veramo/data-store#DataStore | DataStore}.\n *\n * This metadata is most often used by {@link @veramo/message-handler#MessageHandler | MessageHandler} and\n * {@link @veramo/core#IMessageHandler | IMessageHandler} implementations to decorate messages that are interpreted and\n * decoded, but not returned as final, as they pass through the message handler chain.\n *\n * @beta - This API may change without a BREAKING CHANGE notice.\n */\nexport interface MetaData {\n type: string\n value?: string\n}\n\n/**\n * Represents some common properties of an {@link @veramo/core#IMessage} that are stored in a TypeORM database for\n * querying.\n *\n * @see {@link @veramo/core#IDataStoreORM.dataStoreORMGetMessages | dataStoreORMGetMessages}\n * for the interface defining how this can be queried\n *\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('message')\nexport class Message extends BaseEntity {\n @BeforeInsert()\n setId() {\n if (!this.id) {\n this.id = computeEntryHash(this.raw || uuidv4())\n }\n }\n\n @PrimaryColumn()\n //@ts-ignore\n id: string\n\n @BeforeInsert()\n setSaveDate() {\n this.saveDate = new Date()\n this.updateDate = new Date()\n }\n\n @BeforeUpdate()\n setUpdateDate() {\n this.updateDate = new Date()\n }\n\n @Column({ select: false })\n //@ts-ignore\n saveDate: Date\n\n @Column({ select: false })\n //@ts-ignore\n updateDate: Date\n\n @Column({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n expiresAt?: Date\n\n @Column({ nullable: true })\n threadId?: string\n\n @Column()\n //@ts-ignore\n type: string\n\n @Column({ nullable: true })\n raw?: string\n\n @Column('simple-json', { nullable: true })\n data?: object | null\n\n // https://github.com/decentralized-identifier/didcomm-messaging/blob/41f35f992275dd71d459504d14eb8d70b4185533/jwm.md#jwm-profile\n\n @Column('simple-array', { nullable: true })\n replyTo?: string[]\n\n @Column({ nullable: true })\n replyUrl?: string\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.sentMessages, {\n nullable: true,\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n from?: Identifier\n\n @ManyToOne((type) => Identifier, (identifier) => identifier.receivedMessages, {\n nullable: true,\n cascade: ['insert'],\n eager: true,\n onDelete: 'CASCADE',\n })\n to?: Identifier\n\n @Column('simple-json', { nullable: true })\n metaData?: MetaData[] | null\n\n @ManyToMany((type) => Presentation, (presentation) => presentation.messages, {\n cascade: true,\n })\n @JoinTable()\n //@ts-ignore\n presentations: Presentation[]\n\n @ManyToMany((type) => Credential, (credential) => credential.messages, { cascade: true })\n @JoinTable()\n //@ts-ignore\n credentials: Credential[]\n}\n\nexport const createMessageEntity = (args: IMessage): Message => {\n const message = new Message()\n message.id = args.id\n message.threadId = args.threadId\n message.type = args.type\n message.raw = args.raw\n message.data = args.data\n message.metaData = args.metaData\n\n if (args.replyTo) {\n message.replyTo = args.replyTo\n }\n if (args.replyUrl) {\n message.replyUrl = args.replyUrl\n }\n\n if (args.createdAt) {\n message.createdAt = new Date(args.createdAt)\n }\n\n if (args.expiresAt) {\n message.createdAt = new Date(args.expiresAt)\n }\n\n if (args.from) {\n const from = new Identifier()\n from.did = args.from\n message.from = from\n }\n\n if (args.to) {\n const to = new Identifier()\n to.did = args.to\n message.to = to\n }\n\n if (args.presentations) {\n message.presentations = args.presentations.map(createPresentationEntity)\n }\n\n if (args.credentials) {\n message.credentials = args.credentials.map(createCredentialEntity)\n }\n\n return message\n}\n\nexport const createMessage = (args: Message): IMessage => {\n const message: Partial<IMessage> = {\n id: args.id,\n type: args.type,\n raw: args.raw,\n data: args.data,\n metaData: args.metaData,\n }\n\n if (args.threadId) {\n message.threadId = args.threadId\n }\n\n if (args.replyTo) {\n message.replyTo = args.replyTo\n }\n\n if (args.replyTo) {\n message.replyUrl = args.replyUrl\n }\n\n if (args.createdAt) {\n message.createdAt = args.createdAt.toISOString()\n }\n\n if (args.expiresAt) {\n message.expiresAt = args.expiresAt.toISOString()\n }\n\n if (args.from) {\n message.from = args.from.did\n }\n\n if (args.to) {\n message.to = args.to.did\n }\n\n if (args.presentations) {\n message.presentations = args.presentations.map((vp) => vp.raw)\n }\n\n if (args.credentials) {\n message.credentials = args.credentials.map((vc) => vc.raw)\n }\n\n return message as IMessage\n}\n","import {\n Entity,\n Column,\n Connection,\n PrimaryColumn,\n BaseEntity,\n OneToMany,\n ManyToMany,\n Index,\n BeforeInsert,\n BeforeUpdate,\n} from 'typeorm'\nimport { Key } from './key'\nimport { Service } from './service'\nimport { Message } from './message'\nimport { Presentation } from './presentation'\nimport { Credential } from './credential'\nimport { Claim } from './claim'\n\n/**\n * Represents some properties and relationships of an {@link @veramo/core#IIdentifier} that are stored in a TypeORM\n * database for the purpose of keeping track of keys and services associated with a DID managed by a Veramo agent.\n *\n * @see {@link @veramo/data-store#DIDStore | DIDStore} for the implementation used by the\n * {@link @veramo/did-manager#DIDManager | DIDManager}.\n * @see {@link @veramo/data-store#DataStoreORM | DataStoreORM} for the implementation of the query interface.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('identifier')\n@Index(['alias', 'provider'], { unique: true })\nexport class Identifier extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n did: string\n\n @Column({ nullable: true })\n //@ts-ignore\n provider?: string\n\n @Column({ nullable: true })\n //@ts-ignore\n alias?: string\n\n @BeforeInsert()\n setSaveDate() {\n this.saveDate = new Date()\n this.updateDate = new Date()\n }\n\n @BeforeUpdate()\n setUpdateDate() {\n this.updateDate = new Date()\n }\n\n @Column({ select: false })\n //@ts-ignore\n saveDate: Date\n\n @Column({ select: false })\n //@ts-ignore\n updateDate: Date\n\n @Column({ nullable: true })\n //@ts-ignore\n controllerKeyId?: string\n\n @OneToMany((type) => Key, (key) => key.identifier)\n //@ts-ignore\n keys: Key[]\n\n @OneToMany((type) => Service, (service) => service.identifier, {\n cascade: true,\n })\n //@ts-ignore\n services: Service[]\n\n @OneToMany((type) => Message, (message) => message.from)\n //@ts-ignore\n sentMessages: Message[]\n\n @OneToMany((type) => Message, (message) => message.to)\n //@ts-ignore\n receivedMessages: Message[]\n\n @OneToMany((type) => Presentation, (presentation) => presentation.holder)\n //@ts-ignore\n issuedPresentations: Presentation[]\n\n @ManyToMany((type) => Presentation, (presentation) => presentation.verifier)\n //@ts-ignore\n receivedPresentations: Presentation[]\n\n @OneToMany((type) => Credential, (credential) => credential.issuer)\n //@ts-ignore\n issuedCredentials: Credential[]\n\n @OneToMany((type) => Credential, (credential) => credential.subject)\n //@ts-ignore\n receivedCredentials: Credential[]\n\n @OneToMany((type) => Claim, (claim) => claim.issuer)\n //@ts-ignore\n issuedClaims: Claim[]\n\n @OneToMany((type) => Claim, (claim) => claim.subject)\n //@ts-ignore\n receivedClaims: Claim[]\n\n /**\n * Convenience method to get the most recent information about a subject DID as described by Verifiable Credential\n * claims.\n *\n * Example:\n * ```typescript\n * // get the latest claim value for credentials containing `credentialSubject.name` and this Identifier as subject.\n * const name = await identifier.getLatestClaimValue({type: 'name'})\n * ```\n *\n * @param where - The TypeORM `where` filter to use.\n */\n async getLatestClaimValue(\n dbConnection: Promise<Connection>,\n where: any,\n ): Promise<string | null | undefined> {\n const claim = await (await dbConnection).getRepository(Claim).findOne({\n where: {\n ...where,\n subject: this.did,\n },\n order: {\n issuanceDate: 'DESC',\n },\n })\n return claim?.value\n }\n\n shortDid() {\n return `${this.did.slice(0, 15)}...${this.did.slice(-4)}`\n }\n}\n","import { DataSource } from 'typeorm'\nimport { OrPromise } from \"@veramo/utils\";\n\n/**\n * Ensures that the provided DataSource is connected.\n *\n * @param dbConnection - a TypeORM DataSource or a Promise that resolves to a DataSource\n */\nexport async function getConnectedDb(dbConnection: OrPromise<DataSource>): Promise<DataSource> {\n if (dbConnection instanceof Promise) {\n return await dbConnection\n } else if (!dbConnection.isInitialized) {\n return await (<DataSource>dbConnection).initialize()\n } else {\n return dbConnection\n }\n}\n","import { IIdentifier, IKey } from '@veramo/core'\nimport { AbstractDIDStore } from '@veramo/did-manager'\nimport { Identifier } from '../entities/identifier'\nimport { Credential } from '../entities/credential'\nimport { Key } from '../entities/key'\nimport { Service } from '../entities/service'\nimport { DataSource, IsNull, Not } from 'typeorm'\n\nimport Debug from 'debug'\nimport { Presentation } from '../entities/presentation'\nimport { OrPromise } from \"@veramo/utils\";\nimport { getConnectedDb } from \"../utils\";\n\nconst debug = Debug('veramo:typeorm:identifier-store')\n\n/**\n * An implementation of {@link @veramo/did-manager#AbstractDIDStore | AbstractDIDStore} that uses a TypeORM database to\n * store the relationships between DIDs, their providers and controllers and their keys and services as they are known\n * and managed by a Veramo agent.\n *\n * An instance of this class can be used by {@link @veramo/did-manager#DIDManager} as the data storage layer.\n *\n * To make full use of this class, it should use the same database as the one used by\n * {@link @veramo/data-store#KeyStore | KeyStore}.\n *\n * @public\n */\nexport class DIDStore extends AbstractDIDStore {\n constructor(private dbConnection: OrPromise<DataSource>) {\n super()\n }\n\n async get({\n did,\n alias,\n provider,\n }: {\n did: string\n alias: string\n provider: string\n }): Promise<IIdentifier> {\n let where = {}\n if (did !== undefined && alias === undefined) {\n where = { did }\n } else if (did === undefined && alias !== undefined && provider !== undefined) {\n where = { alias, provider }\n } else {\n throw Error('[veramo:data-store:identifier-store] Get requires did or (alias and provider)')\n }\n\n const identifier = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).findOne({\n where,\n relations: ['keys', 'services'],\n })\n\n if (!identifier) throw Error('Identifier not found')\n const result: IIdentifier = {\n did: identifier.did,\n controllerKeyId: identifier.controllerKeyId,\n provider: identifier.provider!!,\n services: identifier.services.map((service) => {\n let endpoint = service.serviceEndpoint.toString()\n try {\n endpoint = JSON.parse(service.serviceEndpoint)\n } catch {}\n return {\n id: service.id,\n type: service.type,\n serviceEndpoint: endpoint,\n description: service.description,\n }\n }),\n keys: identifier.keys.map(\n (k) =>\n ({\n kid: k.kid,\n type: k.type,\n kms: k.kms,\n publicKeyHex: k.publicKeyHex,\n meta: k.meta,\n } as IKey),\n ),\n }\n if (identifier.alias) {\n result.alias = identifier.alias\n }\n return result\n }\n\n async delete({ did }: { did: string }) {\n const identifier = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).findOne({\n where: { did },\n relations: ['keys', 'services', 'issuedCredentials', 'issuedPresentations'],\n })\n if (!identifier || typeof identifier === 'undefined') {\n return true\n }\n // some drivers don't support cascading so we delete these manually\n\n //unlink existing keys that are no longer tied to this identifier\n let existingKeys = identifier.keys.map((key) => {\n delete key.identifier\n return key\n })\n await (await getConnectedDb(this.dbConnection)).getRepository(Key).save(existingKeys)\n\n if (identifier.issuedCredentials || typeof identifier.issuedCredentials !== 'undefined') {\n await (await getConnectedDb(this.dbConnection)).getRepository(Credential).remove(identifier.issuedCredentials)\n }\n\n if (identifier.issuedPresentations || typeof identifier.issuedPresentations !== 'undefined') {\n await (await getConnectedDb(this.dbConnection)).getRepository(Presentation).remove(identifier.issuedPresentations)\n }\n\n //delete existing services that are no longer tied to this identifier\n let oldServices = identifier.services\n const srvRepo = await (await getConnectedDb(this.dbConnection)).getRepository(Service).remove(oldServices)\n\n if (!identifier) throw Error('Identifier not found')\n debug('Deleting', did)\n await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).remove(identifier)\n\n return true\n }\n\n async import(args: IIdentifier) {\n const identifier = new Identifier()\n identifier.did = args.did\n if (args.controllerKeyId) {\n identifier.controllerKeyId = args.controllerKeyId\n }\n identifier.provider = args.provider\n if (args.alias) {\n identifier.alias = args.alias\n }\n\n identifier.keys = []\n for (const argsKey of args.keys) {\n const key = new Key()\n key.kid = argsKey.kid\n key.publicKeyHex = argsKey.publicKeyHex\n key.kms = argsKey.kms\n key.meta = argsKey.meta\n identifier.keys.push(key)\n }\n\n identifier.services = []\n for (const argsService of args.services) {\n const service = new Service()\n service.id = argsService.id\n service.type = argsService.type\n service.serviceEndpoint = (typeof argsService.serviceEndpoint === 'string') ? argsService.serviceEndpoint : JSON.stringify(argsService.serviceEndpoint)\n service.description = argsService.description\n identifier.services.push(service)\n }\n\n await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).save(identifier)\n\n debug('Saving', args.did)\n return true\n }\n\n async list(args: { alias?: string; provider?: string }): Promise<IIdentifier[]> {\n const where: any = { provider: args?.provider || Not(IsNull()) }\n if (args?.alias) {\n where['alias'] = args.alias\n }\n const identifiers = await (await getConnectedDb(this.dbConnection)).getRepository(Identifier).find({\n where,\n relations: ['keys', 'services'],\n })\n return identifiers.map((identifier) => {\n const i = identifier\n if (i.alias === null) {\n delete i.alias\n }\n return i as IIdentifier\n })\n }\n}\n","import { IKey, ManagedKeyInfo } from '@veramo/core'\nimport { AbstractKeyStore } from '@veramo/key-manager'\nimport { DataSource } from 'typeorm'\n\nimport { Key } from '../entities/key'\n\nimport Debug from 'debug'\nimport { OrPromise } from \"@veramo/utils\";\nimport { getConnectedDb } from \"../utils\";\nconst debug = Debug('veramo:typeorm:key-store')\n\n/**\n * An implementation of {@link @veramo/key-manager#AbstractKeyStore | AbstractKeyStore} that uses a TypeORM database to\n * store the relationships between keys, their IDs, aliases and\n * {@link @veramo/key-manager#AbstractKeyManagementSystem | KMS implementations}, as they are known and managed by a\n * Veramo agent.\n *\n * An instance of this class can be used by {@link @veramo/key-manager#KeyManager} as the data storage layer.\n *\n * To make full use of this class, it should use the same database as the one used by\n * {@link @veramo/data-store#DIDStore | DIDStore}.\n *\n * @public\n */\nexport class KeyStore extends AbstractKeyStore {\n constructor(private dbConnection: OrPromise<DataSource>) {\n super()\n }\n\n async get({ kid }: { kid: string }): Promise<IKey> {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(Key).findOneBy({ kid })\n if (!key) throw Error('Key not found')\n return key as IKey\n }\n\n async delete({ kid }: { kid: string }) {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(Key).findOneBy({ kid })\n if (!key) throw Error('Key not found')\n debug('Deleting key', kid)\n await (await getConnectedDb(this.dbConnection)).getRepository(Key).remove(key)\n return true\n }\n\n async import(args: IKey) {\n const key = new Key()\n key.kid = args.kid\n key.publicKeyHex = args.publicKeyHex\n key.type = args.type\n key.kms = args.kms\n key.meta = args.meta\n debug('Saving key', args.kid)\n await (await getConnectedDb(this.dbConnection)).getRepository(Key).save(key)\n return true\n }\n\n async list(args: {} = {}): Promise<ManagedKeyInfo[]> {\n const keys = await (await getConnectedDb(this.dbConnection)).getRepository(Key).find()\n const managedKeys: ManagedKeyInfo[] = keys.map((key) => {\n const { kid, publicKeyHex, type, meta, kms } = key\n return { kid, publicKeyHex, type, meta, kms } as IKey\n })\n return managedKeys\n }\n}\n","import { KeyType } from './key'\nimport { Entity, Column, PrimaryColumn, BaseEntity } from 'typeorm'\n\n/**\n * Represents some properties of a {@link @veramo/key-manager#ManagedPrivateKey | ManagedPrivateKey} that are stored in\n * a TypeORM database when using a {@link @veramo/data-store#PrivateKeyStore | PrivateKeyStore} to store private key\n * data.\n *\n * @see {@link @veramo/kms-local#KeyManagementSystem | KeyManagementSystem} for an implementation of a KMS that can\n * make use of such stored keys.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('private-key')\nexport class PrivateKey extends BaseEntity {\n @PrimaryColumn()\n //@ts-ignore\n alias: string\n\n @Column()\n //@ts-ignore\n type: KeyType\n\n @Column()\n //@ts-ignore\n privateKeyHex: string\n}\n","import { AbstractSecretBox, AbstractPrivateKeyStore } from '@veramo/key-manager'\nimport { DataSource } from 'typeorm'\nimport { ImportablePrivateKey, ManagedPrivateKey } from '@veramo/key-manager'\nimport { PrivateKey } from '../entities/private-key'\nimport { v4 as uuid4 } from 'uuid'\nimport Debug from 'debug'\nimport { OrPromise } from '@veramo/utils'\nimport { getConnectedDb } from '../utils'\n\nconst debug = Debug('veramo:typeorm:key-store')\n\n/**\n * An implementation of {@link @veramo/key-manager#AbstractPrivateKeyStore | AbstractPrivateKeyStore} that uses a\n * TypeORM database connection to store private key material.\n *\n * The keys can be encrypted while at rest if this class is initialized with an\n * {@link @veramo/key-manager#AbstractSecretBox | AbstractSecretBox} implementation.\n *\n * @public\n */\nexport class PrivateKeyStore extends AbstractPrivateKeyStore {\n constructor(private dbConnection: OrPromise<DataSource>, private secretBox?: AbstractSecretBox) {\n super()\n if (!secretBox) {\n console.warn('Please provide SecretBox to the KeyStore')\n }\n }\n\n async get({ alias }: { alias: string }): Promise<ManagedPrivateKey> {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).findOneBy({ alias })\n if (!key) throw Error('Key not found')\n if (this.secretBox && key.privateKeyHex) {\n key.privateKeyHex = await this.secretBox.decrypt(key.privateKeyHex)\n }\n return key as ManagedPrivateKey\n }\n\n async delete({ alias }: { alias: string }) {\n const key = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).findOneBy({ alias })\n if (!key) throw Error(`not_found: Private Key data not found for alias=${alias}`)\n debug('Deleting private key data', alias)\n await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).remove(key)\n return true\n }\n\n async import(args: ImportablePrivateKey): Promise<ManagedPrivateKey> {\n const key = new PrivateKey()\n key.alias = args.alias || uuid4()\n key.privateKeyHex = args.privateKeyHex\n if (this.secretBox && key.privateKeyHex) {\n key.privateKeyHex = await this.secretBox.encrypt(key.privateKeyHex)\n }\n key.type = args.type\n debug('Saving private key data', args.alias)\n const keyRepo = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey)\n const existingKey = await keyRepo.findOneBy({ alias: key.alias })\n if (existingKey && existingKey.privateKeyHex !== key.privateKeyHex) {\n throw new Error(\n `key_already_exists: A key with this alias exists but with different data. Please use a different alias.`,\n )\n }\n await keyRepo.save(key)\n return key\n }\n\n async list(): Promise<Array<ManagedPrivateKey>> {\n const keys = await (await getConnectedDb(this.dbConnection)).getRepository(PrivateKey).find()\n return keys\n }\n}\n","import {\n IAgentPlugin,\n IDataStore,\n IDataStoreDeleteVerifiableCredentialArgs,\n IDataStoreGetMessageArgs,\n IDataStoreGetVerifiableCredentialArgs,\n IDataStoreGetVerifiablePresentationArgs,\n IDataStoreSaveMessageArgs,\n IDataStoreSaveVerifiableCredentialArgs,\n IDataStoreSaveVerifiablePresentationArgs,\n IMessage,\n schema,\n VerifiableCredential,\n VerifiablePresentation,\n} from '@veramo/core'\nimport { createMessage, createMessageEntity, Message } from './entities/message'\nimport { createCredentialEntity, Credential } from './entities/credential'\nimport { Claim } from './entities/claim'\nimport { createPresentationEntity, Presentation } from './entities/presentation'\nimport { DataSource } from 'typeorm'\nimport { getConnectedDb } from './utils'\nimport { OrPromise } from '@veramo/utils'\n\n/**\n * This class implements the {@link @veramo/core#IDataStore} interface using a TypeORM compatible database.\n *\n * This allows you to store and retrieve Verifiable Credentials, Presentations and Messages by their IDs.\n *\n * For more complex queries you should use {@link @veramo/data-store#DataStoreORM} which is the default way to query\n * the stored data by some common properties. These two classes MUST also share the same database connection.\n *\n * @see {@link @veramo/core#IDataStoreORM}\n * @see {@link @veramo/core#IDataStore}\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\nexport class DataStore implements IAgentPlugin {\n readonly methods: IDataStore\n readonly schema = schema.IDataStore\n private dbConnection: OrPromise<DataSource>\n\n constructor(dbConnection: OrPromise<DataSource>) {\n this.dbConnection = dbConnection\n\n this.methods = {\n dataStoreSaveMessage: this.dataStoreSaveMessage.bind(this),\n dataStoreGetMessage: this.dataStoreGetMessage.bind(this),\n dataStoreDeleteVerifiableCredential: this.dataStoreDeleteVerifiableCredential.bind(this),\n dataStoreSaveVerifiableCredential: this.dataStoreSaveVerifiableCredential.bind(this),\n dataStoreGetVerifiableCredential: this.dataStoreGetVerifiableCredential.bind(this),\n dataStoreSaveVerifiablePresentation: this.dataStoreSaveVerifiablePresentation.bind(this),\n dataStoreGetVerifiablePresentation: this.dataStoreGetVerifiablePresentation.bind(this),\n }\n }\n\n async dataStoreSaveMessage(args: IDataStoreSaveMessageArgs): Promise<string> {\n const message = await (await getConnectedDb(this.dbConnection))\n .getRepository(Message)\n .save(createMessageEntity(args.message))\n return message.id\n }\n\n async dataStoreGetMessage(args: IDataStoreGetMessageArgs): Promise<IMessage> {\n const messageEntity = await (await getConnectedDb(this.dbConnection)).getRepository(Message).findOne({\n where: { id: args.id },\n relations: ['credentials', 'presentations'],\n })\n if (!messageEntity) throw new Error('not_found: Message not found')\n\n return createMessage(messageEntity)\n }\n\n async dataStoreDeleteVerifiableCredential(\n args: IDataStoreDeleteVerifiableCredentialArgs,\n ): Promise<boolean> {\n const credentialEntity = await (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .findOneBy({ hash: args.hash })\n if (!credentialEntity) {\n return false\n }\n\n const claims = await (await getConnectedDb(this.dbConnection))\n .getRepository(Claim)\n .find({ where: { credential: { id: credentialEntity.id } } })\n\n await (await getConnectedDb(this.dbConnection)).getRepository(Claim).remove(claims)\n\n await (await getConnectedDb(this.dbConnection)).getRepository(Credential).remove(credentialEntity)\n\n return true\n }\n\n async dataStoreSaveVerifiableCredential(args: IDataStoreSaveVerifiableCredentialArgs): Promise<string> {\n const verifiableCredential = await (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .save(createCredentialEntity(args.verifiableCredential))\n return verifiableCredential.hash\n }\n\n async dataStoreGetVerifiableCredential(\n args: IDataStoreGetVerifiableCredentialArgs,\n ): Promise<VerifiableCredential> {\n const credentialEntity = await (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .findOneBy({ hash: args.hash })\n if (!credentialEntity) throw new Error('not_found: Verifiable credential not found')\n\n return credentialEntity.raw\n }\n\n async dataStoreSaveVerifiablePresentation(args: IDataStoreSaveVerifiablePresentationArgs): Promise<string> {\n const verifiablePresentation = await (await getConnectedDb(this.dbConnection))\n .getRepository(Presentation)\n .save(createPresentationEntity(args.verifiablePresentation))\n return verifiablePresentation.hash\n }\n\n async dataStoreGetVerifiablePresentation(\n args: IDataStoreGetVerifiablePresentationArgs,\n ): Promise<VerifiablePresentation> {\n const presentationEntity = await (await getConnectedDb(this.dbConnection))\n .getRepository(Presentation)\n .findOneBy({ hash: args.hash })\n if (!presentationEntity) throw new Error('not_found: Verifiable presentation not found')\n\n return presentationEntity.raw\n }\n}\n","import {\n AuthorizedDIDContext,\n FindArgs,\n IAgentPlugin,\n IDataStoreORM,\n IIdentifier,\n IMessage,\n PartialIdentifier,\n schema,\n TClaimsColumns,\n TCredentialColumns,\n TIdentifiersColumns,\n TMessageColumns,\n TPresentationColumns,\n UniqueVerifiableCredential,\n UniqueVerifiablePresentation,\n Where,\n} from '@veramo/core'\nimport { createMessage, Message } from './entities/message'\nimport { Claim } from './entities/claim'\nimport { Credential } from './entities/credential'\nimport { Presentation } from './entities/presentation'\nimport { Identifier } from './entities/identifier'\nimport {\n Any,\n Between,\n Brackets,\n DataSource,\n Equal,\n In,\n IsNull,\n LessThan,\n LessThanOrEqual,\n Like,\n MoreThan,\n MoreThanOrEqual,\n Not,\n SelectQueryBuilder,\n} from 'typeorm'\nimport { getConnectedDb } from \"./utils\";\nimport { OrPromise } from \"@veramo/utils\";\n\n/**\n * This class implements the {@link @veramo/core#IDataStoreORM} query interface using a TypeORM compatible database.\n *\n * This allows you to filter Verifiable Credentials, Presentations and Messages by some common properties that are\n * parsed and stored in database tables.\n *\n * This class is designed to work with {@link @veramo/data-store#DataStore} which is the default way to populate the\n * database with Credentials, Presentations and Messages in such a way that they can be queried by this class.\n * These two classes MUST also share the same database connection.\n *\n * @see {@link @veramo/core#IDataStoreORM}\n * @see {@link @veramo/core#IDataStore}\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\nexport class DataStoreORM implements IAgentPlugin {\n readonly methods: IDataStoreORM\n readonly schema = schema.IDataStoreORM\n private dbConnection: OrPromise<DataSource>\n\n constructor(dbConnection: OrPromise<DataSource>) {\n this.dbConnection = dbConnection\n\n this.methods = {\n dataStoreORMGetIdentifiers: this.dataStoreORMGetIdentifiers.bind(this),\n dataStoreORMGetIdentifiersCount: this.dataStoreORMGetIdentifiersCount.bind(this),\n dataStoreORMGetMessages: this.dataStoreORMGetMessages.bind(this),\n dataStoreORMGetMessagesCount: this.dataStoreORMGetMessagesCount.bind(this),\n dataStoreORMGetVerifiableCredentialsByClaims:\n this.dataStoreORMGetVerifiableCredentialsByClaims.bind(this),\n dataStoreORMGetVerifiableCredentialsByClaimsCount:\n this.dataStoreORMGetVerifiableCredentialsByClaimsCount.bind(this),\n dataStoreORMGetVerifiableCredentials: this.dataStoreORMGetVerifiableCredentials.bind(this),\n dataStoreORMGetVerifiableCredentialsCount: this.dataStoreORMGetVerifiableCredentialsCount.bind(this),\n dataStoreORMGetVerifiablePresentations: this.dataStoreORMGetVerifiablePresentations.bind(this),\n dataStoreORMGetVerifiablePresentationsCount:\n this.dataStoreORMGetVerifiablePresentationsCount.bind(this),\n }\n }\n\n // Identifiers\n\n private async identifiersQuery(\n args: FindArgs<TIdentifiersColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Identifier>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Identifier)\n .createQueryBuilder('identifier')\n .leftJoinAndSelect('identifier.keys', 'keys')\n .leftJoinAndSelect('identifier.services', 'services')\n .where(where)\n qb = decorateQB(qb, 'message', args)\n return qb\n }\n\n async dataStoreORMGetIdentifiers(\n args: FindArgs<TIdentifiersColumns>,\n context: AuthorizedDIDContext,\n ): Promise<PartialIdentifier[]> {\n const identifiers = await (await this.identifiersQuery(args, context)).getMany()\n return identifiers.map((i) => {\n const identifier: PartialIdentifier = i as PartialIdentifier\n if (identifier.controllerKeyId === null) {\n delete identifier.controllerKeyId\n }\n if (identifier.alias === null) {\n delete identifier.alias\n }\n if (identifier.provider === null) {\n delete identifier.provider\n }\n return identifier as IIdentifier\n })\n }\n\n async dataStoreORMGetIdentifiersCount(\n args: FindArgs<TIdentifiersColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return await (await this.identifiersQuery(args, context)).getCount()\n }\n\n // Messages\n\n private async messagesQuery(\n args: FindArgs<TMessageColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Message>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Message)\n .createQueryBuilder('message')\n .leftJoinAndSelect('message.from', 'from')\n .leftJoinAndSelect('message.to', 'to')\n .leftJoinAndSelect('message.credentials', 'credentials')\n .leftJoinAndSelect('message.presentations', 'presentations')\n .where(where)\n qb = decorateQB(qb, 'message', args)\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('message.to = :ident', { ident: context.authorizedDID }).orWhere('message.from = :ident', {\n ident: context.authorizedDID,\n })\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetMessages(\n args: FindArgs<TMessageColumns>,\n context: AuthorizedDIDContext,\n ): Promise<IMessage[]> {\n const messages = await (await this.messagesQuery(args, context)).getMany()\n return messages.map(createMessage)\n }\n\n async dataStoreORMGetMessagesCount(\n args: FindArgs<TMessageColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.messagesQuery(args, context)).getCount()\n }\n\n // Claims\n\n private async claimsQuery(\n args: FindArgs<TClaimsColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Claim>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Claim)\n .createQueryBuilder('claim')\n .leftJoinAndSelect('claim.issuer', 'issuer')\n .leftJoinAndSelect('claim.subject', 'subject')\n .where(where)\n qb = decorateQB(qb, 'claim', args)\n qb = qb.leftJoinAndSelect('claim.credential', 'credential')\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('claim.subject = :ident', { ident: context.authorizedDID }).orWhere(\n 'claim.issuer = :ident',\n {\n ident: context.authorizedDID,\n },\n )\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetVerifiableCredentialsByClaims(\n args: FindArgs<TClaimsColumns>,\n context: AuthorizedDIDContext,\n ): Promise<Array<UniqueVerifiableCredential>> {\n // FIXME this breaks if args has order param\n const claims = await (await this.claimsQuery(args, context)).getMany()\n return claims.map((claim) => ({\n hash: claim.credential.hash,\n verifiableCredential: claim.credential.raw,\n }))\n }\n\n async dataStoreORMGetVerifiableCredentialsByClaimsCount(\n args: FindArgs<TClaimsColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.claimsQuery(args, context)).getCount()\n }\n\n // Credentials\n\n private async credentialsQuery(\n args: FindArgs<TCredentialColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Credential>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Credential)\n .createQueryBuilder('credential')\n .leftJoinAndSelect('credential.issuer', 'issuer')\n .leftJoinAndSelect('credential.subject', 'subject')\n .where(where)\n qb = decorateQB(qb, 'credential', args)\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('credential.subject = :ident', { ident: context.authorizedDID }).orWhere(\n 'credential.issuer = :ident',\n {\n ident: context.authorizedDID,\n },\n )\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetVerifiableCredentials(\n args: FindArgs<TCredentialColumns>,\n context: AuthorizedDIDContext,\n ): Promise<Array<UniqueVerifiableCredential>> {\n const credentials = await (await this.credentialsQuery(args, context)).getMany()\n return credentials.map((vc) => ({\n hash: vc.hash,\n verifiableCredential: vc.raw,\n }))\n }\n\n async dataStoreORMGetVerifiableCredentialsCount(\n args: FindArgs<TCredentialColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.credentialsQuery(args, context)).getCount()\n }\n\n // Presentations\n\n private async presentationsQuery(\n args: FindArgs<TPresentationColumns>,\n context: AuthorizedDIDContext,\n ): Promise<SelectQueryBuilder<Presentation>> {\n const where = createWhereObject(args)\n let qb = (await getConnectedDb(this.dbConnection))\n .getRepository(Presentation)\n .createQueryBuilder('presentation')\n .leftJoinAndSelect('presentation.holder', 'holder')\n .leftJoinAndSelect('presentation.verifier', 'verifier')\n .where(where)\n qb = decorateQB(qb, 'presentation', args)\n qb = addVerifierQuery(args, qb)\n if (context.authorizedDID) {\n qb = qb.andWhere(\n new Brackets((qb) => {\n qb.where('verifier.did = :ident', {\n ident: context.authorizedDID,\n }).orWhere('presentation.holder = :ident', { ident: context.authorizedDID })\n }),\n )\n }\n return qb\n }\n\n async dataStoreORMGetVerifiablePresentations(\n args: FindArgs<TPresentationColumns>,\n context: AuthorizedDIDContext,\n ): Promise<Array<UniqueVerifiablePresentation>> {\n const presentations = await (await this.presentationsQuery(args, context)).getMany()\n return presentations.map((vp) => ({\n hash: vp.hash,\n verifiablePresentation: vp.raw,\n }))\n }\n\n async dataStoreORMGetVerifiablePresentationsCount(\n args: FindArgs<TPresentationColumns>,\n context: AuthorizedDIDContext,\n ): Promise<number> {\n return (await this.presentationsQuery(args, context)).getCount()\n }\n}\n\nfunction opToSQL(item: Where<any>): any[] {\n switch (item.op) {\n case 'IsNull':\n return ['IS NULL', '']\n case 'Like':\n if (item.value?.length != 1) throw Error('Operation Equal requires one value')\n return ['LIKE :value', item.value[0]]\n case 'Equal':\n if (item.value?.length != 1) throw Error('Operation Equal requires one value')\n return ['= :value', item.value[0]]\n case 'Any':\n case 'Between':\n case 'LessThan':\n case 'LessThanOrEqual':\n case 'MoreThan':\n case 'MoreThanOrEqual':\n throw new Error(`${item.op} not compatible with DID argument`)\n case 'In':\n default:\n return ['IN (:...value)', item.value]\n }\n}\n\nfunction addVerifierQuery(input: FindArgs<any>, qb: SelectQueryBuilder<any>): SelectQueryBuilder<any> {\n if (!input) {\n return qb\n }\n if (!Array.isArray(input.where)) {\n return qb\n }\n const verifierWhere = input.where.find((item) => item.column === 'verifier')\n if (!verifierWhere) {\n return qb\n }\n const [op, value] = opToSQL(verifierWhere)\n return qb.andWhere(`verifier.did ${op}`, { value })\n}\n\nfunction createWhereObject(\n input: FindArgs<TMessageColumns | TClaimsColumns | TCredentialColumns | TPresentationColumns | TIdentifiersColumns>,\n): any {\n const where: Record<string, any> = {}\n if (input?.where) {\n for (const item of input.where) {\n if (item.column === 'verifier') {\n continue\n }\n switch (item.op) {\n case 'Any':\n if (!Array.isArray(item.value)) throw Error('Operator Any requires value to be an array')\n where[item.column] = Any(item.value)\n break\n case 'Between':\n if (item.value?.length != 2) throw Error('Operation Between requires two values')\n where[item.column] = Between(item.value[0], item.value[1])\n break\n case 'Equal':\n if (item.value?.length != 1) throw Error('Operation Equal requires one value')\n where[item.column] = Equal(item.value[0])\n break\n case 'IsNull':\n where[item.column] = IsNull()\n break\n case 'LessThan':\n if (item.value?.length != 1) throw Error('Operation LessThan requires one value')\n where[item.column] = LessThan(item.value[0])\n break\n case 'LessThanOrEqual':\n if (item.value?.length != 1) throw Error('Operation LessThanOrEqual requires one value')\n where[item.column] = LessThanOrEqual(item.value[0])\n break\n case 'Like':\n if (item.value?.length != 1) throw Error('Operation Like requires one value')\n where[item.column] = Like(item.value[0])\n break\n case 'MoreThan':\n if (item.value?.length != 1) throw Error('Operation MoreThan requires one value')\n where[item.column] = MoreThan(item.value[0])\n break\n case 'MoreThanOrEqual':\n if (item.value?.length != 1) throw Error('Operation MoreThanOrEqual requires one value')\n where[item.column] = MoreThanOrEqual(item.value[0])\n break\n case 'In':\n default:\n if (!Array.isArray(item.value)) throw Error('Operator IN requires value to be an array')\n where[item.column] = In(item.value)\n }\n if (item.not === true) {\n where[item.column] = Not(where[item.column])\n }\n }\n }\n return where\n}\n\nfunction decorateQB(\n qb: SelectQueryBuilder<any>,\n tableName: string,\n input: FindArgs<any>,\n): SelectQueryBuilder<any> {\n if (input?.skip) qb = qb.skip(input.skip)\n if (input?.take) qb = qb.take(input.take)\n\n if (input?.order) {\n for (const item of input.order) {\n qb = qb.orderBy(\n qb.connection.driver.escape(tableName) + '.' + qb.connection.driver.escape(item.column),\n item.direction,\n )\n }\n }\n return qb\n}\n","import { IAgentContext, IDataStoreORM } from '@veramo/core'\nimport {\n AbstractDidDiscoveryProvider,\n IDIDDiscoverMatch,\n IDIDDiscoveryProviderResult,\n IDIDDiscoveryDiscoverDidArgs,\n} from '@veramo/did-discovery'\n\n/**\n * This implementation of {@link @veramo/did-discovery#AbstractDidDiscoveryProvider | AbstractDidDiscoveryProvider}\n * helps you discover DIDs based on data that is stored by a local plugin that implements\n * {@link @veramo/core#IDataStoreORM | IDataStoreORM}.\n *\n * DIDs can be discovered by partial matches of `name` from `Profile` credentials, by partial matches of `alias` of\n * managed DIDs as well as partial matches of DIDs that are issuer or subject of credentials.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\nexport class DataStoreDiscoveryProvider implements AbstractDidDiscoveryProvider {\n readonly name = 'data-store-discovery'\n\n async discoverDid(\n args: IDIDDiscoveryDiscoverDidArgs,\n context: IAgentContext<IDataStoreORM>,\n ): Promise<IDIDDiscoveryProviderResult> {\n const matches: IDIDDiscoverMatch[] = []\n\n const credentialsByName = await context.agent.dataStoreORMGetVerifiableCredentialsByClaims({\n where: [\n { column: 'type', value: ['name'] },\n { column: 'value', value: [`%${args.query}%`], op: 'Like' },\n { column: 'credentialType', value: ['VerifiableCredential,Profile'] },\n ],\n })\n\n credentialsByName.forEach((vc) => {\n matches.push({\n did: vc.verifiableCredential.credentialSubject.id as string,\n metaData: {\n verifiableCredential: vc.verifiableCredential,\n },\n })\n })\n\n const credentialsByDID = await context.agent.dataStoreORMGetVerifiableCredentialsByClaims({\n where: [\n { column: 'type', value: ['name'] },\n { column: 'subject', value: [`%${args.query}%`], op: 'Like' },\n { column: 'credentialType', value: ['VerifiableCredential,Profile'] },\n ],\n })\n\n credentialsByDID.forEach((vc) => {\n matches.push({\n did: vc.verifiableCredential.credentialSubject.id as string,\n metaData: {\n verifiableCredential: vc.verifiableCredential,\n },\n })\n })\n\n const identifiersByDID = await context.agent.dataStoreORMGetIdentifiers({\n where: [\n { column: 'did', value: [`%${args.query}%`], op: 'Like' }\n ]\n })\n\n identifiersByDID.forEach((identifier) => {\n matches.push({\n did: identifier.did as string,\n metaData: {\n alias: identifier.alias\n }\n })\n })\n\n const identifiersByAlias = await context.agent.dataStoreORMGetIdentifiers({\n where: [\n { column: 'alias', value: [`%${args.query}%`], op: 'Like' }\n ]\n })\n\n identifiersByAlias.forEach((identifier) => {\n matches.push({\n did: identifier.did as string,\n metaData: {\n alias: identifier.alias\n }\n })\n })\n\n return {\n provider: this.name,\n matches,\n }\n }\n}\n","import { Column, Entity, PrimaryColumn } from 'typeorm'\nimport { Key } from './key'\n\n/**\n * This represents the private key data of keys that were stored by {@link @veramo/data-store#KeyStore} before Veramo\n * 3.0. During database migration this key material is moved to a different table and accessible by\n * {@link @veramo/data-store#PrivateKeyStore}.\n *\n * @beta This API may change without a BREAKING CHANGE notice.\n */\n@Entity('key', )\nexport class PreMigrationKey extends Key {\n // Key contains all the other columns present needed for successful migrations\n\n @PrimaryColumn()\n //@ts-ignore\n kid: string\n\n @Column({ nullable: true })\n privateKeyHex?: string\n}\n","import { QueryRunner, Table } from 'typeorm'\n\n/**\n * Get an existing table by name. Checks against givenTableName first, and tableName next. Throws an error if not found\n *\n * @param queryRunner The query runner object to use for querying\n * @param givenName The given name of the table to search for\n *\n * @public\n */\nexport function migrationGetExistingTableByName(queryRunner: QueryRunner, givenName: string, strictClassName?: boolean): Table {\n const table = migrationGetTableByNameImpl(queryRunner, givenName, strictClassName)\n if (!table) {\n throw Error(`Could not find table with name ${givenName}`)\n }\n return table\n}\n\n/**\n * Get an existing table by name. Checks against givenTableName first, and tableName next. Returns undefined if not found\n *\n * @param queryRunner The query runner object to use for querying\n * @param givenName The given name of the table to search for\n *\n * @private\n */\nfunction migrationGetTableByNameImpl(queryRunner: QueryRunner, givenName: string, strictClassName?: boolean): Table | undefined {\n let entityMetadata = queryRunner.connection.entityMetadatas.find((meta) => !!strictClassName ? meta.name === givenName : meta.givenTableName === givenName)\n if (!entityMetadata && !strictClassName) {\n // We are doing this separately as we don't want the above filter to use an or expression potentially matching first on tableName instead of givenTableName\n entityMetadata = queryRunner.connection.entityMetadatas.find((meta) => meta.tableName === givenName)\n }\n\n return entityMetadata ? Table.create(entityMetadata, queryRunner.connection.driver) : undefined\n}\n\n/**\n * Get a table name. Checks against givenTableName first, and tableName next from existing tables. Then returns the name. If not found returns the givenName argument\n *\n * @param queryRunner The query runner object to use for querying\n * @param givenName The given name of the table to search for\n *\n * @public\n */\nexport function migrationGetTableName(queryRunner: QueryRunner, givenName: string, strictClassName?: boolean): string {\n const table = migrationGetTableByNameImpl(queryRunner, givenName, strictClassName)\n return !!table ? table.name : givenName\n}\n","import { MigrationInterface, QueryRunner, Table } from 'typeorm'\nimport Debug from 'debug'\nimport { migrationGetTableName } from './migration-functions.js'\n\nconst debug = Debug('veramo:data-store:initial-migration')\n\n/**\n * Create the database layout for Veramo 3.0\n *\n * @public\n */\nexport class CreateDatabase1447159020001 implements MigrationInterface {\n\n name = 'CreateDatabase1447159020001' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n const dateTimeType: string = queryRunner.connection.driver.mappedDataTypes.createDate as string\n\n debug(`creating identifier table`)\n // \"CREATE TABLE \\\"identifier\\\" (\\\"did\\\" varchar PRIMARY KEY NOT NULL, \\\"provider\\\" varchar, \\\"alias\\\" varchar, \\\"saveDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"updateDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"controllerKeyId\\\" varchar)\",\n // \"CREATE UNIQUE INDEX \\\"IDX_6098cca69c838d91e55ef32fe1\\\" ON \\\"identifier\\\" (\\\"alias\\\", \\\"provider\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner,'identifier'),\n columns: [\n { name: 'did', type: 'varchar', isPrimary: true },\n { name: 'provider', type: 'varchar', isNullable: true },\n { name: 'alias', type: 'varchar', isNullable: true },\n { name: 'saveDate', type: dateTimeType },\n { name: 'updateDate', type: dateTimeType },\n { name: 'controllerKeyId', type: 'varchar', isNullable: true },\n ],\n indices: [\n {\n columnNames: ['alias', 'provider'],\n isUnique: true,\n },\n ],\n }),\n true,\n )\n\n debug(`creating key table`)\n // \"CREATE TABLE \\\"key\\\" (\\\"kid\\\" varchar PRIMARY KEY NOT NULL, \\\"kms\\\" varchar NOT NULL, \\\"type\\\" varchar NOT NULL, \\\"publicKeyHex\\\" varchar NOT NULL, \\\"privateKeyHex\\\" varchar NOT NULL, \\\"meta\\\" text, \\\"identifierDid\\\" varchar, CONSTRAINT \\\"FK_3f40a9459b53adf1729dbd3b787\\\" FOREIGN KEY (\\\"identifierDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner,'key'),\n columns: [\n { name: 'kid', type: 'varchar', isPrimary: true },\n { name: 'kms', type: 'varchar' },\n { name: 'type', type: 'varchar' },\n { name: 'publicKeyHex', type: 'varchar' },\n { name: 'privateKeyHex', type: 'varchar', isNullable: true },\n { name: 'meta', type: 'text', isNullable: true },\n { name: 'identifierDid', type: 'varchar' },\n ],\n foreignKeys: [\n {\n columnNames: ['identifierDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n ],\n }),\n true,\n )\n\n debug(`creating service table`)\n // \"CREATE TABLE \\\"service\\\" (\\\"id\\\" varchar PRIMARY KEY NOT NULL, \\\"type\\\" varchar NOT NULL, \\\"serviceEndpoint\\\" varchar NOT NULL, \\\"description\\\" varchar, \\\"identifierDid\\\" varchar, CONSTRAINT \\\"FK_e16e0280d906951809f95dd09f1\\\" FOREIGN KEY (\\\"identifierDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'service'),\n columns: [\n { name: 'id', type: 'varchar', isPrimary: true },\n { name: 'type', type: 'varchar' },\n { name: 'serviceEndpoint', type: 'varchar' },\n { name: 'description', type: 'varchar', isNullable: true },\n { name: 'identifierDid', type: 'varchar' },\n ],\n foreignKeys: [\n {\n columnNames: ['identifierDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating credentials table`)\n // \"CREATE TABLE \\\"credential\\\" (\\\"hash\\\" varchar PRIMARY KEY NOT NULL, \\\"raw\\\" text NOT NULL, \\\"id\\\" varchar, \\\"issuanceDate\\\" datetime NOT NULL, \\\"expirationDate\\\" datetime, \\\"context\\\" text NOT NULL, \\\"type\\\" text NOT NULL, \\\"issuerDid\\\" varchar, \\\"subjectDid\\\" varchar, CONSTRAINT \\\"FK_123d0977e0976565ee0932c0b9e\\\" FOREIGN KEY (\\\"issuerDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_b790831f44e2fa7f9661a017b0a\\\" FOREIGN KEY (\\\"subjectDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'credential'),\n columns: [\n { name: 'hash', type: 'varchar', isPrimary: true },\n { name: 'raw', type: 'text' },\n { name: 'id', type: 'varchar', isNullable: true },\n { name: 'issuanceDate', type: dateTimeType },\n { name: 'expirationDate', type: dateTimeType, isNullable: true },\n { name: 'context', type: 'text' },\n { name: 'type', type: 'text' },\n { name: 'issuerDid', type: 'varchar' },\n { name: 'subjectDid', type: 'varchar', isNullable: true },\n ],\n foreignKeys: [\n {\n columnNames: ['issuerDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['subjectDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n ],\n }),\n true,\n )\n\n debug(`creating claims table`)\n // \"CREATE TABLE \\\"claim\\\" (\\\"hash\\\" varchar PRIMARY KEY NOT NULL, \\\"issuanceDate\\\" datetime NOT NULL, \\\"expirationDate\\\" datetime, \\\"context\\\" text NOT NULL, \\\"credentialType\\\" text NOT NULL, \\\"type\\\" varchar NOT NULL, \\\"value\\\" text, \\\"isObj\\\" boolean NOT NULL, \\\"issuerDid\\\" varchar, \\\"subjectDid\\\" varchar, \\\"credentialHash\\\" varchar, CONSTRAINT \\\"FK_d972c73d0f875c0d14c35b33baa\\\" FOREIGN KEY (\\\"issuerDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_f411679379d373424100a1c73f4\\\" FOREIGN KEY (\\\"subjectDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_3d494b79143de3d0e793883e351\\\" FOREIGN KEY (\\\"credentialHash\\\") REFERENCES \\\"credential\\\" (\\\"hash\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'claim'),\n columns: [\n { name: 'hash', type: 'varchar', isPrimary: true },\n { name: 'issuanceDate', type: dateTimeType },\n { name: 'expirationDate', type: dateTimeType, isNullable: true },\n { name: 'context', type: 'text' },\n { name: 'credentialType', type: 'text' },\n { name: 'value', type: 'text' },\n { name: 'type', type: 'varchar' },\n { name: 'isObj', type: 'boolean' },\n { name: 'issuerDid', type: 'varchar', isNullable: true },\n { name: 'subjectDid', type: 'varchar', isNullable: true },\n { name: 'credentialHash', type: 'varchar' },\n ],\n foreignKeys: [\n {\n columnNames: ['issuerDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['subjectDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n {\n columnNames: ['credentialHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'credential'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating presentations table`)\n // \"CREATE TABLE \\\"presentation\\\" (\\\"hash\\\" varchar PRIMARY KEY NOT NULL, \\\"raw\\\" text NOT NULL, \\\"id\\\" varchar, \\\"issuanceDate\\\" datetime NOT NULL, \\\"expirationDate\\\" datetime, \\\"context\\\" text NOT NULL, \\\"type\\\" text NOT NULL, \\\"holderDid\\\" varchar, CONSTRAINT \\\"FK_a5e418449d9f527776a3bd0ca61\\\" FOREIGN KEY (\\\"holderDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'presentation'),\n columns: [\n { name: 'hash', type: 'varchar', isPrimary: true },\n { name: 'raw', type: 'text' },\n { name: 'id', type: 'varchar', isNullable: true },\n { name: 'issuanceDate', type: dateTimeType },\n { name: 'expirationDate', type: dateTimeType, isNullable: true },\n { name: 'context', type: 'text' },\n { name: 'type', type: 'text' },\n { name: 'holderDid', type: 'varchar', isNullable: true },\n ],\n foreignKeys: [\n {\n columnNames: ['holderDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating message table`)\n // \"CREATE TABLE \\\"message\\\" (\\\"id\\\" varchar PRIMARY KEY NOT NULL, \\\"saveDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"updateDate\\\" datetime NOT NULL DEFAULT (datetime('now')), \\\"createdAt\\\" datetime, \\\"expiresAt\\\" datetime, \\\"threadId\\\" varchar, \\\"type\\\" varchar NOT NULL, \\\"raw\\\" varchar, \\\"data\\\" text, \\\"replyTo\\\" text, \\\"replyUrl\\\" varchar, \\\"metaData\\\" text, \\\"fromDid\\\" varchar, \\\"toDid\\\" varchar, CONSTRAINT \\\"FK_63bf73143b285c727bd046e6710\\\" FOREIGN KEY (\\\"fromDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT \\\"FK_1a666b2c29bb2b68d91259f55df\\\" FOREIGN KEY (\\\"toDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE NO ACTION ON UPDATE NO ACTION)\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'message'),\n columns: [\n { name: 'id', type: 'varchar', isPrimary: true },\n { name: 'saveDate', type: dateTimeType },\n { name: 'updateDate', type: dateTimeType },\n { name: 'createdAt', type: dateTimeType, isNullable: true },\n { name: 'expiresAt', type: dateTimeType, isNullable: true },\n { name: 'threadId', type: 'varchar', isNullable: true },\n { name: 'type', type: 'varchar', isNullable: true },\n { name: 'raw', type: 'varchar', isNullable: true },\n { name: 'data', type: 'text', isNullable: true },\n { name: 'replyTo', type: 'text', isNullable: true },\n { name: 'replyUrl', type: 'varchar', isNullable: true },\n { name: 'metaData', type: 'text', isNullable: true },\n { name: 'fromDid', type: 'varchar', isNullable: true },\n { name: 'toDid', type: 'varchar', isNullable: true },\n ],\n foreignKeys: [\n {\n columnNames: ['fromDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n {\n columnNames: ['toDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n },\n ],\n }),\n true,\n )\n\n debug(`creating presentation_verifier_identifier many to many table`)\n // \"CREATE TABLE \\\"presentation_verifier_identifier\\\" (\\\"presentationHash\\\" varchar NOT NULL, \\\"identifierDid\\\" varchar NOT NULL, CONSTRAINT \\\"FK_05b1eda0f6f5400cb173ebbc086\\\" FOREIGN KEY (\\\"presentationHash\\\") REFERENCES \\\"presentation\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_3a460e48557bad5564504ddad90\\\" FOREIGN KEY (\\\"identifierDid\\\") REFERENCES \\\"identifier\\\" (\\\"did\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"presentationHash\\\", \\\"identifierDid\\\"))\",\n // \"CREATE INDEX \\\"IDX_05b1eda0f6f5400cb173ebbc08\\\" ON \\\"presentation_verifier_identifier\\\" (\\\"presentationHash\\\")\",\n // \"CREATE INDEX \\\"IDX_3a460e48557bad5564504ddad9\\\" ON \\\"presentation_verifier_identifier\\\" (\\\"identifierDid\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'presentation_verifier_identifier'),\n columns: [\n { name: 'presentationHash', type: 'varchar', isPrimary: true },\n { name: 'identifierDid', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['presentationHash', 'identifierDid'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['presentationHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'presentation'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['identifierDid'],\n referencedColumnNames: ['did'],\n referencedTableName: migrationGetTableName(queryRunner, 'identifier'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating presentation_credentials_credential many to many table`)\n // \"CREATE TABLE \\\"presentation_credentials_credential\\\" (\\\"presentationHash\\\" varchar NOT NULL, \\\"credentialHash\\\" varchar NOT NULL, CONSTRAINT \\\"FK_d796bcde5e182136266b2a6b72c\\\" FOREIGN KEY (\\\"presentationHash\\\") REFERENCES \\\"presentation\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_ef88f92988763fee884c37db63b\\\" FOREIGN KEY (\\\"credentialHash\\\") REFERENCES \\\"credential\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"presentationHash\\\", \\\"credentialHash\\\"))\",\n // \"CREATE INDEX \\\"IDX_d796bcde5e182136266b2a6b72\\\" ON \\\"presentation_credentials_credential\\\" (\\\"presentationHash\\\")\",\n // \"CREATE INDEX \\\"IDX_ef88f92988763fee884c37db63\\\" ON \\\"presentation_credentials_credential\\\" (\\\"credentialHash\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'presentation_credentials_credential'),\n columns: [\n { name: 'presentationHash', type: 'varchar', isPrimary: true },\n { name: 'credentialHash', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['presentationHash', 'credentialHash'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['presentationHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'presentation'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['credentialHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'credential'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating message_presentations_presentation many to many table`)\n // \"CREATE TABLE \\\"message_presentations_presentation\\\" (\\\"messageId\\\" varchar NOT NULL, \\\"presentationHash\\\" varchar NOT NULL, CONSTRAINT \\\"FK_7e7094f2cd6e5ec93914ac5138f\\\" FOREIGN KEY (\\\"messageId\\\") REFERENCES \\\"message\\\" (\\\"id\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_a13b5cf828c669e61faf489c182\\\" FOREIGN KEY (\\\"presentationHash\\\") REFERENCES \\\"presentation\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"messageId\\\", \\\"presentationHash\\\"))\",\n // \"CREATE INDEX \\\"IDX_7e7094f2cd6e5ec93914ac5138\\\" ON \\\"message_presentations_presentation\\\" (\\\"messageId\\\")\",\n // \"CREATE INDEX \\\"IDX_a13b5cf828c669e61faf489c18\\\" ON \\\"message_presentations_presentation\\\" (\\\"presentationHash\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'message_presentations_presentation'),\n columns: [\n { name: 'messageId', type: 'varchar', isPrimary: true },\n { name: 'presentationHash', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['messageId', 'presentationHash'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['messageId'],\n referencedColumnNames: ['id'],\n referencedTableName: migrationGetTableName(queryRunner, 'message'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['presentationHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'presentation'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n\n debug(`creating message_credentials_credential many to many table`)\n // \"CREATE TABLE \\\"message_credentials_credential\\\" (\\\"messageId\\\" varchar NOT NULL, \\\"credentialHash\\\" varchar NOT NULL, CONSTRAINT \\\"FK_1c111357e73db91a08525914b59\\\" FOREIGN KEY (\\\"messageId\\\") REFERENCES \\\"message\\\" (\\\"id\\\") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT \\\"FK_8ae8195a94b667b185d2c023e33\\\" FOREIGN KEY (\\\"credentialHash\\\") REFERENCES \\\"credential\\\" (\\\"hash\\\") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY (\\\"messageId\\\", \\\"credentialHash\\\"))\",\n // \"CREATE INDEX \\\"IDX_1c111357e73db91a08525914b5\\\" ON \\\"message_credentials_credential\\\" (\\\"messageId\\\")\",\n // \"CREATE INDEX \\\"IDX_8ae8195a94b667b185d2c023e3\\\" ON \\\"message_credentials_credential\\\" (\\\"credentialHash\\\")\",\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'message_credentials_credential'),\n columns: [\n { name: 'messageId', type: 'varchar', isPrimary: true },\n { name: 'credentialHash', type: 'varchar', isPrimary: true },\n ],\n indices: [\n {\n columnNames: ['messageId', 'credentialHash'],\n },\n ],\n foreignKeys: [\n {\n columnNames: ['messageId'],\n referencedColumnNames: ['id'],\n referencedTableName: migrationGetTableName(queryRunner, 'message'),\n onDelete: 'cascade',\n },\n {\n columnNames: ['credentialHash'],\n referencedColumnNames: ['hash'],\n referencedTableName: migrationGetTableName(queryRunner, 'credential'),\n onDelete: 'cascade',\n },\n ],\n }),\n true,\n )\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n throw new Error('illegal_operation: cannot roll back initial migration')\n }\n}\n","import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'\nimport { migrationGetExistingTableByName } from './migration-functions'\nimport { PreMigrationKey } from '../entities/PreMigrationEntities'\n\n/**\n * Fix inconsistencies between Entity data and column data.\n *\n * @public\n */\nexport class SimplifyRelations1447159020002 implements MigrationInterface {\n\n name = 'SimplifyRelations1447159020002' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.changeColumn(\n migrationGetExistingTableByName(queryRunner, 'PreMigrationKey', true),\n 'identifierDid',\n new TableColumn({ name: 'identifierDid', type: 'varchar', isNullable: true }),\n )\n await queryRunner.changeColumn(\n migrationGetExistingTableByName(queryRunner, 'service'),\n 'identifierDid',\n new TableColumn({ name: 'identifierDid', type: 'varchar', isNullable: true }),\n )\n\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n throw new Error('illegal_operation: cannot roll back initial migration')\n }\n}\n","import { MigrationInterface, QueryRunner, Table, TableColumn } from 'typeorm'\nimport { PrivateKey } from '..'\nimport { PreMigrationKey } from '../entities/PreMigrationEntities'\nimport Debug from 'debug'\nimport { migrationGetExistingTableByName, migrationGetTableName } from './migration-functions'\n\nconst debug = Debug('veramo:data-store:migrate-private-keys')\n\n/**\n * Migration of existing private keys from Veramo 2.x to Veramo 3.x\n *\n * @public\n */\nexport class CreatePrivateKeyStorage1629293428674 implements MigrationInterface {\n\n name = 'CreatePrivateKeyStorage1629293428674' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n // 1.create new table\n debug(`creating new private-key table`)\n await queryRunner.createTable(\n new Table({\n name: migrationGetTableName(queryRunner, 'private-key'),\n columns: [\n {\n name: 'alias',\n type: 'varchar',\n isPrimary: true,\n },\n {\n name: 'type',\n type: 'varchar',\n },\n {\n name: 'privateKeyHex',\n type: 'varchar',\n },\n ],\n }),\n true,\n )\n // 2. copy key data\n const keys: PreMigrationKey[] = await queryRunner.manager.find(PreMigrationKey)\n debug(`got ${keys.length} potential keys to migrate`)\n const privKeys = keys\n .filter((key) => typeof key.privateKeyHex !== 'undefined' && key.privateKeyHex !== null)\n .map((key) => ({\n alias: key.kid,\n type: key.type,\n privateKeyHex: key.privateKeyHex,\n }))\n debug(`${privKeys.length} keys need to be migrated`)\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(migrationGetTableName(queryRunner, 'private-key'))\n .values(privKeys)\n .execute()\n // 3. drop old column\n debug(`dropping privKeyHex column from old key table`)\n await queryRunner.dropColumn(migrationGetExistingTableByName(queryRunner, 'PreMigrationKey', true), 'privateKeyHex')\n //4. done\n debug(`migrated ${privKeys.length} keys to private key storage`)\n\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n\n // 1. add old column back\n debug(`adding back privateKeyHex column to key table`)\n await queryRunner.addColumn(\n 'key',\n new TableColumn({\n name: 'privateKeyHex',\n type: 'varchar',\n isNullable: true,\n }),\n )\n // 2. copy key data\n debug(`checking keys to be rolled back`)\n const keys: PrivateKey[] = await queryRunner.manager.find(PrivateKey)\n debug(`copying ${keys.length} keys`)\n for (const key of keys) {\n await queryRunner.manager\n .createQueryBuilder()\n .update(PreMigrationKey)\n .set({ privateKeyHex: key.privateKeyHex })\n .where('kid = :alias', { alias: key.alias })\n .execute()\n }\n debug(`dropping private-key table`)\n // 3. drop the new private key table\n await queryRunner.dropTable(migrationGetExistingTableByName(queryRunner, 'private-key'))\n // 4. done\n debug(`rolled back ${keys.length} keys`)\n }\n}\n","import { MigrationInterface, QueryRunner } from 'typeorm'\nimport { Presentation } from '..'\nimport Debug from 'debug'\nimport { migrationGetExistingTableByName } from './migration-functions.js'\n\nconst debug = Debug('veramo:data-store:migrate-presentation-issuance-date')\n\n/**\n * Reduce issuanceDate constraint of Presentations.\n *\n * @public\n */\nexport class AllowNullIssuanceDateForPresentations1637237492913 implements MigrationInterface {\n\n name = 'AllowNullIssuanceDateForPresentations1637237492913' // Used in case this class gets minified, which would change the classname\n\n async up(queryRunner: QueryRunner): Promise<void> {\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning off foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=off')\n await queryRunner.startTransaction()\n }\n\n // update issuanceDate column\n const table = migrationGetExistingTableByName(queryRunner, 'presentation')\n const oldColumn = table?.findColumnByName('issuanceDate')!\n const newColumn = oldColumn.clone()\n newColumn.isNullable = true\n debug(`updating issuanceDate for presentations to allow null`)\n await queryRunner.changeColumn(table!, oldColumn, newColumn)\n debug(`updated issuanceDate for presentations to allow null`)\n\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning on foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=on')\n await queryRunner.startTransaction()\n }\n }\n\n async down(queryRunner: QueryRunner): Promise<void> {\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning off foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=off')\n await queryRunner.startTransaction()\n }\n\n const table = migrationGetExistingTableByName(queryRunner, 'presentation')\n debug(`DOWN update NULL 'issuanceDate' with FAKE data for '${table.name}' table`)\n await queryRunner.manager\n .createQueryBuilder()\n .update(Presentation)\n .set({ issuanceDate: new Date(0) })\n .where('issuanceDate is NULL')\n .execute()\n // update issuanceDate column\n\n const oldColumn = table?.findColumnByName('issuanceDate')!\n const newColumn = oldColumn.clone()\n newColumn.isNullable = false\n debug(`updating issuanceDate for presentations to NOT allow null`)\n await queryRunner.changeColumn(table!, oldColumn, newColumn)\n debug(`updated issuanceDate for presentations to NOT allow null`)\n\n if (queryRunner.connection.driver.options.type === 'sqlite') {\n debug(`splitting migration into multiple transactions to allow sqlite table updates`)\n await queryRunner.commitTransaction()\n debug(`turning on foreign keys`)\n await queryRunner.query('PRAGMA foreign_keys=on')\n await queryRunner.startTransaction()\n }\n\n debug(`DOWN updated issuanceDate for presentations to NOT allow null`)\n }\n}\n","import { CreateDatabase1447159020001 } from './1.createDatabase'\nimport { SimplifyRelations1447159020002 } from './2.simplifyRelations'\nimport { CreatePrivateKeyStorage1629293428674 } from './3.createPrivateKeyStorage'\nimport { AllowNullIssuanceDateForPresentations1637237492913 } from './4.allowNullVPIssuanceDate'\n\n\n/**\n * Allow others to use shared migration functions if they extend Veramo\n *\n * @public\n */\nexport * from './migration-functions.js'\n\n/**\n * The migrations array that SHOULD be used when initializing a TypeORM database connection.\n *\n * These ensure the correct creation of tables and the proper migrations of data when tables change between versions.\n *\n * @public\n */\n\nexport const migrations = [\n CreateDatabase1447159020001,\n SimplifyRelations1447159020002,\n CreatePrivateKeyStorage1629293428674,\n AllowNullIssuanceDateForPresentations1637237492913,\n]\n","/**\n * {@link https://typeorm.io/ | TypeORM } backed plugins. {@link @veramo/core#Agent}\n * {@link @veramo/data-store#DataStore | plugin} that implements {@link @veramo/core#IDataStore } interface.\n * {@link @veramo/core#Agent} {@link @veramo/data-store#DataStoreORM | plugin} that implements\n * {@link @veramo/core#IDataStoreORM} interface. Provides {@link @veramo/data-store#KeyStore} for\n * {@link @veramo/key-manager#KeyManager} and {@link @veramo/data-store#DIDStore} for\n * {@link @veramo/did-manager#DIDManager}\n *\n * @packageDocumentation\n */\n\nexport { DIDStore } from './identifier/did-store'\nexport { KeyStore } from './identifier/key-store'\nexport { PrivateKeyStore } from './identifier/private-key-store'\nexport { DataStore } from './data-store'\nexport { DataStoreORM } from './data-store-orm'\nexport { DataStoreDiscoveryProvider } from './did-discovery-provider'\nimport { Key, KeyType } from './entities/key'\nimport { Identifier } from './entities/identifier'\nimport { Claim } from './entities/claim'\nimport { Credential } from './entities/credential'\nimport { Presentation } from './entities/presentation'\nimport { Service } from './entities/service'\nimport { Message, MetaData } from './entities/message'\nimport { PrivateKey } from './entities/private-key'\nimport { PreMigrationKey } from './entities/PreMigrationEntities'\n\n/**\n * The TypeORM entities used by this package.\n *\n * This array SHOULD be used when creating a TypeORM connection.\n *\n * @public\n */\nexport const Entities = [\n Key,\n Identifier,\n Message,\n Claim,\n Credential,\n Presentation,\n Service,\n PrivateKey,\n PreMigrationKey,\n]\nexport {\n KeyType,\n Key,\n Identifier,\n Message,\n Claim,\n Credential,\n Presentation,\n MetaData,\n Service,\n PrivateKey,\n PreMigrationKey,\n}\nexport { migrations } from './migrations'\n\n// re-export the interfaces that were moved to core for backward compatibility\nexport { IDataStore, IDataStoreORM } from '@veramo/core'\n","{\n \"IWellKnownDidIssuer\": {\n \"components\": {\n \"schemas\": {\n \"IIssueDidConfigurationResourceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuances\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"additionalProperties\": true\n }\n }\n },\n \"credentialIssuance\": {\n \"type\": \"string\"\n },\n \"save\": {\n \"type\": \"boolean\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"issuances\", \"credentialIssuance\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.addLinkedDomainsService } \"\n },\n \"IIssueDomainLinkageCredentialArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"did\": {\n \"type\": \"string\"\n },\n \"origin\": {\n \"type\": \"string\"\n },\n \"serviceId\": {\n \"type\": \"string\"\n },\n \"issuanceDate\": {\n \"type\": \"date\"\n },\n \"expirationDate\": {\n \"type\": \"date\"\n },\n \"save\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"type\": \"object\",\n \"properties\": {\n \"additionalProperties\": true\n }\n },\n \"credentialIssuance\": {\n \"type\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"did\", \"origin\", \"expirationDate\", \"options\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.issueDomainLinkageCredential } \"\n },\n \"IGetDidConfigurationResourceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"origin\": {\n \"type\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"origin\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.getDidConfigurationResource } \"\n },\n \"IAddLinkedDomainsServiceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"did\": {\n \"type\": \"string\"\n },\n \"origin\": {\n \"type\": \"string\"\n },\n \"serviceId\": {\n \"type\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"did\", \"origin\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.addLinkedDomainsService } \"\n },\n \"ISaveDidConfigurationResourceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"origin\": {\n \"type\": \"string\"\n },\n \"didConfigurationResource\": {\n \"type\": \"object\",\n \"properties\": {\n \"additionalProperties\": true\n }\n },\n \"additionalProperties\": false\n },\n \"required\": [\"did\", \"origin\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.saveDidConfigurationResource } \"\n },\n \"IRemoveCredentialIssuanceArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"origin\": {\n \"callbackName\": \"string\"\n },\n \"additionalProperties\": false\n },\n \"required\": [\"callbackName\"],\n \"description\": \"Arguments needed for {@link IWellKnownDidIssuer.removeCredentialIssuance } \"\n }\n },\n \"methods\": {\n \"addLinkedDomainsService\": {\n \"description\": \"Adds a LinkedDomains service to the DID\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IAddLinkedDomainsServiceArgs\"\n }\n },\n \"getDidConfigurationResource\": {\n \"description\": \"Retrieves a DID configuration resource from the database\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IGetDidConfigurationResourceArgs\"\n },\n \"returnType\": \"object\"\n },\n \"issueDidConfigurationResource\": {\n \"description\": \"Issues a DID configuration resource\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IAddLinkedDomainsServiceArgs\"\n },\n \"returnType\": \"object\"\n },\n \"issueDomainLinkageCredential\": {\n \"description\": \"Retrieves a domain linkage credential\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IIssueDomainLinkageCredentialArgs\"\n },\n \"returnType\": \"object\"\n },\n \"removeCredentialIssuance\": {\n \"description\": \"Removes a registered callback\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IRemoveCredentialIssuanceArgs\"\n },\n \"returnType\": \"boolean\"\n },\n \"saveDidConfigurationResource\": {\n \"description\": \"Saves a DID configuration resource to the database\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/ISaveDidConfigurationResourceArgs\"\n }\n }\n }\n }\n }\n}\n","import { DidConfigurationResourceEntity } from './entities/DidConfigurationResourceEntity'\n\n/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { DidConfigurationResourceEntity } from './entities/DidConfigurationResourceEntity'\nexport { WellKnownDidIssuer } from './agent/WellKnownDidIssuer'\nexport * from './types/IWellKnownDidIssuer'\nexport const WellknownDidIssuerEntities = [DidConfigurationResourceEntity]\nexport { WellknownDidIssuerMigrations } from './migrations'\n","import { DomainLinkageCredential, IDidConfigurationResource, ISignedDomainLinkageCredential } from '@sphereon/wellknown-dids-client'\nimport { VerifiableCredential } from '@veramo/core'\nimport { Credential, Identifier, Claim } from '@veramo/data-store'\nimport { asArray, computeEntryHash, extractIssuer } from '@veramo/utils'\nimport { Entity, Column, PrimaryColumn, CreateDateColumn, UpdateDateColumn, ManyToMany, JoinTable, BaseEntity } from 'typeorm'\n\n@Entity('DidConfigurationResource')\nexport class DidConfigurationResourceEntity extends BaseEntity {\n @PrimaryColumn({ nullable: false })\n origin!: string\n\n @Column({ nullable: false })\n context!: string\n\n // TODO cascade of delete should be true when the VC is only attached to one DID configuration resource\n @ManyToMany(() => Credential, (credential: Credential) => credential.hash, { nullable: false, cascade: true, onDelete: 'NO ACTION' })\n @JoinTable({ name: 'DidConfigurationResourceCredentials' })\n linkedDids!: Array<Credential>\n\n @CreateDateColumn({ name: 'created_at', nullable: false })\n createdAt!: Date\n\n @UpdateDateColumn({ name: 'last_updated_at', nullable: false })\n lastUpdatedAt!: Date\n}\n\nexport const didConfigurationResourceFrom = (didConfigurationResource: DidConfigurationResourceEntity): IDidConfigurationResource => {\n return {\n '@context': didConfigurationResource.context,\n linked_dids: linkedDidsFrom(didConfigurationResource.linkedDids),\n }\n}\n\nconst linkedDidsFrom = (credentials: Array<Credential>): Array<DomainLinkageCredential> => {\n return credentials.map((credential: Credential) =>\n credential?.raw?.proof?.type === 'JwtProof2020' && typeof credential?.raw?.proof?.jwt === 'string'\n ? credential.raw.proof.jwt\n : (credential.raw as ISignedDomainLinkageCredential),\n )\n}\n\nexport const createCredentialEntity = (vci: VerifiableCredential): Credential => {\n const vc = vci\n const credential = new Credential()\n credential.context = asArray(vc['@context'])\n credential.type = asArray(vc.type || [])\n credential.id = vc.id\n\n if (vc.issuanceDate) {\n credential.issuanceDate = new Date(vc.issuanceDate)\n }\n\n if (vc.expirationDate) {\n credential.expirationDate = new Date(vc.expirationDate)\n }\n\n const issuer = new Identifier()\n issuer.did = extractIssuer(vc)\n credential.issuer = issuer\n\n if (vc.credentialSubject.id) {\n const subject = new Identifier()\n subject.did = vc.credentialSubject.id\n credential.subject = subject\n }\n credential.claims = []\n for (const type in vc.credentialSubject) {\n if (vc.credentialSubject.hasOwnProperty(type)) {\n const value = vc.credentialSubject[type]\n\n if (type !== 'id') {\n const isObj = typeof value === 'function' || (typeof value === 'object' && !!value)\n const claim = new Claim()\n claim.hash = computeEntryHash(JSON.stringify(vc) + type)\n claim.type = type\n claim.value = isObj ? JSON.stringify(value) : value\n claim.isObj = isObj\n claim.issuer = credential.issuer\n claim.subject = credential.subject\n claim.expirationDate = credential.expirationDate\n claim.issuanceDate = credential.issuanceDate\n claim.credentialType = credential.type\n claim.context = credential.context\n credential.claims.push(claim)\n }\n }\n }\n\n credential.raw = vci\n return credential\n}\n","import { CredentialCorrelationType, CredentialRole, DigitalCredential } from '@sphereon/ssi-sdk.credential-store'\nimport { CredentialMapper, parseDid } from '@sphereon/ssi-types'\nimport {\n DomainLinkageCredential,\n IDidConfigurationResource,\n IssuanceCallback,\n ServiceTypesEnum,\n WellKnownDidIssuer as Issuer,\n} from '@sphereon/wellknown-dids-client'\nimport { IAgentPlugin, IIdentifier, VerifiableCredential } from '@veramo/core'\nimport { OrPromise } from '@veramo/utils'\n// @ts-ignore\nimport { normalizeCredential } from 'did-jwt-vc'\n// @ts-ignore\nimport { Service } from 'did-resolver/lib/resolver'\nimport { Connection } from 'typeorm'\nimport { v4 as uuidv4 } from 'uuid'\nimport { createCredentialEntity, DidConfigurationResourceEntity, didConfigurationResourceFrom } from '../entities/DidConfigurationResourceEntity'\nimport { schema } from '../index'\nimport {\n IAddLinkedDomainsServiceArgs,\n IGetDidConfigurationResourceArgs,\n IIssueDidConfigurationResourceArgs,\n IIssueDomainLinkageCredentialArgs,\n IRegisterIssueCredentialArgs,\n IRemoveCredentialIssuanceArgs,\n ISaveDidConfigurationResourceArgs,\n IWellKnownDidIssuer,\n IWellKnownDidIssuerOptionsArgs,\n RequiredContext,\n} from '../types/IWellKnownDidIssuer'\nimport { RegulationType } from '@sphereon/ssi-sdk.data-store-types'\n\n/**\n * {@inheritDoc IWellKnownDidIssuer}\n */\nexport class WellKnownDidIssuer implements IAgentPlugin {\n readonly schema = schema.IWellKnownDidVerifier\n readonly methods: IWellKnownDidIssuer = {\n addLinkedDomainsService: this.addLinkedDomainsService.bind(this),\n getDidConfigurationResource: this.getDidConfigurationResource.bind(this),\n issueDidConfigurationResource: this.issueDidConfigurationResource.bind(this),\n issueDomainLinkageCredential: this.issueDomainLinkageCredential.bind(this),\n registerCredentialIssuance: this.registerCredentialIssuance.bind(this),\n removeCredentialIssuance: this.removeCredentialIssuance.bind(this),\n saveDidConfigurationResource: this.saveDidConfigurationResource.bind(this),\n }\n\n private readonly credentialIssuances: Record<string, IssuanceCallback>\n private readonly didConfigurationResourceRelations = ['linkedDids']\n\n constructor(\n private dbConnection: OrPromise<Connection>,\n args?: IWellKnownDidIssuerOptionsArgs,\n ) {\n this.credentialIssuances = (args && args.credentialIssuances) || {}\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.registerSignatureVerification} */\n private async registerCredentialIssuance(args: IRegisterIssueCredentialArgs, context: RequiredContext): Promise<void> {\n if (this.credentialIssuances[args.callbackName] !== undefined) {\n return Promise.reject(new Error(`Credential issuance with callbackName: ${args.callbackName} already present`))\n }\n\n this.credentialIssuances[args.callbackName] = args.credentialIssuance\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.removeSignatureVerification} */\n private async removeCredentialIssuance(args: IRemoveCredentialIssuanceArgs, context: RequiredContext): Promise<boolean> {\n return delete this.credentialIssuances[args.callbackName]\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.issueDidConfigurationResource} */\n private async issueDidConfigurationResource(\n args: IIssueDidConfigurationResourceArgs,\n context: RequiredContext,\n ): Promise<IDidConfigurationResource> {\n if (!args.issuances.every((issuance: IIssueDomainLinkageCredentialArgs) => issuance.origin === args.issuances[0].origin)) {\n return Promise.reject(Error('All verifiableCredentials should be issued for the same origin'))\n }\n\n // TODO We should combine all origins into one service when we update to Veramo 3.1.6.next-165 or higher, as then we can support multiple origins\n const addServices = args.issuances.map((issuance: IIssueDomainLinkageCredentialArgs) =>\n this.addLinkedDomainsService(\n {\n did: issuance.did,\n origin: issuance.origin,\n serviceId: issuance.serviceId,\n },\n context,\n ),\n )\n\n return Promise.all(addServices).then(async () =>\n new Issuer()\n .issueDidConfigurationResource({\n issuances: await this.mapIssuances(args.issuances),\n issueCallback:\n typeof args.credentialIssuance === 'string' ? await this.getCredentialIssuance(args.credentialIssuance) : args.credentialIssuance,\n })\n .then(async (didConfigurationResource: IDidConfigurationResource) => {\n if (args.save) {\n // TODO add support for multiple origins when we upgrade Veramo version\n await this.saveDidConfigurationResource({ origin: args.issuances[0].origin, didConfigurationResource }, context)\n }\n return didConfigurationResource\n })\n .catch((error: Error) => Promise.reject(Error(`Unable to issue DID configuration resource. Error: ${error.message}`))),\n )\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.saveDidConfigurationResource} */\n public async saveDidConfigurationResource(args: ISaveDidConfigurationResourceArgs, context: RequiredContext): Promise<void> {\n const didConfigurationEntity = {\n origin: args.origin,\n context: args.didConfigurationResource['@context'],\n linkedDids: args.didConfigurationResource.linked_dids.map((credential: DomainLinkageCredential) =>\n createCredentialEntity(this.normalizeCredential(credential)),\n ),\n }\n\n await (await this.dbConnection).getRepository(DidConfigurationResourceEntity).save(didConfigurationEntity, { transaction: true })\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.getDidConfigurationResource} */\n public async getDidConfigurationResource(args: IGetDidConfigurationResourceArgs, context: RequiredContext): Promise<IDidConfigurationResource> {\n const result = await (await this.dbConnection).getRepository(DidConfigurationResourceEntity).findOne({\n where: { origin: args.origin },\n relations: this.didConfigurationResourceRelations,\n })\n\n if (!result) {\n return Promise.reject(Error(`No DID configuration resource found for origin: ${args.origin}`))\n }\n\n return didConfigurationResourceFrom(result)\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.issueDomainLinkageCredential} */\n public async issueDomainLinkageCredential(args: IIssueDomainLinkageCredentialArgs, context: RequiredContext): Promise<DomainLinkageCredential> {\n const did: string = parseDid(args.did).did\n\n if (new URL(args.origin).origin !== args.origin) {\n return Promise.reject(Error(`Origin ${args.origin} is not valid`))\n }\n\n if (new URL(args.origin).protocol !== 'https:') {\n return Promise.reject(Error(`Origin ${args.origin} is not a https URL`))\n }\n\n if (args.issuanceDate && isNaN(Date.parse(args.issuanceDate))) {\n return Promise.reject(Error(`IssuanceDate ${args.issuanceDate} is not a valid date`))\n }\n\n if (isNaN(Date.parse(args.expirationDate))) {\n return Promise.reject(Error(`ExpirationDate ${args.expirationDate} is not a valid date`))\n }\n\n const credentialIssuance: IssuanceCallback =\n typeof args.credentialIssuance === 'string'\n ? await this.getCredentialIssuance(args.credentialIssuance)\n : (args.credentialIssuance as IssuanceCallback)\n\n return new Issuer()\n .issueDomainLinkageCredential({\n did,\n origin: args.origin,\n issuanceDate: args.issuanceDate,\n expirationDate: args.expirationDate,\n options: args.options,\n issueCallback: credentialIssuance,\n })\n .then(async (credential: DomainLinkageCredential) => {\n if (args.save) {\n await this.saveDomainLinkageCredential(credential, context)\n }\n return credential\n })\n .catch((error: Error) => Promise.reject(Error(`Unable to issue domain linkage credential for DID: ${did}. Error: ${error.message}`)))\n }\n\n /** {@inheritDoc IWellKnownDidIssuer.addLinkedDomainsService} */\n public async addLinkedDomainsService(args: IAddLinkedDomainsServiceArgs, context: RequiredContext): Promise<void> {\n const did: string = parseDid(args.did).did\n\n if (new URL(args.origin).origin !== args.origin) {\n return Promise.reject(Error(`Origin ${args.origin} is not valid`))\n }\n\n if (new URL(args.origin).protocol !== 'https:') {\n return Promise.reject(Error(`Origin ${args.origin} is not a https URL`))\n }\n\n context.agent\n .didManagerGet({ did })\n .catch(() => Promise.reject(Error('DID cannot be found')))\n .then(async (identifier: IIdentifier) => {\n if (\n !identifier.services ||\n identifier.services.filter(\n // TODO we should also check for the origins in the serviceEndpoint objects when we start supporting multiple origins\n (service: Service) => service.type === ServiceTypesEnum.LINKED_DOMAINS && service.serviceEndpoint === args.origin,\n ).length === 0\n ) {\n await context.agent.didManagerAddService({\n did: identifier.did,\n service: {\n id: args.serviceId || uuidv4(),\n type: ServiceTypesEnum.LINKED_DOMAINS,\n // TODO We should support a serviceEndpoint object here when we update to Veramo 3.1.6.next-165 or higher, as then we can support multiple origins\n serviceEndpoint: args.origin,\n },\n })\n }\n })\n .catch((error: Error) => Promise.reject(Error(`Unable to add LinkedDomains service to DID: ${args.did}. Error: ${error.message}`)))\n }\n\n private async getCredentialIssuance(callbackName: string): Promise<IssuanceCallback> {\n if (this.credentialIssuances[callbackName] === undefined) {\n return Promise.reject(new Error(`Credential issuance not found for callbackName: ${callbackName}`))\n }\n\n return this.credentialIssuances[callbackName]\n }\n\n private async saveDomainLinkageCredential(credential: DomainLinkageCredential, context: RequiredContext): Promise<DigitalCredential> {\n const vc = this.normalizeCredential(credential)\n return context.agent.crsAddCredential({\n credential: {\n rawDocument: JSON.stringify(vc),\n credentialRole: CredentialRole.ISSUER,\n regulationType: RegulationType.NON_REGULATED, // FIXME funke\n kmsKeyRef: 'FIXME', // FIXME funke\n identifierMethod: 'did',\n issuerCorrelationId: CredentialMapper.issuerCorrelationIdFromIssuerType(vc.issuer),\n issuerCorrelationType: CredentialCorrelationType.DID,\n subjectCorrelationId: CredentialMapper.issuerCorrelationIdFromIssuerType(vc.issuer), // FIXME get separate did for subject\n subjectCorrelationType: CredentialCorrelationType.DID,\n },\n })\n }\n\n private normalizeCredential(credential: DomainLinkageCredential): VerifiableCredential {\n return typeof credential === 'string' ? normalizeCredential(credential) : credential\n }\n\n private async mapIssuances(issuances: Array<IIssueDomainLinkageCredentialArgs>): Promise<Array<IIssueDomainLinkageCredentialArgs>> {\n const promises = issuances.map(async (issuance: IIssueDomainLinkageCredentialArgs) => {\n return {\n ...issuance,\n issueCallback:\n typeof issuance.credentialIssuance === 'string'\n ? await this.getCredentialIssuance(issuance.credentialIssuance)\n : issuance.credentialIssuance,\n }\n })\n return Promise.all(promises)\n }\n}\n","import {\n DomainLinkageCredential,\n IDidConfigurationResource,\n IIssueDomainLinkageCredentialOptions,\n IssuanceCallback,\n} from '@sphereon/wellknown-dids-client'\nimport { IAgentContext, IPluginMethodMap, IDIDManager } from '@veramo/core'\nimport { ICredentialStore } from '@sphereon/ssi-sdk.credential-store'\n\nexport interface IWellKnownDidIssuer extends IPluginMethodMap {\n addLinkedDomainsService(args: IAddLinkedDomainsServiceArgs, context: RequiredContext): Promise<void>\n getDidConfigurationResource(args: IGetDidConfigurationResourceArgs, context: RequiredContext): Promise<IDidConfigurationResource>\n issueDidConfigurationResource(args: IIssueDidConfigurationResourceArgs, context: RequiredContext): Promise<IDidConfigurationResource>\n issueDomainLinkageCredential(args: IIssueDomainLinkageCredentialArgs, context: RequiredContext): Promise<DomainLinkageCredential>\n registerCredentialIssuance(args: IRegisterIssueCredentialArgs, context: RequiredContext): Promise<void>\n removeCredentialIssuance(args: IRemoveCredentialIssuanceArgs, context: RequiredContext): Promise<boolean>\n saveDidConfigurationResource(args: ISaveDidConfigurationResourceArgs, context: RequiredContext): Promise<void>\n}\n\nexport interface IWellKnownDidIssuerOptionsArgs {\n credentialIssuances?: Record<string, IssuanceCallback>\n}\n\nexport interface IRegisterIssueCredentialArgs {\n callbackName: string\n credentialIssuance: IssuanceCallback\n}\n\nexport interface IRemoveCredentialIssuanceArgs {\n callbackName: string\n}\n\nexport interface IIssueDidConfigurationResourceArgs {\n issuances: Array<IIssueDomainLinkageCredentialArgs>\n credentialIssuance?: string | IssuanceCallback\n save?: boolean\n}\n\nexport interface IIssueDomainLinkageCredentialArgs {\n did: string\n origin: string\n serviceId?: string\n issuanceDate?: string\n expirationDate: string\n save?: boolean\n options: IIssueDomainLinkageCredentialOptions\n credentialIssuance?: string | IssuanceCallback\n}\n\nexport interface IGetDidConfigurationResourceArgs {\n origin: string\n}\n\nexport interface IAddLinkedDomainsServiceArgs {\n did: string\n origin: string\n serviceId?: string\n}\n\nexport interface ISaveDidConfigurationResourceArgs {\n origin: string\n didConfigurationResource: IDidConfigurationResource\n}\n\nexport type RequiredContext = IAgentContext<IDIDManager & ICredentialStore>\n","export { WellknownDidIssuerMigrations } from './generic'\n","import { CreateWellknownDidIssuer1661162010000 } from './1-CreateWellknownDidIssuer'\n\n/**\n * The migrations array that SHOULD be used when initializing a TypeORM database connection.\n *\n * These ensure the correct creation of tables and the proper migrations of data when tables change between versions.\n *\n * @public\n */\nexport const WellknownDidIssuerMigrations = [CreateWellknownDidIssuer1661162010000]\n","import { MigrationInterface, QueryRunner } from 'typeorm'\nimport Debug from 'debug'\nimport { CreateWellknownDidIssuer1661165115000 } from '../postgres/1661165115000-CreateWellknownDidIssuer'\nimport { CreateWellknownDidIssuer1661161799000 } from '../sqlite/1661161799000-CreateWellknownDidIssuer'\n\nconst debug = Debug('sphereon:ssi-sdk:migrations')\n\nexport class CreateWellknownDidIssuer1661162010000 implements MigrationInterface {\n name = 'CreateWellknownDidIssuer1661162010000'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n debug('migration: creating well-known DID tables')\n const dbType = queryRunner.connection.driver.options.type\n if (dbType === 'postgres') {\n debug('using postgres migration file')\n const mig = new CreateWellknownDidIssuer1661165115000()\n const up = await mig.up(queryRunner)\n debug('Migration statements executed')\n return up\n } else if (dbType === 'sqlite' || dbType === 'react-native' || dbType === 'expo') {\n debug('using sqlite/react-native migration file')\n const mig = new CreateWellknownDidIssuer1661161799000()\n const up = await mig.up(queryRunner)\n debug('Migration statements executed')\n return up\n } else {\n return Promise.reject(\n `Migrations are currently only supported for sqlite, react-native, expor and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,\n )\n }\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n debug('reverting well-known DID tables')\n const dbType = queryRunner.connection.driver.options.type\n if (dbType === 'postgres') {\n debug('using postgres migration file')\n const mig = new CreateWellknownDidIssuer1661165115000()\n const down = await mig.down(queryRunner)\n debug('Migration statements executed')\n return down\n } else if (dbType === 'sqlite' || dbType === 'react-native' || dbType === 'expo') {\n debug('using sqlite/react-native migration file')\n const mig = new CreateWellknownDidIssuer1661161799000()\n const down = await mig.down(queryRunner)\n debug('Migration statements executed')\n return down\n } else {\n return Promise.reject(\n `Migrations are currently only supported for sqlite, react-native, expor and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,\n )\n }\n }\n}\n","import { MigrationInterface, QueryRunner } from 'typeorm'\n\nexport class CreateWellknownDidIssuer1661165115000 implements MigrationInterface {\n name = 'CreateWellknownDidIssuer1661165115000'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(\n `CREATE TABLE \"DidConfigurationResource\" (\"origin\" varchar NOT NULL, \"context\" varchar NOT NULL, \"created_at\" TIMESTAMP NOT NULL DEFAULT now(), \"last_updated_at\" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT \"PK_Origin\" PRIMARY KEY (\"origin\"))`,\n )\n await queryRunner.query(\n `CREATE TABLE \"DidConfigurationResourceCredentials\" (\"didConfigurationResourceOrigin\" varchar NOT NULL, \"credentialHash\" varchar NOT NULL)`,\n )\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(`DROP TABLE \"DidConfigurationResource\"`)\n await queryRunner.query(`DROP TABLE \"DidConfigurationResourceCredentials\"`)\n }\n}\n","import { MigrationInterface, QueryRunner } from 'typeorm'\n\nexport class CreateWellknownDidIssuer1661161799000 implements MigrationInterface {\n name = 'CreateWellknownDidIssuer1661161799000'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(\n `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')))`,\n )\n await queryRunner.query(\n `CREATE TABLE \"DidConfigurationResourceCredentials\" (\"didConfigurationResourceOrigin\" varchar NOT NULL, \"credentialHash\" varchar NOT NULL)`,\n )\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n await queryRunner.query(`DROP TABLE \"DidConfigurationResource\"`)\n await queryRunner.query(`DROP TABLE \"DidConfigurationResourceCredentials\"`)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;ACCA,QAAA,YAAA,QAAA,SAAA;AACA,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AMC,6BAA6B;EAACC;;","names":["Claim","Credential","createCredentialEntity","Identifier","debug","debug","debug","qb","debug","debug","debug","module","DidConfigurationResourceEntity","BaseEntity","origin","context","linkedDids","createdAt","lastUpdatedAt","nullable","Credential","credential","hash","cascade","onDelete","name","didConfigurationResourceFrom","didConfigurationResource","linked_dids","linkedDidsFrom","credentials","map","raw","proof","type","jwt","createCredentialEntity","vci","vc","asArray","id","issuanceDate","Date","expirationDate","issuer","Identifier","did","extractIssuer","credentialSubject","subject","claims","hasOwnProperty","value","isObj","claim","Claim","computeEntryHash","JSON","stringify","credentialType","push","import_ssi_sdk","WellKnownDidIssuer","schema","IWellKnownDidVerifier","methods","addLinkedDomainsService","bind","getDidConfigurationResource","issueDidConfigurationResource","issueDomainLinkageCredential","registerCredentialIssuance","removeCredentialIssuance","saveDidConfigurationResource","credentialIssuances","didConfigurationResourceRelations","dbConnection","args","context","callbackName","undefined","Promise","reject","Error","credentialIssuance","issuances","every","issuance","origin","addServices","map","did","serviceId","all","then","Issuer","mapIssuances","issueCallback","getCredentialIssuance","didConfigurationResource","save","catch","error","message","didConfigurationEntity","linkedDids","linked_dids","credential","createCredentialEntity","normalizeCredential","getRepository","DidConfigurationResourceEntity","transaction","result","findOne","where","relations","didConfigurationResourceFrom","parseDid","URL","protocol","issuanceDate","isNaN","Date","parse","expirationDate","options","saveDomainLinkageCredential","agent","didManagerGet","identifier","services","filter","service","type","ServiceTypesEnum","LINKED_DOMAINS","serviceEndpoint","length","didManagerAddService","id","uuidv4","vc","crsAddCredential","rawDocument","JSON","stringify","credentialRole","CredentialRole","ISSUER","regulationType","RegulationType","NON_REGULATED","kmsKeyRef","identifierMethod","issuerCorrelationId","CredentialMapper","issuerCorrelationIdFromIssuerType","issuer","issuerCorrelationType","CredentialCorrelationType","DID","subjectCorrelationId","subjectCorrelationType","promises","CreateWellknownDidIssuer1661165115000","name","up","queryRunner","query","down","CreateWellknownDidIssuer1661161799000","name","up","queryRunner","query","down","debug","Debug","CreateWellknownDidIssuer1661162010000","name","up","queryRunner","dbType","connection","driver","options","type","mig","CreateWellknownDidIssuer1661165115000","CreateWellknownDidIssuer1661161799000","Promise","reject","down","WellknownDidIssuerMigrations","CreateWellknownDidIssuer1661162010000","schema","require","WellknownDidIssuerEntities","DidConfigurationResourceEntity"]}