Skip to content

Commit

Permalink
feat: add method overloads
Browse files Browse the repository at this point in the history
For better type information
  • Loading branch information
wolfy1339 committed Feb 23, 2024
1 parent e164054 commit ee6147d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/node/sign.ts
Expand Up @@ -2,6 +2,8 @@ import { createHmac } from "node:crypto";
import { Algorithm, type SignOptions } from "../types.js";
import { VERSION } from "../version.js";

export async function sign(secret: string, payload: string): Promise<string>;
export async function sign(options: SignOptions, payload: string): Promise<string>;
export async function sign(
options: SignOptions | string,
payload: string,
Expand Down
2 changes: 2 additions & 0 deletions src/web.ts
Expand Up @@ -45,6 +45,8 @@ async function importKey(secret: string, algorithm: AlgorithmLike) {
);
}

export async function sign(secret: string, payload: string): Promise<string>;
export async function sign(options: SignOptions, payload: string): Promise<string>;
export async function sign(options: SignOptions | string, payload: string) {
const { secret, algorithm } =
typeof options === "object"
Expand Down

0 comments on commit ee6147d

Please sign in to comment.