Skip to content

Commit

Permalink
feat(Pollux)!: BREAKING CHANGE - removing pollux and adding plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Curtish <[email protected]>
  • Loading branch information
curtis-h committed Jan 28, 2025
1 parent bda7c5f commit 497047e
Show file tree
Hide file tree
Showing 114 changed files with 7,439 additions and 7,384 deletions.
428 changes: 105 additions & 323 deletions demos/next/src/components/Message.tsx

Large diffs are not rendered by default.

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;
}
31 changes: 3 additions & 28 deletions src/domain/models/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import {
AttachmentBase64,
AttachmentData,
AttachmentDescriptor,
AttachmentFormats,
AttachmentJsonData,
} from "./MessageAttachment";
import { AgentError } from "./Errors";
import { CredentialType, JsonString } from ".";
import { JsonString } from ".";
import { Pluto } from "../buildingBlocks/Pluto";
import { JsonObj, asJsonObj, isArray, isNil, isObject, isString, notEmptyString, notNil } from "../../utils";
import { base64, base64url } from "multiformats/bases/base64";
Expand Down Expand Up @@ -42,31 +41,6 @@ export class Message implements Pluto.Storable {
this.body = asJsonObj(body);
}

get credentialFormat() {
const [attachment] = this.attachments;
if (!attachment) {
throw new Error("Required Attachment");
}

const format = this.body.formats?.find((format: any) => format.attach_id === attachment.id)?.format ?? attachment.format;
if (
format === AttachmentFormats.AnonCreds ||
format === AttachmentFormats.ANONCREDS_PROOF_REQUEST ||
format === AttachmentFormats.ANONCREDS_OFFER ||
format === AttachmentFormats.ANONCREDS_ISSUE ||
format === AttachmentFormats.ANONCREDS_REQUEST
) {
return CredentialType.AnonCreds;
}
if (format === CredentialType.JWT) {
return CredentialType.JWT;
}
if (format === CredentialType.SDJWT) {
return CredentialType.SDJWT;
}
return CredentialType.Unknown;
}

static fromJson(jsonString: JsonString | any): Message {
const messageObj = typeof jsonString === "object" ? jsonString : JSON.parse(jsonString);

Expand Down Expand Up @@ -178,7 +152,8 @@ const decodeBase64 = (data: string) => {
} catch (err) {
return base64.baseDecode(data);
}
}
};

export namespace Message {
export namespace Attachment {
/**
Expand Down
Loading

0 comments on commit 497047e

Please sign in to comment.