@supersdk/supercli 0.1.0-dev.1

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 (100) hide show
  1. package/dist/api/consoleClient.js +132 -0
  2. package/dist/api/consoleClient.js.map +1 -0
  3. package/dist/auth/browserAuth.js +163 -0
  4. package/dist/auth/browserAuth.js.map +1 -0
  5. package/dist/auth/refresh.js +32 -0
  6. package/dist/auth/refresh.js.map +1 -0
  7. package/dist/cli.js +46 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/commands/accounts.js +46 -0
  10. package/dist/commands/accounts.js.map +1 -0
  11. package/dist/commands/createApp.js +225 -0
  12. package/dist/commands/createApp.js.map +1 -0
  13. package/dist/commands/login.js +54 -0
  14. package/dist/commands/login.js.map +1 -0
  15. package/dist/commands/logout.js +99 -0
  16. package/dist/commands/logout.js.map +1 -0
  17. package/dist/commands/publishSite.js +361 -0
  18. package/dist/commands/publishSite.js.map +1 -0
  19. package/dist/commands/switchaccount.js +35 -0
  20. package/dist/commands/switchaccount.js.map +1 -0
  21. package/dist/commands/update.js +95 -0
  22. package/dist/commands/update.js.map +1 -0
  23. package/dist/config/environments.js +53 -0
  24. package/dist/config/environments.js.map +1 -0
  25. package/dist/createApp/copyTemplate.js +237 -0
  26. package/dist/createApp/copyTemplate.js.map +1 -0
  27. package/dist/publish/orgResolve.js +30 -0
  28. package/dist/publish/orgResolve.js.map +1 -0
  29. package/dist/publish/responseClassifier.js +111 -0
  30. package/dist/publish/responseClassifier.js.map +1 -0
  31. package/dist/publish/siteClient.js +113 -0
  32. package/dist/publish/siteClient.js.map +1 -0
  33. package/dist/publish/siteConfig.js +190 -0
  34. package/dist/publish/siteConfig.js.map +1 -0
  35. package/dist/publish/siteZip.js +172 -0
  36. package/dist/publish/siteZip.js.map +1 -0
  37. package/dist/store/accountStore.js +236 -0
  38. package/dist/store/accountStore.js.map +1 -0
  39. package/dist/store/backends/encryptedFile.js +162 -0
  40. package/dist/store/backends/encryptedFile.js.map +1 -0
  41. package/dist/store/backends/osKeyring.js +283 -0
  42. package/dist/store/backends/osKeyring.js.map +1 -0
  43. package/dist/store/credentialStore.js +65 -0
  44. package/dist/store/credentialStore.js.map +1 -0
  45. package/dist/template/README.md +144 -0
  46. package/dist/template/android/.gitkeep +1 -0
  47. package/dist/template/android/app/build.gradle.kts +122 -0
  48. package/dist/template/android/app/src/main/AndroidManifest.xml +19 -0
  49. package/dist/template/android/app/src/main/java/com/supersdk/simple/MainActivity.java +17 -0
  50. package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +22 -0
  51. package/dist/template/android/app/src/test/java/com/supersdk/simple/AppNameResourceTest.java +19 -0
  52. package/dist/template/android/build.gradle.kts +3 -0
  53. package/dist/template/android/gradle/supersdk-config-reader.gradle +61 -0
  54. package/dist/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  55. package/dist/template/android/gradle/wrapper/gradle-wrapper.properties +8 -0
  56. package/dist/template/android/gradle.properties +3 -0
  57. package/dist/template/android/gradlew +251 -0
  58. package/dist/template/android/settings.gradle.kts +25 -0
  59. package/dist/template/android/supersdk-default.config.json +17 -0
  60. package/dist/template/ios/MockSuperSDKPackage/Package.swift +15 -0
  61. package/dist/template/ios/MockSuperSDKPackage/Sources/SuperSDK/SuperSDK.swift +25 -0
  62. package/dist/template/ios/Resources/Info.plist +43 -0
  63. package/dist/template/ios/Sources/App/AppDelegate.swift +20 -0
  64. package/dist/template/ios/Sources/App/SceneDelegate.swift +14 -0
  65. package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +7 -0
  66. package/dist/template/ios/Sources/App/SimpleSDKProbe.swift +26 -0
  67. package/dist/template/ios/Sources/App/SimpleSDKProvider.swift +4 -0
  68. package/dist/template/ios/Sources/App/SimpleViewController.swift +20 -0
  69. package/dist/template/ios/Tests/SimpleAppTests/SimpleSDKInitializationTests.swift +17 -0
  70. package/dist/template/ios/project.yml +67 -0
  71. package/dist/template/scripts/android_snapshot_canary.py +136 -0
  72. package/dist/template/scripts/build_android.sh +240 -0
  73. package/dist/template/scripts/build_ios.sh +261 -0
  74. package/dist/template/scripts/build_web.sh +12 -0
  75. package/dist/template/scripts/serve_web.py +51 -0
  76. package/dist/template/scripts/super_build_orchestrator.py +400 -0
  77. package/dist/template/scripts/supersdk_template.py +611 -0
  78. package/dist/template/scripts/web_host_validator.py +103 -0
  79. package/dist/template/scripts/web_package.py +202 -0
  80. package/dist/template/scripts/ws03_shared_schema_merge_guard.py +73 -0
  81. package/dist/template/super_build.sh +116 -0
  82. package/dist/template/supersdk.yaml +15 -0
  83. package/dist/template/web/src/css/style.css +83 -0
  84. package/dist/template/web/src/index.html +37 -0
  85. package/dist/template/web/src/js/app.js +99 -0
  86. package/dist/template/web/src/js/supersdk.js +1848 -0
  87. package/dist/template/web/src/js/supersdk.provenance.json +6 -0
  88. package/dist/update/channelResolver.js +183 -0
  89. package/dist/update/channelResolver.js.map +1 -0
  90. package/dist/update/installSafety.js +135 -0
  91. package/dist/update/installSafety.js.map +1 -0
  92. package/dist/util/fsAtomic.js +294 -0
  93. package/dist/util/fsAtomic.js.map +1 -0
  94. package/dist/util/log.js +55 -0
  95. package/dist/util/log.js.map +1 -0
  96. package/dist/util/origin.js +66 -0
  97. package/dist/util/origin.js.map +1 -0
  98. package/dist/util/prompt.js +113 -0
  99. package/dist/util/prompt.js.map +1 -0
  100. package/package.json +43 -0
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ // Redacted structured logging (AC-8 / TC-27 / TC-28).
3
+ //
4
+ // Discipline enforced across the codebase: raw secret values (authorization
5
+ // code, access_token, refresh_token, passphrase) must NEVER be passed to log()
6
+ // — not even under a "safe" key. This module's redact() is defense-in-depth for
7
+ // meta objects that might accidentally carry a secret-shaped field, not the
8
+ // primary control; the primary control is "call sites never log secrets".
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.log = void 0;
11
+ exports.maskEmail = maskEmail;
12
+ const SECRET_KEY_PATTERN = /token|secret|passphrase|password|code/i;
13
+ const REDACTED = '[redacted]';
14
+ function redact(value, depth = 0) {
15
+ if (value == null || depth > 4)
16
+ return value;
17
+ if (Array.isArray(value))
18
+ return value.map((v) => redact(v, depth + 1));
19
+ if (typeof value === 'object') {
20
+ const out = {};
21
+ for (const [k, v] of Object.entries(value)) {
22
+ out[k] = SECRET_KEY_PATTERN.test(k) ? REDACTED : redact(v, depth + 1);
23
+ }
24
+ return out;
25
+ }
26
+ return value;
27
+ }
28
+ /** `a***@example.com` — enough to recognize an account, not enough to log the email plainly. */
29
+ function maskEmail(email) {
30
+ const at = email.indexOf('@');
31
+ if (at <= 0)
32
+ return '***';
33
+ const local = email.slice(0, at);
34
+ const head = local.length <= 1 ? local : local[0];
35
+ return `${head}***${email.slice(at)}`;
36
+ }
37
+ function write(level, message, meta) {
38
+ const stream = level === 'error' || level === 'warn' ? process.stderr : process.stdout;
39
+ const safeMeta = meta ? redact(meta) : undefined;
40
+ if (process.env.SUPERCLI_LOG === 'json') {
41
+ stream.write(`${JSON.stringify({ level, ts: new Date().toISOString(), message, ...(safeMeta ? { meta: safeMeta } : {}) })}\n`);
42
+ return;
43
+ }
44
+ if (level === 'debug' && !process.env.SUPERCLI_DEBUG)
45
+ return;
46
+ const suffix = safeMeta && Object.keys(safeMeta).length > 0 ? ` ${JSON.stringify(safeMeta)}` : '';
47
+ stream.write(`[${level}] ${message}${suffix}\n`);
48
+ }
49
+ exports.log = {
50
+ debug: (message, meta) => write('debug', message, meta),
51
+ info: (message, meta) => write('info', message, meta),
52
+ warn: (message, meta) => write('warn', message, meta),
53
+ error: (message, meta) => write('error', message, meta),
54
+ };
55
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/util/log.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,gFAAgF;AAChF,4EAA4E;AAC5E,0EAA0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,OAAO,EAAE,IAAI,CAAC;IACzF,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;IACvF,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;IACvF,KAAK,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;CAC1F,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ // Origin normalization + transport-security gate (AC-10 / TC-34 / TC-35).
3
+ //
4
+ // Rule: any origin used to talk to a Console API must be HTTPS, EXCEPT loopback
5
+ // hosts (127.0.0.1 / ::1 / localhost) which may use plain HTTP — this is what
6
+ // makes the local full-chain dev loop (docker-compose --profile full) usable
7
+ // without a local TLS cert, while still refusing to send bearer credentials to
8
+ // an arbitrary HTTP endpoint on the open network.
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.OriginError = void 0;
11
+ exports.isLoopbackHost = isLoopbackHost;
12
+ exports.assertOriginAllowed = assertOriginAllowed;
13
+ exports.normalizeOrigin = normalizeOrigin;
14
+ class OriginError extends Error {
15
+ constructor(message) {
16
+ super(message);
17
+ this.name = 'OriginError';
18
+ }
19
+ }
20
+ exports.OriginError = OriginError;
21
+ const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]']);
22
+ function isLoopbackHost(hostname) {
23
+ return LOOPBACK_HOSTS.has(hostname.toLowerCase());
24
+ }
25
+ /**
26
+ * Parses + normalizes an origin string (scheme://host[:port]) and enforces the
27
+ * HTTPS-except-loopback gate. Throws OriginError on any violation. Path/query/
28
+ * fragment are rejected — an "origin" must be exactly scheme+host+port.
29
+ */
30
+ function assertOriginAllowed(input) {
31
+ let url;
32
+ try {
33
+ url = new URL(input);
34
+ }
35
+ catch {
36
+ throw new OriginError(`invalid origin url: ${input}`);
37
+ }
38
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
39
+ throw new OriginError(`origin must be http(s): ${input}`);
40
+ }
41
+ if (url.pathname !== '/' && url.pathname !== '') {
42
+ throw new OriginError(`origin must not include a path: ${input}`);
43
+ }
44
+ if (url.search || url.hash || url.username || url.password) {
45
+ throw new OriginError(`origin must be scheme+host+port only: ${input}`);
46
+ }
47
+ const loopback = isLoopbackHost(url.hostname);
48
+ if (url.protocol === 'http:' && !loopback) {
49
+ throw new OriginError(`origin must be HTTPS (loopback is the only http exception): ${input}`);
50
+ }
51
+ return normalizeOrigin(url);
52
+ }
53
+ /** scheme://host[:port] with no trailing slash, lower-cased host. */
54
+ function normalizeOrigin(url) {
55
+ const u = typeof url === 'string' ? new URL(url) : url;
56
+ const host = u.hostname.toLowerCase();
57
+ const port = u.port ? `:${u.port}` : '';
58
+ return `${u.protocol}//${host}${port}`;
59
+ }
60
+ // Note: an earlier draft of consoleClient distinguished same- vs
61
+ // cross-origin redirects and had a helper here for that (isCrossOrigin).
62
+ // consoleClient.performRequest ended up treating ANY 3xx as a hard failure
63
+ // (AC-10's redirect:'manual' gate is a strict superset — it never follows a
64
+ // redirect at all, same-origin or not), which made that distinction
65
+ // unnecessary. Removed rather than kept as speculative dead code (review A-3).
66
+ //# sourceMappingURL=origin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin.js","sourceRoot":"","sources":["../../src/util/origin.ts"],"names":[],"mappings":";AAAA,0EAA0E;AAC1E,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,kDAAkD;;;AAWlD,wCAEC;AAOD,kDA0BC;AAGD,0CAKC;AApDD,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;C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AAC;IAED,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED,qEAAqE;AACrE,SAAgB,eAAe,CAAC,GAAiB;IAC/C,MAAM,CAAC,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACvD,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,OAAO,GAAG,CAAC,CAAC,QAAQ,KAAK,IAAI,GAAG,IAAI,EAAE,CAAC;AACzC,CAAC;AAED,iEAAiE;AACjE,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,oEAAoE;AACpE,+EAA+E"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.promptLineSync = promptLineSync;
37
+ exports.promptHiddenSync = promptHiddenSync;
38
+ // Synchronous terminal prompts. Kept synchronous (blocking read on fd 0)
39
+ // deliberately: CredentialBackend.get/set are synchronous (store/credentialStore.ts),
40
+ // and a passphrase prompt for the encrypted-file backend must be able to run
41
+ // from inside that synchronous call without infecting the whole store layer
42
+ // with async/await. This is the same technique the `prompt-sync` package uses.
43
+ const fs = __importStar(require("node:fs"));
44
+ const CHAR_LF = String.fromCharCode(10);
45
+ const CHAR_CR = String.fromCharCode(13);
46
+ const CHAR_EOF = String.fromCharCode(4); // Ctrl-D
47
+ const CHAR_ETX = String.fromCharCode(3); // Ctrl-C
48
+ const CHAR_DEL = String.fromCharCode(127);
49
+ const CHAR_BS = String.fromCharCode(8);
50
+ function readCharFromFd(fd, buf) {
51
+ try {
52
+ return fs.readSync(fd, buf, 0, 1, null);
53
+ }
54
+ catch (err) {
55
+ if (err.code === 'EAGAIN') {
56
+ return readCharFromFd(fd, buf);
57
+ }
58
+ throw err;
59
+ }
60
+ }
61
+ /** Visible line input (used for pasting the one-time authorization code). */
62
+ function promptLineSync(question) {
63
+ process.stderr.write(question);
64
+ const buf = Buffer.alloc(1);
65
+ let result = '';
66
+ for (;;) {
67
+ const bytesRead = readCharFromFd(0, buf);
68
+ if (bytesRead === 0)
69
+ break; // EOF
70
+ const ch = buf.toString('utf8');
71
+ if (ch === CHAR_LF)
72
+ break;
73
+ if (ch === CHAR_CR)
74
+ continue;
75
+ result += ch;
76
+ }
77
+ return result;
78
+ }
79
+ /** Masked input where the terminal supports raw mode; falls back to visible input otherwise (piped stdin, CI). */
80
+ function promptHiddenSync(question) {
81
+ const stdin = process.stdin;
82
+ if (!stdin.isTTY || typeof stdin.setRawMode !== 'function') {
83
+ return promptLineSync(question);
84
+ }
85
+ process.stderr.write(question);
86
+ stdin.setRawMode(true);
87
+ const buf = Buffer.alloc(1);
88
+ let result = '';
89
+ try {
90
+ for (;;) {
91
+ const bytesRead = readCharFromFd(0, buf);
92
+ if (bytesRead === 0)
93
+ break;
94
+ const ch = buf.toString('utf8');
95
+ if (ch === CHAR_LF || ch === CHAR_CR || ch === CHAR_EOF)
96
+ break;
97
+ if (ch === CHAR_ETX) {
98
+ process.exit(130);
99
+ }
100
+ if (ch === CHAR_DEL || ch === CHAR_BS) {
101
+ result = result.slice(0, -1);
102
+ continue;
103
+ }
104
+ result += ch;
105
+ }
106
+ }
107
+ finally {
108
+ stdin.setRawMode(false);
109
+ process.stderr.write('\n');
110
+ }
111
+ return result;
112
+ }
113
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/util/prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,wCAaC;AAGD,4CA8BC;AAxED,yEAAyE;AACzE,sFAAsF;AACtF,6EAA6E;AAC7E,4EAA4E;AAC5E,+EAA+E;AAC/E,4CAA8B;AAE9B,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AACxC,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;AAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;AAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AAC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C,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACzC,IAAI,SAAS,KAAK,CAAC;gBAAE,MAAM;YAC3B,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,QAAQ;gBAAE,MAAM;YAC/D,IAAI,EAAE,KAAK,QAAQ,EAAE,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;YACD,IAAI,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;gBACtC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC7B,SAAS;YACX,CAAC;YACD,MAAM,IAAI,EAAE,CAAC;QACf,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@supersdk/supercli",
3
+ "version": "0.1.0-dev.1",
4
+ "description": "SuperSDK official command-line tool: browser-authorized login and multi-account context for supercli commands.",
5
+ "license": "UNLICENSED",
6
+ "bin": {
7
+ "supercli": "dist/cli.js"
8
+ },
9
+ "main": "dist/cli.js",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json && node scripts/postbuild.mjs",
21
+ "prepack": "npm run build",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest",
24
+ "test:unit": "vitest run test/unit",
25
+ "test:integration": "vitest run test/integration --testTimeout=120000",
26
+ "typecheck": "tsc --noEmit -p tsconfig.test.json"
27
+ },
28
+ "dependencies": {
29
+ "commander": "^12.1.0",
30
+ "semver": "^7.8.5",
31
+ "yazl": "^3.3.1"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^20.16.11",
35
+ "@types/semver": "^7.7.1",
36
+ "@types/yazl": "^3.3.1",
37
+ "typescript": "^5.6.3",
38
+ "vitest": "^2.1.4"
39
+ },
40
+ "allowScripts": {
41
+ "esbuild@0.21.5": true
42
+ }
43
+ }