-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not dynamically import crypto
- Loading branch information
Showing
4 changed files
with
17 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,13 +272,25 @@ This library uses a [proxy](https://github.com/getAlby/lightning-address-details | |
|
||
You can disable the proxy by explicitly setting the proxy to false when initializing a lightning address: | ||
|
||
```js | ||
const lightningAddress = new LightningAddress("[email protected]", { | ||
proxy: false, | ||
}); | ||
``` | ||
const lightningAddress = new LightningAddress("[email protected]", {proxy: false}); | ||
|
||
## crypto dependency | ||
|
||
If you get an `crypto is not defined` in NodeJS error you have to import it first: | ||
|
||
```js | ||
import * as crypto from 'crypto'; // or 'node:crypto' | ||
globalThis.crypto = crypto as any; | ||
//or: global.crypto = require('crypto'); | ||
``` | ||
|
||
## fetch() dependency | ||
|
||
This library relies on a global fetch object which will work in browsers and node v18.x or newer. In old version yoi can manually install a global fetch option or polyfill if needed. | ||
This library relies on a global fetch object which will work in browsers and node v18.x or newer. In old version you can manually install a global fetch option or polyfill if needed. | ||
|
||
For example: | ||
|
||
|
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,5 @@ | ||
import * as crypto from "crypto"; // or 'node:crypto' | ||
global.crypto = crypto; | ||
import { LightningAddress } from "@getalby/lightning-tools"; | ||
|
||
const ln = new LightningAddress("[email protected]"); | ||
|
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