|  |  | @ -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<Omit<JWTVerified, "didResolutionResult" | "signer" | "jwt">> { | 
			
		
	
		
			
				
					|  |  |  |   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({ | 
			
		
	
	
		
			
				
					|  |  | 
 |