Skip to content

Commit 3680828

Browse files
authored
Merge pull request #144 from NodeSecure/nodesecure-types
Use NodeSecure npm types
2 parents b29922a + 37e390d commit 3680828

File tree

3 files changed

+6
-102
lines changed

3 files changed

+6
-102
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"homepage": "https://github.com/NodeSecure/npm-registry-sdk#readme",
3030
"dependencies": {
3131
"@myunisoft/httpie": "^4.0.1",
32-
"@npm/types": "^1.0.2"
32+
"@nodesecure/npm-types": "^1.0.0"
3333
},
3434
"devDependencies": {
3535
"@nodesecure/eslint-config": "^1.8.0",

src/api/packument.ts

Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,15 @@
11
// Import Third-party Dependencies
2-
import type { PackageJson, Maintainer, Repository, ObjectOfStrings } from "@npm/types";
2+
import type { Packument, PackumentVersion } from "@nodesecure/npm-types";
33
import * as httpie from "@myunisoft/httpie";
44

55
// Import Internal Dependencies
66
import { getLocalRegistryURL } from "../registry.js";
77
import { getHttpAgent } from "../http.js";
88

9-
export type { PackageJson, Maintainer, Repository };
10-
11-
export interface DistSignature {
12-
keyid: string;
13-
sig: string;
14-
}
15-
16-
export interface Dist {
17-
/**
18-
* the url to the tarball for the package version
19-
*/
20-
tarball: string;
21-
/**
22-
* the sha1 sum of the tarball
23-
*/
24-
shasum: string;
25-
/**
26-
* subresource integrity string! `npm view ssri`
27-
* https://w3c.github.io/webappsec-subresource-integrity/
28-
*/
29-
integrity?: string;
30-
/**
31-
* the number of files in the tarball. this is on most packages published >= 2018
32-
*/
33-
fileCount?: number;
34-
/**
35-
* the unpacked size of the files in the tarball. >= 2018
36-
*/
37-
unpackedSize?: number;
38-
/**
39-
* pgp signed package signature
40-
* https://blog.npmjs.org/post/172999548390/new-pgp-machinery
41-
*/
42-
"npm-signature"?: string;
43-
/**
44-
* NPM Provenance
45-
*
46-
* @see https://docs.npmjs.com/generating-provenance-statements
47-
*/
48-
attestations?: {
49-
url: string;
50-
provenance: {
51-
predicateType: string;
52-
}
53-
};
54-
signatures?: DistSignature[];
55-
}
56-
579
export interface PackumentOptions {
5810
/** Npm API Token **/
5911
token: string;
6012
}
61-
62-
export interface Packument {
63-
_id: string;
64-
_rev: string;
65-
name: string;
66-
readme?: string;
67-
description?: string;
68-
"dist-tags": { latest?: string } & ObjectOfStrings;
69-
versions: {
70-
[key: string]: PackumentVersion
71-
};
72-
maintainers: Maintainer[];
73-
time: {
74-
modified: string,
75-
created: string,
76-
[key: string]: string
77-
};
78-
users?: {
79-
[key: string]: boolean;
80-
}
81-
contributors?: Maintainer[];
82-
homepage?: string;
83-
keywords?: string[];
84-
repository?: Repository;
85-
author?: Maintainer;
86-
bugs?: { url: string };
87-
license: string;
88-
// left out users (stars) deprecated, and attachments (does nothing)
89-
readmeFilename?: string;
90-
}
91-
92-
export type PackumentVersion = PackageJson & {
93-
gitHead?: string;
94-
maintainers: Maintainer[];
95-
dist: Dist;
96-
types?: string;
97-
deprecated?: string;
98-
homepage?: string;
99-
_id: string;
100-
_npmVersion: string;
101-
_nodeVersion: string;
102-
_npmUser: Maintainer;
103-
_hasShrinkwrap?: boolean;
104-
_engineSupported?: boolean;
105-
_defaultsLoaded?: boolean;
106-
_npmOperationalInternal?: {
107-
host: string;
108-
tmp: string;
109-
}
110-
};
111-
11213
export async function packument(
11314
name: string,
11415
options?: PackumentOptions

test/api.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ describe("downloads", () => {
8383
});
8484
});
8585

86-
describe("metadata", () => {
86+
/**
87+
* NOTE: https://registry.npmjs.org return empty Object since 04/2024!
88+
*/
89+
describe.skip("metadata", () => {
8790
it("should return metadata for the npm registry", async() => {
8891
const { db_name: dbName } = await metadata();
8992

0 commit comments

Comments
 (0)