Skip to content

Commit

Permalink
feat: add sign message method (#323)
Browse files Browse the repository at this point in the history
Co-authored-by: Roland <[email protected]>
  • Loading branch information
pavanjoshi914 and rolznz authored Feb 21, 2025
1 parent 672213b commit 74b8d9c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ Please have a look a the Alby OAuth2 Wallet API:

- accountBalance
- accountSummary
- signMessage
- accountInformation
- accountValue4Value
- invoices
Expand Down
16 changes: 16 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SignMessageResponse } from "@webbtc/webln-types";
import { OAuth2Bearer } from "./auth";
import { keysendParamsFromBoostagram } from "./helpers";
import { RequestOptions, rest } from "./request";
Expand All @@ -20,6 +21,7 @@ import {
SendPaymentResponse,
SendBoostagramToAlbyRequestParams,
SwapInfoResponse,
SignMessageRequestParams,
} from "./types";

export class Client {
Expand Down Expand Up @@ -52,6 +54,20 @@ export class Client {
});
}

signMessage(
message: SignMessageRequestParams,
request_options?: Partial<RequestOptions>,
): Promise<SignMessageResponse> {
return rest({
auth: this.auth,
...this.defaultRequestOptions,
...request_options,
endpoint: `/signatures`,
request_body: message,
method: "POST",
});
}

accountSummary(
// eslint-disable-next-line @typescript-eslint/ban-types
params: {},
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ export type GetAccountBalanceResponse = {
unit: string;
};

export type SignMessageRequestParams = {
message: string;
};

export type GetAccountInformationResponse = {
identifier: string;
email: string;
Expand Down

0 comments on commit 74b8d9c

Please sign in to comment.