Skip to content

Commit

Permalink
feat(Pollux)!: plugins (#349)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
curtis-h authored Feb 12, 2025
1 parent 99bea3f commit e2bf9bc
Show file tree
Hide file tree
Showing 117 changed files with 7,803 additions and 7,404 deletions.
27 changes: 25 additions & 2 deletions demos/next-sdjwt-workshop/src/reducers/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ export const initialState: RootState = {
}
}

export type ExtendedMessage = SDK.Domain.Message & { isAnswering: boolean; hasAnswered: boolean, error: TraceableError | null }
export type ExtendedMessage = SDK.Domain.Message & {
credentialFormat: SDK.Domain.CredentialType;
isAnswering: boolean;
hasAnswered: boolean,
error: TraceableError | null
}

export type RootState = {
errors: TraceableError[];
Expand Down Expand Up @@ -230,8 +235,26 @@ const appSlice = createSlice({
state.agent.isSendingMessage = true;
state.agent.hasSentMessage = false;
let credentialFormat = SDK.Domain.CredentialType.Unknown;

try {
credentialFormat = action.meta.arg.message.credentialFormat;
const msg = action.meta.arg.message;
const [attachment] = msg.attachments;

if (!attachment) {
throw new Error("Required Attachment");
}

const format = msg.body.formats?.find((format: any) => format.attach_id === attachment.id)?.format ?? attachment.format;

if (typeof format === "string" && format.startsWith("anoncreds/")) {
credentialFormat = SDK.Domain.CredentialType.AnonCreds;
}
if (format === SDK.Domain.CredentialType.JWT) {
credentialFormat = SDK.Domain.CredentialType.JWT;
}
if (format === SDK.Domain.CredentialType.SDJWT) {
credentialFormat = SDK.Domain.CredentialType.SDJWT;
}
}
catch { }

Expand Down
428 changes: 105 additions & 323 deletions demos/next/src/components/Message.tsx

Large diffs are not rendered by default.

27 changes: 25 additions & 2 deletions demos/next/src/reducers/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ export const initialState: RootState = {
}
}

export type ExtendedMessage = SDK.Domain.Message & { isAnswering: boolean; hasAnswered: boolean, error: TraceableError | null }
export type ExtendedMessage = SDK.Domain.Message & {
credentialFormat: SDK.Domain.CredentialType;
isAnswering: boolean;
hasAnswered: boolean,
error: TraceableError | null
}

export type RootState = {
errors: TraceableError[];
Expand Down Expand Up @@ -209,8 +214,26 @@ const appSlice = createSlice({
state.agent.isSendingMessage = true;
state.agent.hasSentMessage = false;
let credentialFormat = SDK.Domain.CredentialType.Unknown;

try {
credentialFormat = action.meta.arg.message.credentialFormat;
const msg = action.meta.arg.message;
const [attachment] = msg.attachments;

if (!attachment) {
throw new Error("Required Attachment");
}

const format = msg.body.formats?.find((format: any) => format.attach_id === attachment.id)?.format ?? attachment.format;

if (typeof format === "string" && format.startsWith("anoncreds/")) {
credentialFormat = SDK.Domain.CredentialType.AnonCreds;
}
if (format === SDK.Domain.CredentialType.JWT) {
credentialFormat = SDK.Domain.CredentialType.JWT;
}
if (format === SDK.Domain.CredentialType.SDJWT) {
credentialFormat = SDK.Domain.CredentialType.SDJWT;
}
}
catch { }

Expand Down
5 changes: 3 additions & 2 deletions integration-tests/e2e-tests/src/abilities/WalletSdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Ability, Discardable, Initialisable, Interaction, Question, QuestionAdapter } from "@serenity-js/core"
import type SDK from "@hyperledger/identus-edge-agent-sdk"
import SDK from "@hyperledger/identus-edge-agent-sdk"
import axios from "axios"
import { axiosInstance, CloudAgentConfiguration } from "../configuration/CloudAgentConfiguration"
import InMemoryStore from "../configuration/inmemory"
Expand Down Expand Up @@ -173,7 +173,8 @@ export class WalletSdk extends Ability implements Initialisable, Discardable {
pluto,
mediatorDID,
castor
})
});
this.sdk.plugins.register(SDK.Plugins.Anoncreds);

this.sdk.addListener(
ListenerKey.MESSAGE, async (messages: SDK.Domain.Message[]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
} from "@amagyar-iohk/identus-cloud-agent-client-ts"
import { CloudAgentConfiguration } from "../configuration/CloudAgentConfiguration"
import { Utils } from "../Utils"
import SDK from "@hyperledger/identus-edge-agent-sdk"
import { JWTRevocationStatus } from "@hyperledger/identus-edge-agent-sdk/build/domain"

export class CloudAgentWorkflow {
static async createConnection(cloudAgent: Actor, label?: string, goalCode?: string, goal?: string) {
Expand Down Expand Up @@ -306,7 +304,7 @@ export class CloudAgentWorkflow {
const credentialResponse = await this.getCredential(cloudAgent, recordId)
const jwtString = Utils.decodeBase64URL(credentialResponse.credential)
const decoded = CloudAgentWorkflow.instance.JWTCredential.fromJWS(jwtString)
const credentialStatus = decoded.vc.credentialStatus as JWTRevocationStatus
const credentialStatus = decoded.vc.credentialStatus as any
const statusList = credentialStatus.statusListCredential
statusRegistry.set(recordId, statusList)
}
Expand Down
34 changes: 15 additions & 19 deletions integration-tests/node/assertions.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const runTests = (describe, test, assert, SDK) => {
assert("Domain" in SDK);
assert("Mercury" in SDK);
assert("Pluto" in SDK);
assert("Pollux" in SDK);

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

// ?? should be in Pluto
assert("Store" in SDK);

// ?? shouldnt be exported
assert("isPresentationDefinitionRequestType" in SDK);
});

describe("Modules", () => {
Expand Down Expand Up @@ -126,21 +122,21 @@ const runTests = (describe, test, assert, SDK) => {
});
});

describe("Pollux", () => {
test("instantiates", async () => {
const apollo = new SDK.Apollo();
const castor = new SDK.Castor(apollo);
const pollux = new SDK.Pollux(apollo, castor);
assert(pollux instanceof SDK.Pollux);
assert(pollux.revealCredentialFields instanceof Function);
assert(pollux.isCredentialRevoked instanceof Function);
assert(pollux.parseCredential instanceof Function);
assert(pollux.processCredentialOffer instanceof Function);
assert(pollux.createPresentationSubmission instanceof Function);
assert(pollux.verifyPresentationSubmission instanceof Function);
assert(pollux.createPresentationDefinitionRequest instanceof Function);
});
});
// describe("Pollux", () => {
// test("instantiates", async () => {
// const apollo = new SDK.Apollo();
// const castor = new SDK.Castor(apollo);
// const pollux = new SDK.Pollux(apollo, castor);
// assert(pollux instanceof SDK.Pollux);
// assert(pollux.revealCredentialFields instanceof Function);
// assert(pollux.isCredentialRevoked instanceof Function);
// assert(pollux.parseCredential instanceof Function);
// assert(pollux.processCredentialOffer instanceof Function);
// assert(pollux.createPresentationSubmission instanceof Function);
// assert(pollux.verifyPresentationSubmission instanceof Function);
// assert(pollux.createPresentationDefinitionRequest instanceof Function);
// });
// });
});

test("Agent starts", async () => {
Expand Down
166 changes: 0 additions & 166 deletions src/domain/buildingBlocks/Pollux.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/domain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export * from "./buildingBlocks/Apollo";
export * from "./buildingBlocks/Castor";
export * from "./buildingBlocks/Mercury";
export * from "./buildingBlocks/Pluto";
export * from "./buildingBlocks/Pollux";
export * from "./utils/JWT";
22 changes: 3 additions & 19 deletions src/domain/models/Credential.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { CredentialType, LinkSecret } from ".";
import { CredentialType } from "./VerifiableCredential";
import { Pluto } from "../buildingBlocks/Pluto";
import { DID } from "./DID";
import { KeyPair } from "./KeyPair";

type Claim = Record<string, any>;

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

isRevoked() {
const revoked = this.properties.get("revoked");
return revoked === true
return revoked === true;
}
}

export interface ProvableCredential {
presentation(): unknown;
verifiableCredential(): unknown
verifiableCredential(): unknown;
}

export interface StorableCredential {
Expand All @@ -54,17 +52,3 @@ export interface StorableCredential {
availableClaims?: string[];
};
}

export interface CredentialRequestOptions {
keyPair?: KeyPair;
did?: DID;
linkSecret?: LinkSecret;
[name: string]: any;
}

export interface CredentialIssueOptions {
type: CredentialType;
linkSecret?: string;
credentialMetadata?: Record<string, any>;
[name: string]: any;
}
Loading

0 comments on commit e2bf9bc

Please sign in to comment.