forked from jsnbuchanan/crowd-funder-for-time-pwa
refactor: remove unused imports and parameters in passkeyDidPeer.ts
- Remove unused imports: - DIDResolutionResult from did-resolver - sha256 from ethereum-cryptography/sha256.js - Remove unused parameters from verifyJwtP256 and verifyJwtWebCrypto: - credIdHex - clientDataJsonBase64Url - credId This change improves code cleanliness by removing unused code while maintaining the core passkey authentication functionality.
This commit is contained in:
@@ -1,7 +1,37 @@
|
|||||||
export * from "./claims";
|
export type {
|
||||||
export * from "./claims-result";
|
// From common.ts
|
||||||
export * from "./common";
|
GenericCredWrapper,
|
||||||
|
GenericVerifiableCredential,
|
||||||
|
KeyMeta,
|
||||||
|
// Exclude types that are also exported from other files
|
||||||
|
// GiveVerifiableCredential,
|
||||||
|
// OfferVerifiableCredential,
|
||||||
|
// RegisterVerifiableCredential,
|
||||||
|
// PlanSummaryRecord,
|
||||||
|
// UserInfo,
|
||||||
|
} from "./common";
|
||||||
|
|
||||||
|
export type {
|
||||||
|
// From claims.ts
|
||||||
|
GiveVerifiableCredential,
|
||||||
|
OfferVerifiableCredential,
|
||||||
|
RegisterVerifiableCredential,
|
||||||
|
} from "./claims";
|
||||||
|
|
||||||
|
export type {
|
||||||
|
// From claims-result.ts
|
||||||
|
CreateAndSubmitClaimResult,
|
||||||
|
} from "./claims-result";
|
||||||
|
|
||||||
|
export type {
|
||||||
|
// From records.ts
|
||||||
|
PlanSummaryRecord,
|
||||||
|
} from "./records";
|
||||||
|
|
||||||
|
export type {
|
||||||
|
// From user.ts
|
||||||
|
UserInfo,
|
||||||
|
} from "./user";
|
||||||
|
|
||||||
export * from "./limits";
|
export * from "./limits";
|
||||||
export * from "./records";
|
|
||||||
export * from "./user";
|
|
||||||
export * from "./deepLinks";
|
export * from "./deepLinks";
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { Buffer } from "buffer/";
|
import { Buffer } from "buffer/";
|
||||||
import { JWTPayload } from "did-jwt";
|
import { JWTPayload } from "did-jwt";
|
||||||
import { DIDResolutionResult } from "did-resolver";
|
|
||||||
import { sha256 } from "ethereum-cryptography/sha256.js";
|
|
||||||
import { p256 } from "@noble/curves/p256";
|
import { p256 } from "@noble/curves/p256";
|
||||||
import {
|
import {
|
||||||
startAuthentication,
|
startAuthentication,
|
||||||
@@ -318,15 +316,12 @@ export async function createDidPeerJwt(
|
|||||||
// ... and this import:
|
// ... and this import:
|
||||||
// import { p256 } from "@noble/curves/p256";
|
// import { p256 } from "@noble/curves/p256";
|
||||||
export async function verifyJwtP256(
|
export async function verifyJwtP256(
|
||||||
credIdHex: string,
|
|
||||||
issuerDid: string,
|
issuerDid: string,
|
||||||
authenticatorData: ArrayBuffer,
|
authenticatorData: ArrayBuffer,
|
||||||
challenge: Uint8Array,
|
challenge: Uint8Array,
|
||||||
clientDataJsonBase64Url: Base64URLString,
|
|
||||||
signature: Base64URLString,
|
signature: Base64URLString,
|
||||||
) {
|
) {
|
||||||
const authDataFromBase = Buffer.from(authenticatorData);
|
const authDataFromBase = Buffer.from(authenticatorData);
|
||||||
const clientDataFromBase = Buffer.from(clientDataJsonBase64Url, "base64");
|
|
||||||
const sigBuffer = Buffer.from(signature, "base64");
|
const sigBuffer = Buffer.from(signature, "base64");
|
||||||
const finalSigBuffer = unwrapEC2Signature(sigBuffer);
|
const finalSigBuffer = unwrapEC2Signature(sigBuffer);
|
||||||
const publicKeyBytes = peerDidToPublicKeyBytes(issuerDid);
|
const publicKeyBytes = peerDidToPublicKeyBytes(issuerDid);
|
||||||
@@ -386,15 +381,12 @@ export async function verifyJwtSimplewebauthn(
|
|||||||
|
|
||||||
// similar code is in endorser-ch util-crypto.ts verifyPeerSignature
|
// similar code is in endorser-ch util-crypto.ts verifyPeerSignature
|
||||||
export async function verifyJwtWebCrypto(
|
export async function verifyJwtWebCrypto(
|
||||||
credId: Base64URLString,
|
|
||||||
issuerDid: string,
|
issuerDid: string,
|
||||||
authenticatorData: ArrayBuffer,
|
authenticatorData: ArrayBuffer,
|
||||||
challenge: Uint8Array,
|
challenge: Uint8Array,
|
||||||
clientDataJsonBase64Url: Base64URLString,
|
|
||||||
signature: Base64URLString,
|
signature: Base64URLString,
|
||||||
) {
|
) {
|
||||||
const authDataFromBase = Buffer.from(authenticatorData);
|
const authDataFromBase = Buffer.from(authenticatorData);
|
||||||
const clientDataFromBase = Buffer.from(clientDataJsonBase64Url, "base64");
|
|
||||||
const sigBuffer = Buffer.from(signature, "base64");
|
const sigBuffer = Buffer.from(signature, "base64");
|
||||||
const finalSigBuffer = unwrapEC2Signature(sigBuffer);
|
const finalSigBuffer = unwrapEC2Signature(sigBuffer);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user