Skip to content

Commit e2bf9bc

Browse files
authored
feat(Pollux)!: plugins (#349)
BREAKING CHANGES: Pollux completely removed. Anoncreds not available by default, it needs to be loaded (if wanted). Agent no longer requires mediationHandler and connectionManager constructor parameters. Removed lots of exported internal types. Signed-off-by: Curtish <[email protected]>
1 parent 99bea3f commit e2bf9bc

File tree

117 files changed

+7803
-7404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+7803
-7404
lines changed

demos/next-sdjwt-workshop/src/reducers/app.ts

+25-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ export const initialState: RootState = {
119119
}
120120
}
121121

122-
export type ExtendedMessage = SDK.Domain.Message & { isAnswering: boolean; hasAnswered: boolean, error: TraceableError | null }
122+
export type ExtendedMessage = SDK.Domain.Message & {
123+
credentialFormat: SDK.Domain.CredentialType;
124+
isAnswering: boolean;
125+
hasAnswered: boolean,
126+
error: TraceableError | null
127+
}
123128

124129
export type RootState = {
125130
errors: TraceableError[];
@@ -230,8 +235,26 @@ const appSlice = createSlice({
230235
state.agent.isSendingMessage = true;
231236
state.agent.hasSentMessage = false;
232237
let credentialFormat = SDK.Domain.CredentialType.Unknown;
238+
233239
try {
234-
credentialFormat = action.meta.arg.message.credentialFormat;
240+
const msg = action.meta.arg.message;
241+
const [attachment] = msg.attachments;
242+
243+
if (!attachment) {
244+
throw new Error("Required Attachment");
245+
}
246+
247+
const format = msg.body.formats?.find((format: any) => format.attach_id === attachment.id)?.format ?? attachment.format;
248+
249+
if (typeof format === "string" && format.startsWith("anoncreds/")) {
250+
credentialFormat = SDK.Domain.CredentialType.AnonCreds;
251+
}
252+
if (format === SDK.Domain.CredentialType.JWT) {
253+
credentialFormat = SDK.Domain.CredentialType.JWT;
254+
}
255+
if (format === SDK.Domain.CredentialType.SDJWT) {
256+
credentialFormat = SDK.Domain.CredentialType.SDJWT;
257+
}
235258
}
236259
catch { }
237260

demos/next/src/components/Message.tsx

+105-323
Large diffs are not rendered by default.

demos/next/src/reducers/app.ts

+25-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ export const initialState: RootState = {
9898
}
9999
}
100100

101-
export type ExtendedMessage = SDK.Domain.Message & { isAnswering: boolean; hasAnswered: boolean, error: TraceableError | null }
101+
export type ExtendedMessage = SDK.Domain.Message & {
102+
credentialFormat: SDK.Domain.CredentialType;
103+
isAnswering: boolean;
104+
hasAnswered: boolean,
105+
error: TraceableError | null
106+
}
102107

103108
export type RootState = {
104109
errors: TraceableError[];
@@ -209,8 +214,26 @@ const appSlice = createSlice({
209214
state.agent.isSendingMessage = true;
210215
state.agent.hasSentMessage = false;
211216
let credentialFormat = SDK.Domain.CredentialType.Unknown;
217+
212218
try {
213-
credentialFormat = action.meta.arg.message.credentialFormat;
219+
const msg = action.meta.arg.message;
220+
const [attachment] = msg.attachments;
221+
222+
if (!attachment) {
223+
throw new Error("Required Attachment");
224+
}
225+
226+
const format = msg.body.formats?.find((format: any) => format.attach_id === attachment.id)?.format ?? attachment.format;
227+
228+
if (typeof format === "string" && format.startsWith("anoncreds/")) {
229+
credentialFormat = SDK.Domain.CredentialType.AnonCreds;
230+
}
231+
if (format === SDK.Domain.CredentialType.JWT) {
232+
credentialFormat = SDK.Domain.CredentialType.JWT;
233+
}
234+
if (format === SDK.Domain.CredentialType.SDJWT) {
235+
credentialFormat = SDK.Domain.CredentialType.SDJWT;
236+
}
214237
}
215238
catch { }
216239

integration-tests/e2e-tests/src/abilities/WalletSdk.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Ability, Discardable, Initialisable, Interaction, Question, QuestionAdapter } from "@serenity-js/core"
2-
import type SDK from "@hyperledger/identus-edge-agent-sdk"
2+
import SDK from "@hyperledger/identus-edge-agent-sdk"
33
import axios from "axios"
44
import { axiosInstance, CloudAgentConfiguration } from "../configuration/CloudAgentConfiguration"
55
import InMemoryStore from "../configuration/inmemory"
@@ -173,7 +173,8 @@ export class WalletSdk extends Ability implements Initialisable, Discardable {
173173
pluto,
174174
mediatorDID,
175175
castor
176-
})
176+
});
177+
this.sdk.plugins.register(SDK.Plugins.Anoncreds);
177178

178179
this.sdk.addListener(
179180
ListenerKey.MESSAGE, async (messages: SDK.Domain.Message[]) => {

integration-tests/e2e-tests/src/workflow/CloudAgentWorkflow.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
} from "@amagyar-iohk/identus-cloud-agent-client-ts"
1515
import { CloudAgentConfiguration } from "../configuration/CloudAgentConfiguration"
1616
import { Utils } from "../Utils"
17-
import SDK from "@hyperledger/identus-edge-agent-sdk"
18-
import { JWTRevocationStatus } from "@hyperledger/identus-edge-agent-sdk/build/domain"
1917

2018
export class CloudAgentWorkflow {
2119
static async createConnection(cloudAgent: Actor, label?: string, goalCode?: string, goal?: string) {
@@ -306,7 +304,7 @@ export class CloudAgentWorkflow {
306304
const credentialResponse = await this.getCredential(cloudAgent, recordId)
307305
const jwtString = Utils.decodeBase64URL(credentialResponse.credential)
308306
const decoded = CloudAgentWorkflow.instance.JWTCredential.fromJWS(jwtString)
309-
const credentialStatus = decoded.vc.credentialStatus as JWTRevocationStatus
307+
const credentialStatus = decoded.vc.credentialStatus as any
310308
const statusList = credentialStatus.statusListCredential
311309
statusRegistry.set(recordId, statusList)
312310
}

integration-tests/node/assertions.cjs

+15-19
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const runTests = (describe, test, assert, SDK) => {
99
assert("Domain" in SDK);
1010
assert("Mercury" in SDK);
1111
assert("Pluto" in SDK);
12-
assert("Pollux" in SDK);
1312

1413
// misc modules
1514
assert("ApiImpl" in SDK);
@@ -64,9 +63,6 @@ const runTests = (describe, test, assert, SDK) => {
6463

6564
// ?? should be in Pluto
6665
assert("Store" in SDK);
67-
68-
// ?? shouldnt be exported
69-
assert("isPresentationDefinitionRequestType" in SDK);
7066
});
7167

7268
describe("Modules", () => {
@@ -126,21 +122,21 @@ const runTests = (describe, test, assert, SDK) => {
126122
});
127123
});
128124

129-
describe("Pollux", () => {
130-
test("instantiates", async () => {
131-
const apollo = new SDK.Apollo();
132-
const castor = new SDK.Castor(apollo);
133-
const pollux = new SDK.Pollux(apollo, castor);
134-
assert(pollux instanceof SDK.Pollux);
135-
assert(pollux.revealCredentialFields instanceof Function);
136-
assert(pollux.isCredentialRevoked instanceof Function);
137-
assert(pollux.parseCredential instanceof Function);
138-
assert(pollux.processCredentialOffer instanceof Function);
139-
assert(pollux.createPresentationSubmission instanceof Function);
140-
assert(pollux.verifyPresentationSubmission instanceof Function);
141-
assert(pollux.createPresentationDefinitionRequest instanceof Function);
142-
});
143-
});
125+
// describe("Pollux", () => {
126+
// test("instantiates", async () => {
127+
// const apollo = new SDK.Apollo();
128+
// const castor = new SDK.Castor(apollo);
129+
// const pollux = new SDK.Pollux(apollo, castor);
130+
// assert(pollux instanceof SDK.Pollux);
131+
// assert(pollux.revealCredentialFields instanceof Function);
132+
// assert(pollux.isCredentialRevoked instanceof Function);
133+
// assert(pollux.parseCredential instanceof Function);
134+
// assert(pollux.processCredentialOffer instanceof Function);
135+
// assert(pollux.createPresentationSubmission instanceof Function);
136+
// assert(pollux.verifyPresentationSubmission instanceof Function);
137+
// assert(pollux.createPresentationDefinitionRequest instanceof Function);
138+
// });
139+
// });
144140
});
145141

146142
test("Agent starts", async () => {

src/domain/buildingBlocks/Pollux.ts

-166
This file was deleted.

src/domain/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ export * from "./buildingBlocks/Apollo";
66
export * from "./buildingBlocks/Castor";
77
export * from "./buildingBlocks/Mercury";
88
export * from "./buildingBlocks/Pluto";
9-
export * from "./buildingBlocks/Pollux";
109
export * from "./utils/JWT";

src/domain/models/Credential.ts

+3-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { CredentialType, LinkSecret } from ".";
1+
import { CredentialType } from "./VerifiableCredential";
22
import { Pluto } from "../buildingBlocks/Pluto";
3-
import { DID } from "./DID";
4-
import { KeyPair } from "./KeyPair";
53

64
type Claim = Record<string, any>;
75

@@ -30,13 +28,13 @@ export abstract class Credential implements Pluto.Storable {
3028

3129
isRevoked() {
3230
const revoked = this.properties.get("revoked");
33-
return revoked === true
31+
return revoked === true;
3432
}
3533
}
3634

3735
export interface ProvableCredential {
3836
presentation(): unknown;
39-
verifiableCredential(): unknown
37+
verifiableCredential(): unknown;
4038
}
4139

4240
export interface StorableCredential {
@@ -54,17 +52,3 @@ export interface StorableCredential {
5452
availableClaims?: string[];
5553
};
5654
}
57-
58-
export interface CredentialRequestOptions {
59-
keyPair?: KeyPair;
60-
did?: DID;
61-
linkSecret?: LinkSecret;
62-
[name: string]: any;
63-
}
64-
65-
export interface CredentialIssueOptions {
66-
type: CredentialType;
67-
linkSecret?: string;
68-
credentialMetadata?: Record<string, any>;
69-
[name: string]: any;
70-
}

0 commit comments

Comments
 (0)