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.
- package/README.md +15 -0
- package/dist/@types/payment.d.ts +10 -0
- package/dist/auth.d.ts +20 -0
- package/dist/auth.js +157 -0
- package/dist/ciam.d.ts +259 -0
- package/dist/ciam.js +351 -0
- package/dist/client.d.ts +56 -0
- package/dist/client.js +276 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +70 -0
- package/dist/device.d.ts +23 -0
- package/dist/device.js +107 -0
- package/dist/encrypt.d.ts +37 -0
- package/dist/encrypt.js +259 -0
- package/dist/family-plan.d.ts +28 -0
- package/dist/family-plan.js +325 -0
- package/dist/family.d.ts +146 -0
- package/dist/family.js +365 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1487 -0
- package/dist/lib/decoy.d.ts +17 -0
- package/dist/lib/decoy.js +117 -0
- package/dist/lib/encrypt-helper.d.ts +71 -0
- package/dist/lib/encrypt-helper.js +166 -0
- package/dist/lib/payment.d.ts +116 -0
- package/dist/lib/payment.js +271 -0
- package/dist/lib/utils.d.ts +15 -0
- package/dist/lib/utils.js +290 -0
- package/dist/notification.d.ts +28 -0
- package/dist/notification.js +275 -0
- package/dist/package.d.ts +259 -0
- package/dist/package.js +387 -0
- package/dist/payments/balance.d.ts +2 -0
- package/dist/payments/balance.js +408 -0
- package/dist/payments/decoy.d.ts +1 -0
- package/dist/payments/decoy.js +6 -0
- package/dist/payments/ewallet.d.ts +11 -0
- package/dist/payments/ewallet.js +373 -0
- package/dist/payments/index.d.ts +3 -0
- package/dist/payments/index.js +632 -0
- package/dist/payments/qris.d.ts +2 -0
- package/dist/payments/qris.js +378 -0
- package/dist/profile.d.ts +1 -0
- package/dist/profile.js +266 -0
- package/dist/verification.d.ts +2 -0
- package/dist/verification.js +279 -0
- package/package.json +116 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type DecoyType = 'balance' | 'qris' | 'qris0';
|
|
2
|
+
export type DecoyDataType = {
|
|
3
|
+
family_name: string;
|
|
4
|
+
family_code: string;
|
|
5
|
+
is_enterprise: boolean | null;
|
|
6
|
+
migration_type: string | null;
|
|
7
|
+
variant_code: string;
|
|
8
|
+
option_name: string;
|
|
9
|
+
order: number;
|
|
10
|
+
price: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getDecoyName: (paymentMethod: string) => DecoyType;
|
|
13
|
+
export declare const decoyIsExits: (paymentMethod: string) => boolean;
|
|
14
|
+
export declare const getDecoyData: ({ subscriptionType, decoy, }: {
|
|
15
|
+
subscriptionType: string;
|
|
16
|
+
decoy: DecoyType;
|
|
17
|
+
}) => DecoyDataType;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/data/decoys/decoy-default-balance.json
|
|
3
|
+
var decoy_default_balance_default = {
|
|
4
|
+
family_name: "XL PASS",
|
|
5
|
+
family_code: "b0a20d74-0c54-4e3b-8f3f-01e7482e50bf",
|
|
6
|
+
is_enterprise: true,
|
|
7
|
+
migration_type: "NONE",
|
|
8
|
+
variant_code: "719d093f-6f8d-46a4-8390-6a0003a172ea",
|
|
9
|
+
option_name: "XL PASS 30 days",
|
|
10
|
+
order: 1,
|
|
11
|
+
price: 889750
|
|
12
|
+
};
|
|
13
|
+
// src/data/decoys/decoy-default-qris.json
|
|
14
|
+
var decoy_default_qris_default = {
|
|
15
|
+
family_name: "",
|
|
16
|
+
family_code: "580c1f94-7dc4-416e-96f6-8faf26567516",
|
|
17
|
+
is_enterprise: false,
|
|
18
|
+
migration_type: "NONE",
|
|
19
|
+
variant_code: "b50f954a-696e-46d0-8700-8e4d38521525",
|
|
20
|
+
option_name: "",
|
|
21
|
+
order: 27,
|
|
22
|
+
price: 1000
|
|
23
|
+
};
|
|
24
|
+
// src/data/decoys/decoy-default-qris0.json
|
|
25
|
+
var decoy_default_qris0_default = {
|
|
26
|
+
family_name: "Kuota Aplikasi BIZ 2GB",
|
|
27
|
+
family_code: "c6f2cd72-8b21-420a-b8d5-e0186afe5be6",
|
|
28
|
+
is_enterprise: true,
|
|
29
|
+
migration_type: "NONE",
|
|
30
|
+
variant_code: "b7cf278e-c989-4760-8a26-0a20c1a47a40",
|
|
31
|
+
option_name: "Vidio 2GB",
|
|
32
|
+
order: 11,
|
|
33
|
+
price: 0
|
|
34
|
+
};
|
|
35
|
+
// src/data/decoys/decoy-prio-balance.json
|
|
36
|
+
var decoy_prio_balance_default = {
|
|
37
|
+
family_name: "PRIO PASS",
|
|
38
|
+
family_code: "2512b72a-a3cd-4c70-a736-132cf2c1f0c0",
|
|
39
|
+
is_enterprise: null,
|
|
40
|
+
migration_type: null,
|
|
41
|
+
variant_code: "cff298bd-8ec8-4696-b689-12407d36be15",
|
|
42
|
+
option_name: "PRIO PASS 30 days",
|
|
43
|
+
order: 1,
|
|
44
|
+
price: 999000
|
|
45
|
+
};
|
|
46
|
+
// src/data/decoys/decoy-prio-qris.json
|
|
47
|
+
var decoy_prio_qris_default = {
|
|
48
|
+
family_name: "Conference",
|
|
49
|
+
family_code: "5dab52d5-6f02-4678-b72f-088396ceb113",
|
|
50
|
+
is_enterprise: true,
|
|
51
|
+
migration_type: "PRIOH_TO_PRIO",
|
|
52
|
+
variant_code: "bf84ad5b-87e9-4769-9bd2-2359535c05e4",
|
|
53
|
+
option_name: "Conference 2GB",
|
|
54
|
+
order: 1,
|
|
55
|
+
price: 2000
|
|
56
|
+
};
|
|
57
|
+
// src/data/decoys/decoy-prio-qris0.json
|
|
58
|
+
var decoy_prio_qris0_default = {
|
|
59
|
+
family_name: "Conference",
|
|
60
|
+
family_code: "5dab52d5-6f02-4678-b72f-088396ceb113",
|
|
61
|
+
is_enterprise: true,
|
|
62
|
+
migration_type: "PRIOH_TO_PRIO",
|
|
63
|
+
variant_code: "bf84ad5b-87e9-4769-9bd2-2359535c05e4",
|
|
64
|
+
option_name: "Conference 2GB",
|
|
65
|
+
order: 1,
|
|
66
|
+
price: 2000
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/lib/decoy.ts
|
|
70
|
+
var needPrioDecoys = ["PRIORITAS", "PRIOHYBRID", "GO"];
|
|
71
|
+
var getDecoyName = (paymentMethod) => {
|
|
72
|
+
switch (paymentMethod) {
|
|
73
|
+
case "BALANCE_DECOY" /* PulsaDecoy */:
|
|
74
|
+
return "balance";
|
|
75
|
+
case "BALANCE_DECOY_V2" /* PulsaDecoyV2 */:
|
|
76
|
+
return "balance";
|
|
77
|
+
case "QRIS_DECOY" /* QRISDecoy */:
|
|
78
|
+
return "qris";
|
|
79
|
+
case "QRIS_DECOY_V2" /* QRISDecoyV2 */:
|
|
80
|
+
return "qris0";
|
|
81
|
+
default:
|
|
82
|
+
return "balance";
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var decoyIsExits = (paymentMethod) => {
|
|
86
|
+
return [
|
|
87
|
+
"BALANCE_DECOY" /* PulsaDecoy */,
|
|
88
|
+
"BALANCE_DECOY_V2" /* PulsaDecoyV2 */,
|
|
89
|
+
"QRIS_DECOY" /* QRISDecoy */,
|
|
90
|
+
"QRIS_DECOY_V2" /* QRISDecoyV2 */
|
|
91
|
+
].includes(paymentMethod);
|
|
92
|
+
};
|
|
93
|
+
var decoyMap = {
|
|
94
|
+
prio: {
|
|
95
|
+
balance: decoy_prio_balance_default,
|
|
96
|
+
qris: decoy_prio_qris_default,
|
|
97
|
+
qris0: decoy_prio_qris0_default
|
|
98
|
+
},
|
|
99
|
+
default: {
|
|
100
|
+
balance: decoy_default_balance_default,
|
|
101
|
+
qris: decoy_default_qris_default,
|
|
102
|
+
qris0: decoy_default_qris0_default
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var getDecoyData = ({
|
|
106
|
+
subscriptionType,
|
|
107
|
+
decoy
|
|
108
|
+
}) => {
|
|
109
|
+
const isPrio = needPrioDecoys.includes(subscriptionType);
|
|
110
|
+
const group = isPrio ? "prio" : "default";
|
|
111
|
+
return decoyMap[group][decoy];
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
getDecoyName,
|
|
115
|
+
getDecoyData,
|
|
116
|
+
decoyIsExits
|
|
117
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* encrypt-helper.ts
|
|
3
|
+
*
|
|
4
|
+
* Pure TypeScript port of xldor/encrypt_helper.py
|
|
5
|
+
* Uses Node.js built-in `crypto` — no external HTTP call needed.
|
|
6
|
+
*
|
|
7
|
+
* Algorithms used:
|
|
8
|
+
* - AES-CBC (128-bit key from hex string → 16 bytes) for xdata / field encryption
|
|
9
|
+
* - HMAC-SHA512 for x-signature variants
|
|
10
|
+
* - HMAC-SHA256 for ax-api-signature
|
|
11
|
+
* - SHA-256 hash to derive IV from timestamp
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Encrypt a plaintext string with AES-128-CBC.
|
|
15
|
+
* Key = XDATA_KEY (16-char ASCII string → 16 bytes)
|
|
16
|
+
* IV = first 16 chars of SHA256(xtime_ms) as ASCII bytes
|
|
17
|
+
*
|
|
18
|
+
* Returns URL-safe base64 ciphertext (no padding chars).
|
|
19
|
+
*/
|
|
20
|
+
export declare function encryptXData(plaintext: string, xtimeMs: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Decrypt URL-safe base64 xdata with AES-128-CBC.
|
|
23
|
+
* Returns plaintext string.
|
|
24
|
+
*/
|
|
25
|
+
export declare function decryptXData(xdata: string, xtimeMs: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate x-signature for API requests.
|
|
28
|
+
* key = `${X_API_BASE_SECRET};${idToken};${method};${path};${sigTimeSec}`
|
|
29
|
+
* msg = `${idToken};${sigTimeSec};`
|
|
30
|
+
*/
|
|
31
|
+
export declare function makeXSignature(idToken: string, method: string, path: string, sigTimeSec: number): string;
|
|
32
|
+
/**
|
|
33
|
+
* Generate x-signature for payment requests.
|
|
34
|
+
* key = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`
|
|
35
|
+
* msg = `${accessToken};${tokenPayment};${sigTimeSec};${paymentFor};${paymentMethod};${packageCode};`
|
|
36
|
+
*/
|
|
37
|
+
export declare function makeXSignaturePayment(accessToken: string, sigTimeSec: number, packageCode: string, tokenPayment: string, paymentMethod: string, paymentFor: string, path: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Generate x-signature for bounty redemption.
|
|
40
|
+
*/
|
|
41
|
+
export declare function makeXSignatureBounty(accessToken: string, sigTimeSec: number, packageCode: string, tokenPayment: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Generate x-signature for loyalty/allotment.
|
|
44
|
+
*/
|
|
45
|
+
export declare function makeXSignatureLoyalty(sigTimeSec: number, packageCode: string, tokenConfirmation: string, path: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Generate x-signature for bounty allotment (with destination MSISDN).
|
|
48
|
+
*/
|
|
49
|
+
export declare function makeXSignatureBountyAllotment(sigTimeSec: number, packageCode: string, tokenConfirmation: string, path: string, destinationMsisdn: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Basic x-signature (no token, for unauthenticated requests).
|
|
52
|
+
* key = `${X_API_BASE_SECRET};${method};${path};${sigTimeSec}`
|
|
53
|
+
* msg = `${sigTimeSec};en;`
|
|
54
|
+
*/
|
|
55
|
+
export declare function makeXSignatureBasic(method: string, path: string, sigTimeSec: number): string;
|
|
56
|
+
/**
|
|
57
|
+
* Generate Ax-Api-Signature header value.
|
|
58
|
+
* pre-image = `${tsForSign}password${contactType}${contact}${code}openid`
|
|
59
|
+
* Returns standard base64 (not URL-safe).
|
|
60
|
+
*/
|
|
61
|
+
export declare function makeAxApiSignature(tsForSign: string, contact: string, code: string, contactType: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Decrypt a circle-MSISDN / encrypted-field value.
|
|
64
|
+
* Format: urlsafe_b64(ciphertext) + iv_hex16 (last 16 ASCII chars)
|
|
65
|
+
*/
|
|
66
|
+
export declare function decryptEncryptedField(encryptedB64: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Encrypt a plaintext string as an encrypted field.
|
|
69
|
+
* Returns: urlsafe_b64(ciphertext) + iv_hex16
|
|
70
|
+
*/
|
|
71
|
+
export declare function encryptEncryptedField(plaintext: string): string;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
3
|
+
|
|
4
|
+
// src/encrypt.ts
|
|
5
|
+
var init_encrypt = __esm(() => {
|
|
6
|
+
init_config();
|
|
7
|
+
init_encrypt_helper();
|
|
8
|
+
init_encrypt_helper();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// src/lib/utils.ts
|
|
12
|
+
import axios from "axios";
|
|
13
|
+
import { v4 as uuidv4 } from "uuid";
|
|
14
|
+
import { DateTime } from "luxon";
|
|
15
|
+
function unseal(getter, fallback) {
|
|
16
|
+
try {
|
|
17
|
+
const hex = getter();
|
|
18
|
+
if (!hex || typeof __SEED__ === "undefined")
|
|
19
|
+
return fallback;
|
|
20
|
+
const seed = Buffer.from(__SEED__, "hex");
|
|
21
|
+
const data = Buffer.from(hex, "hex");
|
|
22
|
+
return Buffer.from(data.map((b, i) => b ^ seed[i % seed.length])).toString("utf8");
|
|
23
|
+
} catch {
|
|
24
|
+
return fallback;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
var init_utils = __esm(() => {
|
|
28
|
+
init_config();
|
|
29
|
+
init_encrypt();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// src/config.ts
|
|
33
|
+
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;
|
|
34
|
+
var init_config = __esm(() => {
|
|
35
|
+
init_utils();
|
|
36
|
+
BASE_API_URL = unseal(() => __E_BASE_API_URL__, "https://api.myxl.xlaxiata.co.id");
|
|
37
|
+
BASE_CIAM_URL = unseal(() => __E_BASE_CIAM_URL__, "https://gede.ciam.xlaxiata.co.id");
|
|
38
|
+
BASIC_AUTH = unseal(() => __E_BASIC_AUTH__, "OWZjOTdlZDEtNmEzMC00OGQ1LTk1MTYtNjBjNTNjZTNhMTM1OllEV21GNExKajlYSUt3UW56eTJlMmxiMHRKUWIyOW8z");
|
|
39
|
+
AX_FP_KEY = unseal(() => __E_AX_FP_KEY__, "18b4d589826af50241177961590e6693");
|
|
40
|
+
UA = unseal(() => __E_UA__, "myXL / 8.9.0(1202); com.android.vending; (samsung; SM-N935F; SDK 33; Android 13)");
|
|
41
|
+
API_KEY = unseal(() => __E_API_KEY__, "vT8tINqHaOxXbGE7eOWAhA==");
|
|
42
|
+
ENCRYPTED_FIELD_KEY = unseal(() => __E_ENCRYPTED_FIELD_KEY__, "5dccbf08920a5527");
|
|
43
|
+
XDATA_KEY = unseal(() => __E_XDATA_KEY__, "5dccbf08920a5527b99e222789c34bb7");
|
|
44
|
+
AX_API_SIG_KEY = unseal(() => __E_AX_API_SIG_KEY__, "18b4d589826af50241177961590e6693");
|
|
45
|
+
X_API_BASE_SECRET = unseal(() => __E_X_API_BASE_SECRET__, "mU1Y4n1vBjf3M7tMnRkFU08mVyUJHed8B5En3EAniu1mXLixeuASmBmKnkyzVziOye7rG5nIekMdthensbQMcOJ6SLnrkGyfXALD7mrBC6vuWv6G01pmD3XlU5rT7Tzx");
|
|
46
|
+
CIRCLE_MSISDN_KEY = unseal(() => __E_CIRCLE_MSISDN_KEY__, "5dccbf08920a5527");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/lib/encrypt-helper.ts
|
|
50
|
+
import crypto from "crypto";
|
|
51
|
+
function pkcs7Pad(buf, blockSize = 16) {
|
|
52
|
+
const pad = blockSize - buf.length % blockSize;
|
|
53
|
+
const padBuf = Buffer.alloc(pad, pad);
|
|
54
|
+
return Buffer.concat([buf, padBuf]);
|
|
55
|
+
}
|
|
56
|
+
function pkcs7Unpad(buf) {
|
|
57
|
+
const pad = buf[buf.length - 1] ?? 16;
|
|
58
|
+
if (pad < 1 || pad > 16)
|
|
59
|
+
throw new Error("Invalid PKCS7 padding");
|
|
60
|
+
return buf.slice(0, buf.length - pad);
|
|
61
|
+
}
|
|
62
|
+
function deriveIv(xtimeMs) {
|
|
63
|
+
const sha = crypto.createHash("sha256").update(String(xtimeMs)).digest("hex");
|
|
64
|
+
return Buffer.from(sha.slice(0, 16), "ascii");
|
|
65
|
+
}
|
|
66
|
+
function urlsafeB64Encode(buf) {
|
|
67
|
+
return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_");
|
|
68
|
+
}
|
|
69
|
+
function urlsafeB64Decode(s) {
|
|
70
|
+
const b64 = s.replace(/-/g, "+").replace(/_/g, "/");
|
|
71
|
+
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
72
|
+
return Buffer.from(padded, "base64");
|
|
73
|
+
}
|
|
74
|
+
function encryptXData(plaintext, xtimeMs) {
|
|
75
|
+
const key = Buffer.from(XDATA_KEY, "ascii");
|
|
76
|
+
const iv = deriveIv(xtimeMs);
|
|
77
|
+
const padded = pkcs7Pad(Buffer.from(plaintext, "utf-8"));
|
|
78
|
+
const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
|
|
79
|
+
cipher.setAutoPadding(false);
|
|
80
|
+
const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
|
|
81
|
+
return urlsafeB64Encode(ct);
|
|
82
|
+
}
|
|
83
|
+
function decryptXData2(xdata, xtimeMs) {
|
|
84
|
+
const key = Buffer.from(XDATA_KEY, "ascii");
|
|
85
|
+
const iv = deriveIv(xtimeMs);
|
|
86
|
+
const ct = urlsafeB64Decode(xdata);
|
|
87
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
|
88
|
+
decipher.setAutoPadding(false);
|
|
89
|
+
const pt = Buffer.concat([decipher.update(ct), decipher.final()]);
|
|
90
|
+
return pkcs7Unpad(pt).toString("utf-8");
|
|
91
|
+
}
|
|
92
|
+
function makeXSignature(idToken, method, path, sigTimeSec) {
|
|
93
|
+
const keyStr = `${X_API_BASE_SECRET};${idToken};${method};${path};${sigTimeSec}`;
|
|
94
|
+
const msg = `${idToken};${sigTimeSec};`;
|
|
95
|
+
return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
|
|
96
|
+
}
|
|
97
|
+
function makeXSignaturePayment(accessToken, sigTimeSec, packageCode, tokenPayment, paymentMethod, paymentFor, path) {
|
|
98
|
+
const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
|
|
99
|
+
const msg = `${accessToken};${tokenPayment};${sigTimeSec};${paymentFor};${paymentMethod};${packageCode};`;
|
|
100
|
+
return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
|
|
101
|
+
}
|
|
102
|
+
function makeXSignatureBounty(accessToken, sigTimeSec, packageCode, tokenPayment) {
|
|
103
|
+
const path = "api/v8/personalization/bounties-exchange";
|
|
104
|
+
const keyStr = `${X_API_BASE_SECRET};${accessToken};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
|
|
105
|
+
const msg = `${accessToken};${tokenPayment};${sigTimeSec};${packageCode};`;
|
|
106
|
+
return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
|
|
107
|
+
}
|
|
108
|
+
function makeXSignatureLoyalty(sigTimeSec, packageCode, tokenConfirmation, path) {
|
|
109
|
+
const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;POST;${path};${sigTimeSec}`;
|
|
110
|
+
const msg = `${tokenConfirmation};${sigTimeSec};${packageCode};`;
|
|
111
|
+
return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
|
|
112
|
+
}
|
|
113
|
+
function makeXSignatureBountyAllotment(sigTimeSec, packageCode, tokenConfirmation, path, destinationMsisdn) {
|
|
114
|
+
const keyStr = `${X_API_BASE_SECRET};${sigTimeSec}#ae-hei_9Tee6he+Ik3Gais5=;${destinationMsisdn};POST;${path};${sigTimeSec}`;
|
|
115
|
+
const msg = `${tokenConfirmation};${sigTimeSec};${destinationMsisdn};${packageCode};`;
|
|
116
|
+
return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
|
|
117
|
+
}
|
|
118
|
+
function makeXSignatureBasic(method, path, sigTimeSec) {
|
|
119
|
+
const keyStr = `${X_API_BASE_SECRET};${method};${path};${sigTimeSec}`;
|
|
120
|
+
const msg = `${sigTimeSec};en;`;
|
|
121
|
+
return crypto.createHmac("sha512", keyStr).update(msg).digest("hex");
|
|
122
|
+
}
|
|
123
|
+
function makeAxApiSignature(tsForSign, contact, code, contactType) {
|
|
124
|
+
const preimage = `${tsForSign}password${contactType}${contact}${code}openid`;
|
|
125
|
+
const digest = crypto.createHmac("sha256", Buffer.from(AX_API_SIG_KEY, "ascii")).update(preimage).digest();
|
|
126
|
+
return digest.toString("base64");
|
|
127
|
+
}
|
|
128
|
+
function decryptEncryptedField(encryptedB64) {
|
|
129
|
+
const ivAscii = encryptedB64.slice(-16);
|
|
130
|
+
const b64Part = encryptedB64.slice(0, -16);
|
|
131
|
+
const key = Buffer.from(ENCRYPTED_FIELD_KEY, "ascii");
|
|
132
|
+
const iv = Buffer.from(ivAscii, "ascii");
|
|
133
|
+
const ct = urlsafeB64Decode(b64Part);
|
|
134
|
+
const decipher = crypto.createDecipheriv("aes-128-cbc", key, iv);
|
|
135
|
+
decipher.setAutoPadding(false);
|
|
136
|
+
const pt = Buffer.concat([decipher.update(ct), decipher.final()]);
|
|
137
|
+
return pkcs7Unpad(pt).toString("utf-8");
|
|
138
|
+
}
|
|
139
|
+
function encryptEncryptedField(plaintext) {
|
|
140
|
+
const key = Buffer.from(ENCRYPTED_FIELD_KEY, "ascii");
|
|
141
|
+
const ivHex = crypto.randomBytes(8).toString("hex");
|
|
142
|
+
const iv = Buffer.from(ivHex, "ascii");
|
|
143
|
+
const padded = pkcs7Pad(Buffer.from(plaintext, "utf-8"));
|
|
144
|
+
const cipher = crypto.createCipheriv("aes-128-cbc", key, iv);
|
|
145
|
+
cipher.setAutoPadding(false);
|
|
146
|
+
const ct = Buffer.concat([cipher.update(padded), cipher.final()]);
|
|
147
|
+
return urlsafeB64Encode(ct) + ivHex;
|
|
148
|
+
}
|
|
149
|
+
var init_encrypt_helper = __esm(() => {
|
|
150
|
+
init_config();
|
|
151
|
+
});
|
|
152
|
+
init_encrypt_helper();
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
makeXSignaturePayment,
|
|
156
|
+
makeXSignatureLoyalty,
|
|
157
|
+
makeXSignatureBountyAllotment,
|
|
158
|
+
makeXSignatureBounty,
|
|
159
|
+
makeXSignatureBasic,
|
|
160
|
+
makeXSignature,
|
|
161
|
+
makeAxApiSignature,
|
|
162
|
+
encryptXData,
|
|
163
|
+
encryptEncryptedField,
|
|
164
|
+
decryptXData2 as decryptXData,
|
|
165
|
+
decryptEncryptedField
|
|
166
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export type Item = {
|
|
2
|
+
item_code: string;
|
|
3
|
+
product_type: string;
|
|
4
|
+
item_price: number;
|
|
5
|
+
item_name: string;
|
|
6
|
+
tax: number;
|
|
7
|
+
token_confirmation: string;
|
|
8
|
+
};
|
|
9
|
+
type GetTransactionDetailProps = {
|
|
10
|
+
idToken: string;
|
|
11
|
+
transactionId: string;
|
|
12
|
+
};
|
|
13
|
+
type AdditionalData = {
|
|
14
|
+
akrab_m2m_group_id: string;
|
|
15
|
+
balance_type: string;
|
|
16
|
+
benefit_type: string;
|
|
17
|
+
cashtag: string;
|
|
18
|
+
combo_details: any[];
|
|
19
|
+
discount_promo: number;
|
|
20
|
+
discount_recurring: number;
|
|
21
|
+
has_bonus: boolean;
|
|
22
|
+
is_akrab_m2m: boolean;
|
|
23
|
+
is_family_plan: boolean;
|
|
24
|
+
is_referral_finalized: boolean;
|
|
25
|
+
is_spend_limit: boolean;
|
|
26
|
+
is_spend_limit_temporary: boolean;
|
|
27
|
+
is_switch_plan: boolean;
|
|
28
|
+
migration_type: string;
|
|
29
|
+
mission_id: string;
|
|
30
|
+
original_price: number;
|
|
31
|
+
quota_bonus: number;
|
|
32
|
+
spend_limit_amount: number;
|
|
33
|
+
tax: number;
|
|
34
|
+
ticket_number: string;
|
|
35
|
+
};
|
|
36
|
+
export type TransactionDetail = {
|
|
37
|
+
additional_data: AdditionalData;
|
|
38
|
+
can_refund: boolean;
|
|
39
|
+
can_trigger_rating: boolean;
|
|
40
|
+
deeplink_url: string;
|
|
41
|
+
details: {
|
|
42
|
+
amount: number;
|
|
43
|
+
name: string;
|
|
44
|
+
tax: number;
|
|
45
|
+
};
|
|
46
|
+
expired_at: number;
|
|
47
|
+
failure_reason: string;
|
|
48
|
+
formated_date: string;
|
|
49
|
+
have_offer: boolean;
|
|
50
|
+
is_myxl_wallet: boolean;
|
|
51
|
+
payment_for: string;
|
|
52
|
+
payment_id: string;
|
|
53
|
+
payment_with: string;
|
|
54
|
+
price: string;
|
|
55
|
+
qr_code: string;
|
|
56
|
+
remaining_time: number;
|
|
57
|
+
status: string;
|
|
58
|
+
timestamp: number;
|
|
59
|
+
title: string;
|
|
60
|
+
total_discount: number;
|
|
61
|
+
total_tax: number;
|
|
62
|
+
virtual_account_number: string;
|
|
63
|
+
};
|
|
64
|
+
export type SettlementProps = {
|
|
65
|
+
idToken: string;
|
|
66
|
+
accessToken: string;
|
|
67
|
+
item: Item;
|
|
68
|
+
items: Item[];
|
|
69
|
+
paymentFor: string;
|
|
70
|
+
tokenConfirmation: string;
|
|
71
|
+
topup_number?: string;
|
|
72
|
+
stage_token?: string;
|
|
73
|
+
overwriteAmount: number | null;
|
|
74
|
+
paymentTargetsMethodsOption?: string;
|
|
75
|
+
walletNumber?: string;
|
|
76
|
+
};
|
|
77
|
+
export type SettlementDetail = {
|
|
78
|
+
amount: number;
|
|
79
|
+
campaign_id: string;
|
|
80
|
+
code: string;
|
|
81
|
+
name: string;
|
|
82
|
+
status: string;
|
|
83
|
+
tax: number;
|
|
84
|
+
};
|
|
85
|
+
export type Settlement = {
|
|
86
|
+
can_trigger_rating: boolean;
|
|
87
|
+
deeplink: string;
|
|
88
|
+
details: SettlementDetail[];
|
|
89
|
+
have_offer: boolean;
|
|
90
|
+
is_myxl_wallet: boolean;
|
|
91
|
+
migration_type: string;
|
|
92
|
+
payment_method: string;
|
|
93
|
+
points_gained: number;
|
|
94
|
+
ticket_number: string;
|
|
95
|
+
total_amount: number;
|
|
96
|
+
total_discount: number;
|
|
97
|
+
total_fee: number;
|
|
98
|
+
total_tax: number;
|
|
99
|
+
transaction_code: string;
|
|
100
|
+
};
|
|
101
|
+
export type SettlementSucceess = {
|
|
102
|
+
code: string;
|
|
103
|
+
status: "SUCCESS";
|
|
104
|
+
data: Settlement;
|
|
105
|
+
};
|
|
106
|
+
export type SettlementError = {
|
|
107
|
+
code: string;
|
|
108
|
+
status: "FAILED";
|
|
109
|
+
code_detail: string;
|
|
110
|
+
description: string;
|
|
111
|
+
message: string;
|
|
112
|
+
title: string;
|
|
113
|
+
};
|
|
114
|
+
export type SettlementResponse = SettlementSucceess | SettlementError;
|
|
115
|
+
export declare function getTransactionDetail({ idToken, transactionId }: GetTransactionDetailProps): Promise<TransactionDetail>;
|
|
116
|
+
export {};
|