Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(present-proof): add support for aries RFC 510 #1676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"@stablelib/ed25519": "^1.0.2",
"@stablelib/random": "^1.0.1",
"@stablelib/sha256": "^1.0.1",
"@sphereon/pex": "^2.2.2",
"@sphereon/pex-models": "^2.1.2",
"@sphereon/ssi-types": "^0.17.5",
"@types/ws": "^8.5.4",
"abort-controller": "^3.0.0",
"big-integer": "^1.6.51",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/agent/AgentModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CacheModule } from '../modules/cache'
import { ConnectionsModule } from '../modules/connections'
import { CredentialsModule } from '../modules/credentials'
import { DidsModule } from '../modules/dids'
import { DifPresentationExchangeModule } from '../modules/dif-presentation-exchange'
import { DiscoverFeaturesModule } from '../modules/discover-features'
import { GenericRecordsModule } from '../modules/generic-records'
import { MessagePickupModule } from '../modules/message-pickup'
Expand Down Expand Up @@ -131,6 +132,7 @@ function getDefaultAgentModules() {
oob: () => new OutOfBandModule(),
w3cCredentials: () => new W3cCredentialsModule(),
cache: () => new CacheModule(),
pex: () => new DifPresentationExchangeModule(),
} as const
}

Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/agent/__tests__/AgentModules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CacheModule } from '../../modules/cache'
import { ConnectionsModule } from '../../modules/connections'
import { CredentialsModule } from '../../modules/credentials'
import { DidsModule } from '../../modules/dids'
import { DifPresentationExchangeModule } from '../../modules/dif-presentation-exchange'
import { DiscoverFeaturesModule } from '../../modules/discover-features'
import { GenericRecordsModule } from '../../modules/generic-records'
import { MessagePickupModule } from '../../modules/message-pickup'
Expand Down Expand Up @@ -62,6 +63,7 @@ describe('AgentModules', () => {
mediationRecipient: expect.any(MediationRecipientModule),
messagePickup: expect.any(MessagePickupModule),
basicMessages: expect.any(BasicMessagesModule),
pex: expect.any(DifPresentationExchangeModule),
genericRecords: expect.any(GenericRecordsModule),
discovery: expect.any(DiscoverFeaturesModule),
dids: expect.any(DidsModule),
Expand All @@ -86,6 +88,7 @@ describe('AgentModules', () => {
mediationRecipient: expect.any(MediationRecipientModule),
messagePickup: expect.any(MessagePickupModule),
basicMessages: expect.any(BasicMessagesModule),
pex: expect.any(DifPresentationExchangeModule),
genericRecords: expect.any(GenericRecordsModule),
discovery: expect.any(DiscoverFeaturesModule),
dids: expect.any(DidsModule),
Expand Down Expand Up @@ -113,6 +116,7 @@ describe('AgentModules', () => {
mediationRecipient: expect.any(MediationRecipientModule),
messagePickup: expect.any(MessagePickupModule),
basicMessages: expect.any(BasicMessagesModule),
pex: expect.any(DifPresentationExchangeModule),
genericRecords: expect.any(GenericRecordsModule),
discovery: expect.any(DiscoverFeaturesModule),
dids: expect.any(DidsModule),
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/decorators/attachment/Attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Expose, Type } from 'class-transformer'
import { IsDate, IsHash, IsInstance, IsInt, IsMimeType, IsOptional, IsString, ValidateNested } from 'class-validator'

import { AriesFrameworkError } from '../../error'
import { JsonValue } from '../../types'
import { JsonEncoder } from '../../utils/JsonEncoder'
import { uuid } from '../../utils/uuid'

Expand All @@ -19,7 +20,7 @@ export interface AttachmentOptions {

export interface AttachmentDataOptions {
base64?: string
json?: Record<string, unknown>
json?: JsonValue
links?: string[]
jws?: JwsDetachedFormat | JwsFlattenedDetachedFormat
sha256?: string
Expand All @@ -40,7 +41,7 @@ export class AttachmentData {
* Directly embedded JSON data, when representing content inline instead of via links, and when the content is natively conveyable as JSON. Optional.
*/
@IsOptional()
public json?: Record<string, unknown>
public json?: JsonValue

/**
* A list of zero or more locations at which the content may be fetched. Optional.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { AriesFrameworkError } from '../../error'

export class DifPresentationExchangeError extends AriesFrameworkError {
public additionalMessages?: Array<string>

public constructor(
message: string,
{ cause, additionalMessages }: { cause?: Error; additionalMessages?: Array<string> } = {}
) {
super(message, { cause })
this.additionalMessages = additionalMessages
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { DependencyManager, Module } from '../../plugins'

import { AgentConfig } from '../../agent/AgentConfig'

import { DifPresentationExchangeService } from './DifPresentationExchangeService'

/**
* @public
*/
export class DifPresentationExchangeModule implements Module {
/**
* Registers the dependencies of the presentation-exchange module on the dependency manager.
*/
public register(dependencyManager: DependencyManager) {
// Warn about experimental module
dependencyManager
.resolve(AgentConfig)
.logger.warn(
"The 'DifPresentationExchangeModule' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @aries-framework packages."
)

// service
dependencyManager.registerSingleton(DifPresentationExchangeService)
}
}
Loading
Loading