@gelglx/arjunakey 1.0.0 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +13 -8
  2. package/cli.js +18 -28
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -4,17 +4,16 @@ CLI satu akun untuk:
4
4
 
5
5
  1. membuat informasi akun acak,
6
6
  2. register ke `https://dash.arjuna.dev/register`,
7
- 3. login,
8
- 4. klaim kode welcome/voucher,
7
+ 3. mempertahankan session hasil register (login ulang hanya jika server tidak memberi session),
8
+ 4. redeem voucher melalui form `Redeem voucher`,
9
9
  5. mengambil API key dari `/api/me`.
10
10
 
11
11
  Tidak ada dependency npm eksternal.
12
12
 
13
- ## Instalasi lokal
13
+ ## Instalasi
14
14
 
15
15
  ```bash
16
- cd /home/ubuntu/arjuna-key-cli
17
- npm install -g .
16
+ npm install -g @gelglx/arjunakey@latest
18
17
  ```
19
18
 
20
19
  ## Pemakaian
@@ -23,13 +22,19 @@ npm install -g .
23
22
  arjunakey create
24
23
  ```
25
24
 
26
- Kode default:
25
+ Voucher default:
27
26
 
28
27
  ```text
29
- ONE-GROUP-6T2E-2V7N-H37Q
28
+ ONE-CAC0-209C-55C0-1535-831E
30
29
  ```
31
30
 
32
- Kode tersebut adalah welcome-group code. Website memprosesnya melalui `/api/billing/signup-bonus`, bukan form voucher billing biasa. CLI mencoba welcome endpoint lebih dulu lalu fallback ke `/api/billing/redeem` untuk voucher biasa.
31
+ CLI mengirim voucher ke `POST /api/billing/redeem`, sama seperti form `Redeem voucher`. CLI tidak menggunakan form `2. Enter group code` dan tidak memanggil `/api/billing/signup-bonus`.
32
+
33
+ Ganti voucher jika diperlukan:
34
+
35
+ ```bash
36
+ arjunakey create --voucher-code ONE-CAC0-209C-55C0-1535-831E
37
+ ```
33
38
 
34
39
  Output hanya API key:
35
40
 
package/cli.js CHANGED
@@ -8,9 +8,9 @@ const https = require('https');
8
8
  const path = require('path');
9
9
  const { URL } = require('url');
10
10
 
11
- const VERSION = '1.0.0';
11
+ const VERSION = '1.1.0';
12
12
  const DEFAULT_BASE_URL = 'https://dash.arjuna.dev';
13
- const DEFAULT_CODE = 'ONE-GROUP-6T2E-2V7N-H37Q';
13
+ const DEFAULT_VOUCHER_CODE = 'ONE-CAC0-209C-55C0-1535-831E';
14
14
 
15
15
  class ApiError extends Error {
16
16
  constructor(message, response = null) {
@@ -138,24 +138,12 @@ async function register(client, profile) {
138
138
  assertOk(response, 'Gagal membuat akun');
139
139
  }
140
140
 
141
- async function claimCode(client, code) {
142
- const groupResponse = await client.request('POST', '/api/billing/signup-bonus', { code });
143
- if (groupResponse.status >= 200 && groupResponse.status < 300) {
144
- return { kind: 'welcome-group', ...groupResponse.data };
145
- }
146
-
147
- if (![400, 404].includes(groupResponse.status)) {
148
- throw new ApiError(apiMessage(groupResponse, 'Gagal klaim welcome code'), groupResponse);
149
- }
150
-
141
+ async function redeemVoucher(client, code) {
151
142
  const voucherResponse = await client.request('POST', '/api/billing/redeem', { code });
152
143
  if (voucherResponse.status >= 200 && voucherResponse.status < 300) {
153
144
  return { kind: 'voucher', ...voucherResponse.data };
154
145
  }
155
-
156
- const groupError = apiMessage(groupResponse, 'Welcome code ditolak');
157
- const voucherError = apiMessage(voucherResponse, 'Voucher ditolak');
158
- throw new ApiError(`${groupError}; ${voucherError}`, voucherResponse);
146
+ throw new ApiError(apiMessage(voucherResponse, 'Voucher ditolak'), voucherResponse);
159
147
  }
160
148
 
161
149
  async function getAccount(client) {
@@ -169,7 +157,7 @@ function parseArgs(argv) {
169
157
  const opts = {
170
158
  command: 'create',
171
159
  baseUrl: process.env.ARJUNA_BASE_URL || DEFAULT_BASE_URL,
172
- voucher: process.env.ARJUNA_VOUCHER || DEFAULT_CODE,
160
+ voucherCode: process.env.ARJUNA_VOUCHER_CODE || DEFAULT_VOUCHER_CODE,
173
161
  emailDomain: process.env.ARJUNA_EMAIL_DOMAIN || 'example.com',
174
162
  timeout: Number(process.env.ARJUNA_TIMEOUT || 30),
175
163
  json: false,
@@ -180,7 +168,7 @@ function parseArgs(argv) {
180
168
 
181
169
  const input = [...argv];
182
170
  if (input[0] && !input[0].startsWith('-')) opts.command = input.shift();
183
- const valueFlags = new Set(['--base-url', '--voucher', '--email-domain', '--name', '--email', '--password', '--save', '--account-out', '--timeout']);
171
+ const valueFlags = new Set(['--base-url', '--voucher-code', '--email-domain', '--name', '--email', '--password', '--save', '--account-out', '--timeout']);
184
172
 
185
173
  for (let i = 0; i < input.length; i++) {
186
174
  let flag = input[i];
@@ -200,7 +188,7 @@ function parseArgs(argv) {
200
188
 
201
189
  switch (flag) {
202
190
  case '--base-url': opts.baseUrl = value; break;
203
- case '--voucher': opts.voucher = value; break;
191
+ case '--voucher-code': opts.voucherCode = value; break;
204
192
  case '--email-domain': opts.emailDomain = value; break;
205
193
  case '--name': opts.name = value; break;
206
194
  case '--email': opts.email = value; break;
@@ -272,11 +260,11 @@ Pemakaian:
272
260
  arjunakey create [opsi]
273
261
  arjunakey login --email EMAIL --password PASSWORD [opsi]
274
262
 
275
- create membuat satu akun acak, login, klaim kode, lalu mengambil API key.
276
- Kode default: ${DEFAULT_CODE}
263
+ create membuat satu akun acak, redeem voucher, lalu mengambil API key.
264
+ Voucher default: ${DEFAULT_VOUCHER_CODE}
277
265
 
278
266
  Opsi:
279
- --voucher CODE Welcome/voucher code
267
+ --voucher-code CODE Kode pada form "Redeem voucher"
280
268
  --email-domain HOST Domain email acak (default: example.com)
281
269
  --name NAME Ganti nama acak
282
270
  --email EMAIL Ganti email acak
@@ -293,7 +281,7 @@ Opsi:
293
281
 
294
282
  Environment:
295
283
  ARJUNA_EMAIL, ARJUNA_PASSWORD, ARJUNA_BASE_URL,
296
- ARJUNA_VOUCHER, ARJUNA_EMAIL_DOMAIN, ARJUNA_TIMEOUT`);
284
+ ARJUNA_VOUCHER_CODE, ARJUNA_EMAIL_DOMAIN, ARJUNA_TIMEOUT`);
297
285
  }
298
286
 
299
287
  async function main() {
@@ -314,8 +302,10 @@ async function main() {
314
302
  validateProfile(profile);
315
303
  if (!opts.quiet && !opts.raw && !opts.json) console.error('Membuat akun...');
316
304
  await register(client, profile);
317
- if (!opts.quiet && !opts.raw && !opts.json) console.error('Masuk ke akun...');
318
- await login(client, profile.email, profile.password);
305
+ if (!client.cookies.size) {
306
+ if (!opts.quiet && !opts.raw && !opts.json) console.error('Masuk ke akun...');
307
+ await login(client, profile.email, profile.password);
308
+ }
319
309
  } else {
320
310
  profile = {
321
311
  email: (opts.email || process.env.ARJUNA_EMAIL).toLowerCase(),
@@ -325,10 +315,10 @@ async function main() {
325
315
  await login(client, profile.email, profile.password);
326
316
  }
327
317
 
328
- if (!opts.noClaim && opts.voucher) {
329
- if (!opts.quiet && !opts.raw && !opts.json) console.error('Mengklaim kode...');
318
+ if (!opts.noClaim && opts.voucherCode) {
319
+ if (!opts.quiet && !opts.raw && !opts.json) console.error('Redeem voucher...');
330
320
  try {
331
- claim = await claimCode(client, opts.voucher);
321
+ claim = await redeemVoucher(client, opts.voucherCode);
332
322
  } catch (error) {
333
323
  if (opts.command === 'login' && error instanceof ApiError && /already|sudah|claimed/i.test(error.message)) {
334
324
  claim = { kind: 'already-claimed' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gelglx/arjunakey",
3
- "version": "1.0.0",
4
- "description": "Single-account CLI for OneStore registration, welcome-code claiming, and API-key retrieval",
3
+ "version": "1.1.0",
4
+ "description": "Single-account CLI for OneStore registration, voucher redemption, and API-key retrieval",
5
5
  "bin": {
6
6
  "arjunakey": "cli.js"
7
7
  },