@icsnpc/onepass-cli 0.0.0-stage → 1.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 CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @icsnpc/onepass-cli
2
+
3
+ > Official Command-Line Developer Tool for the Integrated Computer Society (ICS) OnePass identity system.
4
+
5
+ ## Quickstart
6
+
7
+ Run directly using `npx`:
8
+
9
+ ```bash
10
+ # Verify credentials, endpoint connectivity, and key formats
11
+ npx @icsnpc/onepass-cli doctor
12
+
13
+ # Scaffold starter .env.onepass
14
+ npx @icsnpc/onepass-cli init
15
+
16
+ # Test connectivity to OnePass API
17
+ npx @icsnpc/onepass-cli test
18
+ ```
19
+
20
+ MIT © Integrated Computer Society (NPC).
2
21
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @icsnpc/onepass-cli
4
+ * Command-Line Developer Tool for ICS OnePass Integrations
5
+ */
6
+ declare const args: string[];
7
+ declare const command: string;
8
+ declare const VERSION = "1.0.0";
9
+ declare function printHeader(): void;
10
+ declare function handleDoctor(): Promise<void>;
11
+ declare function handleTest(): Promise<void>;
12
+ declare function handleInit(): Promise<void>;
13
+ declare function printHelp(): void;
14
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,QAAA,MAAM,IAAI,UAAwB,CAAC;AACnC,QAAA,MAAM,OAAO,QAAoB,CAAC;AAElC,QAAA,MAAM,OAAO,UAAU,CAAC;AAExB,iBAAS,WAAW,SAOnB;AAED,iBAAe,YAAY,kBA2D1B;AAED,iBAAe,UAAU,kBAiBxB;AAED,iBAAe,UAAU,kBAuYxB;AAED,iBAAS,SAAS,SAejB"}
package/dist/cli.js ADDED
@@ -0,0 +1,505 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * @icsnpc/onepass-cli
5
+ * Command-Line Developer Tool for ICS OnePass Integrations
6
+ */
7
+ const args = process.argv.slice(2);
8
+ const command = args[0] || 'help';
9
+ const VERSION = '1.0.0';
10
+ function printHeader() {
11
+ console.log(`\x1b[31m\x1b[1m
12
+ ╔════════════════════════════════════════════════════╗
13
+ ║ ICS OnePass Developer CLI ║
14
+ ║ Integrated Computer Society • Official Tooling ║
15
+ ╚════════════════════════════════════════════════════╝
16
+ \x1b[0m`);
17
+ }
18
+ async function handleDoctor() {
19
+ printHeader();
20
+ console.log('\x1b[36mRunning OnePass integration health check...\x1b[0m\n');
21
+ const fs = await import('node:fs');
22
+ const path = await import('node:path');
23
+ // 1. Check for environment files
24
+ const envFiles = ['.env', '.env.local'];
25
+ let foundEnv = false;
26
+ let clientId = '';
27
+ for (const file of envFiles) {
28
+ const fullPath = path.resolve(process.cwd(), file);
29
+ if (fs.existsSync(fullPath)) {
30
+ foundEnv = true;
31
+ const content = fs.readFileSync(fullPath, 'utf8');
32
+ const match = content.match(/ONEPASS_CLIENT_ID\s*=\s*(.*)/);
33
+ if (match) {
34
+ clientId = match[1].trim().replace(/^['"]|['"]$/g, '');
35
+ }
36
+ break;
37
+ }
38
+ }
39
+ if (!foundEnv) {
40
+ console.log(' \x1b[33m⚠ No .env file detected in current directory.\x1b[0m');
41
+ }
42
+ else {
43
+ console.log(' \x1b[32m✔ .env configuration file detected.\x1b[0m');
44
+ }
45
+ // 2. Validate Client ID key standard
46
+ if (!clientId) {
47
+ console.log(' \x1b[33m⚠ ONEPASS_CLIENT_ID not found in .env\x1b[0m');
48
+ }
49
+ else if (clientId.startsWith('op_live_client_')) {
50
+ console.log(` \x1b[32m✔ Client ID format valid: Production Live Key (${clientId.slice(0, 20)}...)\x1b[0m`);
51
+ }
52
+ else if (clientId.startsWith('op_test_client_')) {
53
+ console.log(` \x1b[32m✔ Client ID format valid: Sandbox Test Key (${clientId.slice(0, 20)}...)\x1b[0m`);
54
+ }
55
+ else if (clientId.startsWith('cp3_client_')) {
56
+ console.log(` \x1b[33m⚠ Legacy Client ID detected (${clientId}). Upgrade to op_live_* in Developer Console.\x1b[0m`);
57
+ }
58
+ else {
59
+ console.log(` \x1b[31m✖ Invalid Client ID format: ${clientId}\x1b[0m`);
60
+ }
61
+ // 3. Check connectivity to Discovery endpoint
62
+ const targetBase = process.env.ONEPASS_URL || 'https://onepass-gdbe.onrender.com';
63
+ console.log(`\n Checking OIDC Discovery endpoint: ${targetBase}...`);
64
+ try {
65
+ const res = await fetch(`${targetBase}/.well-known/openid-configuration`);
66
+ if (res.ok) {
67
+ console.log(' \x1b[32m✔ OIDC Discovery Endpoint reachable (HTTP 200 OK).\x1b[0m');
68
+ }
69
+ else {
70
+ console.log(` \x1b[31m✖ Server responded with HTTP ${res.status}\x1b[0m`);
71
+ }
72
+ }
73
+ catch (err) {
74
+ console.log(` \x1b[33m⚠ Could not reach Discovery Endpoint: ${err.message}\x1b[0m`);
75
+ }
76
+ console.log('\n\x1b[32mDoctor inspection completed.\x1b[0m\n');
77
+ }
78
+ async function handleTest() {
79
+ printHeader();
80
+ console.log('\x1b[36mTesting OnePass Core API Health...\x1b[0m\n');
81
+ const targetBase = process.env.ONEPASS_URL || 'https://onepass-gdbe.onrender.com';
82
+ try {
83
+ const res = await fetch(`${targetBase}/api/health`);
84
+ if (res.ok) {
85
+ const data = await res.json();
86
+ console.log(' \x1b[32m✔ OnePass API is healthy.\x1b[0m');
87
+ console.log(` Status: ${data.status || 'online'} | Version: ${data.version || 'v1'}`);
88
+ }
89
+ else {
90
+ console.log(` \x1b[31m✖ Health check returned HTTP ${res.status}\x1b[0m`);
91
+ }
92
+ }
93
+ catch (err) {
94
+ console.log(` \x1b[31m✖ Health check failed: ${err.message}\x1b[0m`);
95
+ }
96
+ }
97
+ async function handleInit() {
98
+ printHeader();
99
+ const fs = await import('node:fs');
100
+ const path = await import('node:path');
101
+ const initArgs = args.slice(1);
102
+ let appName = '';
103
+ let template = 'vanilla';
104
+ for (let i = 0; i < initArgs.length; i++) {
105
+ const arg = initArgs[i];
106
+ if (arg === '--type' || arg.startsWith('--type=')) {
107
+ console.error('The --type option has been removed. The OnePass CLI scaffolds member applications.');
108
+ process.exitCode = 1;
109
+ return;
110
+ }
111
+ else if ((arg === '--template' || arg === '-t') && initArgs[i + 1]) {
112
+ const val = initArgs[i + 1].toLowerCase();
113
+ if (val === 'react' || val === 'vue' || val === 'vanilla') {
114
+ template = val;
115
+ }
116
+ i++;
117
+ }
118
+ else if (arg.startsWith('--template=')) {
119
+ const val = arg.split('=')[1].toLowerCase();
120
+ if (val === 'react' || val === 'vue' || val === 'vanilla') {
121
+ template = val;
122
+ }
123
+ }
124
+ else if (!arg.startsWith('-') && !appName) {
125
+ appName = arg;
126
+ }
127
+ }
128
+ if (appName) {
129
+ console.log(`\x1b[36mScaffolding new MEMBER project (${template}): ${appName}...\x1b[0m\n`);
130
+ const targetDir = path.resolve(process.cwd(), appName);
131
+ if (!fs.existsSync(targetDir)) {
132
+ fs.mkdirSync(targetDir, { recursive: true });
133
+ }
134
+ const srcDir = path.resolve(targetDir, 'src');
135
+ if (!fs.existsSync(srcDir)) {
136
+ fs.mkdirSync(srcDir, { recursive: true });
137
+ }
138
+ if (template === 'react') {
139
+ // React 19 + Vite + OnePass Scaffolding
140
+ const envContent = `VITE_ONEPASS_URL=https://onepass-gdbe.onrender.com
141
+ VITE_ONEPASS_CLIENT_ID=op_test_client_sample123
142
+ `;
143
+ fs.writeFileSync(path.resolve(targetDir, '.env'), envContent, 'utf8');
144
+ const pkg = {
145
+ name: appName,
146
+ private: true,
147
+ version: '1.0.0',
148
+ type: 'module',
149
+ scripts: {
150
+ dev: 'vite',
151
+ build: 'tsc && vite build',
152
+ preview: 'vite preview',
153
+ },
154
+ dependencies: {
155
+ '@icsnpc/onepass-members': '^1.0.0',
156
+ react: '^19.0.0',
157
+ 'react-dom': '^19.0.0',
158
+ },
159
+ devDependencies: {
160
+ '@types/react': '^19.0.0',
161
+ '@types/react-dom': '^19.0.0',
162
+ '@vitejs/plugin-react': '^4.3.4',
163
+ typescript: '^5.7.0',
164
+ vite: '^6.0.0',
165
+ },
166
+ };
167
+ fs.writeFileSync(path.resolve(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', 'utf8');
168
+ const viteConfig = `import { defineConfig } from 'vite';
169
+ import react from '@vitejs/plugin-react';
170
+
171
+ export default defineConfig({
172
+ plugins: [react()],
173
+ server: { port: 3000 },
174
+ });
175
+ `;
176
+ fs.writeFileSync(path.resolve(targetDir, 'vite.config.ts'), viteConfig, 'utf8');
177
+ const indexHtml = `<!doctype html>
178
+ <html lang="en">
179
+ <head>
180
+ <meta charset="UTF-8" />
181
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
182
+ <title>${appName} — OnePass</title>
183
+ </head>
184
+ <body>
185
+ <div id="root"></div>
186
+ <script type="module" src="/src/main.tsx"></script>
187
+ </body>
188
+ </html>
189
+ `;
190
+ fs.writeFileSync(path.resolve(targetDir, 'index.html'), indexHtml, 'utf8');
191
+ const mainTsx = `import React from 'react';
192
+ import ReactDOM from 'react-dom/client';
193
+ import App from './App';
194
+
195
+ ReactDOM.createRoot(document.getElementById('root')!).render(
196
+ <React.StrictMode>
197
+ <App />
198
+ </React.StrictMode>
199
+ );
200
+ `;
201
+ fs.writeFileSync(path.resolve(srcDir, 'main.tsx'), mainTsx, 'utf8');
202
+ const appTsx = `import React, { useEffect, useState } from 'react';
203
+ import { OnePass, type OnePassUser } from '@icsnpc/onepass-members';
204
+
205
+ const onepass = new OnePass({
206
+ clientId: import.meta.env.VITE_ONEPASS_CLIENT_ID || 'op_test_client_sample123',
207
+ baseUrl: import.meta.env.VITE_ONEPASS_URL || 'https://onepass-gdbe.onrender.com',
208
+ redirectUri: typeof window !== 'undefined' ? window.location.origin : '',
209
+ scopes: ['openid', 'profile', 'email', 'student_id'],
210
+ });
211
+
212
+ export default function App() {
213
+ const [user, setUser] = useState<OnePassUser | null>(null);
214
+ const [loading, setLoading] = useState(true);
215
+
216
+ useEffect(() => {
217
+ async function init() {
218
+ if (window.location.search.includes('code=')) {
219
+ try {
220
+ const { user } = await onepass.handleCallback();
221
+ setUser(user);
222
+ window.history.replaceState({}, '', window.location.pathname);
223
+ } catch (err) {
224
+ console.error('OnePass callback error:', err);
225
+ }
226
+ } else if (onepass.isAuthenticated()) {
227
+ const u = await onepass.getUser();
228
+ setUser(u);
229
+ }
230
+ setLoading(false);
231
+ }
232
+ init();
233
+ }, []);
234
+
235
+ if (loading) {
236
+ return <div style={{ padding: 32, fontFamily: 'sans-serif' }}>Authenticating with OnePass...</div>;
237
+ }
238
+
239
+ return (
240
+ <div style={{ maxWidth: 480, margin: '60px auto', fontFamily: 'sans-serif', padding: 24, border: '1px solid #e4e4e7', borderRadius: 16 }}>
241
+ <h1 style={{ color: '#8c1d27', margin: 0 }}>OnePass App</h1>
242
+ <p style={{ color: '#71717a' }}>Integrated Computer Society Single Sign-On</p>
243
+
244
+ {user ? (
245
+ <div>
246
+ <h3>Welcome, {user.name}!</h3>
247
+ <p>Student ID: <code>{user.student_id || 'N/A'}</code></p>
248
+ <p>Email: {user.email}</p>
249
+ <button onClick={() => { onepass.logout(); setUser(null); }} style={{ padding: '8px 16px', background: '#18181b', color: '#fff', border: 'none', borderRadius: 8, cursor: 'pointer' }}>
250
+ Sign Out
251
+ </button>
252
+ </div>
253
+ ) : (
254
+ <button onClick={() => onepass.login()} style={{ padding: '10px 20px', background: '#8c1d27', color: '#fff', border: 'none', borderRadius: 8, cursor: 'pointer', fontWeight: 'bold' }}>
255
+ Sign in with OnePass
256
+ </button>
257
+ )}
258
+ </div>
259
+ );
260
+ }
261
+ `;
262
+ fs.writeFileSync(path.resolve(srcDir, 'App.tsx'), appTsx, 'utf8');
263
+ console.log(' \x1b[32m✔ Scaffolded React 19 + Vite + OnePass SSO template.\x1b[0m');
264
+ }
265
+ else if (template === 'vue') {
266
+ // Vue 3 + Vite + OnePass Scaffolding
267
+ const envContent = `VITE_ONEPASS_URL=https://onepass-gdbe.onrender.com
268
+ VITE_ONEPASS_CLIENT_ID=op_test_client_sample123
269
+ `;
270
+ fs.writeFileSync(path.resolve(targetDir, '.env'), envContent, 'utf8');
271
+ const pkg = {
272
+ name: appName,
273
+ private: true,
274
+ version: '1.0.0',
275
+ type: 'module',
276
+ scripts: {
277
+ dev: 'vite',
278
+ build: 'vue-tsc && vite build',
279
+ preview: 'vite preview',
280
+ },
281
+ dependencies: {
282
+ '@icsnpc/onepass-members': '^1.0.0',
283
+ vue: '^3.5.0',
284
+ },
285
+ devDependencies: {
286
+ '@vitejs/plugin-vue': '^5.2.0',
287
+ typescript: '^5.7.0',
288
+ vite: '^6.0.0',
289
+ 'vue-tsc': '^2.1.0',
290
+ },
291
+ };
292
+ fs.writeFileSync(path.resolve(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', 'utf8');
293
+ const viteConfig = `import { defineConfig } from 'vite';
294
+ import vue from '@vitejs/plugin-vue';
295
+
296
+ export default defineConfig({
297
+ plugins: [vue()],
298
+ server: { port: 3000 },
299
+ });
300
+ `;
301
+ fs.writeFileSync(path.resolve(targetDir, 'vite.config.ts'), viteConfig, 'utf8');
302
+ const indexHtml = `<!doctype html>
303
+ <html lang="en">
304
+ <head>
305
+ <meta charset="UTF-8" />
306
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
307
+ <title>${appName} — OnePass</title>
308
+ </head>
309
+ <body>
310
+ <div id="app"></div>
311
+ <script type="module" src="/src/main.ts"></script>
312
+ </body>
313
+ </html>
314
+ `;
315
+ fs.writeFileSync(path.resolve(targetDir, 'index.html'), indexHtml, 'utf8');
316
+ const mainTs = `import { createApp } from 'vue';
317
+ import App from './App.vue';
318
+
319
+ createApp(App).mount('#app');
320
+ `;
321
+ fs.writeFileSync(path.resolve(srcDir, 'main.ts'), mainTs, 'utf8');
322
+ const appVue = `<script setup lang="ts">
323
+ import { ref, onMounted } from 'vue';
324
+ import { OnePass, type OnePassUser } from '@icsnpc/onepass-members';
325
+
326
+ const onepass = new OnePass({
327
+ clientId: import.meta.env.VITE_ONEPASS_CLIENT_ID || 'op_test_client_sample123',
328
+ baseUrl: import.meta.env.VITE_ONEPASS_URL || 'https://onepass-gdbe.onrender.com',
329
+ redirectUri: typeof window !== 'undefined' ? window.location.origin : '',
330
+ scopes: ['openid', 'profile', 'email', 'student_id'],
331
+ });
332
+
333
+ const user = ref<OnePassUser | null>(null);
334
+ const loading = ref(true);
335
+
336
+ onMounted(async () => {
337
+ if (window.location.search.includes('code=')) {
338
+ try {
339
+ const res = await onepass.handleCallback();
340
+ user.value = res.user;
341
+ window.history.replaceState({}, '', window.location.pathname);
342
+ } catch (err) {
343
+ console.error('OnePass callback error:', err);
344
+ }
345
+ } else if (onepass.isAuthenticated()) {
346
+ user.value = await onepass.getUser();
347
+ }
348
+ loading.value = false;
349
+ });
350
+
351
+ function login() {
352
+ onepass.login();
353
+ }
354
+
355
+ function logout() {
356
+ onepass.logout();
357
+ user.value = null;
358
+ }
359
+ </script>
360
+
361
+ <template>
362
+ <div style="max-width: 480px; margin: 60px auto; font-family: sans-serif; padding: 24px; border: 1px solid #e4e4e7; border-radius: 16px;">
363
+ <h1 style="color: #8c1d27; margin: 0;">OnePass Vue App</h1>
364
+ <p style="color: #71717a;">Integrated Computer Society Single Sign-On</p>
365
+
366
+ <div v-if="loading">Authenticating with OnePass...</div>
367
+ <div v-else-if="user">
368
+ <h3>Welcome, {{ user.name }}!</h3>
369
+ <p>Student ID: <code>{{ user.student_id || 'N/A' }}</code></p>
370
+ <p>Email: {{ user.email }}</p>
371
+ <button @click="logout" style="padding: 8px 16px; background: #18181b; color: #fff; border: none; border-radius: 8px; cursor: pointer;">
372
+ Sign Out
373
+ </button>
374
+ </div>
375
+ <div v-else>
376
+ <button @click="login" style="padding: 10px 20px; background: #8c1d27; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: bold;">
377
+ Sign in with OnePass
378
+ </button>
379
+ </div>
380
+ </div>
381
+ </template>
382
+ `;
383
+ fs.writeFileSync(path.resolve(srcDir, 'App.vue'), appVue, 'utf8');
384
+ console.log(' \x1b[32m✔ Scaffolded Vue 3 + Vite + OnePass SSO template.\x1b[0m');
385
+ }
386
+ else {
387
+ // 1. .env.onepass
388
+ const envSample = `# ICS OnePass Configuration (Student Member App)
389
+ ONEPASS_URL=https://onepass-gdbe.onrender.com
390
+ ONEPASS_CLIENT_ID=op_test_client_sample123
391
+ ONEPASS_CLIENT_SECRET=op_test_sec_sample1234567890
392
+ ONEPASS_REDIRECT_URI=http://localhost:3000/callback
393
+ `;
394
+ fs.writeFileSync(path.resolve(targetDir, '.env.onepass'), envSample, 'utf8');
395
+ console.log(' \x1b[32m✔ Created .env.onepass configuration.\x1b[0m');
396
+ // 2. package.json
397
+ const pkg = {
398
+ name: appName,
399
+ version: '1.0.0',
400
+ type: 'module',
401
+ scripts: {
402
+ dev: 'tsx src/index.ts',
403
+ build: 'tsc',
404
+ },
405
+ dependencies: {
406
+ '@icsnpc/onepass-members': '^1.0.0',
407
+ },
408
+ devDependencies: {
409
+ typescript: '^5.7.0',
410
+ },
411
+ };
412
+ fs.writeFileSync(path.resolve(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', 'utf8');
413
+ console.log(' \x1b[32m✔ Created package.json.\x1b[0m');
414
+ // 3. src/index.ts
415
+ const sampleCode = `import { OnePass } from '@icsnpc/onepass-members';
416
+
417
+ const onepass = new OnePass({
418
+ clientId: process.env.ONEPASS_CLIENT_ID || 'op_test_client_sample123',
419
+ redirectUri: process.env.ONEPASS_REDIRECT_URI || 'http://localhost:3000/callback',
420
+ scopes: ['openid', 'profile', 'email', 'student_id'],
421
+ });
422
+
423
+ async function main() {
424
+ console.log('ICS OnePass Member Client initialized.');
425
+ }
426
+
427
+ main().catch(console.error);
428
+ `;
429
+ fs.writeFileSync(path.resolve(srcDir, 'index.ts'), sampleCode, 'utf8');
430
+ console.log(' \x1b[32m✔ Created src/index.ts.\x1b[0m');
431
+ }
432
+ // 4. README.md
433
+ const readme = `# ${appName}
434
+
435
+ ICS OnePass Student Member App scaffolded with \`@icsnpc/onepass-cli\`.
436
+
437
+ ## Getting Started
438
+ 1. Configure your client credentials in \`.env.onepass\` (obtain from Developer Console).
439
+ 2. Install dependencies:
440
+ \`\`\`bash
441
+ npm install
442
+ \`\`\`
443
+ 3. Run development server:
444
+ \`\`\`bash
445
+ npm run dev
446
+ \`\`\`
447
+ `;
448
+ fs.writeFileSync(path.resolve(targetDir, 'README.md'), readme, 'utf8');
449
+ console.log(' \x1b[32m✔ Created README.md.\x1b[0m');
450
+ console.log(`\n\x1b[32mProject ${appName} initialized! Change directory with: cd ${appName}\x1b[0m\n`);
451
+ return;
452
+ }
453
+ console.log('\x1b[36mScaffolding OnePass configuration...\x1b[0m\n');
454
+ const envSample = `# ICS OnePass Application Configuration
455
+ ONEPASS_URL=https://onepass-gdbe.onrender.com
456
+ ONEPASS_CLIENT_ID=op_test_client_sample123
457
+ ONEPASS_CLIENT_SECRET=op_test_sec_sample1234567890
458
+ ONEPASS_REDIRECT_URI=http://localhost:3000/callback
459
+ `;
460
+ const targetEnv = path.resolve(process.cwd(), '.env.onepass');
461
+ if (!fs.existsSync(targetEnv)) {
462
+ fs.writeFileSync(targetEnv, envSample, 'utf8');
463
+ console.log(' \x1b[32m✔ Created .env.onepass sample template.\x1b[0m');
464
+ }
465
+ else {
466
+ console.log(' \x1b[33mℹ .env.onepass already exists. Skipping.\x1b[0m');
467
+ }
468
+ console.log('\n\x1b[32mInitialization complete! Update credentials in your Developer Console.\x1b[0m\n');
469
+ }
470
+ function printHelp() {
471
+ printHeader();
472
+ console.log(`
473
+ Usage:
474
+ npx @icsnpc/onepass-cli <command> [options]
475
+
476
+ Available Commands:
477
+ init [name] [--template react|vue|vanilla] Scaffold a OnePass project or sample .env.onepass
478
+ doctor Verify local credentials, Client ID format, and endpoint connectivity
479
+ test Run ping check against OnePass Core API
480
+ help Display this guide
481
+
482
+ Flags:
483
+ --version Show CLI version (${VERSION})
484
+ `);
485
+ }
486
+ if (args.includes('--version') || args.includes('-v')) {
487
+ console.log(`@icsnpc/onepass-cli v${VERSION}`);
488
+ process.exit(0);
489
+ }
490
+ switch (command) {
491
+ case 'init':
492
+ handleInit();
493
+ break;
494
+ case 'doctor':
495
+ handleDoctor();
496
+ break;
497
+ case 'test':
498
+ handleTest();
499
+ break;
500
+ case 'help':
501
+ default:
502
+ printHelp();
503
+ break;
504
+ }
505
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA;;;GAGG;AAEH,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AAElC,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,SAAS,WAAW;IAClB,OAAO,CAAC,GAAG,CAAC;;;;;UAKJ,CAAC,CAAC;AACZ,CAAC;AAED,KAAK,UAAU,YAAY;IACzB,WAAW,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;IAE5E,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;IAEvC,iCAAiC;IACjC,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAElB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAA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;QAC/C,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;IAC1E,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,2FAA2F,CAAC,CAAC;AAC3G,CAAC;AAED,SAAS,SAAS;IAChB,WAAW,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;gCAWkB,OAAO;GACpC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,QAAQ,OAAO,EAAE,CAAC;IAChB,KAAK,MAAM;QACT,UAAU,EAAE,CAAC;QACb,MAAM;IACR,KAAK,QAAQ;QACX,YAAY,EAAE,CAAC;QACf,MAAM;IACR,KAAK,MAAM;QACT,UAAU,EAAE,CAAC;QACb,MAAM;IACR,KAAK,MAAM,CAAC;IACZ;QACE,SAAS,EAAE,CAAC;QACZ,MAAM;AACV,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const CLI_VERSION = "1.0.0";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export const CLI_VERSION = '1.0.0';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "@icsnpc/onepass-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Official CLI developer tool for scaffolding, inspecting, and testing ICS OnePass integrations.",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "onepass": "dist/cli.js",
9
+ "create-onepass-app": "dist/cli.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "src",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.json",
18
+ "clean": "rm -rf dist"
19
+ },
20
+ "keywords": [
21
+ "onepass",
22
+ "ics",
23
+ "cli",
24
+ "developer-tools",
25
+ "oauth2"
26
+ ],
27
+ "author": "Integrated Computer Society (NPC)",
28
+ "license": "MIT"
29
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,532 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @icsnpc/onepass-cli
5
+ * Command-Line Developer Tool for ICS OnePass Integrations
6
+ */
7
+
8
+ const args = process.argv.slice(2);
9
+ const command = args[0] || 'help';
10
+
11
+ const VERSION = '1.0.0';
12
+
13
+ function printHeader() {
14
+ console.log(`\x1b[31m\x1b[1m
15
+ ╔════════════════════════════════════════════════════╗
16
+ ║ ICS OnePass Developer CLI ║
17
+ ║ Integrated Computer Society • Official Tooling ║
18
+ ╚════════════════════════════════════════════════════╝
19
+ \x1b[0m`);
20
+ }
21
+
22
+ async function handleDoctor() {
23
+ printHeader();
24
+ console.log('\x1b[36mRunning OnePass integration health check...\x1b[0m\n');
25
+
26
+ const fs = await import('node:fs');
27
+ const path = await import('node:path');
28
+
29
+ // 1. Check for environment files
30
+ const envFiles = ['.env', '.env.local'];
31
+ let foundEnv = false;
32
+ let clientId = '';
33
+
34
+ for (const file of envFiles) {
35
+ const fullPath = path.resolve(process.cwd(), file);
36
+ if (fs.existsSync(fullPath)) {
37
+ foundEnv = true;
38
+ const content = fs.readFileSync(fullPath, 'utf8');
39
+ const match = content.match(/ONEPASS_CLIENT_ID\s*=\s*(.*)/);
40
+ if (match) {
41
+ clientId = match[1].trim().replace(/^['"]|['"]$/g, '');
42
+ }
43
+ break;
44
+ }
45
+ }
46
+
47
+ if (!foundEnv) {
48
+ console.log(' \x1b[33m⚠ No .env file detected in current directory.\x1b[0m');
49
+ } else {
50
+ console.log(' \x1b[32m✔ .env configuration file detected.\x1b[0m');
51
+ }
52
+
53
+ // 2. Validate Client ID key standard
54
+ if (!clientId) {
55
+ console.log(' \x1b[33m⚠ ONEPASS_CLIENT_ID not found in .env\x1b[0m');
56
+ } else if (clientId.startsWith('op_live_client_')) {
57
+ console.log(` \x1b[32m✔ Client ID format valid: Production Live Key (${clientId.slice(0, 20)}...)\x1b[0m`);
58
+ } else if (clientId.startsWith('op_test_client_')) {
59
+ console.log(` \x1b[32m✔ Client ID format valid: Sandbox Test Key (${clientId.slice(0, 20)}...)\x1b[0m`);
60
+ } else if (clientId.startsWith('cp3_client_')) {
61
+ console.log(` \x1b[33m⚠ Legacy Client ID detected (${clientId}). Upgrade to op_live_* in Developer Console.\x1b[0m`);
62
+ } else {
63
+ console.log(` \x1b[31m✖ Invalid Client ID format: ${clientId}\x1b[0m`);
64
+ }
65
+
66
+ // 3. Check connectivity to Discovery endpoint
67
+ const targetBase = process.env.ONEPASS_URL || 'https://onepass-gdbe.onrender.com';
68
+ console.log(`\n Checking OIDC Discovery endpoint: ${targetBase}...`);
69
+ try {
70
+ const res = await fetch(`${targetBase}/.well-known/openid-configuration`);
71
+ if (res.ok) {
72
+ console.log(' \x1b[32m✔ OIDC Discovery Endpoint reachable (HTTP 200 OK).\x1b[0m');
73
+ } else {
74
+ console.log(` \x1b[31m✖ Server responded with HTTP ${res.status}\x1b[0m`);
75
+ }
76
+ } catch (err: any) {
77
+ console.log(` \x1b[33m⚠ Could not reach Discovery Endpoint: ${err.message}\x1b[0m`);
78
+ }
79
+
80
+ console.log('\n\x1b[32mDoctor inspection completed.\x1b[0m\n');
81
+ }
82
+
83
+ async function handleTest() {
84
+ printHeader();
85
+ console.log('\x1b[36mTesting OnePass Core API Health...\x1b[0m\n');
86
+ const targetBase = process.env.ONEPASS_URL || 'https://onepass-gdbe.onrender.com';
87
+
88
+ try {
89
+ const res = await fetch(`${targetBase}/api/health`);
90
+ if (res.ok) {
91
+ const data = await res.json();
92
+ console.log(' \x1b[32m✔ OnePass API is healthy.\x1b[0m');
93
+ console.log(` Status: ${data.status || 'online'} | Version: ${data.version || 'v1'}`);
94
+ } else {
95
+ console.log(` \x1b[31m✖ Health check returned HTTP ${res.status}\x1b[0m`);
96
+ }
97
+ } catch (err: any) {
98
+ console.log(` \x1b[31m✖ Health check failed: ${err.message}\x1b[0m`);
99
+ }
100
+ }
101
+
102
+ async function handleInit() {
103
+ printHeader();
104
+
105
+ const fs = await import('node:fs');
106
+ const path = await import('node:path');
107
+
108
+ const initArgs = args.slice(1);
109
+ let appName = '';
110
+ let template: 'vanilla' | 'react' | 'vue' = 'vanilla';
111
+
112
+ for (let i = 0; i < initArgs.length; i++) {
113
+ const arg = initArgs[i];
114
+ if (arg === '--type' || arg.startsWith('--type=')) {
115
+ console.error('The --type option has been removed. The OnePass CLI scaffolds member applications.');
116
+ process.exitCode = 1;
117
+ return;
118
+ } else if ((arg === '--template' || arg === '-t') && initArgs[i + 1]) {
119
+ const val = initArgs[i + 1].toLowerCase();
120
+ if (val === 'react' || val === 'vue' || val === 'vanilla') {
121
+ template = val as 'vanilla' | 'react' | 'vue';
122
+ }
123
+ i++;
124
+ } else if (arg.startsWith('--template=')) {
125
+ const val = arg.split('=')[1].toLowerCase();
126
+ if (val === 'react' || val === 'vue' || val === 'vanilla') {
127
+ template = val as 'vanilla' | 'react' | 'vue';
128
+ }
129
+ } else if (!arg.startsWith('-') && !appName) {
130
+ appName = arg;
131
+ }
132
+ }
133
+
134
+ if (appName) {
135
+ console.log(`\x1b[36mScaffolding new MEMBER project (${template}): ${appName}...\x1b[0m\n`);
136
+ const targetDir = path.resolve(process.cwd(), appName);
137
+
138
+ if (!fs.existsSync(targetDir)) {
139
+ fs.mkdirSync(targetDir, { recursive: true });
140
+ }
141
+
142
+ const srcDir = path.resolve(targetDir, 'src');
143
+ if (!fs.existsSync(srcDir)) {
144
+ fs.mkdirSync(srcDir, { recursive: true });
145
+ }
146
+
147
+ if (template === 'react') {
148
+ // React 19 + Vite + OnePass Scaffolding
149
+ const envContent = `VITE_ONEPASS_URL=https://onepass-gdbe.onrender.com
150
+ VITE_ONEPASS_CLIENT_ID=op_test_client_sample123
151
+ `;
152
+ fs.writeFileSync(path.resolve(targetDir, '.env'), envContent, 'utf8');
153
+
154
+ const pkg = {
155
+ name: appName,
156
+ private: true,
157
+ version: '1.0.0',
158
+ type: 'module',
159
+ scripts: {
160
+ dev: 'vite',
161
+ build: 'tsc && vite build',
162
+ preview: 'vite preview',
163
+ },
164
+ dependencies: {
165
+ '@icsnpc/onepass-members': '^1.0.0',
166
+ react: '^19.0.0',
167
+ 'react-dom': '^19.0.0',
168
+ },
169
+ devDependencies: {
170
+ '@types/react': '^19.0.0',
171
+ '@types/react-dom': '^19.0.0',
172
+ '@vitejs/plugin-react': '^4.3.4',
173
+ typescript: '^5.7.0',
174
+ vite: '^6.0.0',
175
+ },
176
+ };
177
+ fs.writeFileSync(path.resolve(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', 'utf8');
178
+
179
+ const viteConfig = `import { defineConfig } from 'vite';
180
+ import react from '@vitejs/plugin-react';
181
+
182
+ export default defineConfig({
183
+ plugins: [react()],
184
+ server: { port: 3000 },
185
+ });
186
+ `;
187
+ fs.writeFileSync(path.resolve(targetDir, 'vite.config.ts'), viteConfig, 'utf8');
188
+
189
+ const indexHtml = `<!doctype html>
190
+ <html lang="en">
191
+ <head>
192
+ <meta charset="UTF-8" />
193
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
194
+ <title>${appName} — OnePass</title>
195
+ </head>
196
+ <body>
197
+ <div id="root"></div>
198
+ <script type="module" src="/src/main.tsx"></script>
199
+ </body>
200
+ </html>
201
+ `;
202
+ fs.writeFileSync(path.resolve(targetDir, 'index.html'), indexHtml, 'utf8');
203
+
204
+ const mainTsx = `import React from 'react';
205
+ import ReactDOM from 'react-dom/client';
206
+ import App from './App';
207
+
208
+ ReactDOM.createRoot(document.getElementById('root')!).render(
209
+ <React.StrictMode>
210
+ <App />
211
+ </React.StrictMode>
212
+ );
213
+ `;
214
+ fs.writeFileSync(path.resolve(srcDir, 'main.tsx'), mainTsx, 'utf8');
215
+
216
+ const appTsx = `import React, { useEffect, useState } from 'react';
217
+ import { OnePass, type OnePassUser } from '@icsnpc/onepass-members';
218
+
219
+ const onepass = new OnePass({
220
+ clientId: import.meta.env.VITE_ONEPASS_CLIENT_ID || 'op_test_client_sample123',
221
+ baseUrl: import.meta.env.VITE_ONEPASS_URL || 'https://onepass-gdbe.onrender.com',
222
+ redirectUri: typeof window !== 'undefined' ? window.location.origin : '',
223
+ scopes: ['openid', 'profile', 'email', 'student_id'],
224
+ });
225
+
226
+ export default function App() {
227
+ const [user, setUser] = useState<OnePassUser | null>(null);
228
+ const [loading, setLoading] = useState(true);
229
+
230
+ useEffect(() => {
231
+ async function init() {
232
+ if (window.location.search.includes('code=')) {
233
+ try {
234
+ const { user } = await onepass.handleCallback();
235
+ setUser(user);
236
+ window.history.replaceState({}, '', window.location.pathname);
237
+ } catch (err) {
238
+ console.error('OnePass callback error:', err);
239
+ }
240
+ } else if (onepass.isAuthenticated()) {
241
+ const u = await onepass.getUser();
242
+ setUser(u);
243
+ }
244
+ setLoading(false);
245
+ }
246
+ init();
247
+ }, []);
248
+
249
+ if (loading) {
250
+ return <div style={{ padding: 32, fontFamily: 'sans-serif' }}>Authenticating with OnePass...</div>;
251
+ }
252
+
253
+ return (
254
+ <div style={{ maxWidth: 480, margin: '60px auto', fontFamily: 'sans-serif', padding: 24, border: '1px solid #e4e4e7', borderRadius: 16 }}>
255
+ <h1 style={{ color: '#8c1d27', margin: 0 }}>OnePass App</h1>
256
+ <p style={{ color: '#71717a' }}>Integrated Computer Society Single Sign-On</p>
257
+
258
+ {user ? (
259
+ <div>
260
+ <h3>Welcome, {user.name}!</h3>
261
+ <p>Student ID: <code>{user.student_id || 'N/A'}</code></p>
262
+ <p>Email: {user.email}</p>
263
+ <button onClick={() => { onepass.logout(); setUser(null); }} style={{ padding: '8px 16px', background: '#18181b', color: '#fff', border: 'none', borderRadius: 8, cursor: 'pointer' }}>
264
+ Sign Out
265
+ </button>
266
+ </div>
267
+ ) : (
268
+ <button onClick={() => onepass.login()} style={{ padding: '10px 20px', background: '#8c1d27', color: '#fff', border: 'none', borderRadius: 8, cursor: 'pointer', fontWeight: 'bold' }}>
269
+ Sign in with OnePass
270
+ </button>
271
+ )}
272
+ </div>
273
+ );
274
+ }
275
+ `;
276
+ fs.writeFileSync(path.resolve(srcDir, 'App.tsx'), appTsx, 'utf8');
277
+ console.log(' \x1b[32m✔ Scaffolded React 19 + Vite + OnePass SSO template.\x1b[0m');
278
+ } else if (template === 'vue') {
279
+ // Vue 3 + Vite + OnePass Scaffolding
280
+ const envContent = `VITE_ONEPASS_URL=https://onepass-gdbe.onrender.com
281
+ VITE_ONEPASS_CLIENT_ID=op_test_client_sample123
282
+ `;
283
+ fs.writeFileSync(path.resolve(targetDir, '.env'), envContent, 'utf8');
284
+
285
+ const pkg = {
286
+ name: appName,
287
+ private: true,
288
+ version: '1.0.0',
289
+ type: 'module',
290
+ scripts: {
291
+ dev: 'vite',
292
+ build: 'vue-tsc && vite build',
293
+ preview: 'vite preview',
294
+ },
295
+ dependencies: {
296
+ '@icsnpc/onepass-members': '^1.0.0',
297
+ vue: '^3.5.0',
298
+ },
299
+ devDependencies: {
300
+ '@vitejs/plugin-vue': '^5.2.0',
301
+ typescript: '^5.7.0',
302
+ vite: '^6.0.0',
303
+ 'vue-tsc': '^2.1.0',
304
+ },
305
+ };
306
+ fs.writeFileSync(path.resolve(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', 'utf8');
307
+
308
+ const viteConfig = `import { defineConfig } from 'vite';
309
+ import vue from '@vitejs/plugin-vue';
310
+
311
+ export default defineConfig({
312
+ plugins: [vue()],
313
+ server: { port: 3000 },
314
+ });
315
+ `;
316
+ fs.writeFileSync(path.resolve(targetDir, 'vite.config.ts'), viteConfig, 'utf8');
317
+
318
+ const indexHtml = `<!doctype html>
319
+ <html lang="en">
320
+ <head>
321
+ <meta charset="UTF-8" />
322
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
323
+ <title>${appName} — OnePass</title>
324
+ </head>
325
+ <body>
326
+ <div id="app"></div>
327
+ <script type="module" src="/src/main.ts"></script>
328
+ </body>
329
+ </html>
330
+ `;
331
+ fs.writeFileSync(path.resolve(targetDir, 'index.html'), indexHtml, 'utf8');
332
+
333
+ const mainTs = `import { createApp } from 'vue';
334
+ import App from './App.vue';
335
+
336
+ createApp(App).mount('#app');
337
+ `;
338
+ fs.writeFileSync(path.resolve(srcDir, 'main.ts'), mainTs, 'utf8');
339
+
340
+ const appVue = `<script setup lang="ts">
341
+ import { ref, onMounted } from 'vue';
342
+ import { OnePass, type OnePassUser } from '@icsnpc/onepass-members';
343
+
344
+ const onepass = new OnePass({
345
+ clientId: import.meta.env.VITE_ONEPASS_CLIENT_ID || 'op_test_client_sample123',
346
+ baseUrl: import.meta.env.VITE_ONEPASS_URL || 'https://onepass-gdbe.onrender.com',
347
+ redirectUri: typeof window !== 'undefined' ? window.location.origin : '',
348
+ scopes: ['openid', 'profile', 'email', 'student_id'],
349
+ });
350
+
351
+ const user = ref<OnePassUser | null>(null);
352
+ const loading = ref(true);
353
+
354
+ onMounted(async () => {
355
+ if (window.location.search.includes('code=')) {
356
+ try {
357
+ const res = await onepass.handleCallback();
358
+ user.value = res.user;
359
+ window.history.replaceState({}, '', window.location.pathname);
360
+ } catch (err) {
361
+ console.error('OnePass callback error:', err);
362
+ }
363
+ } else if (onepass.isAuthenticated()) {
364
+ user.value = await onepass.getUser();
365
+ }
366
+ loading.value = false;
367
+ });
368
+
369
+ function login() {
370
+ onepass.login();
371
+ }
372
+
373
+ function logout() {
374
+ onepass.logout();
375
+ user.value = null;
376
+ }
377
+ </script>
378
+
379
+ <template>
380
+ <div style="max-width: 480px; margin: 60px auto; font-family: sans-serif; padding: 24px; border: 1px solid #e4e4e7; border-radius: 16px;">
381
+ <h1 style="color: #8c1d27; margin: 0;">OnePass Vue App</h1>
382
+ <p style="color: #71717a;">Integrated Computer Society Single Sign-On</p>
383
+
384
+ <div v-if="loading">Authenticating with OnePass...</div>
385
+ <div v-else-if="user">
386
+ <h3>Welcome, {{ user.name }}!</h3>
387
+ <p>Student ID: <code>{{ user.student_id || 'N/A' }}</code></p>
388
+ <p>Email: {{ user.email }}</p>
389
+ <button @click="logout" style="padding: 8px 16px; background: #18181b; color: #fff; border: none; border-radius: 8px; cursor: pointer;">
390
+ Sign Out
391
+ </button>
392
+ </div>
393
+ <div v-else>
394
+ <button @click="login" style="padding: 10px 20px; background: #8c1d27; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: bold;">
395
+ Sign in with OnePass
396
+ </button>
397
+ </div>
398
+ </div>
399
+ </template>
400
+ `;
401
+ fs.writeFileSync(path.resolve(srcDir, 'App.vue'), appVue, 'utf8');
402
+ console.log(' \x1b[32m✔ Scaffolded Vue 3 + Vite + OnePass SSO template.\x1b[0m');
403
+ } else {
404
+ // 1. .env.onepass
405
+ const envSample = `# ICS OnePass Configuration (Student Member App)
406
+ ONEPASS_URL=https://onepass-gdbe.onrender.com
407
+ ONEPASS_CLIENT_ID=op_test_client_sample123
408
+ ONEPASS_CLIENT_SECRET=op_test_sec_sample1234567890
409
+ ONEPASS_REDIRECT_URI=http://localhost:3000/callback
410
+ `;
411
+ fs.writeFileSync(path.resolve(targetDir, '.env.onepass'), envSample, 'utf8');
412
+ console.log(' \x1b[32m✔ Created .env.onepass configuration.\x1b[0m');
413
+
414
+ // 2. package.json
415
+ const pkg = {
416
+ name: appName,
417
+ version: '1.0.0',
418
+ type: 'module',
419
+ scripts: {
420
+ dev: 'tsx src/index.ts',
421
+ build: 'tsc',
422
+ },
423
+ dependencies: {
424
+ '@icsnpc/onepass-members': '^1.0.0',
425
+ },
426
+ devDependencies: {
427
+ typescript: '^5.7.0',
428
+ },
429
+ };
430
+ fs.writeFileSync(path.resolve(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', 'utf8');
431
+ console.log(' \x1b[32m✔ Created package.json.\x1b[0m');
432
+
433
+ // 3. src/index.ts
434
+ const sampleCode = `import { OnePass } from '@icsnpc/onepass-members';
435
+
436
+ const onepass = new OnePass({
437
+ clientId: process.env.ONEPASS_CLIENT_ID || 'op_test_client_sample123',
438
+ redirectUri: process.env.ONEPASS_REDIRECT_URI || 'http://localhost:3000/callback',
439
+ scopes: ['openid', 'profile', 'email', 'student_id'],
440
+ });
441
+
442
+ async function main() {
443
+ console.log('ICS OnePass Member Client initialized.');
444
+ }
445
+
446
+ main().catch(console.error);
447
+ `;
448
+ fs.writeFileSync(path.resolve(srcDir, 'index.ts'), sampleCode, 'utf8');
449
+ console.log(' \x1b[32m✔ Created src/index.ts.\x1b[0m');
450
+ }
451
+
452
+ // 4. README.md
453
+ const readme = `# ${appName}
454
+
455
+ ICS OnePass Student Member App scaffolded with \`@icsnpc/onepass-cli\`.
456
+
457
+ ## Getting Started
458
+ 1. Configure your client credentials in \`.env.onepass\` (obtain from Developer Console).
459
+ 2. Install dependencies:
460
+ \`\`\`bash
461
+ npm install
462
+ \`\`\`
463
+ 3. Run development server:
464
+ \`\`\`bash
465
+ npm run dev
466
+ \`\`\`
467
+ `;
468
+ fs.writeFileSync(path.resolve(targetDir, 'README.md'), readme, 'utf8');
469
+ console.log(' \x1b[32m✔ Created README.md.\x1b[0m');
470
+
471
+ console.log(`\n\x1b[32mProject ${appName} initialized! Change directory with: cd ${appName}\x1b[0m\n`);
472
+ return;
473
+ }
474
+
475
+ console.log('\x1b[36mScaffolding OnePass configuration...\x1b[0m\n');
476
+
477
+ const envSample = `# ICS OnePass Application Configuration
478
+ ONEPASS_URL=https://onepass-gdbe.onrender.com
479
+ ONEPASS_CLIENT_ID=op_test_client_sample123
480
+ ONEPASS_CLIENT_SECRET=op_test_sec_sample1234567890
481
+ ONEPASS_REDIRECT_URI=http://localhost:3000/callback
482
+ `;
483
+
484
+ const targetEnv = path.resolve(process.cwd(), '.env.onepass');
485
+ if (!fs.existsSync(targetEnv)) {
486
+ fs.writeFileSync(targetEnv, envSample, 'utf8');
487
+ console.log(' \x1b[32m✔ Created .env.onepass sample template.\x1b[0m');
488
+ } else {
489
+ console.log(' \x1b[33mℹ .env.onepass already exists. Skipping.\x1b[0m');
490
+ }
491
+
492
+ console.log('\n\x1b[32mInitialization complete! Update credentials in your Developer Console.\x1b[0m\n');
493
+ }
494
+
495
+ function printHelp() {
496
+ printHeader();
497
+ console.log(`
498
+ Usage:
499
+ npx @icsnpc/onepass-cli <command> [options]
500
+
501
+ Available Commands:
502
+ init [name] [--template react|vue|vanilla] Scaffold a OnePass project or sample .env.onepass
503
+ doctor Verify local credentials, Client ID format, and endpoint connectivity
504
+ test Run ping check against OnePass Core API
505
+ help Display this guide
506
+
507
+ Flags:
508
+ --version Show CLI version (${VERSION})
509
+ `);
510
+ }
511
+
512
+ if (args.includes('--version') || args.includes('-v')) {
513
+ console.log(`@icsnpc/onepass-cli v${VERSION}`);
514
+ process.exit(0);
515
+ }
516
+
517
+ switch (command) {
518
+ case 'init':
519
+ handleInit();
520
+ break;
521
+ case 'doctor':
522
+ handleDoctor();
523
+ break;
524
+ case 'test':
525
+ handleTest();
526
+ break;
527
+ case 'help':
528
+ default:
529
+ printHelp();
530
+ break;
531
+ }
532
+
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export const CLI_VERSION = '1.0.0';
2
+