myxl-core 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.
Files changed (47) hide show
  1. package/README.md +15 -0
  2. package/dist/@types/payment.d.ts +10 -0
  3. package/dist/auth.d.ts +20 -0
  4. package/dist/auth.js +157 -0
  5. package/dist/ciam.d.ts +259 -0
  6. package/dist/ciam.js +351 -0
  7. package/dist/client.d.ts +56 -0
  8. package/dist/client.js +276 -0
  9. package/dist/config.d.ts +14 -0
  10. package/dist/config.js +70 -0
  11. package/dist/device.d.ts +23 -0
  12. package/dist/device.js +107 -0
  13. package/dist/encrypt.d.ts +37 -0
  14. package/dist/encrypt.js +259 -0
  15. package/dist/family-plan.d.ts +28 -0
  16. package/dist/family-plan.js +325 -0
  17. package/dist/family.d.ts +146 -0
  18. package/dist/family.js +365 -0
  19. package/dist/index.d.ts +19 -0
  20. package/dist/index.js +1487 -0
  21. package/dist/lib/decoy.d.ts +17 -0
  22. package/dist/lib/decoy.js +117 -0
  23. package/dist/lib/encrypt-helper.d.ts +71 -0
  24. package/dist/lib/encrypt-helper.js +166 -0
  25. package/dist/lib/payment.d.ts +116 -0
  26. package/dist/lib/payment.js +271 -0
  27. package/dist/lib/utils.d.ts +15 -0
  28. package/dist/lib/utils.js +290 -0
  29. package/dist/notification.d.ts +28 -0
  30. package/dist/notification.js +275 -0
  31. package/dist/package.d.ts +259 -0
  32. package/dist/package.js +387 -0
  33. package/dist/payments/balance.d.ts +2 -0
  34. package/dist/payments/balance.js +408 -0
  35. package/dist/payments/decoy.d.ts +1 -0
  36. package/dist/payments/decoy.js +6 -0
  37. package/dist/payments/ewallet.d.ts +11 -0
  38. package/dist/payments/ewallet.js +373 -0
  39. package/dist/payments/index.d.ts +3 -0
  40. package/dist/payments/index.js +632 -0
  41. package/dist/payments/qris.d.ts +2 -0
  42. package/dist/payments/qris.js +378 -0
  43. package/dist/profile.d.ts +1 -0
  44. package/dist/profile.js +266 -0
  45. package/dist/verification.d.ts +2 -0
  46. package/dist/verification.js +279 -0
  47. package/package.json +116 -0
@@ -0,0 +1,378 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toCommonJS = (from) => {
10
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
+ if (entry)
12
+ return entry;
13
+ entry = __defProp({}, "__esModule", { value: true });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (var key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(entry, key))
17
+ __defProp(entry, key, {
18
+ get: __accessProp.bind(from, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ __moduleCache.set(from, entry);
23
+ return entry;
24
+ };
25
+ var __moduleCache;
26
+ var __returnValue = (v) => v;
27
+ function __exportSetter(name, newValue) {
28
+ this[name] = __returnValue.bind(null, newValue);
29
+ }
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, {
33
+ get: all[name],
34
+ enumerable: true,
35
+ configurable: true,
36
+ set: __exportSetter.bind(all, name)
37
+ });
38
+ };
39
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
+
41
+ // src/lib/utils.ts
42
+ import axios from "axios";
43
+ import { v4 as uuidv4 } from "uuid";
44
+ import { DateTime } from "luxon";
45
+ function javaLikeTimestamp(dt = DateTime.now()) {
46
+ return dt.toMillis().toString();
47
+ }
48
+ async function sendApiRequest(path, payloadDict, idToken, method = "POST") {
49
+ const encryptedPayload = encryptSignXData(method, path, idToken, payloadDict);
50
+ const xtime = Number(encryptedPayload.encrypted_body.xtime);
51
+ const sigTimeSec = Math.floor(xtime / 1000);
52
+ const body = encryptedPayload.encrypted_body;
53
+ const x_sig = encryptedPayload.x_signature;
54
+ const headers = {
55
+ host: BASE_API_URL.replace(/^https?:\/\//, ""),
56
+ "content-type": "application/json; charset=utf-8",
57
+ "user-agent": UA,
58
+ "x-api-key": API_KEY,
59
+ authorization: `Bearer ${idToken}`,
60
+ "x-hv": "v3",
61
+ "x-signature-time": String(sigTimeSec),
62
+ "x-signature": x_sig,
63
+ "x-request-id": uuidv4(),
64
+ "x-request-at": javaLikeTimestamp(),
65
+ "x-version-app": X_APP_VERSION
66
+ };
67
+ const url = `${BASE_API_URL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
68
+ const resp = await axios.post(url, body, {
69
+ headers,
70
+ timeout: 30000
71
+ });
72
+ const respData = resp.data;
73
+ const decryptedXData = await decryptXData(respData.xdata, respData.xtime);
74
+ if (decryptedXData.status === "FAILED") {
75
+ throw new Error(JSON.stringify(decryptedXData));
76
+ }
77
+ return decryptedXData;
78
+ }
79
+ async function interceptPage(idToken, optionCode, isEnterprise = false) {
80
+ const path = "misc/api/v8/utility/intercept-page";
81
+ const rawPayload = {
82
+ is_enterprise: isEnterprise,
83
+ lang: "en",
84
+ package_option_code: optionCode
85
+ };
86
+ console.log("Fetching intercept page...");
87
+ try {
88
+ const res = await sendApiRequest(path, rawPayload, idToken, "POST");
89
+ if ("status" in res) {
90
+ console.log(`Intercept status: ${res["status"]}`);
91
+ } else {
92
+ console.log("Intercept error");
93
+ }
94
+ } catch (err) {
95
+ console.log("Intercept error", err);
96
+ }
97
+ }
98
+ function unseal(getter, fallback) {
99
+ try {
100
+ const hex = getter();
101
+ if (!hex || typeof __SEED__ === "undefined")
102
+ return fallback;
103
+ const seed = Buffer.from(__SEED__, "hex");
104
+ const data = Buffer.from(hex, "hex");
105
+ return Buffer.from(data.map((b, i) => b ^ seed[i % seed.length])).toString("utf8");
106
+ } catch {
107
+ return fallback;
108
+ }
109
+ }
110
+ var init_utils = __esm(() => {
111
+ init_config();
112
+ init_encrypt();
113
+ });
114
+
115
+ // src/config.ts
116
+ var BASE_API_URL, BASE_CIAM_URL, BASIC_AUTH, AX_FP_KEY, UA, API_KEY, ENCRYPTED_FIELD_KEY, XDATA_KEY, AX_API_SIG_KEY, X_API_BASE_SECRET, CIRCLE_MSISDN_KEY, X_APP_VERSION = "8.9.0";
117
+ var init_config = __esm(() => {
118
+ init_utils();
119
+ BASE_API_URL = unseal(() => __E_BASE_API_URL__, "https://api.myxl.xlaxiata.co.id");
120
+ BASE_CIAM_URL = unseal(() => __E_BASE_CIAM_URL__, "https://gede.ciam.xlaxiata.co.id");
121
+ BASIC_AUTH = unseal(() => __E_BASIC_AUTH__, "OWZjOTdlZDEtNmEzMC00OGQ1LTk1MTYtNjBjNTNjZTNhMTM1OllEV21GNExKajlYSUt3UW56eTJlMmxiMHRKUWIyOW8z");
122
+ AX_FP_KEY = unseal(() => __E_AX_FP_KEY__, "18b4d589826af50241177961590e6693");
123
+ UA = unseal(() => __E_UA__, "myXL / 8.9.0(1202); com.android.vending; (samsung; SM-N935F; SDK 33; Android 13)");
124
+ API_KEY = unseal(() => __E_API_KEY__, "vT8tINqHaOxXbGE7eOWAhA==");
125
+ ENCRYPTED_FIELD_KEY = unseal(() => __E_ENCRYPTED_FIELD_KEY__, "5dccbf08920a5527");
126
+ XDATA_KEY = unseal(() => __E_XDATA_KEY__, "5dccbf08920a5527b99e222789c34bb7");
127
+ AX_API_SIG_KEY = unseal(() => __E_AX_API_SIG_KEY__, "18b4d589826af50241177961590e6693");
128
+ X_API_BASE_SECRET = unseal(() => __E_X_API_BASE_SECRET__, "mU1Y4n1vBjf3M7tMnRkFU08mVyUJHed8B5En3EAniu1mXLixeuASmBmKnkyzVziOye7rG5nIekMdthensbQMcOJ6SLnrkGyfXALD7mrBC6vuWv6G01pmD3XlU5rT7Tzx");
129
+ CIRCLE_MSISDN_KEY = unseal(() => __E_CIRCLE_MSISDN_KEY__, "5dccbf08920a5527");
130
+ });
131
+
132
+ // src/lib/encrypt-helper.ts
133
+ var exports_encrypt_helper = {};
134
+ __export(exports_encrypt_helper, {
135
+ makeXSignaturePayment: () => makeXSignaturePayment,
136
+ makeXSignatureLoyalty: () => makeXSignatureLoyalty,
137
+ makeXSignatureBountyAllotment: () => makeXSignatureBountyAllotment,
138
+ makeXSignatureBounty: () => makeXSignatureBounty,
139
+ makeXSignatureBasic: () => makeXSignatureBasic,
140
+ makeXSignature: () => makeXSignature,
141
+ makeAxApiSignature: () => makeAxApiSignature,
142
+ encryptXData: () => encryptXData,
143
+ encryptEncryptedField: () => encryptEncryptedField,
144
+ decryptXData: () => decryptXData2,
145
+ decryptEncryptedField: () => decryptEncryptedField
146
+ });
147
+ import crypto from "crypto";
148
+ function pkcs7Pad(buf, blockSize = 16) {
149
+ const pad = blockSize - buf.length % blockSize;
150
+ const padBuf = Buffer.alloc(pad, pad);
151
+ return Buffer.concat([buf, padBuf]);
152
+ }
153
+ function pkcs7Unpad(buf) {
154
+ const pad = buf[buf.length - 1] ?? 16;
155
+ if (pad < 1 || pad > 16)
156
+ throw new Error("Invalid PKCS7 padding");
157
+ return buf.slice(0, buf.length - pad);
158
+ }
159
+ function deriveIv(xtimeMs) {
160
+ const sha = crypto.createHash("sha256").update(String(xtimeMs)).digest("hex");
161
+ return Buffer.from(sha.slice(0, 16), "ascii");
162
+ }
163
+ function urlsafeB64Encode(buf) {
164
+ return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_");
165
+ }
166
+ function urlsafeB64Decode(s) {
167
+ const b64 = s.replace(/-/g, "+").replace(/_/g, "/");
168
+ const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
169
+ return Buffer.from(padded, "base64");
170
+ }
171
+ function encryptXData(plaintext, xtimeMs) {
172
+ const key = Buffer.from(XDATA_KEY, "ascii");
173
+ const iv = deriveIv(xtimeMs);
174
+ const padded = pkcs7Pad(Buffer.from(plaintext, "utf-8"));
175
+ const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
176
+ cipher.setAutoPadding(false);
177
+ const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
178
+ return urlsafeB64Encode(ct);
179
+ }
180
+ function decryptXData2(xdata, xtimeMs) {
181
+ const key = Buffer.from(XDATA_KEY, "ascii");
182
+ const iv = deriveIv(xtimeMs);
183
+ const ct = urlsafeB64Decode(xdata);
184
+ const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
185
+ decipher.setAutoPadding(false);
186
+ const pt = Buffer.concat([decipher.update(ct), decipher.final()]);
187
+ return pkcs7Unpad(pt).toString("utf-8");
188
+ }
189
+ function makeXSignature(idToken, method, path, sigTimeSec) {
190
+ const keyStr = `${X_API_BASE_SECRET};${idToken};${method};${path};${sigTimeSec}`;
191
+ const msg = `${idToken};${sigTimeSec};`;
192
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
193
+ }
194
+ function makeXSignaturePayment(accessToken, sigTimeSec, packageCode, tokenPayment, paymentMethod, paymentFor, path) {
195
+ const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
196
+ const msg = `${accessToken};${tokenPayment};${sigTimeSec};${paymentFor};${paymentMethod};${packageCode};`;
197
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
198
+ }
199
+ function makeXSignatureBounty(accessToken, sigTimeSec, packageCode, tokenPayment) {
200
+ const path = "api/v8/personalization/bounties-exchange";
201
+ const keyStr = `${X_API_BASE_SECRET};${accessToken};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
202
+ const msg = `${accessToken};${tokenPayment};${sigTimeSec};${packageCode};`;
203
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
204
+ }
205
+ function makeXSignatureLoyalty(sigTimeSec, packageCode, tokenConfirmation, path) {
206
+ const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
207
+ const msg = `${tokenConfirmation};${sigTimeSec};${packageCode};`;
208
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
209
+ }
210
+ function makeXSignatureBountyAllotment(sigTimeSec, packageCode, tokenConfirmation, path, destinationMsisdn) {
211
+ const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;${destinationMsisdn};POST;${path};${sigTimeSec}`;
212
+ const msg = `${tokenConfirmation};${sigTimeSec};${destinationMsisdn};${packageCode};`;
213
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
214
+ }
215
+ function makeXSignatureBasic(method, path, sigTimeSec) {
216
+ const keyStr = `${X_API_BASE_SECRET};${method};${path};${sigTimeSec}`;
217
+ const msg = `${sigTimeSec};en;`;
218
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
219
+ }
220
+ function makeAxApiSignature(tsForSign, contact, code, contactType) {
221
+ const preimage = `${tsForSign}password${contactType}${contact}${code}openid`;
222
+ const digest = crypto.createHmac("sha256", Buffer.from(AX_API_SIG_KEY, "ascii")).update(preimage).digest();
223
+ return digest.toString("base64");
224
+ }
225
+ function decryptEncryptedField(encryptedB64) {
226
+ const ivAscii = encryptedB64.slice(-16);
227
+ const b64Part = encryptedB64.slice(0, -16);
228
+ const key = Buffer.from(ENCRYPTED_FIELD_KEY, "ascii");
229
+ const iv = Buffer.from(ivAscii, "ascii");
230
+ const ct = urlsafeB64Decode(b64Part);
231
+ const decipher = crypto.createDecipheriv("aes-128-cbc", key, iv);
232
+ decipher.setAutoPadding(false);
233
+ const pt = Buffer.concat([decipher.update(ct), decipher.final()]);
234
+ return pkcs7Unpad(pt).toString("utf-8");
235
+ }
236
+ function encryptEncryptedField(plaintext) {
237
+ const key = Buffer.from(ENCRYPTED_FIELD_KEY, "ascii");
238
+ const ivHex = crypto.randomBytes(8).toString("hex");
239
+ const iv = Buffer.from(ivHex, "ascii");
240
+ const padded = pkcs7Pad(Buffer.from(plaintext, "utf-8"));
241
+ const cipher = crypto.createCipheriv("aes-128-cbc", key, iv);
242
+ cipher.setAutoPadding(false);
243
+ const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
244
+ return urlsafeB64Encode(ct) + ivHex;
245
+ }
246
+ var init_encrypt_helper = __esm(() => {
247
+ init_config();
248
+ });
249
+
250
+ // src/encrypt.ts
251
+ function encryptSignXData(method, path, idToken, payload) {
252
+ const plainBody = JSON.stringify(payload);
253
+ const xtime = Date.now();
254
+ const xdata = encryptXData(plainBody, xtime);
255
+ const sigTimeSec = Math.floor(xtime / 1000);
256
+ const xSignature = makeXSignature(idToken, method, path, sigTimeSec);
257
+ return {
258
+ x_signature: xSignature,
259
+ encrypted_body: { xdata, xtime }
260
+ };
261
+ }
262
+ async function decryptXData(xdata, xtimeMs) {
263
+ const { decryptXData: _decrypt } = (init_encrypt_helper(), __toCommonJS(exports_encrypt_helper));
264
+ return JSON.parse(_decrypt(xdata, xtimeMs));
265
+ }
266
+ var init_encrypt = __esm(() => {
267
+ init_config();
268
+ init_encrypt_helper();
269
+ init_encrypt_helper();
270
+ });
271
+
272
+ // src/payments/qris.ts
273
+ init_encrypt();
274
+ init_utils();
275
+ init_config();
276
+ import axios2 from "axios";
277
+ import { v4 as uuidv42 } from "uuid";
278
+ import { DateTime as DateTime2 } from "luxon";
279
+ async function settlementQris({
280
+ idToken,
281
+ accessToken,
282
+ item,
283
+ items,
284
+ paymentFor,
285
+ tokenConfirmation,
286
+ topup_number = "",
287
+ stage_token = "",
288
+ overwriteAmount = null,
289
+ paymentTargetsMethodsOption
290
+ }) {
291
+ const payment_targets = items.map((item2) => item2.item_code).join(";");
292
+ await interceptPage(idToken, item.item_code, false);
293
+ const paymentRes = await sendApiRequest("payments/api/v8/payment-methods-option", {
294
+ payment_type: "PURCHASE",
295
+ is_enterprise: false,
296
+ payment_target: paymentTargetsMethodsOption ?? item.item_code,
297
+ lang: "en",
298
+ is_referral: false,
299
+ token_confirmation: tokenConfirmation
300
+ }, idToken, "POST");
301
+ const { token_payment, timestamp } = paymentRes.data;
302
+ const price = overwriteAmount === 0 ? 0 : item.item_price;
303
+ const settlementPath = "payments/api/v8/settlement-multipayment/qris";
304
+ const settlementPayload = {
305
+ akrab: {
306
+ akrab_members: [],
307
+ akrab_parent_alias: "",
308
+ members: []
309
+ },
310
+ can_trigger_rating: false,
311
+ total_discount: 0,
312
+ coupon: "",
313
+ payment_for: paymentFor,
314
+ topup_number,
315
+ stage_token,
316
+ is_enterprise: false,
317
+ autobuy: {
318
+ is_using_autobuy: false,
319
+ activated_autobuy_code: "",
320
+ autobuy_threshold_setting: {
321
+ label: "",
322
+ type: "",
323
+ value: 0
324
+ }
325
+ },
326
+ access_token: accessToken,
327
+ is_myxl_wallet: false,
328
+ additional_data: {
329
+ original_price: item.item_price,
330
+ is_spend_limit_temporary: false,
331
+ migration_type: "",
332
+ spend_limit_amount: 0,
333
+ is_spend_limit: false,
334
+ tax: 0,
335
+ benefit_type: "",
336
+ quota_bonus: 0,
337
+ cashtag: "",
338
+ is_family_plan: false,
339
+ combo_details: [],
340
+ is_switch_plan: false,
341
+ discount_recurring: 0,
342
+ has_bonus: false,
343
+ discount_promo: 0
344
+ },
345
+ total_amount: price,
346
+ total_fee: 0,
347
+ is_use_point: false,
348
+ lang: "en",
349
+ items,
350
+ verification_token: token_payment,
351
+ payment_method: "QRIS",
352
+ timestamp
353
+ };
354
+ const encrypted = await encryptSignXData("POST", settlementPath, idToken, settlementPayload);
355
+ const xtimeRaw = encrypted.encrypted_body?.xtime;
356
+ const sigTimeSec = Math.floor((typeof xtimeRaw === "string" ? parseInt(xtimeRaw) : Number(xtimeRaw)) / 1000);
357
+ const xSig = await makeXSignaturePayment(accessToken, timestamp, payment_targets, token_payment, "QRIS", paymentFor, settlementPath);
358
+ const headers = {
359
+ host: BASE_API_URL.replace("https://", ""),
360
+ "content-type": "application/json; charset=utf-8",
361
+ "user-agent": UA,
362
+ "x-api-key": API_KEY,
363
+ authorization: `Bearer ${idToken}`,
364
+ "x-hv": "v3",
365
+ "x-signature-time": String(sigTimeSec),
366
+ "x-signature": xSig,
367
+ "x-request-id": uuidv42(),
368
+ "x-request-at": javaLikeTimestamp(DateTime2.fromSeconds(sigTimeSec, { zone: "utc" }).setZone("local")),
369
+ "x-version-app": X_APP_VERSION
370
+ };
371
+ const url = `${BASE_API_URL}/${settlementPath}`;
372
+ const resp = await axios2.post(url, encrypted.encrypted_body, { headers, timeout: 30000 });
373
+ const decryptedXData = await decryptXData(resp.data.xdata, resp.data.xtime);
374
+ return decryptedXData;
375
+ }
376
+ export {
377
+ settlementQris
378
+ };
@@ -0,0 +1 @@
1
+ export declare function getPendingTransaction(idToken: string): Promise<any>;
@@ -0,0 +1,266 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toCommonJS = (from) => {
10
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
+ if (entry)
12
+ return entry;
13
+ entry = __defProp({}, "__esModule", { value: true });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (var key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(entry, key))
17
+ __defProp(entry, key, {
18
+ get: __accessProp.bind(from, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ __moduleCache.set(from, entry);
23
+ return entry;
24
+ };
25
+ var __moduleCache;
26
+ var __returnValue = (v) => v;
27
+ function __exportSetter(name, newValue) {
28
+ this[name] = __returnValue.bind(null, newValue);
29
+ }
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, {
33
+ get: all[name],
34
+ enumerable: true,
35
+ configurable: true,
36
+ set: __exportSetter.bind(all, name)
37
+ });
38
+ };
39
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
+
41
+ // src/config.ts
42
+ var BASE_API_URL, BASE_CIAM_URL, BASIC_AUTH, AX_FP_KEY, UA, API_KEY, ENCRYPTED_FIELD_KEY, XDATA_KEY, AX_API_SIG_KEY, X_API_BASE_SECRET, CIRCLE_MSISDN_KEY, X_APP_VERSION = "8.9.0";
43
+ var init_config = __esm(() => {
44
+ init_utils();
45
+ BASE_API_URL = unseal(() => __E_BASE_API_URL__, "https://api.myxl.xlaxiata.co.id");
46
+ BASE_CIAM_URL = unseal(() => __E_BASE_CIAM_URL__, "https://gede.ciam.xlaxiata.co.id");
47
+ BASIC_AUTH = unseal(() => __E_BASIC_AUTH__, "OWZjOTdlZDEtNmEzMC00OGQ1LTk1MTYtNjBjNTNjZTNhMTM1OllEV21GNExKajlYSUt3UW56eTJlMmxiMHRKUWIyOW8z");
48
+ AX_FP_KEY = unseal(() => __E_AX_FP_KEY__, "18b4d589826af50241177961590e6693");
49
+ UA = unseal(() => __E_UA__, "myXL / 8.9.0(1202); com.android.vending; (samsung; SM-N935F; SDK 33; Android 13)");
50
+ API_KEY = unseal(() => __E_API_KEY__, "vT8tINqHaOxXbGE7eOWAhA==");
51
+ ENCRYPTED_FIELD_KEY = unseal(() => __E_ENCRYPTED_FIELD_KEY__, "5dccbf08920a5527");
52
+ XDATA_KEY = unseal(() => __E_XDATA_KEY__, "5dccbf08920a5527b99e222789c34bb7");
53
+ AX_API_SIG_KEY = unseal(() => __E_AX_API_SIG_KEY__, "18b4d589826af50241177961590e6693");
54
+ X_API_BASE_SECRET = unseal(() => __E_X_API_BASE_SECRET__, "mU1Y4n1vBjf3M7tMnRkFU08mVyUJHed8B5En3EAniu1mXLixeuASmBmKnkyzVziOye7rG5nIekMdthensbQMcOJ6SLnrkGyfXALD7mrBC6vuWv6G01pmD3XlU5rT7Tzx");
55
+ CIRCLE_MSISDN_KEY = unseal(() => __E_CIRCLE_MSISDN_KEY__, "5dccbf08920a5527");
56
+ });
57
+
58
+ // src/lib/encrypt-helper.ts
59
+ var exports_encrypt_helper = {};
60
+ __export(exports_encrypt_helper, {
61
+ makeXSignaturePayment: () => makeXSignaturePayment,
62
+ makeXSignatureLoyalty: () => makeXSignatureLoyalty,
63
+ makeXSignatureBountyAllotment: () => makeXSignatureBountyAllotment,
64
+ makeXSignatureBounty: () => makeXSignatureBounty,
65
+ makeXSignatureBasic: () => makeXSignatureBasic,
66
+ makeXSignature: () => makeXSignature,
67
+ makeAxApiSignature: () => makeAxApiSignature,
68
+ encryptXData: () => encryptXData,
69
+ encryptEncryptedField: () => encryptEncryptedField,
70
+ decryptXData: () => decryptXData,
71
+ decryptEncryptedField: () => decryptEncryptedField
72
+ });
73
+ import crypto from "crypto";
74
+ function pkcs7Pad(buf, blockSize = 16) {
75
+ const pad = blockSize - buf.length % blockSize;
76
+ const padBuf = Buffer.alloc(pad, pad);
77
+ return Buffer.concat([buf, padBuf]);
78
+ }
79
+ function pkcs7Unpad(buf) {
80
+ const pad = buf[buf.length - 1] ?? 16;
81
+ if (pad < 1 || pad > 16)
82
+ throw new Error("Invalid PKCS7 padding");
83
+ return buf.slice(0, buf.length - pad);
84
+ }
85
+ function deriveIv(xtimeMs) {
86
+ const sha = crypto.createHash("sha256").update(String(xtimeMs)).digest("hex");
87
+ return Buffer.from(sha.slice(0, 16), "ascii");
88
+ }
89
+ function urlsafeB64Encode(buf) {
90
+ return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_");
91
+ }
92
+ function urlsafeB64Decode(s) {
93
+ const b64 = s.replace(/-/g, "+").replace(/_/g, "/");
94
+ const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
95
+ return Buffer.from(padded, "base64");
96
+ }
97
+ function encryptXData(plaintext, xtimeMs) {
98
+ const key = Buffer.from(XDATA_KEY, "ascii");
99
+ const iv = deriveIv(xtimeMs);
100
+ const padded = pkcs7Pad(Buffer.from(plaintext, "utf-8"));
101
+ const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
102
+ cipher.setAutoPadding(false);
103
+ const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
104
+ return urlsafeB64Encode(ct);
105
+ }
106
+ function decryptXData(xdata, xtimeMs) {
107
+ const key = Buffer.from(XDATA_KEY, "ascii");
108
+ const iv = deriveIv(xtimeMs);
109
+ const ct = urlsafeB64Decode(xdata);
110
+ const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
111
+ decipher.setAutoPadding(false);
112
+ const pt = Buffer.concat([decipher.update(ct), decipher.final()]);
113
+ return pkcs7Unpad(pt).toString("utf-8");
114
+ }
115
+ function makeXSignature(idToken, method, path, sigTimeSec) {
116
+ const keyStr = `${X_API_BASE_SECRET};${idToken};${method};${path};${sigTimeSec}`;
117
+ const msg = `${idToken};${sigTimeSec};`;
118
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
119
+ }
120
+ function makeXSignaturePayment(accessToken, sigTimeSec, packageCode, tokenPayment, paymentMethod, paymentFor, path) {
121
+ const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
122
+ const msg = `${accessToken};${tokenPayment};${sigTimeSec};${paymentFor};${paymentMethod};${packageCode};`;
123
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
124
+ }
125
+ function makeXSignatureBounty(accessToken, sigTimeSec, packageCode, tokenPayment) {
126
+ const path = "api/v8/personalization/bounties-exchange";
127
+ const keyStr = `${X_API_BASE_SECRET};${accessToken};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
128
+ const msg = `${accessToken};${tokenPayment};${sigTimeSec};${packageCode};`;
129
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
130
+ }
131
+ function makeXSignatureLoyalty(sigTimeSec, packageCode, tokenConfirmation, path) {
132
+ const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
133
+ const msg = `${tokenConfirmation};${sigTimeSec};${packageCode};`;
134
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
135
+ }
136
+ function makeXSignatureBountyAllotment(sigTimeSec, packageCode, tokenConfirmation, path, destinationMsisdn) {
137
+ const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;${destinationMsisdn};POST;${path};${sigTimeSec}`;
138
+ const msg = `${tokenConfirmation};${sigTimeSec};${destinationMsisdn};${packageCode};`;
139
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
140
+ }
141
+ function makeXSignatureBasic(method, path, sigTimeSec) {
142
+ const keyStr = `${X_API_BASE_SECRET};${method};${path};${sigTimeSec}`;
143
+ const msg = `${sigTimeSec};en;`;
144
+ return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
145
+ }
146
+ function makeAxApiSignature(tsForSign, contact, code, contactType) {
147
+ const preimage = `${tsForSign}password${contactType}${contact}${code}openid`;
148
+ const digest = crypto.createHmac("sha256", Buffer.from(AX_API_SIG_KEY, "ascii")).update(preimage).digest();
149
+ return digest.toString("base64");
150
+ }
151
+ function decryptEncryptedField(encryptedB64) {
152
+ const ivAscii = encryptedB64.slice(-16);
153
+ const b64Part = encryptedB64.slice(0, -16);
154
+ const key = Buffer.from(ENCRYPTED_FIELD_KEY, "ascii");
155
+ const iv = Buffer.from(ivAscii, "ascii");
156
+ const ct = urlsafeB64Decode(b64Part);
157
+ const decipher = crypto.createDecipheriv("aes-128-cbc", key, iv);
158
+ decipher.setAutoPadding(false);
159
+ const pt = Buffer.concat([decipher.update(ct), decipher.final()]);
160
+ return pkcs7Unpad(pt).toString("utf-8");
161
+ }
162
+ function encryptEncryptedField(plaintext) {
163
+ const key = Buffer.from(ENCRYPTED_FIELD_KEY, "ascii");
164
+ const ivHex = crypto.randomBytes(8).toString("hex");
165
+ const iv = Buffer.from(ivHex, "ascii");
166
+ const padded = pkcs7Pad(Buffer.from(plaintext, "utf-8"));
167
+ const cipher = crypto.createCipheriv("aes-128-cbc", key, iv);
168
+ cipher.setAutoPadding(false);
169
+ const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
170
+ return urlsafeB64Encode(ct) + ivHex;
171
+ }
172
+ var init_encrypt_helper = __esm(() => {
173
+ init_config();
174
+ });
175
+
176
+ // src/encrypt.ts
177
+ function encryptSignXData(method, path, idToken, payload) {
178
+ const plainBody = JSON.stringify(payload);
179
+ const xtime = Date.now();
180
+ const xdata = encryptXData(plainBody, xtime);
181
+ const sigTimeSec = Math.floor(xtime / 1000);
182
+ const xSignature = makeXSignature(idToken, method, path, sigTimeSec);
183
+ return {
184
+ x_signature: xSignature,
185
+ encrypted_body: { xdata, xtime }
186
+ };
187
+ }
188
+ async function decryptXData2(xdata, xtimeMs) {
189
+ const { decryptXData: _decrypt } = (init_encrypt_helper(), __toCommonJS(exports_encrypt_helper));
190
+ return JSON.parse(_decrypt(xdata, xtimeMs));
191
+ }
192
+ var init_encrypt = __esm(() => {
193
+ init_config();
194
+ init_encrypt_helper();
195
+ init_encrypt_helper();
196
+ });
197
+
198
+ // src/lib/utils.ts
199
+ import axios from "axios";
200
+ import { v4 as uuidv4 } from "uuid";
201
+ import { DateTime } from "luxon";
202
+ function javaLikeTimestamp(dt = DateTime.now()) {
203
+ return dt.toMillis().toString();
204
+ }
205
+ async function sendApiRequest(path, payloadDict, idToken, method = "POST") {
206
+ const encryptedPayload = encryptSignXData(method, path, idToken, payloadDict);
207
+ const xtime = Number(encryptedPayload.encrypted_body.xtime);
208
+ const sigTimeSec = Math.floor(xtime / 1000);
209
+ const body = encryptedPayload.encrypted_body;
210
+ const x_sig = encryptedPayload.x_signature;
211
+ const headers = {
212
+ host: BASE_API_URL.replace(/^https?:\/\//, ""),
213
+ "content-type": "application/json; charset=utf-8",
214
+ "user-agent": UA,
215
+ "x-api-key": API_KEY,
216
+ authorization: `Bearer ${idToken}`,
217
+ "x-hv": "v3",
218
+ "x-signature-time": String(sigTimeSec),
219
+ "x-signature": x_sig,
220
+ "x-request-id": uuidv4(),
221
+ "x-request-at": javaLikeTimestamp(),
222
+ "x-version-app": X_APP_VERSION
223
+ };
224
+ const url = `${BASE_API_URL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
225
+ const resp = await axios.post(url, body, {
226
+ headers,
227
+ timeout: 30000
228
+ });
229
+ const respData = resp.data;
230
+ const decryptedXData = await decryptXData2(respData.xdata, respData.xtime);
231
+ if (decryptedXData.status === "FAILED") {
232
+ throw new Error(JSON.stringify(decryptedXData));
233
+ }
234
+ return decryptedXData;
235
+ }
236
+ function unseal(getter, fallback) {
237
+ try {
238
+ const hex = getter();
239
+ if (!hex || typeof __SEED__ === "undefined")
240
+ return fallback;
241
+ const seed = Buffer.from(__SEED__, "hex");
242
+ const data = Buffer.from(hex, "hex");
243
+ return Buffer.from(data.map((b, i) => b ^ seed[i % seed.length])).toString("utf8");
244
+ } catch {
245
+ return fallback;
246
+ }
247
+ }
248
+ var init_utils = __esm(() => {
249
+ init_config();
250
+ init_encrypt();
251
+ });
252
+
253
+ // src/profile.ts
254
+ init_utils();
255
+ async function getPendingTransaction(idToken) {
256
+ const path = "api/v8/profile";
257
+ const payload = {
258
+ is_enterprise: false,
259
+ lang: "en"
260
+ };
261
+ const res = await sendApiRequest(path, payload, idToken, "POST");
262
+ return res.data;
263
+ }
264
+ export {
265
+ getPendingTransaction
266
+ };
@@ -0,0 +1,2 @@
1
+ export declare function validatePuk(msisdn: string, puk: string): Promise<any>;
2
+ export declare function checkDukcapil(msisdn: string, kk: string, nik: string): Promise<any>;