@gojinko/cli 0.2.0 → 0.4.5

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 (103) hide show
  1. package/README.md +86 -18
  2. package/SKILL.md +96 -18
  3. package/dist/bin/jinko.js +0 -0
  4. package/dist/commands/auth/index.d.ts.map +1 -1
  5. package/dist/commands/auth/index.js +103 -27
  6. package/dist/commands/auth/index.js.map +1 -1
  7. package/dist/commands/auth/prompt.d.ts +14 -0
  8. package/dist/commands/auth/prompt.d.ts.map +1 -0
  9. package/dist/commands/auth/prompt.js +32 -0
  10. package/dist/commands/auth/prompt.js.map +1 -0
  11. package/dist/commands/book.js +1 -1
  12. package/dist/commands/book.js.map +1 -1
  13. package/dist/commands/checkout.d.ts +3 -0
  14. package/dist/commands/checkout.d.ts.map +1 -0
  15. package/dist/commands/checkout.js +18 -0
  16. package/dist/commands/checkout.js.map +1 -0
  17. package/dist/commands/confirm-payment.d.ts +3 -0
  18. package/dist/commands/confirm-payment.d.ts.map +1 -0
  19. package/dist/commands/confirm-payment.js +24 -0
  20. package/dist/commands/confirm-payment.js.map +1 -0
  21. package/dist/commands/find-destination.js +1 -1
  22. package/dist/commands/find-destination.js.map +1 -1
  23. package/dist/commands/find-flight.js +1 -1
  24. package/dist/commands/find-flight.js.map +1 -1
  25. package/dist/commands/flight-calendar.js +1 -1
  26. package/dist/commands/flight-calendar.js.map +1 -1
  27. package/dist/commands/flight-search.d.ts.map +1 -1
  28. package/dist/commands/flight-search.js +8 -4
  29. package/dist/commands/flight-search.js.map +1 -1
  30. package/dist/commands/quote.d.ts +3 -0
  31. package/dist/commands/quote.d.ts.map +1 -0
  32. package/dist/commands/quote.js +14 -0
  33. package/dist/commands/quote.js.map +1 -0
  34. package/dist/commands/refund.d.ts +3 -0
  35. package/dist/commands/refund.d.ts.map +1 -0
  36. package/dist/commands/refund.js +37 -0
  37. package/dist/commands/refund.js.map +1 -0
  38. package/dist/commands/select-ancillaries.d.ts +3 -0
  39. package/dist/commands/select-ancillaries.d.ts.map +1 -0
  40. package/dist/commands/select-ancillaries.js +33 -0
  41. package/dist/commands/select-ancillaries.js.map +1 -0
  42. package/dist/commands/trip.js +1 -1
  43. package/dist/commands/trip.js.map +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +12 -1
  46. package/dist/index.js.map +1 -1
  47. package/package.json +13 -12
  48. package/dist/commands/book/index.d.ts +0 -3
  49. package/dist/commands/book/index.d.ts.map +0 -1
  50. package/dist/commands/book/index.js +0 -61
  51. package/dist/commands/book/index.js.map +0 -1
  52. package/dist/commands/flights/calendar.d.ts +0 -3
  53. package/dist/commands/flights/calendar.d.ts.map +0 -1
  54. package/dist/commands/flights/calendar.js +0 -51
  55. package/dist/commands/flights/calendar.js.map +0 -1
  56. package/dist/commands/flights/destinations.d.ts +0 -3
  57. package/dist/commands/flights/destinations.d.ts.map +0 -1
  58. package/dist/commands/flights/destinations.js +0 -53
  59. package/dist/commands/flights/destinations.js.map +0 -1
  60. package/dist/commands/flights/find.d.ts +0 -3
  61. package/dist/commands/flights/find.d.ts.map +0 -1
  62. package/dist/commands/flights/find.js +0 -43
  63. package/dist/commands/flights/find.js.map +0 -1
  64. package/dist/commands/flights/index.d.ts +0 -3
  65. package/dist/commands/flights/index.d.ts.map +0 -1
  66. package/dist/commands/flights/index.js +0 -14
  67. package/dist/commands/flights/index.js.map +0 -1
  68. package/dist/commands/flights/search.d.ts +0 -3
  69. package/dist/commands/flights/search.d.ts.map +0 -1
  70. package/dist/commands/flights/search.js +0 -58
  71. package/dist/commands/flights/search.js.map +0 -1
  72. package/dist/commands/travelers/index.d.ts +0 -3
  73. package/dist/commands/travelers/index.d.ts.map +0 -1
  74. package/dist/commands/travelers/index.js +0 -118
  75. package/dist/commands/travelers/index.js.map +0 -1
  76. package/dist/commands/trip/add-flight.d.ts +0 -3
  77. package/dist/commands/trip/add-flight.d.ts.map +0 -1
  78. package/dist/commands/trip/add-flight.js +0 -22
  79. package/dist/commands/trip/add-flight.js.map +0 -1
  80. package/dist/commands/trip/checkout.d.ts +0 -3
  81. package/dist/commands/trip/checkout.d.ts.map +0 -1
  82. package/dist/commands/trip/checkout.js +0 -59
  83. package/dist/commands/trip/checkout.js.map +0 -1
  84. package/dist/commands/trip/create.d.ts +0 -3
  85. package/dist/commands/trip/create.d.ts.map +0 -1
  86. package/dist/commands/trip/create.js +0 -14
  87. package/dist/commands/trip/create.js.map +0 -1
  88. package/dist/commands/trip/index.d.ts +0 -3
  89. package/dist/commands/trip/index.d.ts.map +0 -1
  90. package/dist/commands/trip/index.js +0 -14
  91. package/dist/commands/trip/index.js.map +0 -1
  92. package/dist/commands/trip/remove.d.ts +0 -3
  93. package/dist/commands/trip/remove.d.ts.map +0 -1
  94. package/dist/commands/trip/remove.js +0 -19
  95. package/dist/commands/trip/remove.js.map +0 -1
  96. package/dist/commands/trip/show.d.ts +0 -3
  97. package/dist/commands/trip/show.d.ts.map +0 -1
  98. package/dist/commands/trip/show.js +0 -17
  99. package/dist/commands/trip/show.js.map +0 -1
  100. package/dist/commands/trip/travelers.d.ts +0 -3
  101. package/dist/commands/trip/travelers.d.ts.map +0 -1
  102. package/dist/commands/trip/travelers.js +0 -38
  103. package/dist/commands/trip/travelers.js.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gojinko/cli
2
2
 
3
- Command-line tool for the Jinko developer platform. 6 commands matching MCP tools 1:1.
3
+ Command-line tool for the Jinko developer platform. 11 commands matching MCP tools 1:1.
4
4
 
5
5
  ## Install
6
6
 
@@ -10,40 +10,82 @@ npm install -g @gojinko/cli
10
10
 
11
11
  ## Authentication
12
12
 
13
+ Two methods — pick one:
14
+
13
15
  ```bash
16
+ # OAuth (recommended) — opens browser, no API key needed
17
+ jinko auth login
18
+
19
+ # API key
14
20
  jinko auth login --key jnk_YOUR_KEY
15
- # or
21
+
22
+ # Or via environment variable (skips login)
16
23
  export JINKO_API_KEY=jnk_YOUR_KEY
17
24
  ```
18
25
 
26
+ OAuth tokens refresh automatically. API keys don't expire but can be revoked from the dashboard.
27
+
28
+ ### Auth commands
29
+
30
+ ```bash
31
+ jinko auth login # Interactive — choose OAuth or API key
32
+ jinko auth login --key jnk_... # Direct API key
33
+ jinko auth status # Show current method, token, expiry
34
+ jinko auth logout # Clear stored credentials
35
+ ```
36
+
19
37
  ## Commands
20
38
 
21
- | Command | MCP Tool | Mode | Description |
22
- |---------|----------|------|-------------|
23
- | `find-flight` | `find_flight` | Cached | Find cheapest flights, returns offer_token |
24
- | `find-destination` | `find_destination` | Cached | Discover destinations from origins |
25
- | `flight-calendar` | `flight_calendar` | Cached | Cheapest prices across a date range |
26
- | `flight-search` | `flight_search` | Live | Live search or price-check an offer |
27
- | `trip` | `trip` | Live | Create trip, add flight, set travelers |
28
- | `book` | `book` | Live | Checkout a trip, returns checkout_url |
39
+ ### Discovery (cached)
40
+
41
+ | Command | MCP Tool | Description |
42
+ |---------|----------|-------------|
43
+ | `find-flight` | `find_flight` | Find cheapest flights, returns offer_token |
44
+ | `find-destination` | `find_destination` | Discover destinations from origins |
45
+ | `flight-calendar` | `flight_calendar` | Cheapest prices across a date range |
46
+
47
+ ### Search & Trip (live)
48
+
49
+ | Command | MCP Tool | Description |
50
+ |---------|----------|-------------|
51
+ | `flight-search` | `flight_search` | Live search or price-check an offer, returns trip_item_token |
52
+ | `trip` | `trip` | Create trip, add flight, set travelers |
53
+
54
+ ### Booking — Cart V2 (live)
55
+
56
+ | Command | MCP Tool | Description |
57
+ |---------|----------|-------------|
58
+ | `quote` | `book` (quote) | Schedule a quote — returns items with available ancillaries and pricing |
59
+ | `select-ancillaries` | `trip` (ancillaries) | Select baggage, seats, or meals for a trip item |
60
+ | `checkout` | `book` (fulfillment) | Schedule fulfillment — creates Stripe payment, returns checkout_url |
61
+ | `confirm-payment` | `book` (confirm) | Verify Stripe payment after checkout |
62
+ | `book` | `book` | Legacy shortcut — quote + checkout in one step |
63
+
64
+ ### Post-Booking (live)
65
+
66
+ | Command | MCP Tool | Description |
67
+ |---------|----------|-------------|
68
+ | `refund check` | — | Check refund eligibility and estimated amount |
69
+ | `refund commit` | — | Initiate a refund for a booked flight |
29
70
 
30
71
  ### Utility
31
72
 
32
73
  | Command | Description |
33
74
  |---------|-------------|
34
- | `auth login` | Configure API key |
35
- | `auth status` | Show auth status |
36
75
  | `config set` | Set a config value |
37
76
  | `config show` | Show config |
38
77
  | `schema [cmd]` | Show request/response schemas |
39
78
 
40
- ## Token Flow
79
+ ## Token Flow (Cart V2)
41
80
 
42
81
  ```
43
- find-flight (filters) → offer_token (cached)
44
- flight-search (offer_token) → trip_item_token (live)
82
+ find-flight (filters) → offer_token (cached)
83
+ flight-search (offer_token) → trip_item_token (live)
45
84
  trip (trip_item_token + travelers + contact) → trip_id
46
- book (trip_id) checkout_url
85
+ quote (trip_id) items + ancillary offers
86
+ select-ancillaries (trip_id, item_id, offer_ids) → updated cart
87
+ checkout (trip_id) → checkout_url + session_id
88
+ confirm-payment (trip_id) → booking confirmation
47
89
  ```
48
90
 
49
91
  ## Examples
@@ -58,9 +100,12 @@ jinko find-destination --from PAR
58
100
  # Price calendar
59
101
  jinko flight-calendar --from PAR --to NYC --month 2026-06
60
102
 
61
- # Live search
103
+ # Live search (city codes — default)
62
104
  jinko flight-search --from PAR --to NYC --date 2026-06-15
63
105
 
106
+ # Live search (airport codes)
107
+ jinko flight-search --from CDG --origin-type airport --to JFK --destination-type airport --date 2026-06-15
108
+
64
109
  # Price-check an offer
65
110
  jinko flight-search --offer-token <offer_token>
66
111
 
@@ -69,8 +114,31 @@ jinko trip --trip-item-token <token> \
69
114
  --travelers '[{"first_name":"John","last_name":"Doe","date_of_birth":"1990-01-15","gender":"MALE","passenger_type":"ADULT"}]' \
70
115
  --contact '{"email":"john@example.com","phone":"+33612345678"}'
71
116
 
72
- # Checkout
117
+ # Get quote with available ancillaries
118
+ jinko quote --trip-id <trip_id>
119
+
120
+ # Optionally add baggage, seats, or meals
121
+ jinko select-ancillaries \
122
+ --trip-id <trip_id> \
123
+ --item-id <item_id> \
124
+ --select <offer_id_1>,<offer_id_2> \
125
+ --pax <passenger_ref> \
126
+ --quantity 2
127
+
128
+ # Create Stripe payment session
129
+ jinko checkout --trip-id <trip_id>
130
+
131
+ # Verify payment after checkout
132
+ jinko confirm-payment --trip-id <trip_id> --checkout-session <cs_xxx>
133
+
134
+ # Legacy shortcut (quote + checkout in one step)
73
135
  jinko book --trip-id <trip_id>
136
+
137
+ # Check refund eligibility
138
+ jinko refund check --booking-ref <ref> --pnr <pnr>
139
+
140
+ # Initiate a refund
141
+ jinko refund commit --booking-ref <ref> --pnr <pnr> --reason "schedule change"
74
142
  ```
75
143
 
76
144
  ## Output Formats
package/SKILL.md CHANGED
@@ -4,33 +4,72 @@ You are using `jinko`, a CLI for the Jinko developer platform. Commands match MC
4
4
 
5
5
  ## Authentication
6
6
 
7
+ ### Option 1: OAuth (recommended for interactive use)
8
+
9
+ ```bash
10
+ jinko auth login
11
+ # Opens a browser-based sign-in flow (WorkOS device authorization)
12
+ ```
13
+
14
+ This is a CLI-specific OAuth flow — separate from MCP OAuth. Tokens are stored locally and refreshed automatically.
15
+
16
+ ### Option 2: API Key (recommended for agents and CI/CD)
17
+
7
18
  ```bash
8
19
  jinko auth login --key jnk_YOUR_KEY
9
20
  # or
10
21
  export JINKO_API_KEY=jnk_YOUR_KEY
11
22
  ```
12
23
 
13
- ## 6 Tools
24
+ > **Note:** CLI OAuth tokens cannot be reused as Bearer tokens on the MCP endpoint (`https://mcp.builders.gojinko.com/mcp`). For programmatic MCP access, use an API key (`jnk_*`).
25
+
26
+ ## 11 Tools
27
+
28
+ ### Discovery (cached)
29
+
30
+ | CLI Command | Description |
31
+ |-------------|-------------|
32
+ | `find-flight` | Find cheapest flights, returns `offer_token` |
33
+ | `find-destination` | Discover destinations from origins |
34
+ | `flight-calendar` | Cheapest prices across a date range |
35
+
36
+ ### Search & Trip (live)
37
+
38
+ | CLI Command | Description |
39
+ |-------------|-------------|
40
+ | `flight-search` | Live search or price-check an offer, returns `trip_item_token` |
41
+ | `trip` | Create trip, add flight, set travelers |
42
+
43
+ ### Booking (v2 flow)
44
+
45
+ | CLI Command | Description |
46
+ |-------------|-------------|
47
+ | `quote` | Schedule a quote — returns items with available ancillaries and pricing |
48
+ | `select-ancillaries` | Select baggage, seats, or meals for a trip item |
49
+ | `checkout` | Schedule fulfillment — creates Stripe payment, returns `checkout_url` |
50
+ | `confirm-payment` | Verify Stripe payment after checkout |
51
+ | `book` | Legacy shortcut — quote + checkout in one step |
14
52
 
15
- | CLI Command | MCP Tool | Mode | Description |
16
- |-------------|----------|------|-------------|
17
- | `find-flight` | `find_flight` | Cached | Find cheapest flights, returns offer_token |
18
- | `find-destination` | `find_destination` | Cached | Discover destinations from origins |
19
- | `flight-calendar` | `flight_calendar` | Cached | Cheapest prices across a date range |
20
- | `flight-search` | `flight_search` | Live | Live search or price-check an offer |
21
- | `trip` | `trip` | Live | Create trip, add flight, set travelers |
22
- | `book` | `book` | Live | Checkout a trip, returns checkout_url |
53
+ ### Post-booking
54
+
55
+ | CLI Command | Description |
56
+ |-------------|-------------|
57
+ | `refund check` | Check refund eligibility and estimated amount |
58
+ | `refund commit` | Initiate a refund for a booked flight |
23
59
 
24
60
  ## Token Flow
25
61
 
26
62
  ```
27
- find-flight (filters) → offer_token (cached)
28
- flight-search (offer_token) → trip_item_token (live)
63
+ find-flight (filters) → offer_token (cached)
64
+ flight-search (offer_token) → trip_item_token (live)
29
65
  trip (trip_item_token + travelers + contact) → trip_id
30
- book (trip_id) checkout_url
66
+ quote (trip_id) items + ancillary offers
67
+ select-ancillaries (trip_id, item_id, offer_ids) → updated cart
68
+ checkout (trip_id) → checkout_url + session_id
69
+ confirm-payment (trip_id) → booking confirmation
31
70
  ```
32
71
 
33
- ## Core Workflow: Find → Price → Trip → Book
72
+ ## Core Workflow: Find → Price → Trip → Quote → Book
34
73
 
35
74
  ### Step 1: Discover flights
36
75
 
@@ -66,13 +105,44 @@ jinko trip \
66
105
 
67
106
  Returns `trip_id`.
68
107
 
69
- ### Step 4: Book
108
+ ### Step 4: Quote and ancillaries
109
+
110
+ ```bash
111
+ # Get quote with available ancillaries
112
+ jinko quote --trip-id <trip_id>
113
+
114
+ # Optionally add baggage, seats, or meals
115
+ jinko select-ancillaries \
116
+ --trip-id <trip_id> \
117
+ --item-id <item_id> \
118
+ --select <offer_id_1>,<offer_id_2> \
119
+ --pax <passenger_ref> # optional, for per-pax ancillaries
120
+ --quantity 2 # optional, default 1
121
+ ```
122
+
123
+ ### Step 5: Checkout and payment
70
124
 
71
125
  ```bash
72
- jinko book --trip-id <trip_id>
126
+ # Create Stripe payment session
127
+ jinko checkout --trip-id <trip_id>
128
+
129
+ # User completes payment in browser at checkout_url, then:
130
+ jinko confirm-payment --trip-id <trip_id> --checkout-session <cs_xxx>
131
+ # or
132
+ jinko confirm-payment --trip-id <trip_id> --payment-intent <pi_xxx>
73
133
  ```
74
134
 
75
- Returns `checkout_url` user opens in browser to complete payment.
135
+ > **Legacy shortcut**: `jinko book --trip-id <trip_id>` combines quote + checkout in one step (skips ancillary selection).
136
+
137
+ ### Post-booking: Refunds
138
+
139
+ ```bash
140
+ # Check if a booking is refundable
141
+ jinko refund check --booking-ref <ref> --pnr <pnr>
142
+
143
+ # Initiate the refund
144
+ jinko refund commit --booking-ref <ref> --pnr <pnr> --reason "schedule change"
145
+ ```
76
146
 
77
147
  ## Tool Selection Guide
78
148
 
@@ -84,7 +154,13 @@ Returns `checkout_url` — user opens in browser to complete payment.
84
154
  | "What's the cheapest day to fly?" | `flight-calendar --from PAR --to NYC --month ...` |
85
155
  | "Get exact price for this flight" | `flight-search --offer-token <token>` |
86
156
  | "Set up a trip with this flight" | `trip --trip-item-token <token> --travelers ... --contact ...` |
87
- | "Book this trip" | `book --trip-id <id>` |
157
+ | "Get a quote with ancillary options" | `quote --trip-id <id>` |
158
+ | "Add extra baggage" | `select-ancillaries --trip-id <id> --item-id <id> --select <ids>` |
159
+ | "Pay for this trip" | `checkout --trip-id <id>` |
160
+ | "Confirm my payment went through" | `confirm-payment --trip-id <id> --checkout-session <cs_id>` |
161
+ | "Book this trip (quick)" | `book --trip-id <id>` |
162
+ | "Can I get a refund?" | `refund check --booking-ref <ref> --pnr <pnr>` |
163
+ | "Refund my booking" | `refund commit --booking-ref <ref> --pnr <pnr>` |
88
164
 
89
165
  ## Output Format
90
166
 
@@ -96,7 +172,8 @@ All commands output JSON by default. Add `--format table` for human display.
96
172
  jinko schema # List all tools
97
173
  jinko schema find-flight # Show find-flight schema
98
174
  jinko schema flight-search # Show flight-search schema
99
- jinko schema book # Show booking schema
175
+ jinko schema quote # Show quote schema
176
+ jinko schema checkout # Show checkout schema
100
177
  ```
101
178
 
102
179
  ## Important Notes
@@ -107,3 +184,4 @@ jinko schema book # Show booking schema
107
184
  - **Passenger types**: `ADULT`, `CHILD`, `INFANT`
108
185
  - **Cabin classes**: `economy`, `premium_economy`, `business`, `first`
109
186
  - **Cached vs Live**: `find-*` and `flight-calendar` use cached data (fast). `flight-search` uses live pricing (slower, accurate).
187
+ - **v2 flow**: Use `quote` → `select-ancillaries` → `checkout` → `confirm-payment` for full control. Use `book` as a one-step shortcut when ancillaries aren't needed.
package/dist/bin/jinko.js CHANGED
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgF3D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+J3D"}
@@ -1,44 +1,105 @@
1
- import { resolveAuth, writeConfigFile, CONFIG_FILE } from '@gojinko/api-client';
1
+ import { resolveAuth, writeConfigFile, clearAuthConfig, readConfigFile, CONFIG_FILE, requestDeviceAuthorization, pollForToken, OAuthError, } from '@gojinko/api-client';
2
2
  import { output, outputError } from '../shared.js';
3
3
  import { getGlobalOptions } from '../../config/config.js';
4
+ import { promptChoice, promptText } from './prompt.js';
4
5
  export function registerAuthCommands(program) {
5
6
  const auth = program
6
7
  .command('auth')
7
8
  .description('Manage authentication.');
8
9
  auth
9
10
  .command('login')
10
- .description('Configure API key authentication.')
11
- .option('--key <token>', 'API key (jnk_...)')
11
+ .description('Authenticate with Jinko (OAuth or API key).')
12
+ .option('--key <token>', 'API key (jnk_...) — skip interactive prompt')
12
13
  .action(async (opts, cmd) => {
13
14
  const globals = getGlobalOptions(cmd);
14
- let token = opts['key'];
15
- if (!token) {
16
- // Interactive: read from stdin.
17
- const readline = await import('node:readline');
18
- const rl = readline.createInterface({
19
- input: process.stdin,
20
- output: process.stdout,
15
+ // Fast path: --key flag → direct API key save
16
+ if (opts['key']) {
17
+ const token = opts['key'];
18
+ if (!token.startsWith('jnk_')) {
19
+ outputError({ code: 'INVALID_TOKEN', message: 'API key must start with "jnk_". Get one from the Jinko developer platform.' }, globals);
20
+ process.exit(3);
21
+ }
22
+ await writeConfigFile({ api_key: token });
23
+ output({
24
+ status: 'ok',
25
+ method: 'api_key',
26
+ message: `API key saved to ${CONFIG_FILE}`,
27
+ }, { format: globals.format });
28
+ return;
29
+ }
30
+ // Interactive: choose auth method
31
+ const method = await promptChoice('How would you like to authenticate?', [
32
+ { label: 'OAuth — sign in with browser (recommended)', value: 'oauth' },
33
+ { label: 'API key — paste a jnk_... token', value: 'api_key' },
34
+ ]);
35
+ if (method === 'api_key') {
36
+ const token = await promptText('Enter your Jinko API key (jnk_...): ');
37
+ if (!token) {
38
+ outputError({ code: 'INVALID_TOKEN', message: 'No API key provided.' }, globals);
39
+ process.exit(3);
40
+ }
41
+ if (!token.startsWith('jnk_')) {
42
+ outputError({ code: 'INVALID_TOKEN', message: 'API key must start with "jnk_". Get one from the Jinko developer platform.' }, globals);
43
+ process.exit(3);
44
+ }
45
+ await writeConfigFile({ api_key: token });
46
+ output({
47
+ status: 'ok',
48
+ method: 'api_key',
49
+ message: `API key saved to ${CONFIG_FILE}`,
50
+ }, { format: globals.format });
51
+ return;
52
+ }
53
+ // OAuth Device Authorization Flow
54
+ try {
55
+ console.log('Requesting device authorization...\n');
56
+ const device = await requestDeviceAuthorization();
57
+ console.log(`Visit this URL to authenticate:\n`);
58
+ console.log(` ${device.verification_uri_complete}\n`);
59
+ console.log(`Or go to ${device.verification_uri} and enter code: ${device.user_code}\n`);
60
+ // Try to open browser automatically
61
+ try {
62
+ const open = await import('open');
63
+ await open.default(device.verification_uri_complete);
64
+ }
65
+ catch {
66
+ // Browser open failed — URL is already printed above
67
+ }
68
+ console.log('Waiting for approval...');
69
+ const tokens = await pollForToken(device.device_code, {
70
+ intervalSeconds: device.interval,
71
+ expiresIn: device.expires_in,
21
72
  });
22
- token = await new Promise((resolve) => {
23
- rl.question('Enter your Jinko API key (jnk_...): ', (answer) => {
24
- rl.close();
25
- resolve(answer.trim());
26
- });
73
+ await writeConfigFile({
74
+ oauth: {
75
+ access_token: tokens.access_token,
76
+ refresh_token: tokens.refresh_token,
77
+ expires_at: tokens.expires_at,
78
+ },
27
79
  });
80
+ output({
81
+ status: 'ok',
82
+ method: 'oauth',
83
+ message: `Authenticated successfully. Credentials saved to ${CONFIG_FILE}`,
84
+ }, { format: globals.format });
28
85
  }
29
- if (!token) {
30
- outputError({ code: 'INVALID_TOKEN', message: 'No API key provided.' }, globals);
31
- process.exit(3);
32
- }
33
- if (!token.startsWith('jnk_')) {
34
- outputError({ code: 'INVALID_TOKEN', message: 'API key must start with "jnk_". Get one from the Jinko developer platform.' }, globals);
35
- process.exit(3);
86
+ catch (error) {
87
+ if (error instanceof OAuthError) {
88
+ outputError({ code: 'OAUTH_ERROR', message: error.message }, globals);
89
+ process.exit(3);
90
+ }
91
+ throw error;
36
92
  }
37
- await writeConfigFile({ api_key: token });
93
+ });
94
+ auth
95
+ .command('logout')
96
+ .description('Clear stored credentials.')
97
+ .action(async (_opts, cmd) => {
98
+ const globals = getGlobalOptions(cmd);
99
+ await clearAuthConfig();
38
100
  output({
39
101
  status: 'ok',
40
- method: 'api_key',
41
- message: `API key saved to ${CONFIG_FILE}`,
102
+ message: 'Credentials cleared.',
42
103
  }, { format: globals.format });
43
104
  });
44
105
  auth
@@ -63,12 +124,27 @@ export function registerAuthCommands(program) {
63
124
  : process.env['JINKO_API_KEY']
64
125
  ? 'env'
65
126
  : 'config';
66
- output({
127
+ const info = {
67
128
  authenticated: true,
68
129
  method: auth.method,
69
130
  token: masked,
70
131
  source,
71
- }, { format: globals.format });
132
+ };
133
+ // Add expiry info for OAuth
134
+ if (auth.method === 'oauth' && source === 'config') {
135
+ const config = await readConfigFile();
136
+ if (config?.oauth?.expires_at) {
137
+ const remainingMs = config.oauth.expires_at - Date.now();
138
+ if (remainingMs > 0) {
139
+ const minutes = Math.round(remainingMs / 60_000);
140
+ info['expires_in'] = `${minutes} minute${minutes !== 1 ? 's' : ''}`;
141
+ }
142
+ else {
143
+ info['expires_in'] = 'expired (will auto-refresh on next request)';
144
+ }
145
+ }
146
+ }
147
+ output(info, { format: globals.format });
72
148
  });
73
149
  }
74
150
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/auth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,MAAM,IAAI,GAAG,OAAO;SACjB,OAAO,CAAC,MAAM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AO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,14 @@
1
+ interface Choice<T> {
2
+ readonly label: string;
3
+ readonly value: T;
4
+ }
5
+ /**
6
+ * Interactive numbered-menu prompt. Returns selected value.
7
+ */
8
+ export declare function promptChoice<T>(question: string, choices: ReadonlyArray<Choice<T>>): Promise<T>;
9
+ /**
10
+ * Simple text prompt. Returns trimmed input.
11
+ */
12
+ export declare function promptText(question: string): Promise<string>;
13
+ export {};
14
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/prompt.ts"],"names":[],"mappings":"AAEA,UAAU,MAAM,CAAC,CAAC;IAChB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAgBrG;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlE"}
@@ -0,0 +1,32 @@
1
+ import { createInterface } from 'node:readline';
2
+ /**
3
+ * Interactive numbered-menu prompt. Returns selected value.
4
+ */
5
+ export async function promptChoice(question, choices) {
6
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
7
+ const menu = choices.map((c, i) => ` ${i + 1}) ${c.label}`).join('\n');
8
+ return new Promise((resolve, reject) => {
9
+ rl.question(`${question}\n${menu}\n\nChoice: `, (answer) => {
10
+ rl.close();
11
+ const index = parseInt(answer.trim(), 10) - 1;
12
+ if (isNaN(index) || index < 0 || index >= choices.length) {
13
+ reject(new Error('Invalid choice'));
14
+ return;
15
+ }
16
+ resolve(choices[index].value);
17
+ });
18
+ });
19
+ }
20
+ /**
21
+ * Simple text prompt. Returns trimmed input.
22
+ */
23
+ export async function promptText(question) {
24
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
25
+ return new Promise((resolve) => {
26
+ rl.question(question, (answer) => {
27
+ rl.close();
28
+ resolve(answer.trim());
29
+ });
30
+ });
31
+ }
32
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/commands/auth/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,QAAgB,EAAE,OAAiC;IACvF,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7E,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAExE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,EAAE,CAAC,QAAQ,CAAC,GAAG,QAAQ,KAAK,IAAI,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE;YACzD,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;YAC9C,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACzD,MAAM,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBACpC,OAAO;YACT,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAE,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;QACrC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -5,7 +5,7 @@ export function registerBookCommand(program) {
5
5
  .description('Checkout a trip — returns checkout_url + session_id.')
6
6
  .requiredOption('--trip-id <id>', 'trip ID (from trip command)')
7
7
  .action(withClient(async (client, globals, opts) => {
8
- const response = await client.raw.POST('/api/v1/devplatform/trips/checkout', {
8
+ const response = await client.raw.POST('/api/v1/trips/checkout', {
9
9
  body: { trip_id: opts.tripId },
10
10
  });
11
11
  output(response.data, { format: globals.format });
@@ -1 +1 @@
1
- {"version":3,"file":"book.js","sourceRoot":"","sources":["../../src/commands/book.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,sDAAsD,CAAC;SACnE,cAAc,CAAC,gBAAgB,EAAE,6BAA6B,CAAC;SAC/D,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,oCAA6C,EAAE;YACpF,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;SACtB,CAAC,CAAC;QAEZ,MAAM,CAAE,QAA+B,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC,CAAC;AACR,CAAC"}
1
+ {"version":3,"file":"book.js","sourceRoot":"","sources":["../../src/commands/book.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,sDAAsD,CAAC;SACnE,cAAc,CAAC,gBAAgB,EAAE,6BAA6B,CAAC;SAC/D,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAiC,EAAE;YACxE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;SACtB,CAAC,CAAC;QAEZ,MAAM,CAAE,QAA+B,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC,CAAC;AACR,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerCheckoutCommand(program: Command): void;
3
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgB9D"}
@@ -0,0 +1,18 @@
1
+ import { withClient, output } from './shared.js';
2
+ export function registerCheckoutCommand(program) {
3
+ program
4
+ .command('checkout')
5
+ .description('Schedule fulfillment — creates Stripe payment and returns checkout URL.')
6
+ .requiredOption('--trip-id <id>', 'trip ID (must have a completed quote)')
7
+ .option('--idempotency-key <key>', 'idempotency key to prevent duplicates')
8
+ .action(withClient(async (client, globals, opts) => {
9
+ const response = await client.raw.POST('/api/v1/trips/fulfillment', {
10
+ body: {
11
+ trip_id: opts.tripId,
12
+ ...(opts.idempotencyKey && { idempotency_key: opts.idempotencyKey }),
13
+ },
14
+ });
15
+ output(response.data, { format: globals.format });
16
+ }));
17
+ }
18
+ //# sourceMappingURL=checkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,yEAAyE,CAAC;SACtF,cAAc,CAAC,gBAAgB,EAAE,uCAAuC,CAAC;SACzE,MAAM,CAAC,yBAAyB,EAAE,uCAAuC,CAAC;SAC1E,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,2BAAoC,EAAE;YAC3E,IAAI,EAAE;gBACJ,OAAO,EAAE,IAAI,CAAC,MAAM;gBACpB,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,eAAe,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;aACrE;SACO,CAAC,CAAC;QAEZ,MAAM,CAAE,QAA+B,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC,CAAC;AACR,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerConfirmPaymentCommand(program: Command): void;
3
+ //# sourceMappingURL=confirm-payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-payment.d.ts","sourceRoot":"","sources":["../../src/commands/confirm-payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuBpE"}
@@ -0,0 +1,24 @@
1
+ import { withClient, output } from './shared.js';
2
+ export function registerConfirmPaymentCommand(program) {
3
+ program
4
+ .command('confirm-payment')
5
+ .description('Confirm a Stripe payment after checkout.')
6
+ .requiredOption('--trip-id <id>', 'trip ID')
7
+ .option('--checkout-session <id>', 'Stripe checkout session ID')
8
+ .option('--payment-intent <id>', 'Stripe payment intent ID')
9
+ .action(withClient(async (client, globals, opts) => {
10
+ if (!opts.checkoutSession && !opts.paymentIntent) {
11
+ console.error('Error: either --checkout-session or --payment-intent is required');
12
+ process.exit(1);
13
+ }
14
+ const response = await client.raw.POST('/api/v1/trips/confirm-payment', {
15
+ body: {
16
+ trip_id: opts.tripId,
17
+ ...(opts.checkoutSession && { checkout_session_id: opts.checkoutSession }),
18
+ ...(opts.paymentIntent && { payment_intent_id: opts.paymentIntent }),
19
+ },
20
+ });
21
+ output(response.data, { format: globals.format });
22
+ }));
23
+ }
24
+ //# sourceMappingURL=confirm-payment.js.map