Skip to content

Commit

Permalink
feat(did-comm): support DIDComm Messaging attachments (#1087)
Browse files Browse the repository at this point in the history
fixes #612
  • Loading branch information
codynhat authored and mirceanis committed Dec 17, 2022
1 parent 2f57cb1 commit 6679574
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 3 deletions.
180 changes: 180 additions & 0 deletions packages/core/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,13 @@
"$ref": "#/components/schemas/VerifiablePresentation"
},
"description": "Optional. Array of attached verifiable presentations"
},
"attachments": {
"type": "array",
"items": {
"$ref": "#/components/schemas/IMessageAttachment"
},
"description": "Optional. Array of generic attachments"
}
},
"required": [
Expand Down Expand Up @@ -2249,6 +2256,59 @@
"type": "string",
"description": "Represents a Json Web Token in compact form. \"header.payload.signature\""
},
"IMessageAttachment": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"description": {
"type": "string"
},
"filename": {
"type": "string"
},
"media_type": {
"type": "string"
},
"format": {
"type": "string"
},
"lastmod_time": {
"type": "string"
},
"byte_count": {
"type": "number"
},
"data": {
"$ref": "#/components/schemas/IMessageAttachmentData"
}
},
"required": [
"data"
],
"description": "Message attachment"
},
"IMessageAttachmentData": {
"type": "object",
"properties": {
"jws": {},
"hash": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "string"
}
},
"base64": {
"type": "string"
},
"json": {}
},
"description": "The DIDComm message structure for data in an attachment. See https://identity.foundation/didcomm-messaging/spec/#attachments"
},
"IDataStoreGetVerifiableCredentialArgs": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2822,6 +2882,13 @@
"$ref": "#/components/schemas/VerifiablePresentation"
},
"description": "Optional. Array of attached verifiable presentations"
},
"attachments": {
"type": "array",
"items": {
"$ref": "#/components/schemas/IMessageAttachment"
},
"description": "Optional. Array of generic attachments"
}
},
"required": [
Expand Down Expand Up @@ -3039,6 +3106,59 @@
"type": "string",
"description": "Represents a Json Web Token in compact form. \"header.payload.signature\""
},
"IMessageAttachment": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"description": {
"type": "string"
},
"filename": {
"type": "string"
},
"media_type": {
"type": "string"
},
"format": {
"type": "string"
},
"lastmod_time": {
"type": "string"
},
"byte_count": {
"type": "number"
},
"data": {
"$ref": "#/components/schemas/IMessageAttachmentData"
}
},
"required": [
"data"
],
"description": "Message attachment"
},
"IMessageAttachmentData": {
"type": "object",
"properties": {
"jws": {},
"hash": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "string"
}
},
"base64": {
"type": "string"
},
"json": {}
},
"description": "The DIDComm message structure for data in an attachment. See https://identity.foundation/didcomm-messaging/spec/#attachments"
},
"FindCredentialsArgs": {
"$ref": "#/components/schemas/FindArgs-TCredentialColumns",
"description": "The filter that can be used to find {@link VerifiableCredential } s in the data store. See {@link IDataStoreORM.dataStoreORMGetVerifiableCredentials }"
Expand Down Expand Up @@ -3616,6 +3736,13 @@
"$ref": "#/components/schemas/VerifiablePresentation"
},
"description": "Optional. Array of attached verifiable presentations"
},
"attachments": {
"type": "array",
"items": {
"$ref": "#/components/schemas/IMessageAttachment"
},
"description": "Optional. Array of generic attachments"
}
},
"required": [
Expand Down Expand Up @@ -3815,6 +3942,59 @@
"CompactJWT": {
"type": "string",
"description": "Represents a Json Web Token in compact form. \"header.payload.signature\""
},
"IMessageAttachment": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"description": {
"type": "string"
},
"filename": {
"type": "string"
},
"media_type": {
"type": "string"
},
"format": {
"type": "string"
},
"lastmod_time": {
"type": "string"
},
"byte_count": {
"type": "number"
},
"data": {
"$ref": "#/components/schemas/IMessageAttachmentData"
}
},
"required": [
"data"
],
"description": "Message attachment"
},
"IMessageAttachmentData": {
"type": "object",
"properties": {
"jws": {},
"hash": {
"type": "string"
},
"links": {
"type": "array",
"items": {
"type": "string"
}
},
"base64": {
"type": "string"
},
"json": {}
},
"description": "The DIDComm message structure for data in an attachment. See https://identity.foundation/didcomm-messaging/spec/#attachments"
}
},
"methods": {
Expand Down
34 changes: 34 additions & 0 deletions packages/core/src/types/IMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,35 @@ export interface IMetaData {
value?: string
}

/**
* Message attachment
* @public
*/
export interface IMessageAttachment {
id?: string
description?: string
filename?: string
media_type?: string
format?: string
lastmod_time?: string
byte_count?: number
data: IMessageAttachmentData
}

/**
* The DIDComm message structure for data in an attachment.
* See https://identity.foundation/didcomm-messaging/spec/#attachments
*
* @beta This API may change without a BREAKING CHANGE notice.
*/
export interface IMessageAttachmentData {
jws?: any
hash?: string
links?: string[]
base64?: string
json?: any
}

/**
* Represents a DIDComm v1 message payload, with optionally decoded credentials and presentations.
* @public
Expand Down Expand Up @@ -90,4 +119,9 @@ export interface IMessage {
* Optional. Array of attached verifiable presentations
*/
presentations?: VerifiablePresentation[]

/**
* Optional. Array of generic attachments
*/
attachments?: IMessageAttachment[]
}
Loading

0 comments on commit 6679574

Please sign in to comment.