Skip to content

Commit

Permalink
feat: 🎸 Added auth.createAuthSignatureWithSigner
Browse files Browse the repository at this point in the history
  • Loading branch information
kostysh committed Nov 11, 2022
1 parent d3757b6 commit 7464342
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Provider, SignatureValue, SignatureDomain } from './types';
import { utils } from 'ethers';
import { Signer, TypedDataSigner } from '@ethersproject/abstract-signer';

// A signature types
export const types = {
Expand Down Expand Up @@ -34,6 +35,15 @@ export const createAuthSignature = async (provider: Provider, secret: string): P
return await signer._signTypedData(buildSignatureDomain(chainId), types, buildSignatureValue(signerAddress, secret));
};

export const createAuthSignatureWithSigner = async (
chainId: number,
signer: Signer & TypedDataSigner,
secret: string
): Promise<string> => {
const signerAddress = await signer.getAddress();
return await signer._signTypedData(buildSignatureDomain(chainId), types, buildSignatureValue(signerAddress, secret));
};

export const validateAuthSignature = async (
provider: Provider,
secret: string,
Expand Down

0 comments on commit 7464342

Please sign in to comment.