diff --git a/src/libs/crypto/vc/index.ts b/src/libs/crypto/vc/index.ts index 889103b..252ca06 100644 --- a/src/libs/crypto/vc/index.ts +++ b/src/libs/crypto/vc/index.ts @@ -9,7 +9,6 @@ import { Buffer } from "buffer/"; import * as didJwt from "did-jwt"; import { JWTVerified } from "did-jwt"; -import { JWTDecoded } from "did-jwt/lib/JWT"; import { Resolver } from "did-resolver"; import { IIdentifier } from "@veramo/core"; import * as u8a from "uint8arrays"; @@ -41,7 +40,7 @@ export interface KeyMeta { passkeyCredIdHex?: string; } -const resolver = new Resolver({ ethr: didEthLocalResolver }); +const ethLocalResolver = new Resolver({ ethr: didEthLocalResolver }); /** * Tell whether a key is from a passkey @@ -62,6 +61,7 @@ export async function createEndorserJwtForKey( const privateKeyHex = identity.keys[0].privateKeyHex; const signer = await SimpleSigner(privateKeyHex as string); const options = { + // alg: "ES256K", // "K" is the default, "K-R" is used by the server in tests issuer: account.did, signer: signer, expiresIn: undefined as number | undefined, @@ -124,7 +124,8 @@ function bytesToHex(b: Uint8Array): string { } // We should be calling 'verify' in more places, showing warnings if it fails. -export function decodeEndorserJwt(jwt: string): JWTDecoded { +// @returns JWTDecoded with { header: JWTHeader, payload: string, signature: string, data: string } (but doesn't verify the signature) +export function decodeEndorserJwt(jwt: string) { return didJwt.decodeJWT(jwt); } @@ -134,10 +135,8 @@ export async function decodeAndVerifyJwt( jwt: string, ): Promise> { const pieces = jwt.split("."); - console.log("WTF decodeAndVerifyJwt", typeof jwt, jwt, pieces); const header = JSON.parse(base64urlDecodeString(pieces[0])); const payload = JSON.parse(base64urlDecodeString(pieces[1])); - console.log("WTF decodeAndVerifyJwt after", header, payload); const issuerDid = payload.iss; if (!issuerDid) { return Promise.reject({ @@ -149,7 +148,9 @@ export async function decodeAndVerifyJwt( if (issuerDid.startsWith(ETHR_DID_PREFIX)) { try { - const verified = await didJwt.verifyJWT(jwt, { resolver }); + const verified = await didJwt.verifyJWT(jwt, { + resolver: ethLocalResolver, + }); return verified; } catch (e: unknown) { return Promise.reject({ diff --git a/src/router/index.ts b/src/router/index.ts index 5c198c3..ba4b3a2 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -70,7 +70,7 @@ const routes: Array = [ component: () => import("../views/ContactGiftingView.vue"), }, { - path: "/contact-import", + path: "/contact-import/:jwt?", name: "contact-import", component: () => import("../views/ContactImportView.vue"), }, diff --git a/src/views/ContactImportView.vue b/src/views/ContactImportView.vue index b7ec1ba..9a7a5cb 100644 --- a/src/views/ContactImportView.vue +++ b/src/views/ContactImportView.vue @@ -16,10 +16,11 @@ Contact Import - + Make my activity visible to these contacts. +
One contact is the same as an existing contact