@lnurlcash/kit 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -82,8 +82,9 @@ npm pack --dry-run
82
82
  The package and wallet share a version. A wallet tag named `vX.Y.Z` publishes
83
83
  `@lnurlcash/kit@X.Y.Z` from the same commit through
84
84
  `.github/workflows/release-kit.yml` and npm trusted publishing; releases must
85
- not be published from a maintainer workstation. The one-time scoped-package
86
- bootstrap is documented in [RELEASING.md](./RELEASING.md).
85
+ not be published from a maintainer workstation. The release process and
86
+ trusted-publisher configuration are documented in
87
+ [RELEASING.md](./RELEASING.md).
87
88
 
88
89
  ## Licence
89
90
 
package/RELEASING.md CHANGED
@@ -3,27 +3,13 @@
3
3
  The final package is published from `lnurlcash/lnurl-wallet`, not from a
4
4
  workstation and not from the old standalone kit repository.
5
5
 
6
- ## One-time scoped-package bootstrap
6
+ ## Trusted publisher
7
7
 
8
- npm cannot configure a trusted publisher until the package exists. After this
9
- package source has been reviewed and merged, an `lnurlcash` npm organisation
10
- owner must make the one exceptional manual publish:
8
+ The one-time scoped-package bootstrap was completed with `0.14.0-rc.0`, then
9
+ `0.14.0` was published by the reviewed OIDC release workflow. Do not repeat the
10
+ manual bootstrap for later releases.
11
11
 
12
- 1. Build, test and pack the merged source from a disposable clean checkout,
13
- changing only its package version to `0.14.0-rc.0`.
14
- 2. Publish that tarball as a public prerelease with
15
- `npm publish --access public --tag next <tarball>`.
16
- 3. Verify that npm shows `@lnurlcash/kit@0.14.0-rc.0` under the `next` tag and
17
- that no `latest` tag has been created.
18
-
19
- Do not manually publish `0.14.0`: that version is reserved for the reviewed
20
- OIDC release. The prerelease only creates the scoped package so its trusted
21
- publisher can be configured; do not recommend it to production consumers.
22
-
23
- ## One-time trusted-publisher setup
24
-
25
- An npm package owner must configure the trusted publisher for
26
- `@lnurlcash/kit` as:
12
+ The trusted publisher for `@lnurlcash/kit` is configured as:
27
13
 
28
14
  - provider: GitHub Actions
29
15
  - organisation or user: `lnurlcash`
@@ -32,26 +18,31 @@ An npm package owner must configure the trusted publisher for
32
18
  - environment: `npm-publish`
33
19
  - allowed actions: enable direct `npm publish`
34
20
 
35
- A GitHub repository or organisation administrator should create the
36
- `npm-publish` environment, restrict it to `v*` tags and require a maintainer
37
- review. No npm token or GPG key belongs in GitHub secrets; npm uses the
38
- workflow's short-lived OIDC identity and records provenance.
39
-
40
- Do not create a final release until both sides are configured. A missing or
41
- mismatched trusted publisher should fail closed, but it is not a useful release
42
- rehearsal.
21
+ The GitHub `npm-publish` environment restricts deployments to tags matching
22
+ `v*.*.*` and requires a maintainer review. No npm token or GPG key belongs in
23
+ GitHub secrets; npm uses the workflow's short-lived OIDC identity and records
24
+ provenance. A missing or mismatched trusted publisher should fail closed.
43
25
 
44
26
  ## Each release
45
27
 
46
- 1. Choose the next version for both the wallet and kit, then update the kit's
47
- `package.json` and `CHANGELOG.md` in a reviewed pull request.
28
+ The version is never hand-bumped in `package.json` - `src/lib/package.json`'s
29
+ own checked-in `version` (`0.0.0-dev`) is a placeholder, overwritten by
30
+ `release-kit.yml`'s own `npm version "${RELEASE_TAG#v}" --no-git-tag-version`
31
+ step from whichever tag actually triggered the run. This mirrors how the
32
+ wallet's own displayed version already works (`scripts/git-version.mjs` -
33
+ `git describe --tags`, no hand-bumped field either): cutting a release is just
34
+ tagging a commit, nothing to remember to keep in sync first.
35
+
36
+ 1. (Optional but recommended) Add a `CHANGELOG.md` entry summarising what's
37
+ new, in a reviewed pull request.
48
38
  2. Require the wallet CI and the independent `src/lib` package gate to pass.
49
- 3. Merge, then create the shared `vX.Y.Z` tag at that exact merge commit. The
50
- tag must exactly equal `v` plus the version in `src/lib/package.json`.
39
+ 3. Merge, then create the shared `vX.Y.Z` tag at that exact merge commit -
40
+ any valid semver works, npm itself rejects anything else.
51
41
  4. Pushing the tag starts both release workflows. The wallet is tested and
52
- deployed at `X.Y.Z`; `release-kit.yml` independently rebuilds and tests the
53
- package, packs one tarball, performs a dry-run publish and uploads that same
54
- tarball through npm OIDC as `@lnurlcash/kit@X.Y.Z`.
42
+ deployed at `X.Y.Z`; `release-kit.yml` independently sets the package
43
+ version from the tag, rebuilds and tests the package, packs one tarball,
44
+ performs a dry-run publish and uploads that same tarball through npm OIDC
45
+ as `@lnurlcash/kit@X.Y.Z`.
55
46
  5. Verify the workflow, npm version, repository metadata and provenance before
56
47
  announcing the release.
57
48
 
@@ -1,6 +1,6 @@
1
1
  import { type HashWithdrawRequestInfo } from './request.js';
2
2
  import { type Cx1 } from './recoverableNotes.js';
3
- export declare const registerUsername: (server: string, username: string, cx1: string, indexZeroSecretKey: Uint8Array) => Promise<void>;
3
+ export declare const registerUsername: (server: string, username: string, cx1: string, indexZeroSecretKey: Uint8Array, npub?: string) => Promise<void>;
4
4
  export declare const unregisterUsername: (server: string, username: string, indexZeroSecretKey: Uint8Array) => Promise<void>;
5
5
  export type AddressScanResult = {
6
6
  index: number;
package/dist/index.js CHANGED
@@ -337,10 +337,14 @@ var requireNoteK1 = (url) => {
337
337
  };
338
338
  var noteDeclaredAmount = (url) => {
339
339
  try {
340
- const raw = new URL(url).searchParams.get("amount");
341
- if (raw === null) return null;
342
- const n = Number(raw);
343
- return Number.isFinite(n) ? n : null;
340
+ const parsed = new URL(url);
341
+ const raw = parsed.searchParams.get("amount");
342
+ if (raw !== null) {
343
+ const n = Number(raw);
344
+ return Number.isFinite(n) ? n : null;
345
+ }
346
+ const sig = parsed.searchParams.get("sig");
347
+ return sig ? decodeCs1WithAmount(sig)?.amountMsat ?? null : null;
344
348
  } catch {
345
349
  return null;
346
350
  }
@@ -368,10 +372,15 @@ var buildNoteUrl = (withdrawLink, k1, amountMsat) => {
368
372
  }
369
373
  return url.toString();
370
374
  };
375
+ var amountIsImpliedBySignature = (signature) => Boolean(signature) && isCs1WithAmount(signature);
371
376
  var withNewK1 = (url, k1, amountMsat, signature) => {
372
377
  const newUrl = new URL(url);
373
378
  newUrl.searchParams.set("k1", k1);
374
- newUrl.searchParams.set("amount", String(amountMsat));
379
+ if (amountIsImpliedBySignature(signature)) {
380
+ newUrl.searchParams.delete("amount");
381
+ } else {
382
+ newUrl.searchParams.set("amount", String(amountMsat));
383
+ }
375
384
  if (signature) newUrl.searchParams.set("sig", signature);
376
385
  else newUrl.searchParams.delete("sig");
377
386
  return newUrl.toString();
@@ -379,13 +388,22 @@ var withNewK1 = (url, k1, amountMsat, signature) => {
379
388
  var withoutK1 = (url, amountMsat, signature) => {
380
389
  const newUrl = new URL(url);
381
390
  newUrl.searchParams.delete("k1");
382
- newUrl.searchParams.set("amount", String(amountMsat));
391
+ if (amountIsImpliedBySignature(signature)) {
392
+ newUrl.searchParams.delete("amount");
393
+ } else {
394
+ newUrl.searchParams.set("amount", String(amountMsat));
395
+ }
383
396
  if (signature) newUrl.searchParams.set("sig", signature);
384
397
  else newUrl.searchParams.delete("sig");
385
398
  return newUrl.toString();
386
399
  };
387
400
  var withoutSignature = (url) => {
388
401
  const newUrl = new URL(url);
402
+ const sig = newUrl.searchParams.get("sig");
403
+ if (sig && !newUrl.searchParams.has("amount")) {
404
+ const decoded = decodeCs1WithAmount(sig);
405
+ if (decoded) newUrl.searchParams.set("amount", String(decoded.amountMsat));
406
+ }
389
407
  newUrl.searchParams.delete("sig");
390
408
  return newUrl.toString();
391
409
  };
@@ -1190,9 +1208,10 @@ var addressProofUrl = (server, username, indexZeroSecretKey, action) => {
1190
1208
  );
1191
1209
  return url;
1192
1210
  };
1193
- var registerUsername = async (server, username, cx1, indexZeroSecretKey) => {
1211
+ var registerUsername = async (server, username, cx1, indexZeroSecretKey, npub) => {
1194
1212
  const url = addressProofUrl(server, username, indexZeroSecretKey, "register");
1195
1213
  url.searchParams.set("cx1", cx1);
1214
+ if (npub) url.searchParams.set("npub", npub);
1196
1215
  const body = await lnurlFetch(url, "POST");
1197
1216
  if (body?.status !== "OK") {
1198
1217
  throw new Error("SERVICE did not confirm the registration.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lnurlcash/kit",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "description": "LNURLcash (LUD-25) protocol client for TypeScript",
5
5
  "author": "dni",
6
6
  "contributors": [