Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ or for use without any build tools:
<script type="module">
import {
LN /* or NWCClient, or NostrWebLNProvider */,
} from "https://esm.sh/@getalby/sdk@8.0.1"; // jsdelivr.net, skypack.dev also work
} from "https://esm.sh/@getalby/sdk@8.0.2"; // jsdelivr.net, skypack.dev also work

// ... then use the SDK as normal (see below)
</script>
Expand Down
2 changes: 1 addition & 1 deletion examples/lnclient/paywall-esm.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="module">
import { LN, USD } from "https://esm.sh/@getalby/sdk@8.0.1"; // jsdelivr.net, skypack.dev also work
import { LN, USD } from "https://esm.sh/@getalby/sdk@8.0.2"; // jsdelivr.net, skypack.dev also work
const connectionSecret = prompt("Enter a read-only connection secret");
const client = new LN(connectionSecret);

Expand Down
2 changes: 1 addition & 1 deletion examples/nwc/auth.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="module">
import { NostrWebLNProvider } from "https://esm.sh/@getalby/sdk@8.0.1"; // jsdelivr.net, skypack.dev also work
import { NostrWebLNProvider } from "https://esm.sh/@getalby/sdk@8.0.2"; // jsdelivr.net, skypack.dev also work
window.launchNwc = async () => {
try {
const authUrl = prompt("Auth URL", "https://my.albyhub.com/apps/new");
Expand Down
2 changes: 1 addition & 1 deletion examples/nwc/auth_manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import {
NostrWebLNProvider,
NWCClient,
} from "https://esm.sh/@getalby/sdk@8.0.1"; // jsdelivr.net, skypack.dev also work
} from "https://esm.sh/@getalby/sdk@8.0.2"; // jsdelivr.net, skypack.dev also work
import {
generateSecretKey,
getPublicKey,
Expand Down
2 changes: 1 addition & 1 deletion examples/nwc/client/auth.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="module">
import { NWCClient } from "https://esm.sh/@getalby/sdk@8.0.1"; // jsdelivr.net, skypack.dev also work
import { NWCClient } from "https://esm.sh/@getalby/sdk@8.0.2"; // jsdelivr.net, skypack.dev also work

window.launchNwc = async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion examples/nwc/client/auth_manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<button id="reset-button" onclick="window.resetNwc()">Reset</button>

<script type="module">
import { NWCClient } from "https://esm.sh/@getalby/sdk@8.0.1"; // jsdelivr.net, skypack.dev also work
import { NWCClient } from "https://esm.sh/@getalby/sdk@8.0.2"; // jsdelivr.net, skypack.dev also work
import {
generateSecretKey,
getPublicKey,
Expand Down
7 changes: 3 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import crypto from "crypto";
// from https://stackoverflow.com/a/50868276
const toHexString = (bytes: Uint8Array<ArrayBuffer>) =>
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
Expand All @@ -7,11 +6,11 @@ async function generatePreimageAndPaymentHash(): Promise<{
preimage: string;
paymentHash: string;
}> {
const preimageBytes = crypto.randomBytes(32);
const preimageBytes = crypto.getRandomValues(new Uint8Array(32));
const preimage = toHexString(preimageBytes);

const hashBuffer = crypto.createHash("sha256").update(preimageBytes).digest();
const paymentHash = toHexString(hashBuffer);
const hashBuffer = await crypto.subtle.digest("SHA-256", preimageBytes);
const paymentHash = toHexString(new Uint8Array(hashBuffer));

return { preimage, paymentHash };
}
Expand Down
Loading