@pdpp/cli 0.0.0

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 ADDED
@@ -0,0 +1,40 @@
1
+ # @pdpp/cli
2
+
3
+ Command-line tools for PDPP providers.
4
+
5
+ ## Status
6
+
7
+ This package is the public npm home for the `pdpp` command. The initial package
8
+ scaffold is intentionally narrow: package startup, help output, and shared
9
+ package metadata are in place before the no-owner-token `pdpp connect` flow is
10
+ advertised by provider metadata or hosted docs.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npx -y @pdpp/cli@beta --help
16
+ ```
17
+
18
+ Use the `beta` dist-tag until PDPP intentionally enables stable `latest`
19
+ publication.
20
+
21
+ ## Ownership And Publishing
22
+
23
+ The intended npm scope is `@pdpp`, owned by the durable PDPP/Vana project
24
+ organization rather than an individual maintainer. Normal publication is handled
25
+ by semantic-release from GitHub Actions using npm trusted publishing/OIDC and
26
+ registry provenance.
27
+
28
+ After the package exists on npm, configure the trusted publisher with npm CLI
29
+ 11.5.1+:
30
+
31
+ ```bash
32
+ npm trust github @pdpp/cli --repo vana-com/pdpp --file semantic-release.yml
33
+ npm trust list @pdpp/cli
34
+ ```
35
+
36
+ The existing organization `NPM_TOKEN` may be used only to bootstrap first
37
+ package creation or recover from an emergency publishing incident. It is not the
38
+ steady-state release credential. If used, it must be granular,
39
+ automation-scoped, time-limited, rotated after use, and removed from the normal
40
+ release path once npm trusted publishing is verified.
package/bin/pdpp.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runCli } from '../src/index.js';
4
+
5
+ const exitCode = await runCli(process.argv.slice(2), {
6
+ stderr: process.stderr,
7
+ stdout: process.stdout,
8
+ });
9
+
10
+ process.exitCode = exitCode;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@pdpp/cli",
3
+ "version": "0.0.0",
4
+ "description": "Command-line tools for PDPP providers.",
5
+ "type": "module",
6
+ "bin": {
7
+ "pdpp": "./bin/pdpp.js"
8
+ },
9
+ "exports": {
10
+ ".": "./src/index.js",
11
+ "./package-info": "./src/package-info.js"
12
+ },
13
+ "files": [
14
+ "bin/",
15
+ "src/",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "test": "node --test test/*.test.js",
20
+ "verify": "pnpm test",
21
+ "pack:dry-run": "pnpm pack --dry-run"
22
+ },
23
+ "keywords": [
24
+ "pdpp",
25
+ "personal-data",
26
+ "oauth",
27
+ "cli"
28
+ ],
29
+ "license": "ISC",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/vana-com/pdpp.git",
33
+ "directory": "packages/cli"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/vana-com/pdpp/issues"
37
+ },
38
+ "homepage": "https://github.com/vana-com/pdpp#readme",
39
+ "engines": {
40
+ "node": ">=22.14.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public",
44
+ "provenance": false,
45
+ "registry": "https://registry.npmjs.org/",
46
+ "tag": "beta"
47
+ }
48
+ }
package/src/index.js ADDED
@@ -0,0 +1,77 @@
1
+ import {
2
+ createPdppCliCommand,
3
+ getPdppCliPackageInfo,
4
+ PDPP_CLI_BIN_NAME,
5
+ PDPP_CLI_PACKAGE_NAME,
6
+ } from './package-info.js';
7
+
8
+ const HELP = `PDPP CLI
9
+
10
+ Usage:
11
+ ${PDPP_CLI_BIN_NAME} --help
12
+ ${PDPP_CLI_BIN_NAME} package-info [--provider-url <url>]
13
+ ${PDPP_CLI_BIN_NAME} connect <provider-url>
14
+
15
+ Agent access:
16
+ ${createPdppCliCommand()}
17
+
18
+ Notes:
19
+ connect is gated until the reference AS supports no-owner-token scoped grant completion.
20
+ Do not ask users for owner bearer tokens for routine delegated access.
21
+ `;
22
+
23
+ export async function runCli(argv, io = { stdout: process.stdout, stderr: process.stderr }) {
24
+ const [command, ...rest] = argv;
25
+
26
+ if (!command || command === '--help' || command === '-h' || command === 'help') {
27
+ io.stdout.write(`${HELP}\n`);
28
+ return 0;
29
+ }
30
+
31
+ if (command === 'package-info') {
32
+ const providerUrl = readOption(rest, '--provider-url');
33
+ io.stdout.write(`${JSON.stringify(getPdppCliPackageInfo(providerUrl), null, 2)}\n`);
34
+ return 0;
35
+ }
36
+
37
+ if (command === 'connect') {
38
+ const providerUrl = rest[0];
39
+ if (!providerUrl) {
40
+ io.stderr.write('Usage: pdpp connect <provider-url>\n');
41
+ return 64;
42
+ }
43
+
44
+ const normalizedProviderUrl = normalizeProviderUrl(providerUrl);
45
+ if (!normalizedProviderUrl) {
46
+ io.stderr.write(`Invalid provider URL: ${providerUrl}\n`);
47
+ return 64;
48
+ }
49
+
50
+ io.stderr.write(
51
+ `${PDPP_CLI_PACKAGE_NAME} connect is not enabled yet. The reference AS still needs no-owner-token scoped grant completion before this command can be advertised.\n`
52
+ );
53
+ return 69;
54
+ }
55
+
56
+ io.stderr.write(`Unknown command: ${command}\n\n${HELP}\n`);
57
+ return 64;
58
+ }
59
+
60
+ export function normalizeProviderUrl(value) {
61
+ try {
62
+ const parsed = new URL(value.includes('://') ? value : `https://${value}`);
63
+ parsed.hash = '';
64
+ return parsed.origin;
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ function readOption(argv, name) {
71
+ const index = argv.indexOf(name);
72
+ if (index === -1) {
73
+ return undefined;
74
+ }
75
+
76
+ return argv[index + 1];
77
+ }
@@ -0,0 +1,19 @@
1
+ export const PDPP_CLI_PACKAGE_NAME = '@pdpp/cli';
2
+ export const PDPP_CLI_BIN_NAME = 'pdpp';
3
+ export const PDPP_CLI_VERSION_POLICY = 'beta';
4
+ export const PDPP_CLI_PACKAGE_SPECIFIER = `${PDPP_CLI_PACKAGE_NAME}@${PDPP_CLI_VERSION_POLICY}`;
5
+
6
+ export function createPdppCliCommand(providerUrl = '<provider-url>') {
7
+ return `npx -y ${PDPP_CLI_PACKAGE_SPECIFIER} connect ${providerUrl}`;
8
+ }
9
+
10
+ export function getPdppCliPackageInfo(providerUrl) {
11
+ return {
12
+ packageName: PDPP_CLI_PACKAGE_NAME,
13
+ packageSpecifier: PDPP_CLI_PACKAGE_SPECIFIER,
14
+ binName: PDPP_CLI_BIN_NAME,
15
+ versionPolicy: PDPP_CLI_VERSION_POLICY,
16
+ runCommand: createPdppCliCommand(providerUrl),
17
+ noOwnerToken: true,
18
+ };
19
+ }