bpjs-bridge 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 +43 -0
- package/dist/__test__/config.d.ts +3 -0
- package/dist/__test__/config.js +12 -0
- package/dist/__test__/pcare.service.test.d.ts +1 -0
- package/dist/__test__/pcare.service.test.js +138 -0
- package/dist/config/BPJSConfig.d.ts +30 -0
- package/dist/config/BPJSConfig.js +2 -0
- package/dist/config/enpoints.d.ts +286 -0
- package/dist/config/enpoints.js +343 -0
- package/dist/core/configHelper.d.ts +15 -0
- package/dist/core/configHelper.js +13 -0
- package/dist/core/decrypt.d.ts +3 -0
- package/dist/core/decrypt.js +64 -0
- package/dist/core/httpClient.d.ts +5 -0
- package/dist/core/httpClient.js +52 -0
- package/dist/core/security.d.ts +9 -0
- package/dist/core/security.js +34 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +22 -0
- package/dist/lib/redis.d.ts +2 -0
- package/dist/lib/redis.js +12 -0
- package/dist/services/fktp.service.d.ts +45 -0
- package/dist/services/fktp.service.js +167 -0
- package/dist/services/pcare/pcare.service.d.ts +73 -0
- package/dist/services/pcare/pcare.service.js +143 -0
- package/dist/types/global.d.ts +17 -0
- package/dist/types/global.js +2 -0
- package/dist/types/globalModle.d.ts +6 -0
- package/dist/types/globalModle.js +12 -0
- package/dist/types/pcare.d.ts +37 -0
- package/dist/types/pcare.js +2 -0
- package/package.json +44 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseUrl = exports.enpoints = void 0;
|
|
4
|
+
exports.enpoints = [
|
|
5
|
+
{
|
|
6
|
+
name: "diagnosa",
|
|
7
|
+
endpoint: "diagnosa/{kodediag}/{start}/{limit}",
|
|
8
|
+
method: "GET",
|
|
9
|
+
description: "Get Data Diagnosa dari BPJS PCare",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "alergi_jenis",
|
|
13
|
+
endpoint: "alergi/jenis/{jenisAlergi}",
|
|
14
|
+
method: "GET",
|
|
15
|
+
description: "Get Data Alergi berdasarkan jenis",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "dokter",
|
|
19
|
+
endpoint: "dokter/{start}/{limit}",
|
|
20
|
+
method: "GET",
|
|
21
|
+
description: "Get Data Dokter dari BPJS PCare",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "kesadaran",
|
|
25
|
+
endpoint: "kesadaran",
|
|
26
|
+
method: "GET",
|
|
27
|
+
description: "Get Data Kesadaran dari BPJS PCare",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "rujukan_kunjungan",
|
|
31
|
+
endpoint: "kunjungan/rujukan/{nomorKunjungan}",
|
|
32
|
+
method: "GET",
|
|
33
|
+
description: "Get Data Rujukan berdasarkan Nomor Kunjungan",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "riwayat_kunjungan",
|
|
37
|
+
endpoint: "kunjungan/peserta/{nomorKartu}",
|
|
38
|
+
method: "GET",
|
|
39
|
+
description: "Get Data Riwayat Kunjungan berdasarkan Nomor Kartu Peserta",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "tambah_kunjungan",
|
|
43
|
+
endpoint: "kunjungan/v1",
|
|
44
|
+
method: "POST",
|
|
45
|
+
description: "Add Data Kunjungan ke BPJS PCare",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "edit_kunjungan",
|
|
49
|
+
endpoint: "kunjungan/v1",
|
|
50
|
+
method: "PUT",
|
|
51
|
+
description: "Edit Data Kunjungan di BPJS PCare",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "hapus_kunjungan",
|
|
55
|
+
endpoint: "kunjungan/{nomorKunjungan}",
|
|
56
|
+
method: "DELETE",
|
|
57
|
+
description: "Delete Data Kunjungan berdasarkan Nomor Kunjungan",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "dpho",
|
|
61
|
+
endpoint: "obat/dpho/{kodeNamaDPHO}/{start}/{limit}",
|
|
62
|
+
method: "GET",
|
|
63
|
+
description: "Get Data DPHO dari BPJS PCare berdasarkan kode atau nama",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "obat_kunjungan",
|
|
67
|
+
endpoint: "obat/kunjungan/{nomorKunjungan}",
|
|
68
|
+
method: "GET",
|
|
69
|
+
description: "Get Data Obat berdasarkan Nomor Kunjungan",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "tambah_obat",
|
|
73
|
+
endpoint: "obat/kunjungan",
|
|
74
|
+
method: "POST",
|
|
75
|
+
description: "Add Data Obat ke BPJS PCare",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "hapus_obat",
|
|
79
|
+
endpoint: "obat/{kdObatSK}/kunjungan/{nomorKunjungan}",
|
|
80
|
+
method: "DELETE",
|
|
81
|
+
description: "Delete Data Obat berdasarkan kdObatSK dan Nomor Kunjungan",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "provider_rayonisasi",
|
|
85
|
+
endpoint: "provider/{start}/{limit}",
|
|
86
|
+
method: "GET",
|
|
87
|
+
description: "Get Data Provider Rayonisasi dari BPJS PCare",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "icare_validate",
|
|
91
|
+
endpoint: "api/pcare/validate",
|
|
92
|
+
method: "POST",
|
|
93
|
+
description: "API Data Riwayat Pelayanan iCare",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "icare_rs_validate",
|
|
97
|
+
endpoint: "api/rs/validate",
|
|
98
|
+
method: "POST",
|
|
99
|
+
description: "API Data Riwayat Pelayanan iCare RS",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "pendaftaran_by_noUrut",
|
|
103
|
+
endpoint: "pendaftaran/noUrut/{noUrut}/tglDaftar/{tglDaftar}",
|
|
104
|
+
method: "GET",
|
|
105
|
+
description: "Get Data Pendaftaran berdasarkan Nomor Urut dan Tanggal Daftar",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "pendaftaran_provider",
|
|
109
|
+
endpoint: "pendaftaran/tglDaftar/{tglDaftar}/{start}/{limit}",
|
|
110
|
+
method: "GET",
|
|
111
|
+
description: "Get Data Pendaftaran berdasarkan tanggal, start, dan limit",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "tambah_pendaftaran",
|
|
115
|
+
endpoint: "pendaftaran",
|
|
116
|
+
method: "POST",
|
|
117
|
+
description: "Add Data Pendaftaran Baru",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "hapus_pendaftaran",
|
|
121
|
+
endpoint: "pendaftaran/peserta/{noKartu}/tglDaftar/{tglDaftar}/noUrut/{noUrut}/kdPoli/{kdPoli}",
|
|
122
|
+
method: "DELETE",
|
|
123
|
+
description: "Delete Data Pendaftaran berdasarkan Nomor Kartu, Tanggal, Urutan, dan Kode Poli",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "peserta_noka",
|
|
127
|
+
endpoint: "peserta/{noKartu}",
|
|
128
|
+
method: "GET",
|
|
129
|
+
description: "Get Data Peserta berdasarkan Nomor Kartu Peserta",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "peserta_nik_noka",
|
|
133
|
+
endpoint: "peserta/{jenisKartu}/{noIdentitas}",
|
|
134
|
+
method: "GET",
|
|
135
|
+
description: "Get Data Peserta berdasarkan Jenis Kartu (NIK/NOKA) dan Nomor Identitas",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "poli_fktp",
|
|
139
|
+
endpoint: "poli/fktp/{start}/{limit}",
|
|
140
|
+
method: "GET",
|
|
141
|
+
description: "Get Data Poli FKTP dari BPJS PCare",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "prognosa",
|
|
145
|
+
endpoint: "prognosa",
|
|
146
|
+
method: "GET",
|
|
147
|
+
description: "Get Data Prognosa dari BPJS PCare",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "status_pulang",
|
|
151
|
+
endpoint: "statuspulang/rawatInap/{rawatInap}",
|
|
152
|
+
method: "GET",
|
|
153
|
+
description: "Get Status Pulang berdasarkan Rawat Inap (true/false)",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "tindakan_kunjungan",
|
|
157
|
+
endpoint: "tindakan/kunjungan/{nomorKunjungan}",
|
|
158
|
+
method: "GET",
|
|
159
|
+
description: "Get Data Tindakan berdasarkan Nomor Kunjungan",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "referensi_tindakan",
|
|
163
|
+
endpoint: "tindakan/kdTkp/{kdTkp}/{start}/{limit}",
|
|
164
|
+
method: "GET",
|
|
165
|
+
description: "Get Data Referensi Tindakan berdasarkan kdTkp",
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "tambah_tindakan",
|
|
169
|
+
endpoint: "tindakan",
|
|
170
|
+
method: "POST",
|
|
171
|
+
description: "Add Data Tindakan",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "edit_tindakan",
|
|
175
|
+
endpoint: "tindakan",
|
|
176
|
+
method: "PUT",
|
|
177
|
+
description: "Edit Data Tindakan",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "hapus_tindakan",
|
|
181
|
+
endpoint: "tindakan/{kdTindakanSK}/kunjungan/{nomorKunjungan}",
|
|
182
|
+
method: "DELETE",
|
|
183
|
+
description: "Delete Data Tindakan berdasarkan kdTindakanSK dan Nomor Kunjungan",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "referensi_spesialis",
|
|
187
|
+
endpoint: "spesialis",
|
|
188
|
+
method: "GET",
|
|
189
|
+
description: "Get Data Referensi Spesialis",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "referensi_subspesialis",
|
|
193
|
+
endpoint: "spesialis/{kdSpesialis}/subspesialis",
|
|
194
|
+
method: "GET",
|
|
195
|
+
description: "Get Data Referensi Sub Spesialis berdasarkan Kode Spesialis",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "referensi_sarana",
|
|
199
|
+
endpoint: "spesialis/sarana",
|
|
200
|
+
method: "GET",
|
|
201
|
+
description: "Get Data Referensi Sarana",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "referensi_khusus",
|
|
205
|
+
endpoint: "spesialis/khusus",
|
|
206
|
+
method: "GET",
|
|
207
|
+
description: "Get Data Referensi Khusus",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "rujuk_subspesialis",
|
|
211
|
+
endpoint: "spesialis/rujuk/subspesialis/{kdSubSpesialis}/sarana/{kdSarana}/tglEstRujuk/{tglEstRujuk}",
|
|
212
|
+
method: "GET",
|
|
213
|
+
description: "Get Data Faskes Rujukan Sub Spesialis",
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "rujuk_khusus",
|
|
217
|
+
endpoint: "spesialis/rujuk/khusus/{kdKhusus}/noKartu/{noKartu}/tglEstRujuk/{tglEstRujuk}",
|
|
218
|
+
method: "GET",
|
|
219
|
+
description: "Get Data Faskes Rujukan Khusus",
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "rujuk_khusus_subspesialis",
|
|
223
|
+
endpoint: "spesialis/rujuk/khusus/{kdKhusus}/subspesialis/{kdSubSpesialis}/noKartu/{noKartu}/tglEstRujuk/{tglEstRujuk}",
|
|
224
|
+
method: "GET",
|
|
225
|
+
description: "Get Data Faskes Rujukan Khusus untuk THALASEMIA dan HEMOFILI",
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "status_pulang",
|
|
229
|
+
endpoint: "statuspulang/rawatInap/{rawatInap}",
|
|
230
|
+
method: "GET",
|
|
231
|
+
description: "Get Data Status Pulang berdasarkan Rawat Inap (true/false)",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "mcu_kunjungan",
|
|
235
|
+
endpoint: "MCU/kunjungan/{nomorKunjungan}",
|
|
236
|
+
method: "GET",
|
|
237
|
+
description: "Get Data MCU berdasarkan Nomor Kunjungan",
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "tambah_mcu",
|
|
241
|
+
endpoint: "MCU",
|
|
242
|
+
method: "POST",
|
|
243
|
+
description: "Add Data MCU ke BPJS PCare",
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "edit_mcu",
|
|
247
|
+
endpoint: "MCU",
|
|
248
|
+
method: "PUT",
|
|
249
|
+
description: "Edit Data MCU di BPJS PCare",
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "hapus_mcu",
|
|
253
|
+
endpoint: "MCU/{kdMCU}/kunjungan/{nomorKunjungan}",
|
|
254
|
+
method: "DELETE",
|
|
255
|
+
description: "Delete Data MCU berdasarkan kdMCU dan Nomor Kunjungan",
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "get_club_prolanis",
|
|
259
|
+
endpoint: "kelompok/club/{kodeJenisKelompok}",
|
|
260
|
+
method: "GET",
|
|
261
|
+
description: "Get Data Club Prolanis berdasarkan Kode Jenis Kelompok (01: Diabetes Melitus, 02: Hipertensi)",
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "get_kegiatan_kelompok",
|
|
265
|
+
endpoint: "kelompok/kegiatan/{tanggal}",
|
|
266
|
+
method: "GET",
|
|
267
|
+
description: "Get Data Kegiatan Kelompok berdasarkan tanggal (format: dd-mm-yyyy)",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: "get_peserta_kegiatan_kelompok",
|
|
271
|
+
endpoint: "kelompok/peserta/{eduId}",
|
|
272
|
+
method: "GET",
|
|
273
|
+
description: "Get Data Peserta Kegiatan Kelompok berdasarkan eduId",
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "add_kegiatan_kelompok",
|
|
277
|
+
endpoint: "kelompok/kegiatan",
|
|
278
|
+
method: "POST",
|
|
279
|
+
description: "Add Data Kegiatan Kelompok",
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: "add_peserta_kegiatan_kelompok",
|
|
283
|
+
endpoint: "kelompok/peserta",
|
|
284
|
+
method: "POST",
|
|
285
|
+
description: "Add Data Peserta Kegiatan Kelompok",
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: "delete_kegiatan_kelompok",
|
|
289
|
+
endpoint: "kelompok/kegiatan/{eduId}",
|
|
290
|
+
method: "DELETE",
|
|
291
|
+
description: "Delete Data Kegiatan Kelompok berdasarkan eduId",
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "delete_peserta_kegiatan_kelompok",
|
|
295
|
+
endpoint: "kelompok/peserta/{eduId}/{noKartu}",
|
|
296
|
+
method: "DELETE",
|
|
297
|
+
description: "Delete Data Peserta Kegiatan Kelompok berdasarkan eduId dan Nomor Kartu Peserta",
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: "ref_poli_antrol",
|
|
301
|
+
endpoint: "ref/poli/tanggal/{tanggal}",
|
|
302
|
+
method: "GET",
|
|
303
|
+
description: "Melihat referensi poli pada layanan antrean (WS Antrol)",
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
name: "ref_dokter_antrol",
|
|
307
|
+
endpoint: "ref/dokter/kodepoli/{kodepoli}/tanggal/{tanggal}",
|
|
308
|
+
method: "GET",
|
|
309
|
+
description: "Melihat daftar dokter berdasarkan poli dan tanggal (WS Antrol)",
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: "tambah_antrean",
|
|
313
|
+
endpoint: "antrean/add",
|
|
314
|
+
method: "POST",
|
|
315
|
+
description: "Menambah data antrean pasien (WS Antrol)",
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: "update_status_antrean",
|
|
319
|
+
endpoint: "antrean/panggil",
|
|
320
|
+
method: "POST",
|
|
321
|
+
description: "Update status antrean hadir/tidak hadir (WS Antrol)",
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: "batal_antrean",
|
|
325
|
+
endpoint: "antrean/batal",
|
|
326
|
+
method: "POST",
|
|
327
|
+
description: "Membatalkan antrean pasien (WS Antrol)",
|
|
328
|
+
},
|
|
329
|
+
];
|
|
330
|
+
exports.BaseUrl = {
|
|
331
|
+
prod: {
|
|
332
|
+
url_pcare: "https://apijkn-dev.bpjs-kesehatan.go.id/pcare-rest-dev",
|
|
333
|
+
url_icare: "https://apijkn-dev.bpjs-kesehatan.go.id/ihs_dev",
|
|
334
|
+
url_vclaim: "https://apijkn-dev.bpjs-kesehatan.go.id/vclaim-rest-dev",
|
|
335
|
+
url_antrol: "https://apijkn-dev.bpjs-kesehatan.go.id/antreanfktp_dev",
|
|
336
|
+
},
|
|
337
|
+
dev: {
|
|
338
|
+
url_icare: "https://apijkn.bpjs-kesehatan.go.id/ihs",
|
|
339
|
+
url_pcare: "https://apijkn.bpjs-kesehatan.go.id/pcare-rest",
|
|
340
|
+
url_vclaim: "https://apijkn.bpjs-kesehatan.go.id/vclaim-rest",
|
|
341
|
+
url_antrol: "https://apijkn.bpjs-kesehatan.go.id/antreanfktp",
|
|
342
|
+
},
|
|
343
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type configType = {
|
|
2
|
+
username: string;
|
|
3
|
+
password: string;
|
|
4
|
+
consId: string;
|
|
5
|
+
secretKey: string;
|
|
6
|
+
userKey: string;
|
|
7
|
+
mode: "dev" | "prod";
|
|
8
|
+
};
|
|
9
|
+
export declare function resolveConfig(globalCfg: configType, serviceCfg: configType): {
|
|
10
|
+
consId: string;
|
|
11
|
+
secretKey: string;
|
|
12
|
+
userKey: string;
|
|
13
|
+
username: string;
|
|
14
|
+
password: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveConfig = resolveConfig;
|
|
4
|
+
// src/core/configHelper.ts
|
|
5
|
+
function resolveConfig(globalCfg, serviceCfg) {
|
|
6
|
+
return {
|
|
7
|
+
consId: serviceCfg?.consId ?? globalCfg?.consId,
|
|
8
|
+
secretKey: serviceCfg?.secretKey ?? globalCfg?.secretKey,
|
|
9
|
+
userKey: serviceCfg?.userKey ?? globalCfg?.userKey,
|
|
10
|
+
username: serviceCfg?.username ?? globalCfg?.username,
|
|
11
|
+
password: serviceCfg?.password ?? globalCfg?.password,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.decryptBpjsResponse = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto")); // Pastikan path logger sesuai dengan struktur proyek Anda
|
|
38
|
+
const lz_string_1 = require("lz-string");
|
|
39
|
+
const decryptBpjsResponse = (encryptedData, cons_id, secret_key, timestamp) => {
|
|
40
|
+
try {
|
|
41
|
+
if (!encryptedData ||
|
|
42
|
+
typeof encryptedData !== "string" ||
|
|
43
|
+
encryptedData.trim() === "") {
|
|
44
|
+
throw new Error("⚠️ Response BPJS kosong atau tidak terformat base64");
|
|
45
|
+
}
|
|
46
|
+
// Membuat key dengan SHA-256 hash dari kons_id, secret_key, dan timestamp
|
|
47
|
+
const key = crypto
|
|
48
|
+
.createHash("sha256")
|
|
49
|
+
.update(cons_id + secret_key + timestamp)
|
|
50
|
+
.digest();
|
|
51
|
+
const iv = key.subarray(0, 16);
|
|
52
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
|
53
|
+
let decrypted = decipher.update(Buffer.from(encryptedData, "base64"));
|
|
54
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
55
|
+
const decryptedText = decrypted.toString();
|
|
56
|
+
const decompressedText = (0, lz_string_1.decompressFromEncodedURIComponent)(decryptedText);
|
|
57
|
+
const finalText = decompressedText || decryptedText;
|
|
58
|
+
return JSON.parse(finalText);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new Error(`[DECRYPT ERROR] ${error.message}`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.decryptBpjsResponse = decryptBpjsResponse;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createBpjsClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const decrypt_1 = require("./decrypt");
|
|
9
|
+
const security_1 = require("./security");
|
|
10
|
+
const createBpjsClient = (config) => {
|
|
11
|
+
const client = axios_1.default.create({
|
|
12
|
+
baseURL: config.baseUrl,
|
|
13
|
+
timeout: 20000,
|
|
14
|
+
});
|
|
15
|
+
const headers = (0, security_1.generateHeader)(config);
|
|
16
|
+
client.interceptors.request.use((req) => {
|
|
17
|
+
req.headers["X-cons-id"] = headers["X-cons-id"];
|
|
18
|
+
req.headers["X-timestamp"] = headers["X-timestamp"];
|
|
19
|
+
req.headers["X-signature"] = headers["X-signature"];
|
|
20
|
+
req.headers["X-Authorization"] = headers["X-Authorization"];
|
|
21
|
+
req.headers.user_key = headers["userKey"];
|
|
22
|
+
req.headers.Accept = headers["Accept"];
|
|
23
|
+
req.headers["User-Agent"] = "BPJS-Bridge-Client/1.0";
|
|
24
|
+
req.headers["Accept-Encoding"] = "gzip, compress, deflate, br";
|
|
25
|
+
return req;
|
|
26
|
+
});
|
|
27
|
+
client.interceptors.response.use(async (res) => {
|
|
28
|
+
const { response: encryptedData } = res.data;
|
|
29
|
+
// Ensure encryptedData is a string before trying to decrypt
|
|
30
|
+
if (typeof encryptedData === "string") {
|
|
31
|
+
const timestamp = String(headers["X-timestamp"]);
|
|
32
|
+
const decrypted = (0, decrypt_1.decryptBpjsResponse)(encryptedData, config.consId, config.secretKey, timestamp);
|
|
33
|
+
return { ...res, data: decrypted };
|
|
34
|
+
}
|
|
35
|
+
res.data = `[HTTP CLIENT ERROR => URL : ${res.config.baseURL}/${res.config.url} ] => ${res.data.metaData?.message || "unknown error"}`;
|
|
36
|
+
return res;
|
|
37
|
+
}, (err) => {
|
|
38
|
+
console.error("[HTTP CLIENT ERROR]", err.message + " || " + JSON.stringify(err.response?.data) || "");
|
|
39
|
+
const fallback = {
|
|
40
|
+
data: `[HTTP CLIENT ERROR => URL : ${err.config.baseURL}/${err.config.url} ] => ${err.response?.data?.metaData?.message ??
|
|
41
|
+
err.message ??
|
|
42
|
+
"unknown error"}`,
|
|
43
|
+
status: err.status || 500,
|
|
44
|
+
statusText: err.message || "Internal Server Error",
|
|
45
|
+
headers: {},
|
|
46
|
+
config: err.config || {},
|
|
47
|
+
};
|
|
48
|
+
return fallback;
|
|
49
|
+
});
|
|
50
|
+
return client;
|
|
51
|
+
};
|
|
52
|
+
exports.createBpjsClient = createBpjsClient;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { configType } from "./configHelper";
|
|
2
|
+
export declare const generateHeader: ({ consId, password, secretKey, userKey, username, }: configType) => {
|
|
3
|
+
"X-cons-id": string;
|
|
4
|
+
"X-timestamp": string;
|
|
5
|
+
"X-signature": string;
|
|
6
|
+
"X-Authorization": string;
|
|
7
|
+
userKey: string;
|
|
8
|
+
Accept: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateHeader = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const generateSignature = (consId, secretKey) => {
|
|
9
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
10
|
+
const data = `${consId}&${timestamp}`;
|
|
11
|
+
const signature = crypto_1.default
|
|
12
|
+
.createHmac("sha256", secretKey)
|
|
13
|
+
.update(data)
|
|
14
|
+
.digest("base64");
|
|
15
|
+
return { timestamp, signature };
|
|
16
|
+
};
|
|
17
|
+
const generateAuthorization = (username, password) => {
|
|
18
|
+
const authString = `${username}:${password}:095`;
|
|
19
|
+
const base64Auth = Buffer.from(authString).toString("base64");
|
|
20
|
+
return `Basic ${base64Auth}`;
|
|
21
|
+
};
|
|
22
|
+
const generateHeader = ({ consId, password, secretKey, userKey, username, }) => {
|
|
23
|
+
const { signature, timestamp } = generateSignature(consId, secretKey);
|
|
24
|
+
const authorization = generateAuthorization(username, password);
|
|
25
|
+
return {
|
|
26
|
+
"X-cons-id": consId,
|
|
27
|
+
"X-timestamp": String(timestamp),
|
|
28
|
+
"X-signature": signature,
|
|
29
|
+
"X-Authorization": authorization,
|
|
30
|
+
userKey,
|
|
31
|
+
Accept: "application/json",
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.generateHeader = generateHeader;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./core/httpClient"), exports);
|
|
18
|
+
__exportStar(require("./core/configHelper"), exports);
|
|
19
|
+
__exportStar(require("./services/pcare/pcare.service"), exports);
|
|
20
|
+
__exportStar(require("./lib/redis"), exports);
|
|
21
|
+
__exportStar(require("./types/global"), exports);
|
|
22
|
+
__exportStar(require("./types/pcare"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.redis = void 0;
|
|
7
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
|
+
exports.redis = new ioredis_1.default({
|
|
9
|
+
host: "localhost",
|
|
10
|
+
port: 6379,
|
|
11
|
+
password: "",
|
|
12
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
import Redis from "ioredis";
|
|
3
|
+
import { EndpointName } from "../config/enpoints";
|
|
4
|
+
import { BpjsCLient } from "../core/httpClient";
|
|
5
|
+
export declare class FktpService {
|
|
6
|
+
private client;
|
|
7
|
+
private redisClient;
|
|
8
|
+
private defaultRedisKeyPrefix;
|
|
9
|
+
constructor(config: BpjsCLient, redisClient?: Redis, chachePrefix?: string);
|
|
10
|
+
/**
|
|
11
|
+
* Menyimpan data ke Redis dengan TTL (time-to-live)
|
|
12
|
+
* @param key - Kunci data
|
|
13
|
+
* @param value - Data yang akan disimpan
|
|
14
|
+
* @param expInSecond - Waktu kadaluarsa dalam detik (default: 3600)
|
|
15
|
+
*/
|
|
16
|
+
private set;
|
|
17
|
+
/**
|
|
18
|
+
* Mengambil data dari Redis
|
|
19
|
+
* @param key - Kunci data
|
|
20
|
+
* @returns Data dari Redis atau null jika tidak ditemukan
|
|
21
|
+
*/
|
|
22
|
+
private get;
|
|
23
|
+
/**
|
|
24
|
+
* Menghapus data dari Redis
|
|
25
|
+
* @param key - Kunci data
|
|
26
|
+
*/
|
|
27
|
+
private del;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param pattern - Pola kunci untuk menghapus (misal: 'user_*' untuk menghapus semua kunci yang diawali 'user_')
|
|
31
|
+
* Menghapus beberapa kunci berdasarkan pola (pattern)
|
|
32
|
+
*/
|
|
33
|
+
private deleteKeysByPattern;
|
|
34
|
+
/**
|
|
35
|
+
* Membersihkan seluruh cache Redis
|
|
36
|
+
*/
|
|
37
|
+
private flushAll;
|
|
38
|
+
/**
|
|
39
|
+
* Memanggil endpoint BPJS berdasarkan nama dan parameter yang diberikan
|
|
40
|
+
* @param name
|
|
41
|
+
* @param params
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
protected callEndpoint<T>(name: EndpointName, params?: Record<string, any>): Promise<AxiosResponse<T>>;
|
|
45
|
+
}
|