@gjsify/npm-registry 0.4.43 → 0.4.44

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.
Files changed (2) hide show
  1. package/README.md +46 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @gjsify/npm-registry
2
+
3
+ A small npm registry client used by `gjsify install` to resolve and download packages on GJS. Provides packument fetching with ETag revalidation, tarball download with SRI integrity verification, `.npmrc` parsing with Bearer/Basic auth, and exponential-backoff retry for transient failures. Cross-platform — runs on both GJS and Node using only `globalThis.fetch` and `SubtleCrypto`.
4
+
5
+ Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ gjsify install @gjsify/npm-registry
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import {
17
+ fetchPackument,
18
+ fetchTarball,
19
+ parseNpmrc,
20
+ verifyIntegrity,
21
+ whoami,
22
+ DEFAULT_REGISTRY,
23
+ } from '@gjsify/npm-registry';
24
+
25
+ // Fetch a packument (package metadata)
26
+ const packument = await fetchPackument('lodash');
27
+ const latest = packument['dist-tags'].latest;
28
+ const tarballUrl = packument.versions[latest].dist.tarball;
29
+
30
+ // Download the tarball and verify its integrity
31
+ const bytes = await fetchTarball(tarballUrl, {
32
+ integrity: packument.versions[latest].dist.integrity,
33
+ });
34
+
35
+ // Parse ~/.npmrc for auth
36
+ import { readFileSync } from 'node:fs';
37
+ const npmrc = parseNpmrc(readFileSync('/home/user/.npmrc', 'utf8'));
38
+
39
+ // Verify the current auth token
40
+ const { username } = await whoami(DEFAULT_REGISTRY, npmrc);
41
+ console.log('Logged in as:', username);
42
+ ```
43
+
44
+ ## License
45
+
46
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/npm-registry",
3
- "version": "0.4.43",
3
+ "version": "0.4.44",
4
4
  "description": "npm registry client for the gjsify install backend — packuments, tarballs, .npmrc auth (Node + GJS)",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -37,8 +37,8 @@
37
37
  ],
38
38
  "license": "MIT",
39
39
  "devDependencies": {
40
- "@gjsify/cli": "^0.4.43",
41
- "@gjsify/unit": "^0.4.43",
40
+ "@gjsify/cli": "^0.4.44",
41
+ "@gjsify/unit": "^0.4.44",
42
42
  "typescript": "^6.0.3"
43
43
  },
44
44
  "repository": {