Skip to content

Commit

Permalink
fix: Rollback renaming of Attachment to V1Attachment
Browse files Browse the repository at this point in the history
Signed-off-by: Artemkaaas <artem.ivanov@dsr-corporation.com>
  • Loading branch information
Artemkaaas committed Aug 4, 2023
1 parent 1ac8030 commit a70f587
Show file tree
Hide file tree
Showing 60 changed files with 380 additions and 382 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import {
utils,
CredentialProblemReportReason,
JsonTransformer,
V1Attachment,
V1AttachmentData,
Attachment,
AttachmentData,
} from '@aries-framework/core'

import { AnonCredsError } from '../error'
Expand Down Expand Up @@ -451,7 +451,7 @@ export class AnonCredsCredentialFormatService implements CredentialFormatService
* @returns The Attachment if found or undefined
*
*/
public getAttachment(formats: CredentialFormatSpec[], messageAttachments: V1Attachment[]): V1Attachment | undefined {
public getAttachment(formats: CredentialFormatSpec[], messageAttachments: Attachment[]): Attachment | undefined {
const supportedAttachmentIds = formats.filter((f) => this.supportsFormat(f.format)).map((f) => f.attachmentId)
const supportedAttachment = messageAttachments.find((attachment) => supportedAttachmentIds.includes(attachment.id))

Expand Down Expand Up @@ -595,15 +595,15 @@ export class AnonCredsCredentialFormatService implements CredentialFormatService
attributes?: CredentialPreviewAttributeOptions[],
linkedAttachments?: LinkedAttachment[]
): {
attachments?: V1Attachment[]
attachments?: Attachment[]
previewAttributes?: CredentialPreviewAttributeOptions[]
} {
if (!linkedAttachments && !attributes) {
return {}
}

let previewAttributes = attributes ?? []
let attachments: V1Attachment[] | undefined
let attachments: Attachment[] | undefined

if (linkedAttachments) {
// there are linked attachments so transform into the attribute field of the CredentialPreview object for
Expand All @@ -622,11 +622,11 @@ export class AnonCredsCredentialFormatService implements CredentialFormatService
* @param data The data to include in the attach object
* @param id the attach id from the formats component of the message
*/
public getFormatData(data: unknown, id: string): V1Attachment {
const attachment = new V1Attachment({
public getFormatData(data: unknown, id: string): Attachment {
const attachment = new Attachment({
id,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64: JsonEncoder.toBase64(data),
}),
})
Expand Down
10 changes: 5 additions & 5 deletions packages/anoncreds/src/formats/AnonCredsProofFormatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import type {

import {
AriesFrameworkError,
V1Attachment,
V1AttachmentData,
Attachment,
AttachmentData,
JsonEncoder,
ProofFormatSpec,
JsonTransformer,
Expand Down Expand Up @@ -613,11 +613,11 @@ export class AnonCredsProofFormatService implements ProofFormatService<AnonCreds
* @param data The data to include in the attach object
* @param id the attach id from the formats component of the message
*/
private getFormatData(data: unknown, id: string): V1Attachment {
const attachment = new V1Attachment({
private getFormatData(data: unknown, id: string): Attachment {
const attachment = new Attachment({
id,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64: JsonEncoder.toBase64(data),
}),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import {
utils,
CredentialProblemReportReason,
JsonTransformer,
V1Attachment,
V1AttachmentData,
Attachment,
AttachmentData,
} from '@aries-framework/core'

import { AnonCredsError } from '../error'
Expand Down Expand Up @@ -464,7 +464,7 @@ export class LegacyIndyCredentialFormatService implements CredentialFormatServic
* @returns The Attachment if found or undefined
*
*/
public getAttachment(formats: CredentialFormatSpec[], messageAttachments: V1Attachment[]): V1Attachment | undefined {
public getAttachment(formats: CredentialFormatSpec[], messageAttachments: Attachment[]): Attachment | undefined {
const supportedAttachmentIds = formats.filter((f) => this.supportsFormat(f.format)).map((f) => f.attachmentId)
const supportedAttachment = messageAttachments.find((attachment) => supportedAttachmentIds.includes(attachment.id))

Expand Down Expand Up @@ -608,15 +608,15 @@ export class LegacyIndyCredentialFormatService implements CredentialFormatServic
attributes?: CredentialPreviewAttributeOptions[],
linkedAttachments?: LinkedAttachment[]
): {
attachments?: V1Attachment[]
attachments?: Attachment[]
previewAttributes?: CredentialPreviewAttributeOptions[]
} {
if (!linkedAttachments && !attributes) {
return {}
}

let previewAttributes = attributes ?? []
let attachments: V1Attachment[] | undefined
let attachments: Attachment[] | undefined

if (linkedAttachments) {
// there are linked attachments so transform into the attribute field of the CredentialPreview object for
Expand All @@ -635,11 +635,11 @@ export class LegacyIndyCredentialFormatService implements CredentialFormatServic
* @param data The data to include in the attach object
* @param id the attach id from the formats component of the message
*/
public getFormatData(data: unknown, id: string): V1Attachment {
const attachment = new V1Attachment({
public getFormatData(data: unknown, id: string): Attachment {
const attachment = new Attachment({
id,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64: JsonEncoder.toBase64(data),
}),
})
Expand Down
10 changes: 5 additions & 5 deletions packages/anoncreds/src/formats/LegacyIndyProofFormatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import type {

import {
AriesFrameworkError,
V1Attachment,
V1AttachmentData,
Attachment,
AttachmentData,
JsonEncoder,
ProofFormatSpec,
JsonTransformer,
Expand Down Expand Up @@ -626,11 +626,11 @@ export class LegacyIndyProofFormatService implements ProofFormatService<LegacyIn
* @param data The data to include in the attach object
* @param id the attach id from the formats component of the message
*/
private getFormatData(data: unknown, id: string): V1Attachment {
const attachment = new V1Attachment({
private getFormatData(data: unknown, id: string): Attachment {
const attachment = new Attachment({
id,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64: JsonEncoder.toBase64(data),
}),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
CredentialState,
JsonTransformer,
ConnectionService,
V1Attachment,
V1AttachmentData,
Attachment,
AttachmentData,
AckStatus,
CredentialProblemReportReason,
CredentialsModuleConfig,
Expand Down Expand Up @@ -231,8 +231,8 @@ export class V1CredentialProtocol

await this.indyCredentialFormat.processProposal(messageContext.agentContext, {
credentialRecord,
attachment: new V1Attachment({
data: new V1AttachmentData({
attachment: new Attachment({
data: new AttachmentData({
json: JsonTransformer.toJSON(this.rfc0592ProposalFromV1ProposeMessage(proposalMessage)),
}),
}),
Expand Down Expand Up @@ -307,8 +307,8 @@ export class V1CredentialProtocol
attachmentId: INDY_CREDENTIAL_OFFER_ATTACHMENT_ID,
credentialFormats,
credentialRecord,
proposalAttachment: new V1Attachment({
data: new V1AttachmentData({
proposalAttachment: new Attachment({
data: new AttachmentData({
json: JsonTransformer.toJSON(this.rfc0592ProposalFromV1ProposeMessage(proposalMessage)),
}),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
CredentialEventTypes,
AckStatus,
CredentialProblemReportReason,
V1Attachment,
V1AttachmentData,
Attachment,
AttachmentData,
} from '@aries-framework/core'
import { Subject } from 'rxjs'

Expand Down Expand Up @@ -79,27 +79,27 @@ const credentialPreview = V1CredentialPreview.fromRecord({
age: '99',
})

const offerAttachment = new V1Attachment({
const offerAttachment = new Attachment({
id: INDY_CREDENTIAL_OFFER_ATTACHMENT_ID,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64:
'eyJzY2hlbWFfaWQiOiJhYWEiLCJjcmVkX2RlZl9pZCI6IlRoN01wVGFSWlZSWW5QaWFiZHM4MVk6MzpDTDoxNzpUQUciLCJub25jZSI6Im5vbmNlIiwia2V5X2NvcnJlY3RuZXNzX3Byb29mIjp7fX0',
}),
})

const requestAttachment = new V1Attachment({
const requestAttachment = new Attachment({
id: INDY_CREDENTIAL_REQUEST_ATTACHMENT_ID,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64: JsonEncoder.toBase64({}),
}),
})

const credentialAttachment = new V1Attachment({
const credentialAttachment = new Attachment({
id: INDY_CREDENTIAL_ATTACHMENT_ID,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64: JsonEncoder.toBase64({
values: convertAttributesToCredentialValues(credentialPreview.attributes),
}),
Expand Down Expand Up @@ -525,7 +525,7 @@ describe('V1CredentialProtocol', () => {
expect(legacyIndyCredentialFormatService.processCredential).toHaveBeenNthCalledWith(1, agentContext, {
attachment: credentialAttachment,
credentialRecord,
requestAttachment: expect.any(V1Attachment),
requestAttachment: expect.any(Attachment),
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { CredentialProtocolOptions, CredentialStateChangedEvent } from '@ar
import {
EventEmitter,
DidExchangeState,
V1Attachment,
V1AttachmentData,
Attachment,
AttachmentData,
CredentialState,
CredentialFormatSpec,
CredentialExchangeRecord,
Expand Down Expand Up @@ -67,17 +67,17 @@ const credentialPreview = V1CredentialPreview.fromRecord({
age: '99',
})

const offerAttachment = new V1Attachment({
const offerAttachment = new Attachment({
id: INDY_CREDENTIAL_OFFER_ATTACHMENT_ID,
mimeType: 'application/json',
data: new V1AttachmentData({
data: new AttachmentData({
base64:
'eyJzY2hlbWFfaWQiOiJhYWEiLCJjcmVkX2RlZl9pZCI6IlRoN01wVGFSWlZSWW5QaWFiZHM4MVk6MzpDTDoxNzpUQUciLCJub25jZSI6Im5vbmNlIiwia2V5X2NvcnJlY3RuZXNzX3Byb29mIjp7fX0',
}),
})

const proposalAttachment = new V1Attachment({
data: new V1AttachmentData({
const proposalAttachment = new Attachment({
data: new AttachmentData({
json: {
cred_def_id: 'Th7MpTaRZVRYnPiabds81Y:3:CL:17:TAG',
schema_issuer_did: 'GMm4vMw8LLrLJjp81kRRLp',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnonCredsCredential } from '../../../../models'

import { DidCommV1Message, IsValidMessageType, parseMessageType, V1Attachment } from '@aries-framework/core'
import { DidCommV1Message, IsValidMessageType, parseMessageType, Attachment } from '@aries-framework/core'
import { Expose, Type } from 'class-transformer'
import { IsString, IsOptional, IsArray, ValidateNested, IsInstance } from 'class-validator'

Expand All @@ -9,8 +9,8 @@ export const INDY_CREDENTIAL_ATTACHMENT_ID = 'libindy-cred-0'
export interface V1IssueCredentialMessageOptions {
id?: string
comment?: string
credentialAttachments: V1Attachment[]
attachments?: V1Attachment[]
credentialAttachments: Attachment[]
attachments?: Attachment[]
}

export class V1IssueCredentialMessage extends DidCommV1Message {
Expand All @@ -36,13 +36,13 @@ export class V1IssueCredentialMessage extends DidCommV1Message {
public comment?: string

@Expose({ name: 'credentials~attach' })
@Type(() => V1Attachment)
@Type(() => Attachment)
@IsArray()
@ValidateNested({
each: true,
})
@IsInstance(V1Attachment, { each: true })
public credentialAttachments!: V1Attachment[]
@IsInstance(Attachment, { each: true })
public credentialAttachments!: Attachment[]

public get indyCredential(): AnonCredsCredential | null {
const attachment = this.credentialAttachments.find((attachment) => attachment.id === INDY_CREDENTIAL_ATTACHMENT_ID)
Expand All @@ -53,7 +53,7 @@ export class V1IssueCredentialMessage extends DidCommV1Message {
return credentialJson
}

public getCredentialAttachmentById(id: string): V1Attachment | undefined {
public getCredentialAttachmentById(id: string): Attachment | undefined {
return this.credentialAttachments.find((attachment) => attachment.id == id)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnonCredsCredentialOffer } from '../../../../models'

import { DidCommV1Message, IsValidMessageType, parseMessageType, V1Attachment } from '@aries-framework/core'
import { DidCommV1Message, IsValidMessageType, parseMessageType, Attachment } from '@aries-framework/core'
import { Expose, Type } from 'class-transformer'
import { IsArray, IsInstance, IsOptional, IsString, ValidateNested } from 'class-validator'

Expand All @@ -11,9 +11,9 @@ export const INDY_CREDENTIAL_OFFER_ATTACHMENT_ID = 'libindy-cred-offer-0'
export interface V1OfferCredentialMessageOptions {
id?: string
comment?: string
offerAttachments: V1Attachment[]
offerAttachments: Attachment[]
credentialPreview: V1CredentialPreview
attachments?: V1Attachment[]
attachments?: Attachment[]
}

/**
Expand Down Expand Up @@ -51,13 +51,13 @@ export class V1OfferCredentialMessage extends DidCommV1Message {
public credentialPreview!: V1CredentialPreview

@Expose({ name: 'offers~attach' })
@Type(() => V1Attachment)
@Type(() => Attachment)
@IsArray()
@ValidateNested({
each: true,
})
@IsInstance(V1Attachment, { each: true })
public offerAttachments!: V1Attachment[]
@IsInstance(Attachment, { each: true })
public offerAttachments!: Attachment[]

public get indyCredentialOffer(): AnonCredsCredentialOffer | null {
const attachment = this.offerAttachments.find((attachment) => attachment.id === INDY_CREDENTIAL_OFFER_ATTACHMENT_ID)
Expand All @@ -68,7 +68,7 @@ export class V1OfferCredentialMessage extends DidCommV1Message {
return credentialOfferJson
}

public getOfferAttachmentById(id: string): V1Attachment | undefined {
public getOfferAttachmentById(id: string): Attachment | undefined {
return this.offerAttachments.find((attachment) => attachment.id == id)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { V1Attachment } from '@aries-framework/core'
import type { Attachment } from '@aries-framework/core'

import { DidCommV1Message, IsValidMessageType, parseMessageType } from '@aries-framework/core'
import { Expose, Type } from 'class-transformer'
Expand All @@ -23,7 +23,7 @@ export interface V1ProposeCredentialMessageOptions {
schemaVersion?: string
credentialDefinitionId?: string
issuerDid?: string
attachments?: V1Attachment[]
attachments?: Attachment[]
}

/**
Expand Down Expand Up @@ -128,7 +128,7 @@ export class V1ProposeCredentialMessage extends DidCommV1Message {
@Matches(unqualifiedIndyDidRegex)
public issuerDid?: string

public getAttachment(): V1Attachment | undefined {
public getAttachment(): Attachment | undefined {
if (this.appendedAttachments) {
return this.appendedAttachments[0]
} else {
Expand Down
Loading

0 comments on commit a70f587

Please sign in to comment.