Skip to content

Commit

Permalink
Use ref hex
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Feb 22, 2021
1 parent e02af92 commit 2dd1c75
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/webAuthnShareResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ export async function setTorusShare(m: MetadataStorageLayer, webAuthnKeyHex: str
await m.setMetadata(metadataParams, WEBAUTHN_TORUS_SHARE);
}

export async function setDeviceShare(m: MetadataStorageLayer, webAuthnKeyHex: string, verifier: string, verifierData: Json): Promise<void> {
const keyPair = ec.keyFromPrivate(webAuthnKeyHex);
export async function setDeviceShare(m: MetadataStorageLayer, webAuthnRefHex: string, verifier: string, verifierData: Json): Promise<void> {
const keyPair = ec.keyFromPrivate(webAuthnRefHex);
const privKey = keyPair.getPrivate();
const data = await getData(m, webAuthnKeyHex, WEBAUTHN_DEVICE_SHARE);
const data = await getData(m, webAuthnRefHex, WEBAUTHN_DEVICE_SHARE);
let d: Record<string, unknown> = {};
if (data) d = data;
d[verifier] = verifierData;
Expand All @@ -85,8 +85,8 @@ export async function getTorusShare<T>(m: MetadataStorageLayer, webAuthnKeyHex:
return null;
}

export async function getDeviceShare<T>(m: MetadataStorageLayer, webAuthnKeyHex: string, verifier: string): Promise<T | null> {
const data = await getData<T>(m, webAuthnKeyHex, WEBAUTHN_DEVICE_SHARE);
export async function getDeviceShare<T>(m: MetadataStorageLayer, webAuthnRefHex: string, verifier: string): Promise<T | null> {
const data = await getData<T>(m, webAuthnRefHex, WEBAUTHN_DEVICE_SHARE);
if (data) return data[verifier];
return null;
}
4 changes: 3 additions & 1 deletion types/src/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference types="node" />
export declare function keccak256(a: Buffer): Buffer;
import { ec as EC } from "elliptic";
export declare function keccak256(a: string | Buffer): Buffer;
export declare type Json = boolean | number | string | null | {
[property: string]: Json;
} | Json[];
export declare const ec: EC;
8 changes: 4 additions & 4 deletions types/src/webAuthnShareResolver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ declare type EciesHex = {
};
export declare function encParamsHexToBuf(encParamsHex: EciesHex): Ecies;
export declare function encParamsBufToHex(encParams: Ecies): EciesHex;
export declare function setTorusShare(m: MetadataStorageLayer, webAuthnKeyHex: string, verifier: string, data: Json): Promise<void>;
export declare function setDeviceShare(m: MetadataStorageLayer, webAuthnRefHex: string, verifier: string, data: Json): Promise<void>;
export declare function getTorusShare<T>(m: MetadataStorageLayer, webAuthnKeyHex: string, verifier: string): Promise<T>;
export declare function getDeviceShare<T>(m: MetadataStorageLayer, webAuthnRefHex: string, verifier: string): Promise<T>;
export declare function setTorusShare(m: MetadataStorageLayer, webAuthnKeyHex: string, verifier: string, verifierData: Json): Promise<void>;
export declare function setDeviceShare(m: MetadataStorageLayer, webAuthnRefHex: string, verifier: string, verifierData: Json): Promise<void>;
export declare function getTorusShare<T>(m: MetadataStorageLayer, webAuthnKeyHex: string, verifier: string): Promise<T | null>;
export declare function getDeviceShare<T>(m: MetadataStorageLayer, webAuthnRefHex: string, verifier: string): Promise<T | null>;
export {};

0 comments on commit 2dd1c75

Please sign in to comment.