-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from getAlby/feat/remove-browserify
feat: remove browserify, crypto-js and source maps
- Loading branch information
Showing
15 changed files
with
106 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as crypto from "crypto"; // or 'node:crypto' | ||
global.crypto = crypto; | ||
import { LightningAddress } from "@getalby/lightning-tools"; | ||
|
||
const ln = new LightningAddress("hello@getalby.com"); | ||
|
||
await ln.fetch(); | ||
// request an invoice for 1000 satoshis | ||
// this returns a new `Invoice` class that can also be used to validate the payment | ||
const invoice = await ln.requestInvoice({ satoshi: 1000 }); | ||
|
||
console.log(invoice.paymentRequest); // print the payment request | ||
console.log(invoice.paymentHash); // print the payment hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import jestFetchMock from 'jest-fetch-mock'; | ||
import jestFetchMock from "jest-fetch-mock"; | ||
|
||
jestFetchMock.enableMocks(); | ||
jestFetchMock.enableMocks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// from https://stackoverflow.com/a/50868276 | ||
export const fromHexString = (hexString: string) => | ||
Uint8Array.from( | ||
hexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16)), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// from https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest | ||
export async function sha256(message: string | Uint8Array) { | ||
// encode as UTF-8 | ||
const msgBuffer = | ||
typeof message === "string" ? new TextEncoder().encode(message) : message; | ||
|
||
// hash the message | ||
const hashBuffer = await crypto.subtle.digest("SHA-256", msgBuffer); | ||
|
||
// convert ArrayBuffer to Array | ||
const hashArray = Array.from(new Uint8Array(hashBuffer)); | ||
|
||
// convert bytes to hex string | ||
const hashHex = hashArray | ||
.map((b) => b.toString(16).padStart(2, "0")) | ||
.join(""); | ||
return hashHex; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters