@postman-cs/onboarding-api 3.4.6

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/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@postman-cs/onboarding-api",
3
+ "version": "3.4.6",
4
+ "description": "Composite Postman API onboarding GitHub Action.",
5
+ "files": [
6
+ "action.yml",
7
+ "README.md",
8
+ "scripts/verify-release-artifacts.mjs"
9
+ ],
10
+ "engines": {
11
+ "node": ">=24"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/postman-cs/postman-api-onboarding-action"
19
+ },
20
+ "scripts": {
21
+ "prepare": "git config core.hooksPath .githooks",
22
+ "test": "vitest run && node --test scripts/verify-e2e-release.test.mjs",
23
+ "docs:tables": "node scripts/render-action-tables.mjs",
24
+ "typecheck": "tsc --noEmit -p tsconfig.json",
25
+ "lint": "eslint .",
26
+ "lint:fix": "eslint . --fix"
27
+ },
28
+ "keywords": [
29
+ "github-action",
30
+ "postman"
31
+ ],
32
+ "license": "MIT",
33
+ "devDependencies": {
34
+ "@commitlint/cli": "^21.2.1",
35
+ "@commitlint/config-conventional": "^21.2.0",
36
+ "@eslint/js": "^10.0.1",
37
+ "@types/node": "^26.1.1",
38
+ "eslint": "^10.7.0",
39
+ "typescript": "^6.0.3",
40
+ "typescript-eslint": "^8.65.0",
41
+ "vitest": "^4.1.10",
42
+ "yaml": "^2.9.0"
43
+ },
44
+ "overrides": {
45
+ "brace-expansion@1": "1.1.18",
46
+ "brace-expansion@2": "2.1.4",
47
+ "brace-expansion@3": "3.0.6",
48
+ "brace-expansion@4": "5.0.9",
49
+ "brace-expansion@5": "5.0.9",
50
+ "fast-uri": ">=3.1.5",
51
+ "nanoid@3": "3.3.18",
52
+ "js-yaml@4": "4.3.1",
53
+ "postcss": ">=8.5.26",
54
+ "vite@8": "8.2.1",
55
+ "ws": ">=8.21.3",
56
+ "sharp": ">=0.35.0",
57
+ "undici@6": "6.28.0",
58
+ "undici@7": "7.29.0",
59
+ "undici@8": "8.10.0"
60
+ }
61
+ }
@@ -0,0 +1,155 @@
1
+ /* global console, process */
2
+ import { createHash } from 'node:crypto';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { existsSync, readFileSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const SHA256_HEX = /^[a-f0-9]{64}$/;
9
+ const REQUIRED_FIELDS = ['repository', 'commit_sha', 'tag', 'package_name', 'package_version'];
10
+
11
+ /**
12
+ * @param {string | Buffer} fileOrBytes
13
+ * @returns {string}
14
+ */
15
+ export function sha256(fileOrBytes) {
16
+ const bytes = typeof fileOrBytes === 'string' ? readFileSync(fileOrBytes) : fileOrBytes;
17
+ return createHash('sha256').update(bytes).digest('hex');
18
+ }
19
+
20
+ /**
21
+ * @param {string | Buffer} fileOrBytes
22
+ * @returns {string}
23
+ */
24
+ export function computeNpmSri(fileOrBytes) {
25
+ const bytes = typeof fileOrBytes === 'string' ? readFileSync(fileOrBytes) : fileOrBytes;
26
+ return `sha512-${createHash('sha512').update(bytes).digest('base64')}`;
27
+ }
28
+
29
+ /**
30
+ * @param {string} expected
31
+ * @param {string} actual
32
+ */
33
+ export function assertNpmSriMatch(expected, actual) {
34
+ if (String(expected ?? '').trim() !== String(actual ?? '').trim()) {
35
+ throw new Error('Published npm integrity differs from staged tarball');
36
+ }
37
+ }
38
+
39
+ /**
40
+ * @param {string} tag
41
+ * @param {string} packageVersion
42
+ */
43
+ export function validateTagVersion(tag, packageVersion) {
44
+ if (typeof tag !== 'string' || typeof packageVersion !== 'string') {
45
+ throw new Error('tag and package version must be strings');
46
+ }
47
+ if (!/^\d+\.\d+\.\d+$/.test(packageVersion)) {
48
+ throw new Error(`invalid package version ${packageVersion}`);
49
+ }
50
+ const [major, minor, patch] = packageVersion.split('.');
51
+ const allowed = [`v${packageVersion}`];
52
+ if (patch === '0') allowed.push(`v${major}.${minor}`);
53
+ if (!allowed.includes(tag)) {
54
+ throw new Error(`tag ${tag} does not match package version ${packageVersion}`);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * @param {unknown} value
60
+ * @param {string} label
61
+ */
62
+ function assertNonEmptyString(value, label) {
63
+ if (typeof value !== 'string' || value.length === 0) {
64
+ throw new Error(`manifest ${label} must be a non-empty string`);
65
+ }
66
+ }
67
+
68
+ /**
69
+ * @param {unknown} manifest
70
+ * @param {{ repository: string, commitSha: string, tag: string }} expected
71
+ */
72
+ export function validateManifest(manifest, expected) {
73
+ if (!manifest || typeof manifest !== 'object') throw new Error('unsupported manifest schema');
74
+ const body = /** @type {Record<string, unknown>} */ (manifest);
75
+ if (body.schema_version !== 1) throw new Error('unsupported manifest schema');
76
+ for (const key of REQUIRED_FIELDS) assertNonEmptyString(body[key], key);
77
+ for (const [key, value] of Object.entries({
78
+ repository: expected.repository,
79
+ commit_sha: expected.commitSha,
80
+ tag: expected.tag
81
+ })) {
82
+ if (body[key] !== value) throw new Error(`${key} does not match this release`);
83
+ }
84
+ if (!Array.isArray(body.artifacts) || body.artifacts.length !== 1) {
85
+ throw new Error('manifest artifact allowlist is invalid');
86
+ }
87
+ const artifact = /** @type {Record<string, unknown>} */ (body.artifacts[0] ?? {});
88
+ if (artifact.path !== 'release.tgz' || typeof artifact.sha256 !== 'string' || !SHA256_HEX.test(artifact.sha256)) {
89
+ throw new Error('manifest artifact is invalid');
90
+ }
91
+ return body;
92
+ }
93
+
94
+ /**
95
+ * @param {string} tarball
96
+ * @returns {{ name: string, version: string }}
97
+ */
98
+ function packageJson(tarball) {
99
+ return JSON.parse(execFileSync('tar', ['-xOf', tarball, 'package/package.json'], { encoding: 'utf8' }));
100
+ }
101
+
102
+ /**
103
+ * @param {string} directory
104
+ * @param {{ repository: string, commitSha: string, tag: string }} expected
105
+ */
106
+ export function verifyReleaseArtifacts(directory, expected) {
107
+ const manifestPath = path.join(directory, 'release-manifest.json');
108
+ if (!existsSync(manifestPath)) throw new Error('Release artifact verification failed: missing release-manifest.json');
109
+ let manifest;
110
+ try {
111
+ manifest = validateManifest(JSON.parse(readFileSync(manifestPath, 'utf8')), expected);
112
+ } catch (error) {
113
+ throw new Error(`Release artifact verification failed: ${error instanceof Error ? error.message : String(error)}`, {
114
+ cause: error
115
+ });
116
+ }
117
+ const artifact = /** @type {{ path: string, sha256: string }} */ (/** @type {unknown[]} */ (manifest.artifacts)[0]);
118
+ const tarball = path.join(directory, artifact.path);
119
+ if (!existsSync(tarball)) {
120
+ throw new Error(`Release artifact verification failed: missing artifact ${artifact.path}`);
121
+ }
122
+ if (sha256(tarball) !== artifact.sha256) {
123
+ throw new Error(`Release artifact verification failed: checksum mismatch for ${artifact.path}`);
124
+ }
125
+ const pkg = packageJson(tarball);
126
+ if (pkg.name !== manifest.package_name) {
127
+ throw new Error('Release artifact verification failed: package name does not match manifest');
128
+ }
129
+ if (pkg.version !== manifest.package_version) {
130
+ throw new Error('Release artifact verification failed: package version does not match manifest');
131
+ }
132
+ try {
133
+ validateTagVersion(expected.tag, pkg.version);
134
+ } catch (error) {
135
+ throw new Error(`Release artifact verification failed: ${error instanceof Error ? error.message : String(error)}`, {
136
+ cause: error
137
+ });
138
+ }
139
+ return manifest;
140
+ }
141
+
142
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
143
+ try {
144
+ const directory = path.resolve(process.argv[2] ?? '.');
145
+ verifyReleaseArtifacts(directory, {
146
+ repository: process.env.GITHUB_REPOSITORY ?? '',
147
+ commitSha: process.env.GITHUB_SHA ?? '',
148
+ tag: process.env.GITHUB_REF_NAME ?? ''
149
+ });
150
+ console.log('Release artifacts match the manifest and invocation identity.');
151
+ } catch (error) {
152
+ console.error(error instanceof Error ? error.message : String(error));
153
+ process.exitCode = 1;
154
+ }
155
+ }