|
1 | 1 | // Import Third-party Dependencies |
2 | | -import type { PackageJson, Maintainer, Repository, ObjectOfStrings } from "@npm/types"; |
| 2 | +import type { Packument, PackumentVersion } from "@nodesecure/npm-types"; |
3 | 3 | import * as httpie from "@myunisoft/httpie"; |
4 | 4 |
|
5 | 5 | // Import Internal Dependencies |
6 | 6 | import { getLocalRegistryURL } from "../registry.js"; |
7 | 7 | import { getHttpAgent } from "../http.js"; |
8 | 8 |
|
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 | | - |
57 | 9 | export interface PackumentOptions { |
58 | 10 | /** Npm API Token **/ |
59 | 11 | token: string; |
60 | 12 | } |
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 | | - |
112 | 13 | export async function packument( |
113 | 14 | name: string, |
114 | 15 | options?: PackumentOptions |
|
0 commit comments