Skip to content

Commit 934bc6c

Browse files
committed
fix: rename to preSigningHook
1 parent e7dd76b commit 934bc6c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,4 @@ export interface Secp256k1PrecomputedClient {
496496
serverCoeffs: Record<string, string>;
497497
}
498498

499-
export type PreSigningValidatorType = (params: { data: Uint8Array; hashed: boolean }) => Promise<{ success: boolean; error?: string; data?: string }>;
499+
export type PreSigningHookType = (params: { data: Uint8Array; hashed: boolean }) => Promise<{ success: boolean; error?: string; data?: string }>;

src/mpcCoreKit.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
JWTLoginParams,
4444
MPCKeyDetails,
4545
OAuthLoginParams,
46-
PreSigningValidatorType,
46+
PreSigningHookType,
4747
Secp256k1PrecomputedClient,
4848
SessionData,
4949
SubVerifierDetailsParams,
@@ -100,7 +100,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
100100

101101
private atomicCallStackCounter: number = 0;
102102

103-
private preSigningValidator?: PreSigningValidatorType;
103+
private preSigningHook?: PreSigningHookType;
104104

105105
constructor(options: Web3AuthOptions) {
106106
if (!options.web3AuthClientId) {
@@ -459,8 +459,8 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
459459
}
460460
}
461461

462-
setPreSigningValidator(preSigningValidator: PreSigningValidatorType) {
463-
this.preSigningValidator = preSigningValidator;
462+
setPreSigningHook(preSigningValidator: PreSigningHookType) {
463+
this.preSigningHook = preSigningValidator;
464464
}
465465

466466
public async handleRedirectResult(): Promise<void> {
@@ -785,8 +785,8 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
785785
}
786786

787787
public async sign(data: Buffer, hashed: boolean = false, secp256k1Precompute?: Secp256k1PrecomputedClient): Promise<Buffer> {
788-
if (this.preSigningValidator) {
789-
const result = await this.preSigningValidator({ data: Uint8Array.from(data), hashed });
788+
if (this.preSigningHook) {
789+
const result = await this.preSigningHook({ data: Uint8Array.from(data), hashed });
790790
if (!result.success || result.error) {
791791
throw Error(result.error || "preSigningValidator failed");
792792
}

tests/login.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ variable.forEach((testVariable) => {
169169

170170
// should fail to sign due to preSignValidation
171171
{
172-
coreKitInstance.setPreSigningValidator(async ({ data }) => {
172+
coreKitInstance.setPreSigningHook(async ({ data }) => {
173173
return {
174174
success: false,
175175
data: Buffer.from(data).toString("hex")
@@ -186,7 +186,7 @@ variable.forEach((testVariable) => {
186186

187187
// should succeed to sign
188188
{
189-
coreKitInstance.setPreSigningValidator(async ({ data }) => {
189+
coreKitInstance.setPreSigningHook(async ({ data }) => {
190190
return {
191191
success: true,
192192
data: Buffer.from(data).toString("hex")

0 commit comments

Comments
 (0)