Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nmattia committed Oct 24, 2023
1 parent 84d96b6 commit 3caf230
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ export const VcFlowReady = {
method: "vc-flow-ready",
};

const zodPrincipal = z.custom<Principal>((val) => {
if (typeof val !== "string") {
return false;
}
const zodPrincipal = z.string().transform((val, ctx) => {
let principal;
try {
principal = Principal.fromText(val);
} catch {
return false;
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Not a principal " });
return z.NEVER;
}

return principal;
}, "expected principal");
});

// https://www.jsonrpc.org/specification
// https://github.com/dfinity/internet-identity/blob/vc-mvp/docs/vc-spec.md#identity-provider-api
Expand All @@ -41,7 +39,10 @@ export const VcFlowRequest = z.object({
}),
});

export type VcFlowRequest = z.infer<typeof VcFlowRequest>;

// The wire format of a VC flow request
export type VcFlowRequestWire = z.input<typeof VcFlowRequest>;
export type VcFlowRequest = z.output<typeof VcFlowRequest>;

export type VcVerifiablePresentation = {
id: VcFlowRequest["id"];
Expand Down
4 changes: 2 additions & 2 deletions src/showcase/src/pages/vc-test-app.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Layout from "../layouts/Layout.astro";
import { toast } from "$src/components/toast";
import { createRef, ref } from "lit-html/directives/ref.js";
import { withRef } from "$src/utils/lit-html";
import { VcFlowRequest } from "$src/flows/verifiableCredentials/postMessageInterface";
import { VcFlowRequestWire } from "$src/flows/verifiableCredentials/postMessageInterface";
import { decodeJwt } from "jose";

const inferDefaultIIURL = () => {
Expand Down Expand Up @@ -66,7 +66,7 @@ import Layout from "../layouts/Layout.astro";
},
credentialSubject: principal,
},
} satisfies VcFlowRequest,
} satisfies VcFlowRequestWire,
ii.latest.origin
);
}
Expand Down

0 comments on commit 3caf230

Please sign in to comment.