50p82u21t54k 0.0.43 → 0.0.45

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 (110) hide show
  1. package/dist/50p82u21t54k.cjs.js +1 -1
  2. package/dist/50p82u21t54k.es.js +286 -4483
  3. package/dist/50p82u21t54k.umd.js +1 -1
  4. package/dist/api/announcement/announcementApi.d.ts.map +1 -1
  5. package/dist/api/announcement/type.d.ts +6 -2
  6. package/dist/api/announcement/type.d.ts.map +1 -1
  7. package/dist/api/cashWallet/cashWalletApi.d.ts +3 -0
  8. package/dist/api/cashWallet/cashWalletApi.d.ts.map +1 -0
  9. package/dist/api/cashWallet/index.d.ts +3 -0
  10. package/dist/api/cashWallet/index.d.ts.map +1 -0
  11. package/dist/api/cashWallet/type.d.ts +5 -0
  12. package/dist/api/cashWallet/type.d.ts.map +1 -0
  13. package/dist/api/cmsList/cmsListApi.d.ts.map +1 -1
  14. package/dist/api/cmsList/type.d.ts +5 -4
  15. package/dist/api/cmsList/type.d.ts.map +1 -1
  16. package/dist/api/footerInfo/footerInfoApi.d.ts +3 -0
  17. package/dist/api/footerInfo/footerInfoApi.d.ts.map +1 -0
  18. package/dist/api/footerInfo/index.d.ts +3 -0
  19. package/dist/api/footerInfo/index.d.ts.map +1 -0
  20. package/dist/api/footerInfo/type.d.ts +9 -0
  21. package/dist/api/footerInfo/type.d.ts.map +1 -0
  22. package/dist/api/getLocale/getLocaleApi.d.ts.map +1 -1
  23. package/dist/api/getLocale/type.d.ts +5 -1
  24. package/dist/api/getLocale/type.d.ts.map +1 -1
  25. package/dist/api/getWinnerList/getWinnerListApi.d.ts.map +1 -1
  26. package/dist/api/getWinnerList/type.d.ts +6 -2
  27. package/dist/api/getWinnerList/type.d.ts.map +1 -1
  28. package/dist/api/login/loginApi.d.ts +1 -1
  29. package/dist/api/login/loginApi.d.ts.map +1 -1
  30. package/dist/api/login/type.d.ts +9 -9
  31. package/dist/api/login/type.d.ts.map +1 -1
  32. package/dist/api/message/messageApi.d.ts +2 -1
  33. package/dist/api/message/messageApi.d.ts.map +1 -1
  34. package/dist/api/message/type.d.ts +22 -6
  35. package/dist/api/message/type.d.ts.map +1 -1
  36. package/dist/api/mobileBanner/index.d.ts +3 -0
  37. package/dist/api/mobileBanner/index.d.ts.map +1 -0
  38. package/dist/api/mobileBanner/mobileBannerApi.d.ts +3 -0
  39. package/dist/api/mobileBanner/mobileBannerApi.d.ts.map +1 -0
  40. package/dist/api/mobileBanner/type.d.ts +9 -0
  41. package/dist/api/mobileBanner/type.d.ts.map +1 -0
  42. package/dist/api/profile/index.d.ts +3 -0
  43. package/dist/api/profile/index.d.ts.map +1 -0
  44. package/dist/api/profile/profileApi.d.ts +3 -0
  45. package/dist/api/profile/profileApi.d.ts.map +1 -0
  46. package/dist/api/profile/type.d.ts +23 -0
  47. package/dist/api/profile/type.d.ts.map +1 -0
  48. package/dist/index.d.ts +6 -10
  49. package/dist/index.d.ts.map +1 -1
  50. package/package.json +1 -1
  51. package/dist/api/csLink/csLinkApi.d.ts +0 -3
  52. package/dist/api/csLink/csLinkApi.d.ts.map +0 -1
  53. package/dist/api/csLink/index.d.ts +0 -3
  54. package/dist/api/csLink/index.d.ts.map +0 -1
  55. package/dist/api/csLink/type.d.ts +0 -8
  56. package/dist/api/csLink/type.d.ts.map +0 -1
  57. package/dist/api/currentLang/currentLangApi.d.ts +0 -3
  58. package/dist/api/currentLang/currentLangApi.d.ts.map +0 -1
  59. package/dist/api/currentLang/index.d.ts +0 -3
  60. package/dist/api/currentLang/index.d.ts.map +0 -1
  61. package/dist/api/currentLang/type.d.ts +0 -7
  62. package/dist/api/currentLang/type.d.ts.map +0 -1
  63. package/dist/api/eGame/eGameApi.d.ts +0 -3
  64. package/dist/api/eGame/eGameApi.d.ts.map +0 -1
  65. package/dist/api/eGame/index.d.ts +0 -3
  66. package/dist/api/eGame/index.d.ts.map +0 -1
  67. package/dist/api/eGame/type.d.ts +0 -20
  68. package/dist/api/eGame/type.d.ts.map +0 -1
  69. package/dist/api/fishGames/fishGamesApi.d.ts +0 -3
  70. package/dist/api/fishGames/fishGamesApi.d.ts.map +0 -1
  71. package/dist/api/fishGames/index.d.ts +0 -3
  72. package/dist/api/fishGames/index.d.ts.map +0 -1
  73. package/dist/api/fishGames/type.d.ts +0 -27
  74. package/dist/api/fishGames/type.d.ts.map +0 -1
  75. package/dist/api/getLoginKey/getLoginKeyApi.d.ts +0 -3
  76. package/dist/api/getLoginKey/getLoginKeyApi.d.ts.map +0 -1
  77. package/dist/api/getLoginKey/index.d.ts +0 -3
  78. package/dist/api/getLoginKey/index.d.ts.map +0 -1
  79. package/dist/api/getLoginKey/type.d.ts +0 -8
  80. package/dist/api/getLoginKey/type.d.ts.map +0 -1
  81. package/dist/api/getSetting/getSettingApi.d.ts +0 -3
  82. package/dist/api/getSetting/getSettingApi.d.ts.map +0 -1
  83. package/dist/api/getSetting/index.d.ts +0 -3
  84. package/dist/api/getSetting/index.d.ts.map +0 -1
  85. package/dist/api/getSetting/type.d.ts +0 -12
  86. package/dist/api/getSetting/type.d.ts.map +0 -1
  87. package/dist/api/home/homeApi.d.ts +0 -3
  88. package/dist/api/home/homeApi.d.ts.map +0 -1
  89. package/dist/api/home/index.d.ts +0 -3
  90. package/dist/api/home/index.d.ts.map +0 -1
  91. package/dist/api/home/type.d.ts +0 -98
  92. package/dist/api/home/type.d.ts.map +0 -1
  93. package/dist/api/hotGames/hotGamesApi.d.ts +0 -3
  94. package/dist/api/hotGames/hotGamesApi.d.ts.map +0 -1
  95. package/dist/api/hotGames/index.d.ts +0 -3
  96. package/dist/api/hotGames/index.d.ts.map +0 -1
  97. package/dist/api/hotGames/type.d.ts +0 -36
  98. package/dist/api/hotGames/type.d.ts.map +0 -1
  99. package/dist/api/promotion/index.d.ts +0 -3
  100. package/dist/api/promotion/index.d.ts.map +0 -1
  101. package/dist/api/promotion/promotionApi.d.ts +0 -3
  102. package/dist/api/promotion/promotionApi.d.ts.map +0 -1
  103. package/dist/api/promotion/type.d.ts +0 -48
  104. package/dist/api/promotion/type.d.ts.map +0 -1
  105. package/dist/api/trialGames/index.d.ts +0 -3
  106. package/dist/api/trialGames/index.d.ts.map +0 -1
  107. package/dist/api/trialGames/trialGamesApi.d.ts +0 -3
  108. package/dist/api/trialGames/trialGamesApi.d.ts.map +0 -1
  109. package/dist/api/trialGames/type.d.ts +0 -24
  110. package/dist/api/trialGames/type.d.ts.map +0 -1
@@ -998,8 +998,8 @@ function warn$1(msg, ...args) {
998
998
  [
999
999
  // eslint-disable-next-line no-restricted-syntax
1000
1000
  msg + args.map((a) => {
1001
- var _a2, _b;
1002
- return (_b = (_a2 = a.toString) == null ? void 0 : _a2.call(a)) != null ? _b : JSON.stringify(a);
1001
+ var _a, _b;
1002
+ return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
1003
1003
  }).join(""),
1004
1004
  instance && instance.proxy,
1005
1005
  trace.map(
@@ -1427,7 +1427,7 @@ function tryWrap(fn) {
1427
1427
  let devtools$1;
1428
1428
  let buffer = [];
1429
1429
  function setDevtoolsHook$1(hook, target) {
1430
- var _a2, _b;
1430
+ var _a, _b;
1431
1431
  devtools$1 = hook;
1432
1432
  if (devtools$1) {
1433
1433
  devtools$1.enabled = true;
@@ -1440,7 +1440,7 @@ function setDevtoolsHook$1(hook, target) {
1440
1440
  typeof window !== "undefined" && // some envs mock window but not fully
1441
1441
  window.HTMLElement && // also exclude jsdom
1442
1442
  // eslint-disable-next-line no-restricted-syntax
1443
- !((_b = (_a2 = window.navigator) == null ? void 0 : _a2.userAgent) == null ? void 0 : _b.includes("jsdom"))
1443
+ !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
1444
1444
  ) {
1445
1445
  const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
1446
1446
  replay.push((newHook) => {
@@ -2148,4710 +2148,513 @@ const api = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty(
2148
2148
  get,
2149
2149
  post
2150
2150
  }, Symbol.toStringTag, { value: "Module" }));
2151
- const DefaultHomeData = {
2151
+ const DefaultGetLocaleData = {
2152
2152
  data: {
2153
- game: {},
2154
- mobileBanner: [],
2155
- announcement: [],
2156
- alertAnnouncement: []
2153
+ status: true,
2154
+ message: "",
2155
+ localeList: []
2157
2156
  }
2158
2157
  };
2159
- const homeApi = () => __async(null, null, function* () {
2158
+ const getLocaleApi = () => __async(null, null, function* () {
2159
+ var _a, _b, _c;
2160
2160
  let result = __spreadValues({
2161
2161
  status: 200,
2162
2162
  message: ""
2163
- }, DefaultHomeData);
2163
+ }, DefaultGetLocaleData);
2164
2164
  try {
2165
- const request = yield get(`/apis/home`, {
2165
+ const response = yield get(`/apis/getLocale`, {
2166
2166
  render: getRender(),
2167
2167
  json: 1
2168
2168
  });
2169
- const output = request.data;
2170
- result.data = {
2171
- game: Object.fromEntries(
2172
- Object.entries(output.game).map(([key, value]) => [
2173
- key,
2174
- value.map((item) => processPlatformGame(item))
2175
- ])
2176
- ),
2177
- mobileBanner: output.mobileBanner.map((item) => {
2178
- var _a2, _b, _c, _d, _e, _f, _g;
2179
- return {
2180
- name: (_a2 = item.name) != null ? _a2 : "",
2181
- content: (_b = item.content) != null ? _b : "",
2182
- link: (_c = item.link) != null ? _c : "",
2183
- linkTarget: (_d = item.link_target) != null ? _d : "",
2184
- updatedOn: (_e = item.updated_on) != null ? _e : "",
2185
- idCmsCategory: (_f = item.id_cms_category) != null ? _f : 0,
2186
- contentOrg: (_g = item.content_org) != null ? _g : ""
2187
- };
2188
- }),
2189
- announcement: output.announcement.map((item) => {
2190
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
2191
- return {
2192
- announcementIndex: (_a2 = item.announcement_index) != null ? _a2 : 0,
2193
- announcementEnglish: (_b = item.announcement_english) != null ? _b : "",
2194
- announcementSimplified: (_c = item.announcement_simplified) != null ? _c : "",
2195
- announcementTraditional: (_d = item.announcement_traditional) != null ? _d : "",
2196
- announcementMalay: (_e = item.announcement_malay) != null ? _e : "",
2197
- announcementStatus: item.announcement_status === "1",
2198
- announcementShow: item.announcement_show === "1",
2199
- announcementAlert: item.announcement_alert === "1",
2200
- announcementUser: item.announcement_user === "1",
2201
- announcementSequence: (_f = item.announcement_sequence) != null ? _f : 0,
2202
- announcementCompany: item.announcement_company === "1",
2203
- companyIndex: (_g = item.companyindex) != null ? _g : 0,
2204
- announcementLastUpdated: (_h = item.announcement_lastupdated) != null ? _h : "",
2205
- announcementDateCreated: (_i = item.announcement_datecreated) != null ? _i : "",
2206
- announcementSmaid: (_j = item.announcement_smaid) != null ? _j : "",
2207
- annTimer: (_k = item.ann_timer) != null ? _k : "",
2208
- annStart: (_l = item.ann_start) != null ? _l : "",
2209
- annEnd: (_m = item.ann_end) != null ? _m : "",
2210
- grp: (_n = item.grp) != null ? _n : "",
2211
- time: (_o = item.time) != null ? _o : ""
2212
- };
2213
- }),
2214
- alertAnnouncement: output.alert_announcement.map((item) => {
2215
- var _a2, _b;
2216
- return {
2217
- announcementDateCreated: (_a2 = item.announcement_datecreated) != null ? _a2 : "",
2218
- announcementSimplified: (_b = item.announcement_simplified) != null ? _b : ""
2219
- };
2220
- })
2169
+ const output = response.data;
2170
+ result = {
2171
+ status: output.code,
2172
+ message: (_a = output.message) != null ? _a : "",
2173
+ data: {
2174
+ status: output.status,
2175
+ message: (_b = output.message) != null ? _b : "",
2176
+ localeList: (_c = output.results.map((item) => {
2177
+ return {
2178
+ code: item.code,
2179
+ label: item.label
2180
+ };
2181
+ })) != null ? _c : []
2182
+ }
2221
2183
  };
2222
2184
  } catch (error) {
2223
2185
  const extendedError = error;
2224
2186
  result = __spreadValues({
2225
2187
  status: extendedError.status || 500,
2226
2188
  message: error.message
2227
- }, DefaultHomeData);
2189
+ }, DefaultGetLocaleData);
2228
2190
  }
2229
2191
  return result;
2230
2192
  });
2231
- const processPlatformGame = (item) => {
2232
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
2233
- return {
2234
- id: (_a2 = item.id) != null ? _a2 : 0,
2235
- idPlatformMaster: (_b = item.id_PlatformMaster) != null ? _b : 0,
2236
- idProductMaster: (_c = item.id_ProductMaster) != null ? _c : 0,
2237
- name: (_d = item.name) != null ? _d : "",
2238
- shortName: (_e = item.shortName) != null ? _e : "",
2239
- img: (_f = item.img) != null ? _f : "",
2240
- mobileUrl: (_g = item.mobileUrl) != null ? _g : "",
2241
- url: (_h = item.url) != null ? _h : "",
2242
- desc: (_i = item.desc) != null ? _i : "",
2243
- seq: (_j = item.seq) != null ? _j : 0,
2244
- flag: (_k = item.flag) != null ? _k : 0,
2245
- status: (_l = item.status) != null ? _l : "",
2246
- createdBy: (_m = item.created_by) != null ? _m : 0,
2247
- createdOn: (_n = item.created_on) != null ? _n : "",
2248
- categoryID: (_o = item.categoryid) != null ? _o : 0,
2249
- com: (_p = item.com) != null ? _p : "",
2250
- cur: (_q = item.cur) != null ? _q : "",
2251
- pt: (_r = item.pt) != null ? _r : "",
2252
- ppName: (_s = item.pp_name) != null ? _s : "",
2253
- ppImage: (_t = item.pp_image) != null ? _t : "",
2254
- platformCode: (_u = item.platform_code) != null ? _u : "",
2255
- platformName: (_v = item.platform_name) != null ? _v : "",
2256
- classIcon: (_w = item.class_icon) != null ? _w : "",
2257
- productCode: (_x = item.product_code) != null ? _x : "",
2258
- productName: (_y = item.product_name) != null ? _y : "",
2259
- gameID: (_z = item.game_id) != null ? _z : 0,
2260
- fAuth: (_A = item.fAuth) != null ? _A : false,
2261
- platformStatusParams: {
2262
- eb: (_B = item.platform_status_params.eb) != null ? _B : false,
2263
- fit: (_C = item.platform_status_params.fit) != null ? _C : false,
2264
- fs: (_D = item.platform_status_params.fs) != null ? _D : false
2265
- },
2266
- loginFlag: item.login_flag === "1",
2267
- link: (_E = item.link) != null ? _E : "",
2268
- favouriteFlag: item.favourite_flag === 1,
2269
- platformStatusFlag: (_F = item.platform_status_flag) != null ? _F : "",
2270
- platformFlagName: (_G = item.platform_flag_name) != null ? _G : "",
2271
- homeLogo: (_H = item.home_logo) != null ? _H : "",
2272
- imgPf: (_I = item.imgPf) != null ? _I : "",
2273
- imgSport: (_J = item.imgSport) != null ? _J : "",
2274
- imgTemplate: (_K = item.imgTemplate) != null ? _K : ""
2275
- };
2276
- };
2277
- var GameType = /* @__PURE__ */ ((GameType2) => {
2278
- GameType2["SPORT"] = "SPORT";
2279
- GameType2["SPECIAL"] = "SPECIAL";
2280
- GameType2["PVP"] = "PVP";
2281
- GameType2["LIVE"] = "LIVE";
2282
- GameType2["EVENT"] = "EVENT";
2283
- GameType2["ESPORT"] = "ESPORT";
2284
- GameType2["EGAME"] = "EGAME";
2285
- GameType2["BINGO"] = "BINGO";
2286
- return GameType2;
2287
- })(GameType || {});
2288
- const DefaultHotGamesData = {
2193
+ const DefaultCmsListData = {
2289
2194
  data: {
2290
- currentPage: 0,
2291
- data: [],
2292
- from: 0,
2293
- lastPage: 0,
2294
- nextPageUrl: "",
2295
- path: "",
2296
- perPage: 0,
2297
- prevPageUrl: "",
2298
- to: 0,
2299
- total: 0
2195
+ status: true,
2196
+ message: "",
2197
+ mobileBanner: []
2300
2198
  }
2301
2199
  };
2302
- const hotGamesApi = () => __async(null, null, function* () {
2303
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
2200
+ const cmsListApi = () => __async(null, null, function* () {
2201
+ var _a, _b;
2304
2202
  let result = __spreadValues({
2305
2203
  status: 200,
2306
2204
  message: ""
2307
- }, DefaultHotGamesData);
2205
+ }, DefaultCmsListData);
2308
2206
  try {
2309
- const response = yield get(`/apis/hotGames`, {
2207
+ const response = yield get(`/apis/cmsList`, {
2310
2208
  render: getRender(),
2311
2209
  json: 1
2312
2210
  });
2313
2211
  const output = response.data;
2314
- result.data = {
2315
- currentPage: (_a2 = output.current_page) != null ? _a2 : 0,
2316
- data: output.data.map((item) => {
2317
- var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m, _n, _o, _p, _q;
2318
- return {
2319
- id: (_a3 = item.id) != null ? _a3 : 0,
2320
- name: (_b2 = item.name) != null ? _b2 : "",
2321
- pfid: (_c2 = item.pfid) != null ? _c2 : 0,
2322
- ppname: (_d2 = item.ppname) != null ? _d2 : "",
2323
- code: (_e2 = item.code) != null ? _e2 : "",
2324
- img: (_f2 = item.img) != null ? _f2 : "",
2325
- progressive: (_g2 = item.progressive) != null ? _g2 : "",
2326
- ppid: (_h2 = item.ppid) != null ? _h2 : 0,
2327
- notry: item.notry === 1,
2328
- productCode: (_i2 = item.product_code) != null ? _i2 : "",
2329
- imgSrc: (_j = item.imgSrc) != null ? _j : "",
2330
- imgPf: (_k = item.imgPf) != null ? _k : "",
2331
- favouriteFlag: item.favourite_flag === 1,
2332
- platformStatusFlag: (_l = item.platform_status_flag) != null ? _l : "",
2333
- platformFlagName: (_m = item.platform_flag_name) != null ? _m : "",
2334
- platformStatusParams: {
2335
- eb: (_n = item.platform_status_params.eb) != null ? _n : false,
2336
- fit: (_o = item.platform_status_params.fit) != null ? _o : false,
2337
- fs: (_p = item.platform_status_params.fs) != null ? _p : false
2338
- },
2339
- gameId: (_q = item.game_id) != null ? _q : 0
2340
- };
2341
- }),
2342
- from: (_b = output.from) != null ? _b : 0,
2343
- lastPage: (_c = output.last_page) != null ? _c : 0,
2344
- nextPageUrl: (_d = output.next_page_url) != null ? _d : "",
2345
- path: (_e = output.path) != null ? _e : "",
2346
- perPage: (_f = output.per_page) != null ? _f : 0,
2347
- prevPageUrl: (_g = output.prev_page_url) != null ? _g : "",
2348
- to: (_h = output.to) != null ? _h : 0,
2349
- total: (_i = output.total) != null ? _i : 0
2212
+ result = {
2213
+ status: output.code,
2214
+ message: (_a = output.message) != null ? _a : "",
2215
+ data: {
2216
+ status: output.status,
2217
+ message: (_b = output.message) != null ? _b : "",
2218
+ mobileBanner: output.results.mobileBanner.map((item) => item.content)
2219
+ }
2350
2220
  };
2351
2221
  } catch (error) {
2352
2222
  const extendedError = error;
2353
2223
  result = __spreadValues({
2354
2224
  status: extendedError.status || 500,
2355
2225
  message: error.message
2356
- }, DefaultHotGamesData);
2226
+ }, DefaultCmsListData);
2357
2227
  }
2358
2228
  return result;
2359
2229
  });
2360
- const DefaultFishGamesData = {
2230
+ const DefaultLoginData = {
2361
2231
  data: {
2362
- hotfish: [],
2363
- data: []
2232
+ status: true,
2233
+ message: "",
2234
+ loginInfo: {
2235
+ username: "",
2236
+ walletBalance: "",
2237
+ key: "",
2238
+ ip: ""
2239
+ }
2364
2240
  }
2365
2241
  };
2366
- const fishGamesApi = () => __async(null, null, function* () {
2242
+ const loginApi = (username, password) => __async(null, null, function* () {
2243
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2367
2244
  let result = __spreadValues({
2368
2245
  status: 200,
2369
2246
  message: ""
2370
- }, DefaultFishGamesData);
2247
+ }, DefaultLoginData);
2371
2248
  try {
2372
- const response = yield get(`/apis/fishGames`, {
2249
+ const usernameInput = username;
2250
+ const passwordInput = password;
2251
+ const dataObject = {};
2252
+ dataObject.username = usernameInput.trim();
2253
+ dataObject.password = passwordInput.trim();
2254
+ const response = yield post(`/apis/login`, dataObject, {
2373
2255
  render: getRender(),
2374
2256
  json: 1
2375
2257
  });
2376
2258
  const output = response.data;
2377
- result.data = {
2378
- hotfish: output.hotfish.map((item) => {
2379
- return processFishGame(item);
2380
- }),
2381
- data: output.data.map((item) => {
2382
- return processFishGame(item);
2383
- })
2259
+ result = {
2260
+ status: output.code,
2261
+ message: (_a = output.message) != null ? _a : "",
2262
+ data: {
2263
+ status: output.status,
2264
+ message: (_b = output.message) != null ? _b : "",
2265
+ loginInfo: {
2266
+ username: (_d = (_c = output.results) == null ? void 0 : _c.accountcode) != null ? _d : "",
2267
+ walletBalance: (_f = (_e = output.results) == null ? void 0 : _e.balance) != null ? _f : "",
2268
+ key: (_h = (_g = output.results) == null ? void 0 : _g.online_key) != null ? _h : "",
2269
+ ip: (_j = (_i = output.results) == null ? void 0 : _i.user_ip) != null ? _j : ""
2270
+ }
2271
+ }
2384
2272
  };
2385
2273
  } catch (error) {
2386
2274
  const extendedError = error;
2387
2275
  result = __spreadValues({
2388
2276
  status: extendedError.status || 500,
2389
2277
  message: error.message
2390
- }, DefaultFishGamesData);
2278
+ }, DefaultLoginData);
2391
2279
  }
2392
2280
  return result;
2393
2281
  });
2394
- const processFishGame = (raw) => {
2395
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2396
- return {
2397
- id: (_a2 = raw.id) != null ? _a2 : 0,
2398
- name: (_b = raw.name) != null ? _b : "",
2399
- ppid: (_c = raw.pp_id) != null ? _c : "",
2400
- img: (_d = raw.img) != null ? _d : "",
2401
- desc: (_e = raw.desc) != null ? _e : "",
2402
- ppname: (_f = raw.pp_name) != null ? _f : "",
2403
- platformCode: (_g = raw.platform_code) != null ? _g : "",
2404
- code: (_h = raw.code) != null ? _h : "",
2405
- flag: (_i = raw.flag) != null ? _i : 0,
2406
- gameId: (_j = raw.game_id) != null ? _j : 0,
2407
- imgSrc: (_k = raw.imgSrc) != null ? _k : "",
2408
- imgPf: (_l = raw.imgPf) != null ? _l : "",
2409
- favouriteFlag: raw.favourite_flag === 1,
2410
- platformStatusFflag: (_m = raw.platform_status_Fflag) != null ? _m : "",
2411
- platformFlagName: (_n = raw.platform_flag_name) != null ? _n : "",
2412
- platformStatusParams: {
2413
- eb: (_o = raw.platform_status_params.eb) != null ? _o : false,
2414
- fit: (_p = raw.platform_status_params.fit) != null ? _p : false,
2415
- fs: (_q = raw.platform_status_params.fs) != null ? _q : false
2416
- }
2417
- };
2418
- };
2419
- const DefaultTrialGamesData = {
2420
- data: []
2282
+ const DefaultGetWinnerListData = {
2283
+ data: {
2284
+ status: true,
2285
+ message: "",
2286
+ winnerList: []
2287
+ }
2421
2288
  };
2422
- const trialGamesApi = () => __async(null, null, function* () {
2289
+ const getWinnerListApi = () => __async(null, null, function* () {
2290
+ var _a, _b, _c;
2423
2291
  let result = __spreadValues({
2424
2292
  status: 200,
2425
2293
  message: ""
2426
- }, DefaultTrialGamesData);
2294
+ }, DefaultGetWinnerListData);
2427
2295
  try {
2428
- const response = yield get(`/apis/trialGames`, {
2296
+ const response = yield get(`/apis/getWinnerList`, {
2429
2297
  render: getRender(),
2430
2298
  json: 1
2431
2299
  });
2432
2300
  const output = response.data;
2433
- result.data = output.map((item) => {
2434
- var _a2, _b;
2435
- return {
2436
- ppid: (_a2 = item.ppid) != null ? _a2 : 0,
2437
- ppname: (_b = item.ppname) != null ? _b : "",
2438
- games: item.games.map((gameItem) => {
2439
- var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2440
- return {
2441
- id: (_a3 = gameItem.id) != null ? _a3 : 0,
2442
- name: (_b2 = gameItem.name) != null ? _b2 : "",
2443
- img: (_c = gameItem.img) != null ? _c : "",
2444
- progressive: (_d = gameItem.progressive) != null ? _d : "",
2445
- notry: gameItem.notry === 1,
2446
- imgSrc: (_e = gameItem.imgSrc) != null ? _e : "",
2447
- imgPf: (_f = gameItem.imgPf) != null ? _f : "",
2448
- favouriteFlag: gameItem.favourite_flag === 1,
2449
- platformStatusFflag: (_g = gameItem.platform_status_Fflag) != null ? _g : "",
2450
- platformFlagName: (_h = gameItem.platform_flag_name) != null ? _h : "",
2451
- platformStatusParams: {
2452
- eb: (_i = gameItem.platform_status_params.eb) != null ? _i : false,
2453
- fit: (_j = gameItem.platform_status_params.fit) != null ? _j : false,
2454
- fs: (_k = gameItem.platform_status_params.fs) != null ? _k : false
2455
- },
2456
- ppname: (_l = item.ppname) != null ? _l : ""
2457
- };
2458
- })
2459
- };
2460
- });
2301
+ result = {
2302
+ status: output.code,
2303
+ message: (_a = output.message) != null ? _a : "",
2304
+ data: {
2305
+ status: output.status,
2306
+ message: (_b = output.message) != null ? _b : "",
2307
+ winnerList: (_c = output.results.notifications) != null ? _c : []
2308
+ }
2309
+ };
2461
2310
  } catch (error) {
2462
2311
  const extendedError = error;
2463
2312
  result = __spreadValues({
2464
2313
  status: extendedError.status || 500,
2465
2314
  message: error.message
2466
- }, DefaultTrialGamesData);
2315
+ }, DefaultGetWinnerListData);
2467
2316
  }
2468
2317
  return result;
2469
2318
  });
2470
- const DefaultCurrentLangData = {
2319
+ const DefaultAnnouncementData = {
2471
2320
  data: {
2472
- lang: ""
2321
+ status: true,
2322
+ message: "",
2323
+ announcementList: []
2473
2324
  }
2474
2325
  };
2475
- const currentLangApi = () => __async(null, null, function* () {
2326
+ const announcementApi = () => __async(null, null, function* () {
2327
+ var _a, _b;
2476
2328
  let result = __spreadValues({
2477
2329
  status: 200,
2478
2330
  message: ""
2479
- }, DefaultCurrentLangData);
2331
+ }, DefaultAnnouncementData);
2480
2332
  try {
2481
- const response = yield get(`/apis/currentLang`, {
2333
+ const response = yield get(`/apis/announcements`, {
2482
2334
  render: getRender(),
2483
2335
  json: 1
2484
2336
  });
2485
2337
  const output = response.data;
2486
- result.data = {
2487
- lang: output
2338
+ result = {
2339
+ status: output.code,
2340
+ message: (_a = output.message) != null ? _a : "",
2341
+ data: {
2342
+ status: output.status,
2343
+ message: (_b = output.message) != null ? _b : "",
2344
+ announcementList: output.results.data.map((item) => {
2345
+ return {
2346
+ alert: item.announcement_alert == "1",
2347
+ show: item.announcement_show == "1",
2348
+ status: item.announcement_status == "1",
2349
+ announcementId: item.announcement_index,
2350
+ content: item.announcement_content,
2351
+ dateCreated: item.announcement_datecreated
2352
+ };
2353
+ })
2354
+ }
2488
2355
  };
2489
2356
  } catch (error) {
2490
2357
  const extendedError = error;
2491
2358
  result = __spreadValues({
2492
2359
  status: extendedError.status || 500,
2493
2360
  message: error.message
2494
- }, DefaultCurrentLangData);
2361
+ }, DefaultAnnouncementData);
2495
2362
  }
2496
2363
  return result;
2497
2364
  });
2498
- const DefaultPromotionData = {
2499
- data: {
2500
- objList: [],
2501
- promoCat: [],
2502
- resize: 0
2503
- }
2365
+ const DefaultGetJackpotTotalData = {
2366
+ data: 0
2504
2367
  };
2505
- const promotionApi = () => __async(null, null, function* () {
2368
+ const getJackpotTotalApi = () => __async(null, null, function* () {
2369
+ var _a;
2506
2370
  let result = __spreadValues({
2507
2371
  status: 200,
2508
2372
  message: ""
2509
- }, DefaultPromotionData);
2373
+ }, DefaultGetJackpotTotalData);
2510
2374
  try {
2511
- const response = yield get(`/apis/promotion`, {
2375
+ const response = yield get(`/getJackpotTotal`, {
2512
2376
  render: getRender(),
2513
2377
  json: 1
2514
2378
  });
2515
2379
  const output = response.data;
2516
- result.data = {
2517
- objList: output.objList.map((item) => {
2518
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
2519
- return {
2520
- promoIndex: (_a2 = item.promoindex) != null ? _a2 : 0,
2521
- type: (_b = item.type) != null ? _b : 0,
2522
- thumb: (_c = item.thumb) != null ? _c : 0,
2523
- title: (_d = item.title) != null ? _d : "",
2524
- displayTime: (_e = item.display_time) != null ? _e : "",
2525
- handle: (_f = item.handle) != null ? _f : "",
2526
- content: (_g = item.content) != null ? _g : "",
2527
- langList: (_h = item.lang_list) != null ? _h : "",
2528
- agentList: (_i = item.agent_list) != null ? _i : "",
2529
- dateCreated: (_j = item.datecreated) != null ? _j : "",
2530
- updateBy: (_k = item.updateby) != null ? _k : "",
2531
- lastUpdated: (_l = item.lastupdated) != null ? _l : "",
2532
- sequence: (_m = item.sequence) != null ? _m : 0,
2533
- status: item.status === 1,
2534
- timer: (_n = item.timer) != null ? _n : "",
2535
- stime: (_o = item.stime) != null ? _o : "",
2536
- etime: (_p = item.etime) != null ? _p : "",
2537
- smaid: (_q = item.smaid) != null ? _q : "",
2538
- companyIndex: (_r = item.companyindex) != null ? _r : "",
2539
- fileName: (_s = item.filename) != null ? _s : "",
2540
- version: (_t = item.version) != null ? _t : "",
2541
- categoryName: (_u = item.category_name) != null ? _u : "",
2542
- barImg: (_v = item.bar_img) != null ? _v : "",
2543
- buttonImg: (_w = item.button_img) != null ? _w : "",
2544
- promoImg: (_x = item.promo_image) != null ? _x : "",
2545
- catId: (_y = item.catid) != null ? _y : "",
2546
- imageType: (_z = item.image_type) != null ? _z : "",
2547
- image: (_A = item.image) != null ? _A : "",
2548
- isLink: item.isLink,
2549
- latestUpdate: (_B = item.latestupdate) != null ? _B : ""
2550
- };
2551
- }),
2552
- promoCat: output.promoCat.map((item) => {
2553
- var _a2, _b, _c, _d;
2554
- return {
2555
- catId: (_a2 = item.catid) != null ? _a2 : 0,
2556
- name: (_b = item.name) != null ? _b : "",
2557
- barImg: (_c = item.bar_img) != null ? _c : "",
2558
- buttonImg: (_d = item.button_img) != null ? _d : ""
2559
- };
2560
- }),
2561
- resize: output.resize
2562
- };
2380
+ result.data = (_a = output.total) != null ? _a : 0;
2563
2381
  } catch (error) {
2564
2382
  const extendedError = error;
2565
2383
  result = __spreadValues({
2566
2384
  status: extendedError.status || 500,
2567
2385
  message: error.message
2568
- }, DefaultPromotionData);
2386
+ }, DefaultGetJackpotTotalData);
2569
2387
  }
2570
2388
  return result;
2571
2389
  });
2572
- const DefaultGetLocaleData = {
2573
- data: []
2390
+ const DefaultMessageData = {
2391
+ data: {
2392
+ status: true,
2393
+ message: "",
2394
+ messageList: []
2395
+ }
2574
2396
  };
2575
- const getLocaleApi = () => __async(null, null, function* () {
2576
- var _a2;
2397
+ const DefaultGetMessageData = {
2398
+ data: {
2399
+ status: true,
2400
+ message: "",
2401
+ messageContent: {
2402
+ id: 0,
2403
+ status: false,
2404
+ subject: "",
2405
+ content: "",
2406
+ date: ""
2407
+ }
2408
+ }
2409
+ };
2410
+ const messageApi = () => __async(null, null, function* () {
2411
+ var _a, _b, _c, _d;
2577
2412
  let result = __spreadValues({
2578
2413
  status: 200,
2579
2414
  message: ""
2580
- }, DefaultGetLocaleData);
2415
+ }, DefaultMessageData);
2581
2416
  try {
2582
- const response = yield get(`/apis/getLocale`, {
2417
+ const response = yield get(`/apis/msg`, {
2583
2418
  render: getRender(),
2584
2419
  json: 1
2585
2420
  });
2586
2421
  const output = response.data;
2587
- result.data = (_a2 = output.results.map((item) => {
2588
- return {
2589
- code: item.code,
2590
- label: item.label
2591
- };
2592
- })) != null ? _a2 : [];
2422
+ result = {
2423
+ status: output.code,
2424
+ message: (_a = output.message) != null ? _a : "",
2425
+ data: {
2426
+ status: output.status,
2427
+ message: (_b = output.message) != null ? _b : "",
2428
+ messageList: (_d = (_c = output.results) == null ? void 0 : _c.map((item) => {
2429
+ return {
2430
+ id: item.msgindex,
2431
+ status: item.status == "1",
2432
+ subject: item.subject,
2433
+ date: item.cdate
2434
+ };
2435
+ })) != null ? _d : []
2436
+ }
2437
+ };
2593
2438
  } catch (error) {
2594
2439
  const extendedError = error;
2595
2440
  result = __spreadValues({
2596
2441
  status: extendedError.status || 500,
2597
2442
  message: error.message
2598
- }, DefaultGetLocaleData);
2443
+ }, DefaultMessageData);
2599
2444
  }
2600
2445
  return result;
2601
2446
  });
2602
- const DefaultCsLinkData = {
2603
- data: {
2604
- liveChat: ""
2605
- }
2606
- };
2607
- const csLinkApi = () => __async(null, null, function* () {
2608
- var _a2;
2447
+ const getMessageApi = (id) => __async(null, null, function* () {
2448
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2609
2449
  let result = __spreadValues({
2610
2450
  status: 200,
2611
2451
  message: ""
2612
- }, DefaultCsLinkData);
2452
+ }, DefaultGetMessageData);
2613
2453
  try {
2614
- const response = yield get(`/apis/cslink`, {
2454
+ const response = yield get(`/apis/msg/${id}`, {
2615
2455
  render: getRender(),
2616
2456
  json: 1
2617
2457
  });
2618
2458
  const output = response.data;
2619
- result.data = {
2620
- liveChat: (_a2 = output.livechat) != null ? _a2 : ""
2459
+ result = {
2460
+ status: output.code,
2461
+ message: (_a = output.message) != null ? _a : "",
2462
+ data: {
2463
+ status: output.status,
2464
+ message: (_b = output.message) != null ? _b : "",
2465
+ messageContent: {
2466
+ id: (_d = (_c = output.results) == null ? void 0 : _c.msgindex) != null ? _d : 0,
2467
+ status: ((_e = output.results) == null ? void 0 : _e.status) == "1",
2468
+ subject: (_g = (_f = output.results) == null ? void 0 : _f.subject) != null ? _g : "",
2469
+ content: (_i = (_h = output.results) == null ? void 0 : _h.content) != null ? _i : "",
2470
+ date: (_k = (_j = output.results) == null ? void 0 : _j.cdate) != null ? _k : ""
2471
+ }
2472
+ }
2621
2473
  };
2622
2474
  } catch (error) {
2623
2475
  const extendedError = error;
2624
2476
  result = __spreadValues({
2625
2477
  status: extendedError.status || 500,
2626
2478
  message: error.message
2627
- }, DefaultCsLinkData);
2479
+ }, DefaultGetMessageData);
2628
2480
  }
2629
2481
  return result;
2630
2482
  });
2631
- const DefaultEGameData = {
2632
- data: {
2633
- eGameList: []
2634
- }
2483
+ const DefaultGetCashWalletData = {
2484
+ data: 0
2635
2485
  };
2636
- const eGameApi = (id) => __async(null, null, function* () {
2486
+ const getCashWalletApi = (accessToken) => __async(null, null, function* () {
2637
2487
  let result = __spreadValues({
2638
2488
  status: 200,
2639
2489
  message: ""
2640
- }, DefaultEGameData);
2490
+ }, DefaultGetCashWalletData);
2641
2491
  try {
2642
- const response = yield get(`/apis/egame/json/${id}`, {
2492
+ const dataObject = {};
2493
+ dataObject.access_token = accessToken;
2494
+ const response = yield post(`/Cashwallet/get/last`, dataObject, {
2643
2495
  render: getRender(),
2644
2496
  json: 1
2645
2497
  });
2646
2498
  const output = response.data;
2647
- result.data = {
2648
- eGameList: output.map((item) => {
2649
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2650
- return {
2651
- gameId: (_a2 = item.game_id) != null ? _a2 : "",
2652
- imgSrc: (_b = item.imgSrc) != null ? _b : "",
2653
- imgPf: (_c = item.imgPf) != null ? _c : "",
2654
- name: (_d = item.name) != null ? _d : "",
2655
- favouriteFlag: item.favourite_flag === 1,
2656
- platformStatusFflag: (_e = item.platform_status_Fflag) != null ? _e : "",
2657
- platformFlagName: (_f = item.platform_flag_name) != null ? _f : "",
2658
- platformStatusParams: {
2659
- eb: (_g = item.platform_status_params.eb) != null ? _g : false,
2660
- fit: (_h = item.platform_status_params.fit) != null ? _h : false,
2661
- fs: (_i = item.platform_status_params.fs) != null ? _i : false
2662
- },
2663
- progressive: (_j = item.progressive) != null ? _j : "",
2664
- gameCategory: (_k = item.game_category) != null ? _k : "",
2665
- ppid: (_l = item.pp_id) != null ? _l : ""
2666
- };
2667
- })
2668
- };
2499
+ result.data = output.status ? output.last : 0;
2669
2500
  } catch (error) {
2670
2501
  const extendedError = error;
2671
2502
  result = __spreadValues({
2672
2503
  status: extendedError.status || 500,
2673
2504
  message: error.message
2674
- }, DefaultEGameData);
2505
+ }, DefaultGetCashWalletData);
2675
2506
  }
2676
2507
  return result;
2677
2508
  });
2678
- const DefaultCmsListData = {
2509
+ const DefaultMobileBannerData = {
2679
2510
  data: {
2511
+ status: true,
2512
+ message: "",
2680
2513
  mobileBanner: []
2681
2514
  }
2682
2515
  };
2683
- const cmsListApi = () => __async(null, null, function* () {
2516
+ const mobileBannerApi = () => __async(null, null, function* () {
2517
+ var _a, _b;
2684
2518
  let result = __spreadValues({
2685
2519
  status: 200,
2686
2520
  message: ""
2687
- }, DefaultCmsListData);
2521
+ }, DefaultMobileBannerData);
2688
2522
  try {
2689
- const response = yield get(`/apis/cmsList`, {
2523
+ const response = yield get(`/apis/mobileBanner`, {
2690
2524
  render: getRender(),
2691
2525
  json: 1
2692
2526
  });
2693
2527
  const output = response.data;
2694
- result.data = {
2695
- mobileBanner: output.results.mobileBanner.map((item) => item.content)
2528
+ result = {
2529
+ status: output.code,
2530
+ message: (_a = output.message) != null ? _a : "",
2531
+ data: {
2532
+ status: output.status,
2533
+ message: (_b = output.message) != null ? _b : "",
2534
+ mobileBanner: output.results.mobileBanner.map((item) => item.content)
2535
+ }
2696
2536
  };
2697
2537
  } catch (error) {
2698
2538
  const extendedError = error;
2699
2539
  result = __spreadValues({
2700
2540
  status: extendedError.status || 500,
2701
2541
  message: error.message
2702
- }, DefaultCmsListData);
2542
+ }, DefaultMobileBannerData);
2703
2543
  }
2704
2544
  return result;
2705
2545
  });
2706
- const DefaultGetSettingData = {
2546
+ const DefaultFooterInfoData = {
2707
2547
  data: {
2708
- csrf: "",
2709
- getCaptcha: "",
2710
- verificationBeforeLogin: false,
2711
- publicKey: "",
2712
- concantenatedKey: ""
2548
+ status: true,
2549
+ message: "",
2550
+ footerInfo: []
2713
2551
  }
2714
2552
  };
2715
- const getSettingApi = (setting) => __async(null, null, function* () {
2716
- var _a2, _b;
2553
+ const footerInfoApi = () => __async(null, null, function* () {
2554
+ var _a, _b;
2717
2555
  let result = __spreadValues({
2718
2556
  status: 200,
2719
2557
  message: ""
2720
- }, DefaultGetSettingData);
2558
+ }, DefaultFooterInfoData);
2721
2559
  try {
2722
- const response = yield get(`/apis/getSetting`, {
2723
- setting: `${setting}`,
2560
+ const response = yield get(`/apis/footerInfo`, {
2724
2561
  render: getRender(),
2725
2562
  json: 1
2726
2563
  });
2727
2564
  const output = response.data;
2728
- result.data = {
2729
- csrf: (_a2 = output.csrf) != null ? _a2 : "",
2730
- getCaptcha: (_b = output.data.CAPTCHA) != null ? _b : "",
2731
- verificationBeforeLogin: output.data["slide-verification"] === "1",
2732
- publicKey: output.data.encryptkey ? output.data.encryptkey.pub.replace(
2733
- /-----BEGIN PUBLIC KEY-----|-----END PUBLIC KEY-----|\r|\n|=#/g,
2734
- ""
2735
- ) : "",
2736
- concantenatedKey: output.data.encryptkey ? Object.keys(output.data.encryptkey.pubarr).join("+") : ""
2565
+ result = {
2566
+ status: output.code,
2567
+ message: (_a = output.message) != null ? _a : "",
2568
+ data: {
2569
+ status: output.status,
2570
+ message: (_b = output.message) != null ? _b : "",
2571
+ footerInfo: output.results.footerInfo.map((item) => item.content)
2572
+ }
2737
2573
  };
2738
2574
  } catch (error) {
2739
2575
  const extendedError = error;
2740
2576
  result = __spreadValues({
2741
2577
  status: extendedError.status || 500,
2742
2578
  message: error.message
2743
- }, DefaultGetSettingData);
2579
+ }, DefaultFooterInfoData);
2744
2580
  }
2745
2581
  return result;
2746
2582
  });
2747
- var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
2748
- function int2char(n) {
2749
- return BI_RM.charAt(n);
2750
- }
2751
- function op_and(x, y) {
2752
- return x & y;
2753
- }
2754
- function op_or(x, y) {
2755
- return x | y;
2756
- }
2757
- function op_xor(x, y) {
2758
- return x ^ y;
2759
- }
2760
- function op_andnot(x, y) {
2761
- return x & ~y;
2762
- }
2763
- function lbit(x) {
2764
- if (x == 0) {
2765
- return -1;
2766
- }
2767
- var r = 0;
2768
- if ((x & 65535) == 0) {
2769
- x >>= 16;
2770
- r += 16;
2771
- }
2772
- if ((x & 255) == 0) {
2773
- x >>= 8;
2774
- r += 8;
2775
- }
2776
- if ((x & 15) == 0) {
2777
- x >>= 4;
2778
- r += 4;
2779
- }
2780
- if ((x & 3) == 0) {
2781
- x >>= 2;
2782
- r += 2;
2783
- }
2784
- if ((x & 1) == 0) {
2785
- ++r;
2786
- }
2787
- return r;
2788
- }
2789
- function cbit(x) {
2790
- var r = 0;
2791
- while (x != 0) {
2792
- x &= x - 1;
2793
- ++r;
2794
- }
2795
- return r;
2796
- }
2797
- var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2798
- var b64pad = "=";
2799
- function hex2b64(h) {
2800
- var i;
2801
- var c;
2802
- var ret = "";
2803
- for (i = 0; i + 3 <= h.length; i += 3) {
2804
- c = parseInt(h.substring(i, i + 3), 16);
2805
- ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
2806
- }
2807
- if (i + 1 == h.length) {
2808
- c = parseInt(h.substring(i, i + 1), 16);
2809
- ret += b64map.charAt(c << 2);
2810
- } else if (i + 2 == h.length) {
2811
- c = parseInt(h.substring(i, i + 2), 16);
2812
- ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
2813
- }
2814
- while ((ret.length & 3) > 0) {
2815
- ret += b64pad;
2816
- }
2817
- return ret;
2818
- }
2819
- function b64tohex(s) {
2820
- var ret = "";
2821
- var i;
2822
- var k = 0;
2823
- var slop = 0;
2824
- for (i = 0; i < s.length; ++i) {
2825
- if (s.charAt(i) == b64pad) {
2826
- break;
2827
- }
2828
- var v = b64map.indexOf(s.charAt(i));
2829
- if (v < 0) {
2830
- continue;
2831
- }
2832
- if (k == 0) {
2833
- ret += int2char(v >> 2);
2834
- slop = v & 3;
2835
- k = 1;
2836
- } else if (k == 1) {
2837
- ret += int2char(slop << 2 | v >> 4);
2838
- slop = v & 15;
2839
- k = 2;
2840
- } else if (k == 2) {
2841
- ret += int2char(slop);
2842
- ret += int2char(v >> 2);
2843
- slop = v & 3;
2844
- k = 3;
2845
- } else {
2846
- ret += int2char(slop << 2 | v >> 4);
2847
- ret += int2char(v & 15);
2848
- k = 0;
2849
- }
2850
- }
2851
- if (k == 1) {
2852
- ret += int2char(slop << 2);
2853
- }
2854
- return ret;
2855
- }
2856
- var decoder$1;
2857
- var Hex = {
2858
- decode: function(a) {
2859
- var i;
2860
- if (decoder$1 === void 0) {
2861
- var hex = "0123456789ABCDEF";
2862
- var ignore = " \f\n\r  \u2028\u2029";
2863
- decoder$1 = {};
2864
- for (i = 0; i < 16; ++i) {
2865
- decoder$1[hex.charAt(i)] = i;
2866
- }
2867
- hex = hex.toLowerCase();
2868
- for (i = 10; i < 16; ++i) {
2869
- decoder$1[hex.charAt(i)] = i;
2870
- }
2871
- for (i = 0; i < ignore.length; ++i) {
2872
- decoder$1[ignore.charAt(i)] = -1;
2873
- }
2874
- }
2875
- var out = [];
2876
- var bits = 0;
2877
- var char_count = 0;
2878
- for (i = 0; i < a.length; ++i) {
2879
- var c = a.charAt(i);
2880
- if (c == "=") {
2881
- break;
2882
- }
2883
- c = decoder$1[c];
2884
- if (c == -1) {
2885
- continue;
2886
- }
2887
- if (c === void 0) {
2888
- throw new Error("Illegal character at offset " + i);
2889
- }
2890
- bits |= c;
2891
- if (++char_count >= 2) {
2892
- out[out.length] = bits;
2893
- bits = 0;
2894
- char_count = 0;
2895
- } else {
2896
- bits <<= 4;
2897
- }
2898
- }
2899
- if (char_count) {
2900
- throw new Error("Hex encoding incomplete: 4 bits missing");
2901
- }
2902
- return out;
2903
- }
2904
- };
2905
- var decoder;
2906
- var Base64 = {
2907
- decode: function(a) {
2908
- var i;
2909
- if (decoder === void 0) {
2910
- var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2911
- var ignore = "= \f\n\r  \u2028\u2029";
2912
- decoder = /* @__PURE__ */ Object.create(null);
2913
- for (i = 0; i < 64; ++i) {
2914
- decoder[b64.charAt(i)] = i;
2915
- }
2916
- decoder["-"] = 62;
2917
- decoder["_"] = 63;
2918
- for (i = 0; i < ignore.length; ++i) {
2919
- decoder[ignore.charAt(i)] = -1;
2920
- }
2921
- }
2922
- var out = [];
2923
- var bits = 0;
2924
- var char_count = 0;
2925
- for (i = 0; i < a.length; ++i) {
2926
- var c = a.charAt(i);
2927
- if (c == "=") {
2928
- break;
2929
- }
2930
- c = decoder[c];
2931
- if (c == -1) {
2932
- continue;
2933
- }
2934
- if (c === void 0) {
2935
- throw new Error("Illegal character at offset " + i);
2936
- }
2937
- bits |= c;
2938
- if (++char_count >= 4) {
2939
- out[out.length] = bits >> 16;
2940
- out[out.length] = bits >> 8 & 255;
2941
- out[out.length] = bits & 255;
2942
- bits = 0;
2943
- char_count = 0;
2944
- } else {
2945
- bits <<= 6;
2946
- }
2947
- }
2948
- switch (char_count) {
2949
- case 1:
2950
- throw new Error("Base64 encoding incomplete: at least 2 bits missing");
2951
- case 2:
2952
- out[out.length] = bits >> 10;
2953
- break;
2954
- case 3:
2955
- out[out.length] = bits >> 16;
2956
- out[out.length] = bits >> 8 & 255;
2957
- break;
2958
- }
2959
- return out;
2960
- },
2961
- re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,
2962
- unarmor: function(a) {
2963
- var m = Base64.re.exec(a);
2964
- if (m) {
2965
- if (m[1]) {
2966
- a = m[1];
2967
- } else if (m[2]) {
2968
- a = m[2];
2969
- } else {
2970
- throw new Error("RegExp out of sync");
2971
- }
2583
+ const DefaultProfileData = {
2584
+ data: {
2585
+ status: true,
2586
+ message: "",
2587
+ profile: {
2588
+ address: "",
2589
+ city: "",
2590
+ isUserConfirm: false,
2591
+ country: "",
2592
+ dob: "",
2593
+ email: "",
2594
+ fax: "",
2595
+ fullName: "",
2596
+ gender: "",
2597
+ phone: "",
2598
+ qq: "",
2599
+ isSameName: false
2972
2600
  }
2973
- return Base64.decode(a);
2974
2601
  }
2975
2602
  };
2976
- var max = 1e13;
2977
- var Int10 = (
2978
- /** @class */
2979
- (function() {
2980
- function Int102(value) {
2981
- this.buf = [+value || 0];
2982
- }
2983
- Int102.prototype.mulAdd = function(m, c) {
2984
- var b = this.buf;
2985
- var l = b.length;
2986
- var i;
2987
- var t;
2988
- for (i = 0; i < l; ++i) {
2989
- t = b[i] * m + c;
2990
- if (t < max) {
2991
- c = 0;
2992
- } else {
2993
- c = 0 | t / max;
2994
- t -= c * max;
2995
- }
2996
- b[i] = t;
2997
- }
2998
- if (c > 0) {
2999
- b[i] = c;
3000
- }
3001
- };
3002
- Int102.prototype.sub = function(c) {
3003
- var b = this.buf;
3004
- var l = b.length;
3005
- var i;
3006
- var t;
3007
- for (i = 0; i < l; ++i) {
3008
- t = b[i] - c;
3009
- if (t < 0) {
3010
- t += max;
3011
- c = 1;
3012
- } else {
3013
- c = 0;
3014
- }
3015
- b[i] = t;
3016
- }
3017
- while (b[b.length - 1] === 0) {
3018
- b.pop();
3019
- }
3020
- };
3021
- Int102.prototype.toString = function(base) {
3022
- if ((base || 10) != 10) {
3023
- throw new Error("only base 10 is supported");
3024
- }
3025
- var b = this.buf;
3026
- var s = b[b.length - 1].toString();
3027
- for (var i = b.length - 2; i >= 0; --i) {
3028
- s += (max + b[i]).toString().substring(1);
3029
- }
3030
- return s;
3031
- };
3032
- Int102.prototype.valueOf = function() {
3033
- var b = this.buf;
3034
- var v = 0;
3035
- for (var i = b.length - 1; i >= 0; --i) {
3036
- v = v * max + b[i];
3037
- }
3038
- return v;
3039
- };
3040
- Int102.prototype.simplify = function() {
3041
- var b = this.buf;
3042
- return b.length == 1 ? b[0] : this;
3043
- };
3044
- return Int102;
3045
- })()
3046
- );
3047
- var ellipsis = "…";
3048
- var reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
3049
- var reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
3050
- function stringCut(str, len) {
3051
- if (str.length > len) {
3052
- str = str.substring(0, len) + ellipsis;
3053
- }
3054
- return str;
3055
- }
3056
- var Stream = (
3057
- /** @class */
3058
- (function() {
3059
- function Stream2(enc, pos) {
3060
- this.hexDigits = "0123456789ABCDEF";
3061
- if (enc instanceof Stream2) {
3062
- this.enc = enc.enc;
3063
- this.pos = enc.pos;
3064
- } else {
3065
- this.enc = enc;
3066
- this.pos = pos;
3067
- }
3068
- }
3069
- Stream2.prototype.get = function(pos) {
3070
- if (pos === void 0) {
3071
- pos = this.pos++;
3072
- }
3073
- if (pos >= this.enc.length) {
3074
- throw new Error("Requesting byte offset ".concat(pos, " on a stream of length ").concat(this.enc.length));
3075
- }
3076
- return "string" === typeof this.enc ? this.enc.charCodeAt(pos) : this.enc[pos];
3077
- };
3078
- Stream2.prototype.hexByte = function(b) {
3079
- return this.hexDigits.charAt(b >> 4 & 15) + this.hexDigits.charAt(b & 15);
3080
- };
3081
- Stream2.prototype.hexDump = function(start, end, raw) {
3082
- var s = "";
3083
- for (var i = start; i < end; ++i) {
3084
- s += this.hexByte(this.get(i));
3085
- if (raw !== true) {
3086
- switch (i & 15) {
3087
- case 7:
3088
- s += " ";
3089
- break;
3090
- case 15:
3091
- s += "\n";
3092
- break;
3093
- default:
3094
- s += " ";
3095
- }
3096
- }
3097
- }
3098
- return s;
3099
- };
3100
- Stream2.prototype.isASCII = function(start, end) {
3101
- for (var i = start; i < end; ++i) {
3102
- var c = this.get(i);
3103
- if (c < 32 || c > 176) {
3104
- return false;
3105
- }
3106
- }
3107
- return true;
3108
- };
3109
- Stream2.prototype.parseStringISO = function(start, end) {
3110
- var s = "";
3111
- for (var i = start; i < end; ++i) {
3112
- s += String.fromCharCode(this.get(i));
3113
- }
3114
- return s;
3115
- };
3116
- Stream2.prototype.parseStringUTF = function(start, end) {
3117
- var s = "";
3118
- for (var i = start; i < end; ) {
3119
- var c = this.get(i++);
3120
- if (c < 128) {
3121
- s += String.fromCharCode(c);
3122
- } else if (c > 191 && c < 224) {
3123
- s += String.fromCharCode((c & 31) << 6 | this.get(i++) & 63);
3124
- } else {
3125
- s += String.fromCharCode((c & 15) << 12 | (this.get(i++) & 63) << 6 | this.get(i++) & 63);
3126
- }
3127
- }
3128
- return s;
3129
- };
3130
- Stream2.prototype.parseStringBMP = function(start, end) {
3131
- var str = "";
3132
- var hi;
3133
- var lo;
3134
- for (var i = start; i < end; ) {
3135
- hi = this.get(i++);
3136
- lo = this.get(i++);
3137
- str += String.fromCharCode(hi << 8 | lo);
3138
- }
3139
- return str;
3140
- };
3141
- Stream2.prototype.parseTime = function(start, end, shortYear) {
3142
- var s = this.parseStringISO(start, end);
3143
- var m = (shortYear ? reTimeS : reTimeL).exec(s);
3144
- if (!m) {
3145
- return "Unrecognized time: " + s;
3146
- }
3147
- if (shortYear) {
3148
- m[1] = +m[1];
3149
- m[1] += +m[1] < 70 ? 2e3 : 1900;
3150
- }
3151
- s = m[1] + "-" + m[2] + "-" + m[3] + " " + m[4];
3152
- if (m[5]) {
3153
- s += ":" + m[5];
3154
- if (m[6]) {
3155
- s += ":" + m[6];
3156
- if (m[7]) {
3157
- s += "." + m[7];
3158
- }
3159
- }
3160
- }
3161
- if (m[8]) {
3162
- s += " UTC";
3163
- if (m[8] != "Z") {
3164
- s += m[8];
3165
- if (m[9]) {
3166
- s += ":" + m[9];
3167
- }
3168
- }
3169
- }
3170
- return s;
3171
- };
3172
- Stream2.prototype.parseInteger = function(start, end) {
3173
- var v = this.get(start);
3174
- var neg = v > 127;
3175
- var pad = neg ? 255 : 0;
3176
- var len;
3177
- var s = "";
3178
- while (v == pad && ++start < end) {
3179
- v = this.get(start);
3180
- }
3181
- len = end - start;
3182
- if (len === 0) {
3183
- return neg ? -1 : 0;
3184
- }
3185
- if (len > 4) {
3186
- s = v;
3187
- len <<= 3;
3188
- while (((+s ^ pad) & 128) == 0) {
3189
- s = +s << 1;
3190
- --len;
3191
- }
3192
- s = "(" + len + " bit)\n";
3193
- }
3194
- if (neg) {
3195
- v = v - 256;
3196
- }
3197
- var n = new Int10(v);
3198
- for (var i = start + 1; i < end; ++i) {
3199
- n.mulAdd(256, this.get(i));
3200
- }
3201
- return s + n.toString();
3202
- };
3203
- Stream2.prototype.parseBitString = function(start, end, maxLength) {
3204
- var unusedBit = this.get(start);
3205
- var lenBit = (end - start - 1 << 3) - unusedBit;
3206
- var intro = "(" + lenBit + " bit)\n";
3207
- var s = "";
3208
- for (var i = start + 1; i < end; ++i) {
3209
- var b = this.get(i);
3210
- var skip = i == end - 1 ? unusedBit : 0;
3211
- for (var j = 7; j >= skip; --j) {
3212
- s += b >> j & 1 ? "1" : "0";
3213
- }
3214
- if (s.length > maxLength) {
3215
- return intro + stringCut(s, maxLength);
2603
+ const profileApi = () => __async(null, null, function* () {
2604
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2605
+ let result = __spreadValues({
2606
+ status: 200,
2607
+ message: ""
2608
+ }, DefaultProfileData);
2609
+ try {
2610
+ const response = yield get(`/apis/profile`, {
2611
+ render: getRender(),
2612
+ json: 1
2613
+ });
2614
+ const output = response.data;
2615
+ result = {
2616
+ status: output.code,
2617
+ message: (_a = output.message) != null ? _a : "",
2618
+ data: {
2619
+ status: output.status,
2620
+ message: (_b = output.message) != null ? _b : "",
2621
+ profile: {
2622
+ address: (_c = output.results.address) != null ? _c : "",
2623
+ city: (_d = output.results.city) != null ? _d : "",
2624
+ isUserConfirm: output.results.confirm_flag == "1",
2625
+ country: (_e = output.results.country) != null ? _e : "",
2626
+ dob: (_f = output.results.dob) != null ? _f : "",
2627
+ email: (_g = output.results.email) != null ? _g : "",
2628
+ fax: (_h = output.results.faxno) != null ? _h : "",
2629
+ fullName: `${(_i = output.results.firstname) != null ? _i : ""} ${(_j = output.results.lastname) != null ? _j : ""}`.trim(),
2630
+ gender: (_k = output.results.gender) != null ? _k : "",
2631
+ phone: (_l = output.results.mobileno) != null ? _l : "",
2632
+ qq: (_m = output.results.qq) != null ? _m : "",
2633
+ isSameName: output.results.same_name_flag == "1"
3216
2634
  }
3217
2635
  }
3218
- return intro + s;
3219
2636
  };
3220
- Stream2.prototype.parseOctetString = function(start, end, maxLength) {
3221
- if (this.isASCII(start, end)) {
3222
- return stringCut(this.parseStringISO(start, end), maxLength);
3223
- }
3224
- var len = end - start;
3225
- var s = "(" + len + " byte)\n";
3226
- maxLength /= 2;
3227
- if (len > maxLength) {
3228
- end = start + maxLength;
3229
- }
3230
- for (var i = start; i < end; ++i) {
3231
- s += this.hexByte(this.get(i));
3232
- }
3233
- if (len > maxLength) {
3234
- s += ellipsis;
3235
- }
3236
- return s;
3237
- };
3238
- Stream2.prototype.parseOID = function(start, end, maxLength) {
3239
- var s = "";
3240
- var n = new Int10();
3241
- var bits = 0;
3242
- for (var i = start; i < end; ++i) {
3243
- var v = this.get(i);
3244
- n.mulAdd(128, v & 127);
3245
- bits += 7;
3246
- if (!(v & 128)) {
3247
- if (s === "") {
3248
- n = n.simplify();
3249
- if (n instanceof Int10) {
3250
- n.sub(80);
3251
- s = "2." + n.toString();
3252
- } else {
3253
- var m = n < 80 ? n < 40 ? 0 : 1 : 2;
3254
- s = m + "." + (n - m * 40);
3255
- }
3256
- } else {
3257
- s += "." + n.toString();
3258
- }
3259
- if (s.length > maxLength) {
3260
- return stringCut(s, maxLength);
3261
- }
3262
- n = new Int10();
3263
- bits = 0;
3264
- }
3265
- }
3266
- if (bits > 0) {
3267
- s += ".incomplete";
3268
- }
3269
- return s;
3270
- };
3271
- return Stream2;
3272
- })()
3273
- );
3274
- var ASN1 = (
3275
- /** @class */
3276
- (function() {
3277
- function ASN12(stream, header, length, tag, sub) {
3278
- if (!(tag instanceof ASN1Tag)) {
3279
- throw new Error("Invalid tag value.");
3280
- }
3281
- this.stream = stream;
3282
- this.header = header;
3283
- this.length = length;
3284
- this.tag = tag;
3285
- this.sub = sub;
3286
- }
3287
- ASN12.prototype.typeName = function() {
3288
- switch (this.tag.tagClass) {
3289
- case 0:
3290
- switch (this.tag.tagNumber) {
3291
- case 0:
3292
- return "EOC";
3293
- case 1:
3294
- return "BOOLEAN";
3295
- case 2:
3296
- return "INTEGER";
3297
- case 3:
3298
- return "BIT_STRING";
3299
- case 4:
3300
- return "OCTET_STRING";
3301
- case 5:
3302
- return "NULL";
3303
- case 6:
3304
- return "OBJECT_IDENTIFIER";
3305
- case 7:
3306
- return "ObjectDescriptor";
3307
- case 8:
3308
- return "EXTERNAL";
3309
- case 9:
3310
- return "REAL";
3311
- case 10:
3312
- return "ENUMERATED";
3313
- case 11:
3314
- return "EMBEDDED_PDV";
3315
- case 12:
3316
- return "UTF8String";
3317
- case 16:
3318
- return "SEQUENCE";
3319
- case 17:
3320
- return "SET";
3321
- case 18:
3322
- return "NumericString";
3323
- case 19:
3324
- return "PrintableString";
3325
- // ASCII subset
3326
- case 20:
3327
- return "TeletexString";
3328
- // aka T61String
3329
- case 21:
3330
- return "VideotexString";
3331
- case 22:
3332
- return "IA5String";
3333
- // ASCII
3334
- case 23:
3335
- return "UTCTime";
3336
- case 24:
3337
- return "GeneralizedTime";
3338
- case 25:
3339
- return "GraphicString";
3340
- case 26:
3341
- return "VisibleString";
3342
- // ASCII subset
3343
- case 27:
3344
- return "GeneralString";
3345
- case 28:
3346
- return "UniversalString";
3347
- case 30:
3348
- return "BMPString";
3349
- }
3350
- return "Universal_" + this.tag.tagNumber.toString();
3351
- case 1:
3352
- return "Application_" + this.tag.tagNumber.toString();
3353
- case 2:
3354
- return "[" + this.tag.tagNumber.toString() + "]";
3355
- // Context
3356
- case 3:
3357
- return "Private_" + this.tag.tagNumber.toString();
3358
- }
3359
- };
3360
- ASN12.prototype.content = function(maxLength) {
3361
- if (this.tag === void 0) {
3362
- return null;
3363
- }
3364
- if (maxLength === void 0) {
3365
- maxLength = Infinity;
3366
- }
3367
- var content = this.posContent();
3368
- var len = Math.abs(this.length);
3369
- if (!this.tag.isUniversal()) {
3370
- if (this.sub !== null) {
3371
- return "(" + this.sub.length + " elem)";
3372
- }
3373
- return this.stream.parseOctetString(content, content + len, maxLength);
3374
- }
3375
- switch (this.tag.tagNumber) {
3376
- case 1:
3377
- return this.stream.get(content) === 0 ? "false" : "true";
3378
- case 2:
3379
- return this.stream.parseInteger(content, content + len);
3380
- case 3:
3381
- return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseBitString(content, content + len, maxLength);
3382
- case 4:
3383
- return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseOctetString(content, content + len, maxLength);
3384
- // case 0x05: // NULL
3385
- case 6:
3386
- return this.stream.parseOID(content, content + len, maxLength);
3387
- // case 0x07: // ObjectDescriptor
3388
- // case 0x08: // EXTERNAL
3389
- // case 0x09: // REAL
3390
- // case 0x0A: // ENUMERATED
3391
- // case 0x0B: // EMBEDDED_PDV
3392
- case 16:
3393
- // SEQUENCE
3394
- case 17:
3395
- if (this.sub !== null) {
3396
- return "(" + this.sub.length + " elem)";
3397
- } else {
3398
- return "(no elem)";
3399
- }
3400
- case 12:
3401
- return stringCut(this.stream.parseStringUTF(content, content + len), maxLength);
3402
- case 18:
3403
- // NumericString
3404
- case 19:
3405
- // PrintableString
3406
- case 20:
3407
- // TeletexString
3408
- case 21:
3409
- // VideotexString
3410
- case 22:
3411
- // IA5String
3412
- // case 0x19: // GraphicString
3413
- case 26:
3414
- return stringCut(this.stream.parseStringISO(content, content + len), maxLength);
3415
- case 30:
3416
- return stringCut(this.stream.parseStringBMP(content, content + len), maxLength);
3417
- case 23:
3418
- // UTCTime
3419
- case 24:
3420
- return this.stream.parseTime(content, content + len, this.tag.tagNumber == 23);
3421
- }
3422
- return null;
3423
- };
3424
- ASN12.prototype.toString = function() {
3425
- return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + (this.sub === null ? "null" : this.sub.length) + "]";
3426
- };
3427
- ASN12.prototype.toPrettyString = function(indent) {
3428
- if (indent === void 0) {
3429
- indent = "";
3430
- }
3431
- var s = indent + this.typeName() + " @" + this.stream.pos;
3432
- if (this.length >= 0) {
3433
- s += "+";
3434
- }
3435
- s += this.length;
3436
- if (this.tag.tagConstructed) {
3437
- s += " (constructed)";
3438
- } else if (this.tag.isUniversal() && (this.tag.tagNumber == 3 || this.tag.tagNumber == 4) && this.sub !== null) {
3439
- s += " (encapsulates)";
3440
- }
3441
- s += "\n";
3442
- if (this.sub !== null) {
3443
- indent += " ";
3444
- for (var i = 0, max2 = this.sub.length; i < max2; ++i) {
3445
- s += this.sub[i].toPrettyString(indent);
3446
- }
3447
- }
3448
- return s;
3449
- };
3450
- ASN12.prototype.posStart = function() {
3451
- return this.stream.pos;
3452
- };
3453
- ASN12.prototype.posContent = function() {
3454
- return this.stream.pos + this.header;
3455
- };
3456
- ASN12.prototype.posEnd = function() {
3457
- return this.stream.pos + this.header + Math.abs(this.length);
3458
- };
3459
- ASN12.prototype.toHexString = function() {
3460
- return this.stream.hexDump(this.posStart(), this.posEnd(), true);
3461
- };
3462
- ASN12.decodeLength = function(stream) {
3463
- var buf = stream.get();
3464
- var len = buf & 127;
3465
- if (len == buf) {
3466
- return len;
3467
- }
3468
- if (len > 6) {
3469
- throw new Error("Length over 48 bits not supported at position " + (stream.pos - 1));
3470
- }
3471
- if (len === 0) {
3472
- return null;
3473
- }
3474
- buf = 0;
3475
- for (var i = 0; i < len; ++i) {
3476
- buf = buf * 256 + stream.get();
3477
- }
3478
- return buf;
3479
- };
3480
- ASN12.prototype.getHexStringValue = function() {
3481
- var hexString = this.toHexString();
3482
- var offset = this.header * 2;
3483
- var length = this.length * 2;
3484
- return hexString.substring(offset, offset + length);
3485
- };
3486
- ASN12.decode = function(str) {
3487
- var stream;
3488
- if (!(str instanceof Stream)) {
3489
- stream = new Stream(str, 0);
3490
- } else {
3491
- stream = str;
3492
- }
3493
- var streamStart = new Stream(stream);
3494
- var tag = new ASN1Tag(stream);
3495
- var len = ASN12.decodeLength(stream);
3496
- var start = stream.pos;
3497
- var header = start - streamStart.pos;
3498
- var sub = null;
3499
- var getSub = function() {
3500
- var ret = [];
3501
- if (len !== null) {
3502
- var end = start + len;
3503
- while (stream.pos < end) {
3504
- ret[ret.length] = ASN12.decode(stream);
3505
- }
3506
- if (stream.pos != end) {
3507
- throw new Error("Content size is not correct for container starting at offset " + start);
3508
- }
3509
- } else {
3510
- try {
3511
- for (; ; ) {
3512
- var s = ASN12.decode(stream);
3513
- if (s.tag.isEOC()) {
3514
- break;
3515
- }
3516
- ret[ret.length] = s;
3517
- }
3518
- len = start - stream.pos;
3519
- } catch (e) {
3520
- throw new Error("Exception while decoding undefined length content: " + e);
3521
- }
3522
- }
3523
- return ret;
3524
- };
3525
- if (tag.tagConstructed) {
3526
- sub = getSub();
3527
- } else if (tag.isUniversal() && (tag.tagNumber == 3 || tag.tagNumber == 4)) {
3528
- try {
3529
- if (tag.tagNumber == 3) {
3530
- if (stream.get() != 0) {
3531
- throw new Error("BIT STRINGs with unused bits cannot encapsulate.");
3532
- }
3533
- }
3534
- sub = getSub();
3535
- for (var i = 0; i < sub.length; ++i) {
3536
- if (sub[i].tag.isEOC()) {
3537
- throw new Error("EOC is not supposed to be actual content.");
3538
- }
3539
- }
3540
- } catch (e) {
3541
- sub = null;
3542
- }
3543
- }
3544
- if (sub === null) {
3545
- if (len === null) {
3546
- throw new Error("We can't skip over an invalid tag with undefined length at offset " + start);
3547
- }
3548
- stream.pos = start + Math.abs(len);
3549
- }
3550
- return new ASN12(streamStart, header, len, tag, sub);
3551
- };
3552
- return ASN12;
3553
- })()
3554
- );
3555
- var ASN1Tag = (
3556
- /** @class */
3557
- (function() {
3558
- function ASN1Tag2(stream) {
3559
- var buf = stream.get();
3560
- this.tagClass = buf >> 6;
3561
- this.tagConstructed = (buf & 32) !== 0;
3562
- this.tagNumber = buf & 31;
3563
- if (this.tagNumber == 31) {
3564
- var n = new Int10();
3565
- do {
3566
- buf = stream.get();
3567
- n.mulAdd(128, buf & 127);
3568
- } while (buf & 128);
3569
- this.tagNumber = n.simplify();
3570
- }
3571
- }
3572
- ASN1Tag2.prototype.isUniversal = function() {
3573
- return this.tagClass === 0;
3574
- };
3575
- ASN1Tag2.prototype.isEOC = function() {
3576
- return this.tagClass === 0 && this.tagNumber === 0;
3577
- };
3578
- return ASN1Tag2;
3579
- })()
3580
- );
3581
- var dbits;
3582
- var canary = 244837814094590;
3583
- var j_lm = (canary & 16777215) == 15715070;
3584
- var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
3585
- var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
3586
- var BigInteger = (
3587
- /** @class */
3588
- (function() {
3589
- function BigInteger2(a, b, c) {
3590
- if (a != null) {
3591
- if ("number" == typeof a) {
3592
- this.fromNumber(a, b, c);
3593
- } else if (b == null && "string" != typeof a) {
3594
- this.fromString(a, 256);
3595
- } else {
3596
- this.fromString(a, b);
3597
- }
3598
- }
3599
- }
3600
- BigInteger2.prototype.toString = function(b) {
3601
- if (this.s < 0) {
3602
- return "-" + this.negate().toString(b);
3603
- }
3604
- var k;
3605
- if (b == 16) {
3606
- k = 4;
3607
- } else if (b == 8) {
3608
- k = 3;
3609
- } else if (b == 2) {
3610
- k = 1;
3611
- } else if (b == 32) {
3612
- k = 5;
3613
- } else if (b == 4) {
3614
- k = 2;
3615
- } else {
3616
- return this.toRadix(b);
3617
- }
3618
- var km = (1 << k) - 1;
3619
- var d;
3620
- var m = false;
3621
- var r = "";
3622
- var i = this.t;
3623
- var p = this.DB - i * this.DB % k;
3624
- if (i-- > 0) {
3625
- if (p < this.DB && (d = this[i] >> p) > 0) {
3626
- m = true;
3627
- r = int2char(d);
3628
- }
3629
- while (i >= 0) {
3630
- if (p < k) {
3631
- d = (this[i] & (1 << p) - 1) << k - p;
3632
- d |= this[--i] >> (p += this.DB - k);
3633
- } else {
3634
- d = this[i] >> (p -= k) & km;
3635
- if (p <= 0) {
3636
- p += this.DB;
3637
- --i;
3638
- }
3639
- }
3640
- if (d > 0) {
3641
- m = true;
3642
- }
3643
- if (m) {
3644
- r += int2char(d);
3645
- }
3646
- }
3647
- }
3648
- return m ? r : "0";
3649
- };
3650
- BigInteger2.prototype.negate = function() {
3651
- var r = nbi();
3652
- BigInteger2.ZERO.subTo(this, r);
3653
- return r;
3654
- };
3655
- BigInteger2.prototype.abs = function() {
3656
- return this.s < 0 ? this.negate() : this;
3657
- };
3658
- BigInteger2.prototype.compareTo = function(a) {
3659
- var r = this.s - a.s;
3660
- if (r != 0) {
3661
- return r;
3662
- }
3663
- var i = this.t;
3664
- r = i - a.t;
3665
- if (r != 0) {
3666
- return this.s < 0 ? -r : r;
3667
- }
3668
- while (--i >= 0) {
3669
- if ((r = this[i] - a[i]) != 0) {
3670
- return r;
3671
- }
3672
- }
3673
- return 0;
3674
- };
3675
- BigInteger2.prototype.bitLength = function() {
3676
- if (this.t <= 0) {
3677
- return 0;
3678
- }
3679
- return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);
3680
- };
3681
- BigInteger2.prototype.mod = function(a) {
3682
- var r = nbi();
3683
- this.abs().divRemTo(a, null, r);
3684
- if (this.s < 0 && r.compareTo(BigInteger2.ZERO) > 0) {
3685
- a.subTo(r, r);
3686
- }
3687
- return r;
3688
- };
3689
- BigInteger2.prototype.modPowInt = function(e, m) {
3690
- var z;
3691
- if (e < 256 || m.isEven()) {
3692
- z = new Classic(m);
3693
- } else {
3694
- z = new Montgomery(m);
3695
- }
3696
- return this.exp(e, z);
3697
- };
3698
- BigInteger2.prototype.clone = function() {
3699
- var r = nbi();
3700
- this.copyTo(r);
3701
- return r;
3702
- };
3703
- BigInteger2.prototype.intValue = function() {
3704
- if (this.s < 0) {
3705
- if (this.t == 1) {
3706
- return this[0] - this.DV;
3707
- } else if (this.t == 0) {
3708
- return -1;
3709
- }
3710
- } else if (this.t == 1) {
3711
- return this[0];
3712
- } else if (this.t == 0) {
3713
- return 0;
3714
- }
3715
- return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0];
3716
- };
3717
- BigInteger2.prototype.byteValue = function() {
3718
- return this.t == 0 ? this.s : this[0] << 24 >> 24;
3719
- };
3720
- BigInteger2.prototype.shortValue = function() {
3721
- return this.t == 0 ? this.s : this[0] << 16 >> 16;
3722
- };
3723
- BigInteger2.prototype.signum = function() {
3724
- if (this.s < 0) {
3725
- return -1;
3726
- } else if (this.t <= 0 || this.t == 1 && this[0] <= 0) {
3727
- return 0;
3728
- } else {
3729
- return 1;
3730
- }
3731
- };
3732
- BigInteger2.prototype.toByteArray = function() {
3733
- var i = this.t;
3734
- var r = [];
3735
- r[0] = this.s;
3736
- var p = this.DB - i * this.DB % 8;
3737
- var d;
3738
- var k = 0;
3739
- if (i-- > 0) {
3740
- if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) {
3741
- r[k++] = d | this.s << this.DB - p;
3742
- }
3743
- while (i >= 0) {
3744
- if (p < 8) {
3745
- d = (this[i] & (1 << p) - 1) << 8 - p;
3746
- d |= this[--i] >> (p += this.DB - 8);
3747
- } else {
3748
- d = this[i] >> (p -= 8) & 255;
3749
- if (p <= 0) {
3750
- p += this.DB;
3751
- --i;
3752
- }
3753
- }
3754
- if ((d & 128) != 0) {
3755
- d |= -256;
3756
- }
3757
- if (k == 0 && (this.s & 128) != (d & 128)) {
3758
- ++k;
3759
- }
3760
- if (k > 0 || d != this.s) {
3761
- r[k++] = d;
3762
- }
3763
- }
3764
- }
3765
- return r;
3766
- };
3767
- BigInteger2.prototype.equals = function(a) {
3768
- return this.compareTo(a) == 0;
3769
- };
3770
- BigInteger2.prototype.min = function(a) {
3771
- return this.compareTo(a) < 0 ? this : a;
3772
- };
3773
- BigInteger2.prototype.max = function(a) {
3774
- return this.compareTo(a) > 0 ? this : a;
3775
- };
3776
- BigInteger2.prototype.and = function(a) {
3777
- var r = nbi();
3778
- this.bitwiseTo(a, op_and, r);
3779
- return r;
3780
- };
3781
- BigInteger2.prototype.or = function(a) {
3782
- var r = nbi();
3783
- this.bitwiseTo(a, op_or, r);
3784
- return r;
3785
- };
3786
- BigInteger2.prototype.xor = function(a) {
3787
- var r = nbi();
3788
- this.bitwiseTo(a, op_xor, r);
3789
- return r;
3790
- };
3791
- BigInteger2.prototype.andNot = function(a) {
3792
- var r = nbi();
3793
- this.bitwiseTo(a, op_andnot, r);
3794
- return r;
3795
- };
3796
- BigInteger2.prototype.not = function() {
3797
- var r = nbi();
3798
- for (var i = 0; i < this.t; ++i) {
3799
- r[i] = this.DM & ~this[i];
3800
- }
3801
- r.t = this.t;
3802
- r.s = ~this.s;
3803
- return r;
3804
- };
3805
- BigInteger2.prototype.shiftLeft = function(n) {
3806
- var r = nbi();
3807
- if (n < 0) {
3808
- this.rShiftTo(-n, r);
3809
- } else {
3810
- this.lShiftTo(n, r);
3811
- }
3812
- return r;
3813
- };
3814
- BigInteger2.prototype.shiftRight = function(n) {
3815
- var r = nbi();
3816
- if (n < 0) {
3817
- this.lShiftTo(-n, r);
3818
- } else {
3819
- this.rShiftTo(n, r);
3820
- }
3821
- return r;
3822
- };
3823
- BigInteger2.prototype.getLowestSetBit = function() {
3824
- for (var i = 0; i < this.t; ++i) {
3825
- if (this[i] != 0) {
3826
- return i * this.DB + lbit(this[i]);
3827
- }
3828
- }
3829
- if (this.s < 0) {
3830
- return this.t * this.DB;
3831
- }
3832
- return -1;
3833
- };
3834
- BigInteger2.prototype.bitCount = function() {
3835
- var r = 0;
3836
- var x = this.s & this.DM;
3837
- for (var i = 0; i < this.t; ++i) {
3838
- r += cbit(this[i] ^ x);
3839
- }
3840
- return r;
3841
- };
3842
- BigInteger2.prototype.testBit = function(n) {
3843
- var j = Math.floor(n / this.DB);
3844
- if (j >= this.t) {
3845
- return this.s != 0;
3846
- }
3847
- return (this[j] & 1 << n % this.DB) != 0;
3848
- };
3849
- BigInteger2.prototype.setBit = function(n) {
3850
- return this.changeBit(n, op_or);
3851
- };
3852
- BigInteger2.prototype.clearBit = function(n) {
3853
- return this.changeBit(n, op_andnot);
3854
- };
3855
- BigInteger2.prototype.flipBit = function(n) {
3856
- return this.changeBit(n, op_xor);
3857
- };
3858
- BigInteger2.prototype.add = function(a) {
3859
- var r = nbi();
3860
- this.addTo(a, r);
3861
- return r;
3862
- };
3863
- BigInteger2.prototype.subtract = function(a) {
3864
- var r = nbi();
3865
- this.subTo(a, r);
3866
- return r;
3867
- };
3868
- BigInteger2.prototype.multiply = function(a) {
3869
- var r = nbi();
3870
- this.multiplyTo(a, r);
3871
- return r;
3872
- };
3873
- BigInteger2.prototype.divide = function(a) {
3874
- var r = nbi();
3875
- this.divRemTo(a, r, null);
3876
- return r;
3877
- };
3878
- BigInteger2.prototype.remainder = function(a) {
3879
- var r = nbi();
3880
- this.divRemTo(a, null, r);
3881
- return r;
3882
- };
3883
- BigInteger2.prototype.divideAndRemainder = function(a) {
3884
- var q = nbi();
3885
- var r = nbi();
3886
- this.divRemTo(a, q, r);
3887
- return [q, r];
3888
- };
3889
- BigInteger2.prototype.modPow = function(e, m) {
3890
- var i = e.bitLength();
3891
- var k;
3892
- var r = nbv(1);
3893
- var z;
3894
- if (i <= 0) {
3895
- return r;
3896
- } else if (i < 18) {
3897
- k = 1;
3898
- } else if (i < 48) {
3899
- k = 3;
3900
- } else if (i < 144) {
3901
- k = 4;
3902
- } else if (i < 768) {
3903
- k = 5;
3904
- } else {
3905
- k = 6;
3906
- }
3907
- if (i < 8) {
3908
- z = new Classic(m);
3909
- } else if (m.isEven()) {
3910
- z = new Barrett(m);
3911
- } else {
3912
- z = new Montgomery(m);
3913
- }
3914
- var g = [];
3915
- var n = 3;
3916
- var k1 = k - 1;
3917
- var km = (1 << k) - 1;
3918
- g[1] = z.convert(this);
3919
- if (k > 1) {
3920
- var g2 = nbi();
3921
- z.sqrTo(g[1], g2);
3922
- while (n <= km) {
3923
- g[n] = nbi();
3924
- z.mulTo(g2, g[n - 2], g[n]);
3925
- n += 2;
3926
- }
3927
- }
3928
- var j = e.t - 1;
3929
- var w;
3930
- var is1 = true;
3931
- var r2 = nbi();
3932
- var t;
3933
- i = nbits(e[j]) - 1;
3934
- while (j >= 0) {
3935
- if (i >= k1) {
3936
- w = e[j] >> i - k1 & km;
3937
- } else {
3938
- w = (e[j] & (1 << i + 1) - 1) << k1 - i;
3939
- if (j > 0) {
3940
- w |= e[j - 1] >> this.DB + i - k1;
3941
- }
3942
- }
3943
- n = k;
3944
- while ((w & 1) == 0) {
3945
- w >>= 1;
3946
- --n;
3947
- }
3948
- if ((i -= n) < 0) {
3949
- i += this.DB;
3950
- --j;
3951
- }
3952
- if (is1) {
3953
- g[w].copyTo(r);
3954
- is1 = false;
3955
- } else {
3956
- while (n > 1) {
3957
- z.sqrTo(r, r2);
3958
- z.sqrTo(r2, r);
3959
- n -= 2;
3960
- }
3961
- if (n > 0) {
3962
- z.sqrTo(r, r2);
3963
- } else {
3964
- t = r;
3965
- r = r2;
3966
- r2 = t;
3967
- }
3968
- z.mulTo(r2, g[w], r);
3969
- }
3970
- while (j >= 0 && (e[j] & 1 << i) == 0) {
3971
- z.sqrTo(r, r2);
3972
- t = r;
3973
- r = r2;
3974
- r2 = t;
3975
- if (--i < 0) {
3976
- i = this.DB - 1;
3977
- --j;
3978
- }
3979
- }
3980
- }
3981
- return z.revert(r);
3982
- };
3983
- BigInteger2.prototype.modInverse = function(m) {
3984
- var ac = m.isEven();
3985
- if (this.isEven() && ac || m.signum() == 0) {
3986
- return BigInteger2.ZERO;
3987
- }
3988
- var u = m.clone();
3989
- var v = this.clone();
3990
- var a = nbv(1);
3991
- var b = nbv(0);
3992
- var c = nbv(0);
3993
- var d = nbv(1);
3994
- while (u.signum() != 0) {
3995
- while (u.isEven()) {
3996
- u.rShiftTo(1, u);
3997
- if (ac) {
3998
- if (!a.isEven() || !b.isEven()) {
3999
- a.addTo(this, a);
4000
- b.subTo(m, b);
4001
- }
4002
- a.rShiftTo(1, a);
4003
- } else if (!b.isEven()) {
4004
- b.subTo(m, b);
4005
- }
4006
- b.rShiftTo(1, b);
4007
- }
4008
- while (v.isEven()) {
4009
- v.rShiftTo(1, v);
4010
- if (ac) {
4011
- if (!c.isEven() || !d.isEven()) {
4012
- c.addTo(this, c);
4013
- d.subTo(m, d);
4014
- }
4015
- c.rShiftTo(1, c);
4016
- } else if (!d.isEven()) {
4017
- d.subTo(m, d);
4018
- }
4019
- d.rShiftTo(1, d);
4020
- }
4021
- if (u.compareTo(v) >= 0) {
4022
- u.subTo(v, u);
4023
- if (ac) {
4024
- a.subTo(c, a);
4025
- }
4026
- b.subTo(d, b);
4027
- } else {
4028
- v.subTo(u, v);
4029
- if (ac) {
4030
- c.subTo(a, c);
4031
- }
4032
- d.subTo(b, d);
4033
- }
4034
- }
4035
- if (v.compareTo(BigInteger2.ONE) != 0) {
4036
- return BigInteger2.ZERO;
4037
- }
4038
- if (d.compareTo(m) >= 0) {
4039
- return d.subtract(m);
4040
- }
4041
- if (d.signum() < 0) {
4042
- d.addTo(m, d);
4043
- } else {
4044
- return d;
4045
- }
4046
- if (d.signum() < 0) {
4047
- return d.add(m);
4048
- } else {
4049
- return d;
4050
- }
4051
- };
4052
- BigInteger2.prototype.pow = function(e) {
4053
- return this.exp(e, new NullExp());
4054
- };
4055
- BigInteger2.prototype.gcd = function(a) {
4056
- var x = this.s < 0 ? this.negate() : this.clone();
4057
- var y = a.s < 0 ? a.negate() : a.clone();
4058
- if (x.compareTo(y) < 0) {
4059
- var t = x;
4060
- x = y;
4061
- y = t;
4062
- }
4063
- var i = x.getLowestSetBit();
4064
- var g = y.getLowestSetBit();
4065
- if (g < 0) {
4066
- return x;
4067
- }
4068
- if (i < g) {
4069
- g = i;
4070
- }
4071
- if (g > 0) {
4072
- x.rShiftTo(g, x);
4073
- y.rShiftTo(g, y);
4074
- }
4075
- while (x.signum() > 0) {
4076
- if ((i = x.getLowestSetBit()) > 0) {
4077
- x.rShiftTo(i, x);
4078
- }
4079
- if ((i = y.getLowestSetBit()) > 0) {
4080
- y.rShiftTo(i, y);
4081
- }
4082
- if (x.compareTo(y) >= 0) {
4083
- x.subTo(y, x);
4084
- x.rShiftTo(1, x);
4085
- } else {
4086
- y.subTo(x, y);
4087
- y.rShiftTo(1, y);
4088
- }
4089
- }
4090
- if (g > 0) {
4091
- y.lShiftTo(g, y);
4092
- }
4093
- return y;
4094
- };
4095
- BigInteger2.prototype.isProbablePrime = function(t) {
4096
- var i;
4097
- var x = this.abs();
4098
- if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
4099
- for (i = 0; i < lowprimes.length; ++i) {
4100
- if (x[0] == lowprimes[i]) {
4101
- return true;
4102
- }
4103
- }
4104
- return false;
4105
- }
4106
- if (x.isEven()) {
4107
- return false;
4108
- }
4109
- i = 1;
4110
- while (i < lowprimes.length) {
4111
- var m = lowprimes[i];
4112
- var j = i + 1;
4113
- while (j < lowprimes.length && m < lplim) {
4114
- m *= lowprimes[j++];
4115
- }
4116
- m = x.modInt(m);
4117
- while (i < j) {
4118
- if (m % lowprimes[i++] == 0) {
4119
- return false;
4120
- }
4121
- }
4122
- }
4123
- return x.millerRabin(t);
4124
- };
4125
- BigInteger2.prototype.copyTo = function(r) {
4126
- for (var i = this.t - 1; i >= 0; --i) {
4127
- r[i] = this[i];
4128
- }
4129
- r.t = this.t;
4130
- r.s = this.s;
4131
- };
4132
- BigInteger2.prototype.fromInt = function(x) {
4133
- this.t = 1;
4134
- this.s = x < 0 ? -1 : 0;
4135
- if (x > 0) {
4136
- this[0] = x;
4137
- } else if (x < -1) {
4138
- this[0] = x + this.DV;
4139
- } else {
4140
- this.t = 0;
4141
- }
4142
- };
4143
- BigInteger2.prototype.fromString = function(s, b) {
4144
- var k;
4145
- if (b == 16) {
4146
- k = 4;
4147
- } else if (b == 8) {
4148
- k = 3;
4149
- } else if (b == 256) {
4150
- k = 8;
4151
- } else if (b == 2) {
4152
- k = 1;
4153
- } else if (b == 32) {
4154
- k = 5;
4155
- } else if (b == 4) {
4156
- k = 2;
4157
- } else {
4158
- this.fromRadix(s, b);
4159
- return;
4160
- }
4161
- this.t = 0;
4162
- this.s = 0;
4163
- var i = s.length;
4164
- var mi = false;
4165
- var sh = 0;
4166
- while (--i >= 0) {
4167
- var x = k == 8 ? +s[i] & 255 : intAt(s, i);
4168
- if (x < 0) {
4169
- if (s.charAt(i) == "-") {
4170
- mi = true;
4171
- }
4172
- continue;
4173
- }
4174
- mi = false;
4175
- if (sh == 0) {
4176
- this[this.t++] = x;
4177
- } else if (sh + k > this.DB) {
4178
- this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;
4179
- this[this.t++] = x >> this.DB - sh;
4180
- } else {
4181
- this[this.t - 1] |= x << sh;
4182
- }
4183
- sh += k;
4184
- if (sh >= this.DB) {
4185
- sh -= this.DB;
4186
- }
4187
- }
4188
- if (k == 8 && (+s[0] & 128) != 0) {
4189
- this.s = -1;
4190
- if (sh > 0) {
4191
- this[this.t - 1] |= (1 << this.DB - sh) - 1 << sh;
4192
- }
4193
- }
4194
- this.clamp();
4195
- if (mi) {
4196
- BigInteger2.ZERO.subTo(this, this);
4197
- }
4198
- };
4199
- BigInteger2.prototype.clamp = function() {
4200
- var c = this.s & this.DM;
4201
- while (this.t > 0 && this[this.t - 1] == c) {
4202
- --this.t;
4203
- }
4204
- };
4205
- BigInteger2.prototype.dlShiftTo = function(n, r) {
4206
- var i;
4207
- for (i = this.t - 1; i >= 0; --i) {
4208
- r[i + n] = this[i];
4209
- }
4210
- for (i = n - 1; i >= 0; --i) {
4211
- r[i] = 0;
4212
- }
4213
- r.t = this.t + n;
4214
- r.s = this.s;
4215
- };
4216
- BigInteger2.prototype.drShiftTo = function(n, r) {
4217
- for (var i = n; i < this.t; ++i) {
4218
- r[i - n] = this[i];
4219
- }
4220
- r.t = Math.max(this.t - n, 0);
4221
- r.s = this.s;
4222
- };
4223
- BigInteger2.prototype.lShiftTo = function(n, r) {
4224
- var bs = n % this.DB;
4225
- var cbs = this.DB - bs;
4226
- var bm = (1 << cbs) - 1;
4227
- var ds = Math.floor(n / this.DB);
4228
- var c = this.s << bs & this.DM;
4229
- for (var i = this.t - 1; i >= 0; --i) {
4230
- r[i + ds + 1] = this[i] >> cbs | c;
4231
- c = (this[i] & bm) << bs;
4232
- }
4233
- for (var i = ds - 1; i >= 0; --i) {
4234
- r[i] = 0;
4235
- }
4236
- r[ds] = c;
4237
- r.t = this.t + ds + 1;
4238
- r.s = this.s;
4239
- r.clamp();
4240
- };
4241
- BigInteger2.prototype.rShiftTo = function(n, r) {
4242
- r.s = this.s;
4243
- var ds = Math.floor(n / this.DB);
4244
- if (ds >= this.t) {
4245
- r.t = 0;
4246
- return;
4247
- }
4248
- var bs = n % this.DB;
4249
- var cbs = this.DB - bs;
4250
- var bm = (1 << bs) - 1;
4251
- r[0] = this[ds] >> bs;
4252
- for (var i = ds + 1; i < this.t; ++i) {
4253
- r[i - ds - 1] |= (this[i] & bm) << cbs;
4254
- r[i - ds] = this[i] >> bs;
4255
- }
4256
- if (bs > 0) {
4257
- r[this.t - ds - 1] |= (this.s & bm) << cbs;
4258
- }
4259
- r.t = this.t - ds;
4260
- r.clamp();
4261
- };
4262
- BigInteger2.prototype.subTo = function(a, r) {
4263
- var i = 0;
4264
- var c = 0;
4265
- var m = Math.min(a.t, this.t);
4266
- while (i < m) {
4267
- c += this[i] - a[i];
4268
- r[i++] = c & this.DM;
4269
- c >>= this.DB;
4270
- }
4271
- if (a.t < this.t) {
4272
- c -= a.s;
4273
- while (i < this.t) {
4274
- c += this[i];
4275
- r[i++] = c & this.DM;
4276
- c >>= this.DB;
4277
- }
4278
- c += this.s;
4279
- } else {
4280
- c += this.s;
4281
- while (i < a.t) {
4282
- c -= a[i];
4283
- r[i++] = c & this.DM;
4284
- c >>= this.DB;
4285
- }
4286
- c -= a.s;
4287
- }
4288
- r.s = c < 0 ? -1 : 0;
4289
- if (c < -1) {
4290
- r[i++] = this.DV + c;
4291
- } else if (c > 0) {
4292
- r[i++] = c;
4293
- }
4294
- r.t = i;
4295
- r.clamp();
4296
- };
4297
- BigInteger2.prototype.multiplyTo = function(a, r) {
4298
- var x = this.abs();
4299
- var y = a.abs();
4300
- var i = x.t;
4301
- r.t = i + y.t;
4302
- while (--i >= 0) {
4303
- r[i] = 0;
4304
- }
4305
- for (i = 0; i < y.t; ++i) {
4306
- r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
4307
- }
4308
- r.s = 0;
4309
- r.clamp();
4310
- if (this.s != a.s) {
4311
- BigInteger2.ZERO.subTo(r, r);
4312
- }
4313
- };
4314
- BigInteger2.prototype.squareTo = function(r) {
4315
- var x = this.abs();
4316
- var i = r.t = 2 * x.t;
4317
- while (--i >= 0) {
4318
- r[i] = 0;
4319
- }
4320
- for (i = 0; i < x.t - 1; ++i) {
4321
- var c = x.am(i, x[i], r, 2 * i, 0, 1);
4322
- if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
4323
- r[i + x.t] -= x.DV;
4324
- r[i + x.t + 1] = 1;
4325
- }
4326
- }
4327
- if (r.t > 0) {
4328
- r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
4329
- }
4330
- r.s = 0;
4331
- r.clamp();
4332
- };
4333
- BigInteger2.prototype.divRemTo = function(m, q, r) {
4334
- var pm = m.abs();
4335
- if (pm.t <= 0) {
4336
- return;
4337
- }
4338
- var pt = this.abs();
4339
- if (pt.t < pm.t) {
4340
- if (q != null) {
4341
- q.fromInt(0);
4342
- }
4343
- if (r != null) {
4344
- this.copyTo(r);
4345
- }
4346
- return;
4347
- }
4348
- if (r == null) {
4349
- r = nbi();
4350
- }
4351
- var y = nbi();
4352
- var ts = this.s;
4353
- var ms = m.s;
4354
- var nsh = this.DB - nbits(pm[pm.t - 1]);
4355
- if (nsh > 0) {
4356
- pm.lShiftTo(nsh, y);
4357
- pt.lShiftTo(nsh, r);
4358
- } else {
4359
- pm.copyTo(y);
4360
- pt.copyTo(r);
4361
- }
4362
- var ys = y.t;
4363
- var y0 = y[ys - 1];
4364
- if (y0 == 0) {
4365
- return;
4366
- }
4367
- var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);
4368
- var d1 = this.FV / yt;
4369
- var d2 = (1 << this.F1) / yt;
4370
- var e = 1 << this.F2;
4371
- var i = r.t;
4372
- var j = i - ys;
4373
- var t = q == null ? nbi() : q;
4374
- y.dlShiftTo(j, t);
4375
- if (r.compareTo(t) >= 0) {
4376
- r[r.t++] = 1;
4377
- r.subTo(t, r);
4378
- }
4379
- BigInteger2.ONE.dlShiftTo(ys, t);
4380
- t.subTo(y, y);
4381
- while (y.t < ys) {
4382
- y[y.t++] = 0;
4383
- }
4384
- while (--j >= 0) {
4385
- var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
4386
- if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {
4387
- y.dlShiftTo(j, t);
4388
- r.subTo(t, r);
4389
- while (r[i] < --qd) {
4390
- r.subTo(t, r);
4391
- }
4392
- }
4393
- }
4394
- if (q != null) {
4395
- r.drShiftTo(ys, q);
4396
- if (ts != ms) {
4397
- BigInteger2.ZERO.subTo(q, q);
4398
- }
4399
- }
4400
- r.t = ys;
4401
- r.clamp();
4402
- if (nsh > 0) {
4403
- r.rShiftTo(nsh, r);
4404
- }
4405
- if (ts < 0) {
4406
- BigInteger2.ZERO.subTo(r, r);
4407
- }
4408
- };
4409
- BigInteger2.prototype.invDigit = function() {
4410
- if (this.t < 1) {
4411
- return 0;
4412
- }
4413
- var x = this[0];
4414
- if ((x & 1) == 0) {
4415
- return 0;
4416
- }
4417
- var y = x & 3;
4418
- y = y * (2 - (x & 15) * y) & 15;
4419
- y = y * (2 - (x & 255) * y) & 255;
4420
- y = y * (2 - ((x & 65535) * y & 65535)) & 65535;
4421
- y = y * (2 - x * y % this.DV) % this.DV;
4422
- return y > 0 ? this.DV - y : -y;
4423
- };
4424
- BigInteger2.prototype.isEven = function() {
4425
- return (this.t > 0 ? this[0] & 1 : this.s) == 0;
4426
- };
4427
- BigInteger2.prototype.exp = function(e, z) {
4428
- if (e > 4294967295 || e < 1) {
4429
- return BigInteger2.ONE;
4430
- }
4431
- var r = nbi();
4432
- var r2 = nbi();
4433
- var g = z.convert(this);
4434
- var i = nbits(e) - 1;
4435
- g.copyTo(r);
4436
- while (--i >= 0) {
4437
- z.sqrTo(r, r2);
4438
- if ((e & 1 << i) > 0) {
4439
- z.mulTo(r2, g, r);
4440
- } else {
4441
- var t = r;
4442
- r = r2;
4443
- r2 = t;
4444
- }
4445
- }
4446
- return z.revert(r);
4447
- };
4448
- BigInteger2.prototype.chunkSize = function(r) {
4449
- return Math.floor(Math.LN2 * this.DB / Math.log(r));
4450
- };
4451
- BigInteger2.prototype.toRadix = function(b) {
4452
- if (b == null) {
4453
- b = 10;
4454
- }
4455
- if (this.signum() == 0 || b < 2 || b > 36) {
4456
- return "0";
4457
- }
4458
- var cs = this.chunkSize(b);
4459
- var a = Math.pow(b, cs);
4460
- var d = nbv(a);
4461
- var y = nbi();
4462
- var z = nbi();
4463
- var r = "";
4464
- this.divRemTo(d, y, z);
4465
- while (y.signum() > 0) {
4466
- r = (a + z.intValue()).toString(b).substring(1) + r;
4467
- y.divRemTo(d, y, z);
4468
- }
4469
- return z.intValue().toString(b) + r;
4470
- };
4471
- BigInteger2.prototype.fromRadix = function(s, b) {
4472
- this.fromInt(0);
4473
- if (b == null) {
4474
- b = 10;
4475
- }
4476
- var cs = this.chunkSize(b);
4477
- var d = Math.pow(b, cs);
4478
- var mi = false;
4479
- var j = 0;
4480
- var w = 0;
4481
- for (var i = 0; i < s.length; ++i) {
4482
- var x = intAt(s, i);
4483
- if (x < 0) {
4484
- if (s.charAt(i) == "-" && this.signum() == 0) {
4485
- mi = true;
4486
- }
4487
- continue;
4488
- }
4489
- w = b * w + x;
4490
- if (++j >= cs) {
4491
- this.dMultiply(d);
4492
- this.dAddOffset(w, 0);
4493
- j = 0;
4494
- w = 0;
4495
- }
4496
- }
4497
- if (j > 0) {
4498
- this.dMultiply(Math.pow(b, j));
4499
- this.dAddOffset(w, 0);
4500
- }
4501
- if (mi) {
4502
- BigInteger2.ZERO.subTo(this, this);
4503
- }
4504
- };
4505
- BigInteger2.prototype.fromNumber = function(a, b, c) {
4506
- if ("number" == typeof b) {
4507
- if (a < 2) {
4508
- this.fromInt(1);
4509
- } else {
4510
- this.fromNumber(a, c);
4511
- if (!this.testBit(a - 1)) {
4512
- this.bitwiseTo(BigInteger2.ONE.shiftLeft(a - 1), op_or, this);
4513
- }
4514
- if (this.isEven()) {
4515
- this.dAddOffset(1, 0);
4516
- }
4517
- while (!this.isProbablePrime(b)) {
4518
- this.dAddOffset(2, 0);
4519
- if (this.bitLength() > a) {
4520
- this.subTo(BigInteger2.ONE.shiftLeft(a - 1), this);
4521
- }
4522
- }
4523
- }
4524
- } else {
4525
- var x = [];
4526
- var t = a & 7;
4527
- x.length = (a >> 3) + 1;
4528
- b.nextBytes(x);
4529
- if (t > 0) {
4530
- x[0] &= (1 << t) - 1;
4531
- } else {
4532
- x[0] = 0;
4533
- }
4534
- this.fromString(x, 256);
4535
- }
4536
- };
4537
- BigInteger2.prototype.bitwiseTo = function(a, op, r) {
4538
- var i;
4539
- var f;
4540
- var m = Math.min(a.t, this.t);
4541
- for (i = 0; i < m; ++i) {
4542
- r[i] = op(this[i], a[i]);
4543
- }
4544
- if (a.t < this.t) {
4545
- f = a.s & this.DM;
4546
- for (i = m; i < this.t; ++i) {
4547
- r[i] = op(this[i], f);
4548
- }
4549
- r.t = this.t;
4550
- } else {
4551
- f = this.s & this.DM;
4552
- for (i = m; i < a.t; ++i) {
4553
- r[i] = op(f, a[i]);
4554
- }
4555
- r.t = a.t;
4556
- }
4557
- r.s = op(this.s, a.s);
4558
- r.clamp();
4559
- };
4560
- BigInteger2.prototype.changeBit = function(n, op) {
4561
- var r = BigInteger2.ONE.shiftLeft(n);
4562
- this.bitwiseTo(r, op, r);
4563
- return r;
4564
- };
4565
- BigInteger2.prototype.addTo = function(a, r) {
4566
- var i = 0;
4567
- var c = 0;
4568
- var m = Math.min(a.t, this.t);
4569
- while (i < m) {
4570
- c += this[i] + a[i];
4571
- r[i++] = c & this.DM;
4572
- c >>= this.DB;
4573
- }
4574
- if (a.t < this.t) {
4575
- c += a.s;
4576
- while (i < this.t) {
4577
- c += this[i];
4578
- r[i++] = c & this.DM;
4579
- c >>= this.DB;
4580
- }
4581
- c += this.s;
4582
- } else {
4583
- c += this.s;
4584
- while (i < a.t) {
4585
- c += a[i];
4586
- r[i++] = c & this.DM;
4587
- c >>= this.DB;
4588
- }
4589
- c += a.s;
4590
- }
4591
- r.s = c < 0 ? -1 : 0;
4592
- if (c > 0) {
4593
- r[i++] = c;
4594
- } else if (c < -1) {
4595
- r[i++] = this.DV + c;
4596
- }
4597
- r.t = i;
4598
- r.clamp();
4599
- };
4600
- BigInteger2.prototype.dMultiply = function(n) {
4601
- this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
4602
- ++this.t;
4603
- this.clamp();
4604
- };
4605
- BigInteger2.prototype.dAddOffset = function(n, w) {
4606
- if (n == 0) {
4607
- return;
4608
- }
4609
- while (this.t <= w) {
4610
- this[this.t++] = 0;
4611
- }
4612
- this[w] += n;
4613
- while (this[w] >= this.DV) {
4614
- this[w] -= this.DV;
4615
- if (++w >= this.t) {
4616
- this[this.t++] = 0;
4617
- }
4618
- ++this[w];
4619
- }
4620
- };
4621
- BigInteger2.prototype.multiplyLowerTo = function(a, n, r) {
4622
- var i = Math.min(this.t + a.t, n);
4623
- r.s = 0;
4624
- r.t = i;
4625
- while (i > 0) {
4626
- r[--i] = 0;
4627
- }
4628
- for (var j = r.t - this.t; i < j; ++i) {
4629
- r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
4630
- }
4631
- for (var j = Math.min(a.t, n); i < j; ++i) {
4632
- this.am(0, a[i], r, i, 0, n - i);
4633
- }
4634
- r.clamp();
4635
- };
4636
- BigInteger2.prototype.multiplyUpperTo = function(a, n, r) {
4637
- --n;
4638
- var i = r.t = this.t + a.t - n;
4639
- r.s = 0;
4640
- while (--i >= 0) {
4641
- r[i] = 0;
4642
- }
4643
- for (i = Math.max(n - this.t, 0); i < a.t; ++i) {
4644
- r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
4645
- }
4646
- r.clamp();
4647
- r.drShiftTo(1, r);
4648
- };
4649
- BigInteger2.prototype.modInt = function(n) {
4650
- if (n <= 0) {
4651
- return 0;
4652
- }
4653
- var d = this.DV % n;
4654
- var r = this.s < 0 ? n - 1 : 0;
4655
- if (this.t > 0) {
4656
- if (d == 0) {
4657
- r = this[0] % n;
4658
- } else {
4659
- for (var i = this.t - 1; i >= 0; --i) {
4660
- r = (d * r + this[i]) % n;
4661
- }
4662
- }
4663
- }
4664
- return r;
4665
- };
4666
- BigInteger2.prototype.millerRabin = function(t) {
4667
- var n1 = this.subtract(BigInteger2.ONE);
4668
- var k = n1.getLowestSetBit();
4669
- if (k <= 0) {
4670
- return false;
4671
- }
4672
- var r = n1.shiftRight(k);
4673
- t = t + 1 >> 1;
4674
- if (t > lowprimes.length) {
4675
- t = lowprimes.length;
4676
- }
4677
- var a = nbi();
4678
- for (var i = 0; i < t; ++i) {
4679
- a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
4680
- var y = a.modPow(r, this);
4681
- if (y.compareTo(BigInteger2.ONE) != 0 && y.compareTo(n1) != 0) {
4682
- var j = 1;
4683
- while (j++ < k && y.compareTo(n1) != 0) {
4684
- y = y.modPowInt(2, this);
4685
- if (y.compareTo(BigInteger2.ONE) == 0) {
4686
- return false;
4687
- }
4688
- }
4689
- if (y.compareTo(n1) != 0) {
4690
- return false;
4691
- }
4692
- }
4693
- }
4694
- return true;
4695
- };
4696
- BigInteger2.prototype.square = function() {
4697
- var r = nbi();
4698
- this.squareTo(r);
4699
- return r;
4700
- };
4701
- BigInteger2.prototype.gcda = function(a, callback) {
4702
- var x = this.s < 0 ? this.negate() : this.clone();
4703
- var y = a.s < 0 ? a.negate() : a.clone();
4704
- if (x.compareTo(y) < 0) {
4705
- var t = x;
4706
- x = y;
4707
- y = t;
4708
- }
4709
- var i = x.getLowestSetBit();
4710
- var g = y.getLowestSetBit();
4711
- if (g < 0) {
4712
- callback(x);
4713
- return;
4714
- }
4715
- if (i < g) {
4716
- g = i;
4717
- }
4718
- if (g > 0) {
4719
- x.rShiftTo(g, x);
4720
- y.rShiftTo(g, y);
4721
- }
4722
- var gcda1 = function() {
4723
- if ((i = x.getLowestSetBit()) > 0) {
4724
- x.rShiftTo(i, x);
4725
- }
4726
- if ((i = y.getLowestSetBit()) > 0) {
4727
- y.rShiftTo(i, y);
4728
- }
4729
- if (x.compareTo(y) >= 0) {
4730
- x.subTo(y, x);
4731
- x.rShiftTo(1, x);
4732
- } else {
4733
- y.subTo(x, y);
4734
- y.rShiftTo(1, y);
4735
- }
4736
- if (!(x.signum() > 0)) {
4737
- if (g > 0) {
4738
- y.lShiftTo(g, y);
4739
- }
4740
- setTimeout(function() {
4741
- callback(y);
4742
- }, 0);
4743
- } else {
4744
- setTimeout(gcda1, 0);
4745
- }
4746
- };
4747
- setTimeout(gcda1, 10);
4748
- };
4749
- BigInteger2.prototype.fromNumberAsync = function(a, b, c, callback) {
4750
- if ("number" == typeof b) {
4751
- if (a < 2) {
4752
- this.fromInt(1);
4753
- } else {
4754
- this.fromNumber(a, c);
4755
- if (!this.testBit(a - 1)) {
4756
- this.bitwiseTo(BigInteger2.ONE.shiftLeft(a - 1), op_or, this);
4757
- }
4758
- if (this.isEven()) {
4759
- this.dAddOffset(1, 0);
4760
- }
4761
- var bnp_1 = this;
4762
- var bnpfn1_1 = function() {
4763
- bnp_1.dAddOffset(2, 0);
4764
- if (bnp_1.bitLength() > a) {
4765
- bnp_1.subTo(BigInteger2.ONE.shiftLeft(a - 1), bnp_1);
4766
- }
4767
- if (bnp_1.isProbablePrime(b)) {
4768
- setTimeout(function() {
4769
- callback();
4770
- }, 0);
4771
- } else {
4772
- setTimeout(bnpfn1_1, 0);
4773
- }
4774
- };
4775
- setTimeout(bnpfn1_1, 0);
4776
- }
4777
- } else {
4778
- var x = [];
4779
- var t = a & 7;
4780
- x.length = (a >> 3) + 1;
4781
- b.nextBytes(x);
4782
- if (t > 0) {
4783
- x[0] &= (1 << t) - 1;
4784
- } else {
4785
- x[0] = 0;
4786
- }
4787
- this.fromString(x, 256);
4788
- }
4789
- };
4790
- return BigInteger2;
4791
- })()
4792
- );
4793
- var NullExp = (
4794
- /** @class */
4795
- (function() {
4796
- function NullExp2() {
4797
- }
4798
- NullExp2.prototype.convert = function(x) {
4799
- return x;
4800
- };
4801
- NullExp2.prototype.revert = function(x) {
4802
- return x;
4803
- };
4804
- NullExp2.prototype.mulTo = function(x, y, r) {
4805
- x.multiplyTo(y, r);
4806
- };
4807
- NullExp2.prototype.sqrTo = function(x, r) {
4808
- x.squareTo(r);
4809
- };
4810
- return NullExp2;
4811
- })()
4812
- );
4813
- var Classic = (
4814
- /** @class */
4815
- (function() {
4816
- function Classic2(m) {
4817
- this.m = m;
4818
- }
4819
- Classic2.prototype.convert = function(x) {
4820
- if (x.s < 0 || x.compareTo(this.m) >= 0) {
4821
- return x.mod(this.m);
4822
- } else {
4823
- return x;
4824
- }
4825
- };
4826
- Classic2.prototype.revert = function(x) {
4827
- return x;
4828
- };
4829
- Classic2.prototype.reduce = function(x) {
4830
- x.divRemTo(this.m, null, x);
4831
- };
4832
- Classic2.prototype.mulTo = function(x, y, r) {
4833
- x.multiplyTo(y, r);
4834
- this.reduce(r);
4835
- };
4836
- Classic2.prototype.sqrTo = function(x, r) {
4837
- x.squareTo(r);
4838
- this.reduce(r);
4839
- };
4840
- return Classic2;
4841
- })()
4842
- );
4843
- var Montgomery = (
4844
- /** @class */
4845
- (function() {
4846
- function Montgomery2(m) {
4847
- this.m = m;
4848
- this.mp = m.invDigit();
4849
- this.mpl = this.mp & 32767;
4850
- this.mph = this.mp >> 15;
4851
- this.um = (1 << m.DB - 15) - 1;
4852
- this.mt2 = 2 * m.t;
4853
- }
4854
- Montgomery2.prototype.convert = function(x) {
4855
- var r = nbi();
4856
- x.abs().dlShiftTo(this.m.t, r);
4857
- r.divRemTo(this.m, null, r);
4858
- if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) {
4859
- this.m.subTo(r, r);
4860
- }
4861
- return r;
4862
- };
4863
- Montgomery2.prototype.revert = function(x) {
4864
- var r = nbi();
4865
- x.copyTo(r);
4866
- this.reduce(r);
4867
- return r;
4868
- };
4869
- Montgomery2.prototype.reduce = function(x) {
4870
- while (x.t <= this.mt2) {
4871
- x[x.t++] = 0;
4872
- }
4873
- for (var i = 0; i < this.m.t; ++i) {
4874
- var j = x[i] & 32767;
4875
- var u0 = j * this.mpl + ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) & x.DM;
4876
- j = i + this.m.t;
4877
- x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
4878
- while (x[j] >= x.DV) {
4879
- x[j] -= x.DV;
4880
- x[++j]++;
4881
- }
4882
- }
4883
- x.clamp();
4884
- x.drShiftTo(this.m.t, x);
4885
- if (x.compareTo(this.m) >= 0) {
4886
- x.subTo(this.m, x);
4887
- }
4888
- };
4889
- Montgomery2.prototype.mulTo = function(x, y, r) {
4890
- x.multiplyTo(y, r);
4891
- this.reduce(r);
4892
- };
4893
- Montgomery2.prototype.sqrTo = function(x, r) {
4894
- x.squareTo(r);
4895
- this.reduce(r);
4896
- };
4897
- return Montgomery2;
4898
- })()
4899
- );
4900
- var Barrett = (
4901
- /** @class */
4902
- (function() {
4903
- function Barrett2(m) {
4904
- this.m = m;
4905
- this.r2 = nbi();
4906
- this.q3 = nbi();
4907
- BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
4908
- this.mu = this.r2.divide(m);
4909
- }
4910
- Barrett2.prototype.convert = function(x) {
4911
- if (x.s < 0 || x.t > 2 * this.m.t) {
4912
- return x.mod(this.m);
4913
- } else if (x.compareTo(this.m) < 0) {
4914
- return x;
4915
- } else {
4916
- var r = nbi();
4917
- x.copyTo(r);
4918
- this.reduce(r);
4919
- return r;
4920
- }
4921
- };
4922
- Barrett2.prototype.revert = function(x) {
4923
- return x;
4924
- };
4925
- Barrett2.prototype.reduce = function(x) {
4926
- x.drShiftTo(this.m.t - 1, this.r2);
4927
- if (x.t > this.m.t + 1) {
4928
- x.t = this.m.t + 1;
4929
- x.clamp();
4930
- }
4931
- this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
4932
- this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
4933
- while (x.compareTo(this.r2) < 0) {
4934
- x.dAddOffset(1, this.m.t + 1);
4935
- }
4936
- x.subTo(this.r2, x);
4937
- while (x.compareTo(this.m) >= 0) {
4938
- x.subTo(this.m, x);
4939
- }
4940
- };
4941
- Barrett2.prototype.mulTo = function(x, y, r) {
4942
- x.multiplyTo(y, r);
4943
- this.reduce(r);
4944
- };
4945
- Barrett2.prototype.sqrTo = function(x, r) {
4946
- x.squareTo(r);
4947
- this.reduce(r);
4948
- };
4949
- return Barrett2;
4950
- })()
4951
- );
4952
- function nbi() {
4953
- return new BigInteger(null);
4954
- }
4955
- function parseBigInt(str, r) {
4956
- return new BigInteger(str, r);
4957
- }
4958
- var inBrowser = typeof navigator !== "undefined";
4959
- if (inBrowser && j_lm && navigator.appName == "Microsoft Internet Explorer") {
4960
- BigInteger.prototype.am = function am2(i, x, w, j, c, n) {
4961
- var xl = x & 32767;
4962
- var xh = x >> 15;
4963
- while (--n >= 0) {
4964
- var l = this[i] & 32767;
4965
- var h = this[i++] >> 15;
4966
- var m = xh * l + h * xl;
4967
- l = xl * l + ((m & 32767) << 15) + w[j] + (c & 1073741823);
4968
- c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
4969
- w[j++] = l & 1073741823;
4970
- }
4971
- return c;
4972
- };
4973
- dbits = 30;
4974
- } else if (inBrowser && j_lm && navigator.appName != "Netscape") {
4975
- BigInteger.prototype.am = function am1(i, x, w, j, c, n) {
4976
- while (--n >= 0) {
4977
- var v = x * this[i++] + w[j] + c;
4978
- c = Math.floor(v / 67108864);
4979
- w[j++] = v & 67108863;
4980
- }
4981
- return c;
4982
- };
4983
- dbits = 26;
4984
- } else {
4985
- BigInteger.prototype.am = function am3(i, x, w, j, c, n) {
4986
- var xl = x & 16383;
4987
- var xh = x >> 14;
4988
- while (--n >= 0) {
4989
- var l = this[i] & 16383;
4990
- var h = this[i++] >> 14;
4991
- var m = xh * l + h * xl;
4992
- l = xl * l + ((m & 16383) << 14) + w[j] + c;
4993
- c = (l >> 28) + (m >> 14) + xh * h;
4994
- w[j++] = l & 268435455;
4995
- }
4996
- return c;
4997
- };
4998
- dbits = 28;
4999
- }
5000
- BigInteger.prototype.DB = dbits;
5001
- BigInteger.prototype.DM = (1 << dbits) - 1;
5002
- BigInteger.prototype.DV = 1 << dbits;
5003
- var BI_FP = 52;
5004
- BigInteger.prototype.FV = Math.pow(2, BI_FP);
5005
- BigInteger.prototype.F1 = BI_FP - dbits;
5006
- BigInteger.prototype.F2 = 2 * dbits - BI_FP;
5007
- var BI_RC = [];
5008
- var rr;
5009
- var vv;
5010
- rr = "0".charCodeAt(0);
5011
- for (vv = 0; vv <= 9; ++vv) {
5012
- BI_RC[rr++] = vv;
5013
- }
5014
- rr = "a".charCodeAt(0);
5015
- for (vv = 10; vv < 36; ++vv) {
5016
- BI_RC[rr++] = vv;
5017
- }
5018
- rr = "A".charCodeAt(0);
5019
- for (vv = 10; vv < 36; ++vv) {
5020
- BI_RC[rr++] = vv;
5021
- }
5022
- function intAt(s, i) {
5023
- var c = BI_RC[s.charCodeAt(i)];
5024
- return c == null ? -1 : c;
5025
- }
5026
- function nbv(i) {
5027
- var r = nbi();
5028
- r.fromInt(i);
5029
- return r;
5030
- }
5031
- function nbits(x) {
5032
- var r = 1;
5033
- var t;
5034
- if ((t = x >>> 16) != 0) {
5035
- x = t;
5036
- r += 16;
5037
- }
5038
- if ((t = x >> 8) != 0) {
5039
- x = t;
5040
- r += 8;
5041
- }
5042
- if ((t = x >> 4) != 0) {
5043
- x = t;
5044
- r += 4;
5045
- }
5046
- if ((t = x >> 2) != 0) {
5047
- x = t;
5048
- r += 2;
5049
- }
5050
- if ((t = x >> 1) != 0) {
5051
- x = t;
5052
- r += 1;
5053
- }
5054
- return r;
5055
- }
5056
- BigInteger.ZERO = nbv(0);
5057
- BigInteger.ONE = nbv(1);
5058
- var Arcfour = (
5059
- /** @class */
5060
- (function() {
5061
- function Arcfour2() {
5062
- this.i = 0;
5063
- this.j = 0;
5064
- this.S = [];
5065
- }
5066
- Arcfour2.prototype.init = function(key) {
5067
- var i;
5068
- var j;
5069
- var t;
5070
- for (i = 0; i < 256; ++i) {
5071
- this.S[i] = i;
5072
- }
5073
- j = 0;
5074
- for (i = 0; i < 256; ++i) {
5075
- j = j + this.S[i] + key[i % key.length] & 255;
5076
- t = this.S[i];
5077
- this.S[i] = this.S[j];
5078
- this.S[j] = t;
5079
- }
5080
- this.i = 0;
5081
- this.j = 0;
5082
- };
5083
- Arcfour2.prototype.next = function() {
5084
- var t;
5085
- this.i = this.i + 1 & 255;
5086
- this.j = this.j + this.S[this.i] & 255;
5087
- t = this.S[this.i];
5088
- this.S[this.i] = this.S[this.j];
5089
- this.S[this.j] = t;
5090
- return this.S[t + this.S[this.i] & 255];
5091
- };
5092
- return Arcfour2;
5093
- })()
5094
- );
5095
- function prng_newstate() {
5096
- return new Arcfour();
5097
- }
5098
- var rng_psize = 256;
5099
- var rng_state;
5100
- var rng_pool = null;
5101
- var rng_pptr;
5102
- if (rng_pool == null) {
5103
- rng_pool = [];
5104
- rng_pptr = 0;
5105
- var t = void 0;
5106
- if (typeof window !== "undefined" && self.crypto && self.crypto.getRandomValues) {
5107
- var z = new Uint32Array(256);
5108
- self.crypto.getRandomValues(z);
5109
- for (t = 0; t < z.length; ++t) {
5110
- rng_pool[rng_pptr++] = z[t] & 255;
5111
- }
5112
- }
5113
- var count = 0;
5114
- var onMouseMoveListener_1 = function(ev) {
5115
- count = count || 0;
5116
- if (count >= 256 || rng_pptr >= rng_psize) {
5117
- if (self.removeEventListener) {
5118
- self.removeEventListener("mousemove", onMouseMoveListener_1, false);
5119
- } else if (self.detachEvent) {
5120
- self.detachEvent("onmousemove", onMouseMoveListener_1);
5121
- }
5122
- return;
5123
- }
5124
- try {
5125
- var mouseCoordinates = ev.x + ev.y;
5126
- rng_pool[rng_pptr++] = mouseCoordinates & 255;
5127
- count += 1;
5128
- } catch (e) {
5129
- }
5130
- };
5131
- if (typeof window !== "undefined") {
5132
- if (self.addEventListener) {
5133
- self.addEventListener("mousemove", onMouseMoveListener_1, false);
5134
- } else if (self.attachEvent) {
5135
- self.attachEvent("onmousemove", onMouseMoveListener_1);
5136
- }
5137
- }
5138
- }
5139
- function rng_get_byte() {
5140
- if (rng_state == null) {
5141
- rng_state = prng_newstate();
5142
- while (rng_pptr < rng_psize) {
5143
- var random = Math.floor(65536 * Math.random());
5144
- rng_pool[rng_pptr++] = random & 255;
5145
- }
5146
- rng_state.init(rng_pool);
5147
- for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) {
5148
- rng_pool[rng_pptr] = 0;
5149
- }
5150
- rng_pptr = 0;
5151
- }
5152
- return rng_state.next();
5153
- }
5154
- var SecureRandom = (
5155
- /** @class */
5156
- (function() {
5157
- function SecureRandom2() {
5158
- }
5159
- SecureRandom2.prototype.nextBytes = function(ba) {
5160
- for (var i = 0; i < ba.length; ++i) {
5161
- ba[i] = rng_get_byte();
5162
- }
5163
- };
5164
- return SecureRandom2;
5165
- })()
5166
- );
5167
- function rstr_sha256(s) {
5168
- return binb2rstr(binb_sha256(rstr2binb(s), s.length * 8));
5169
- }
5170
- function rstr2hex(input) {
5171
- var hex_tab = "0123456789abcdef";
5172
- var output = "";
5173
- for (var i = 0; i < input.length; i++) {
5174
- var x = input.charCodeAt(i);
5175
- output += hex_tab.charAt(x >>> 4 & 15) + hex_tab.charAt(x & 15);
5176
- }
5177
- return output;
5178
- }
5179
- function rstr2binb(input) {
5180
- var output = Array(input.length >> 2);
5181
- for (var i = 0; i < output.length; i++)
5182
- output[i] = 0;
5183
- for (var i = 0; i < input.length * 8; i += 8)
5184
- output[i >> 5] |= (input.charCodeAt(i / 8) & 255) << 24 - i % 32;
5185
- return output;
5186
- }
5187
- function binb2rstr(input) {
5188
- var output = "";
5189
- for (var i = 0; i < input.length * 32; i += 8)
5190
- output += String.fromCharCode(input[i >> 5] >>> 24 - i % 32 & 255);
5191
- return output;
5192
- }
5193
- function sha256_S(X, n) {
5194
- return X >>> n | X << 32 - n;
5195
- }
5196
- function sha256_R(X, n) {
5197
- return X >>> n;
5198
- }
5199
- function sha256_Ch(x, y, z) {
5200
- return x & y ^ ~x & z;
5201
- }
5202
- function sha256_Maj(x, y, z) {
5203
- return x & y ^ x & z ^ y & z;
5204
- }
5205
- function sha256_Sigma0256(x) {
5206
- return sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22);
5207
- }
5208
- function sha256_Sigma1256(x) {
5209
- return sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25);
5210
- }
5211
- function sha256_Gamma0256(x) {
5212
- return sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3);
5213
- }
5214
- function sha256_Gamma1256(x) {
5215
- return sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10);
5216
- }
5217
- var sha256_K = new Array(1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998);
5218
- function binb_sha256(m, l) {
5219
- var HASH = new Array(1779033703, -1150833019, 1013904242, -1521486534, 1359893119, -1694144372, 528734635, 1541459225);
5220
- var W = new Array(64);
5221
- var a, b, c, d, e, f, g, h;
5222
- var i, j, T1, T2;
5223
- m[l >> 5] |= 128 << 24 - l % 32;
5224
- m[(l + 64 >> 9 << 4) + 15] = l;
5225
- for (i = 0; i < m.length; i += 16) {
5226
- a = HASH[0];
5227
- b = HASH[1];
5228
- c = HASH[2];
5229
- d = HASH[3];
5230
- e = HASH[4];
5231
- f = HASH[5];
5232
- g = HASH[6];
5233
- h = HASH[7];
5234
- for (j = 0; j < 64; j++) {
5235
- if (j < 16)
5236
- W[j] = m[j + i];
5237
- else
5238
- W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]), sha256_Gamma0256(W[j - 15])), W[j - 16]);
5239
- T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)), sha256_K[j]), W[j]);
5240
- T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
5241
- h = g;
5242
- g = f;
5243
- f = e;
5244
- e = safe_add(d, T1);
5245
- d = c;
5246
- c = b;
5247
- b = a;
5248
- a = safe_add(T1, T2);
5249
- }
5250
- HASH[0] = safe_add(a, HASH[0]);
5251
- HASH[1] = safe_add(b, HASH[1]);
5252
- HASH[2] = safe_add(c, HASH[2]);
5253
- HASH[3] = safe_add(d, HASH[3]);
5254
- HASH[4] = safe_add(e, HASH[4]);
5255
- HASH[5] = safe_add(f, HASH[5]);
5256
- HASH[6] = safe_add(g, HASH[6]);
5257
- HASH[7] = safe_add(h, HASH[7]);
5258
- }
5259
- return HASH;
5260
- }
5261
- function safe_add(x, y) {
5262
- var lsw = (x & 65535) + (y & 65535);
5263
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
5264
- return msw << 16 | lsw & 65535;
5265
- }
5266
- function pkcs1pad1(s, n) {
5267
- if (n < s.length + 22) {
5268
- console.error("Message too long for RSA");
5269
- return null;
5270
- }
5271
- var len = n - s.length - 6;
5272
- var filler = "";
5273
- for (var f = 0; f < len; f += 2) {
5274
- filler += "ff";
5275
- }
5276
- var m = "0001" + filler + "00" + s;
5277
- return parseBigInt(m, 16);
5278
- }
5279
- function pkcs1pad2(s, n) {
5280
- if (n < s.length + 11) {
5281
- console.error("Message too long for RSA");
5282
- return null;
5283
- }
5284
- var ba = [];
5285
- var i = s.length - 1;
5286
- while (i >= 0 && n > 0) {
5287
- var c = s.charCodeAt(i--);
5288
- if (c < 128) {
5289
- ba[--n] = c;
5290
- } else if (c > 127 && c < 2048) {
5291
- ba[--n] = c & 63 | 128;
5292
- ba[--n] = c >> 6 | 192;
5293
- } else {
5294
- ba[--n] = c & 63 | 128;
5295
- ba[--n] = c >> 6 & 63 | 128;
5296
- ba[--n] = c >> 12 | 224;
5297
- }
5298
- }
5299
- ba[--n] = 0;
5300
- var rng = new SecureRandom();
5301
- var x = [];
5302
- while (n > 2) {
5303
- x[0] = 0;
5304
- while (x[0] == 0) {
5305
- rng.nextBytes(x);
5306
- }
5307
- ba[--n] = x[0];
5308
- }
5309
- ba[--n] = 2;
5310
- ba[--n] = 0;
5311
- return new BigInteger(ba);
5312
- }
5313
- function oaep_mgf1_arr(seed, len, hashFunc) {
5314
- var mask = "", i = 0;
5315
- while (mask.length < len) {
5316
- mask += hashFunc(String.fromCharCode.apply(String, seed.concat([
5317
- (i & 4278190080) >> 24,
5318
- (i & 16711680) >> 16,
5319
- (i & 65280) >> 8,
5320
- i & 255
5321
- ])));
5322
- i += 1;
5323
- }
5324
- return mask;
5325
- }
5326
- var SHA256_SIZE = 32;
5327
- function oaep_pad(s, n) {
5328
- var hashLen = SHA256_SIZE;
5329
- var hashFunc = rstr_sha256;
5330
- if (s.length + 2 * hashLen + 2 > n) {
5331
- throw "Message too long for RSA";
5332
- }
5333
- var PS = "", i;
5334
- for (i = 0; i < n - s.length - 2 * hashLen - 2; i += 1) {
5335
- PS += "\0";
5336
- }
5337
- var DB = hashFunc("") + PS + "" + s, seed = new Array(hashLen);
5338
- new SecureRandom().nextBytes(seed);
5339
- var dbMask = oaep_mgf1_arr(seed, DB.length, hashFunc), maskedDB = [];
5340
- for (i = 0; i < DB.length; i += 1) {
5341
- maskedDB[i] = DB.charCodeAt(i) ^ dbMask.charCodeAt(i);
5342
- }
5343
- var seedMask = oaep_mgf1_arr(maskedDB, seed.length, hashFunc), maskedSeed = [0];
5344
- for (i = 0; i < seed.length; i += 1) {
5345
- maskedSeed[i + 1] = seed[i] ^ seedMask.charCodeAt(i);
5346
- }
5347
- return new BigInteger(maskedSeed.concat(maskedDB));
5348
- }
5349
- var RSAKey = (
5350
- /** @class */
5351
- (function() {
5352
- function RSAKey2() {
5353
- this.n = null;
5354
- this.e = 0;
5355
- this.d = null;
5356
- this.p = null;
5357
- this.q = null;
5358
- this.dmp1 = null;
5359
- this.dmq1 = null;
5360
- this.coeff = null;
5361
- }
5362
- RSAKey2.prototype.doPublic = function(x) {
5363
- return x.modPowInt(this.e, this.n);
5364
- };
5365
- RSAKey2.prototype.doPrivate = function(x) {
5366
- if (this.p == null || this.q == null) {
5367
- return x.modPow(this.d, this.n);
5368
- }
5369
- var xp = x.mod(this.p).modPow(this.dmp1, this.p);
5370
- var xq = x.mod(this.q).modPow(this.dmq1, this.q);
5371
- while (xp.compareTo(xq) < 0) {
5372
- xp = xp.add(this.p);
5373
- }
5374
- return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq);
5375
- };
5376
- RSAKey2.prototype.setPublic = function(N, E) {
5377
- if (N != null && E != null && N.length > 0 && E.length > 0) {
5378
- this.n = parseBigInt(N, 16);
5379
- this.e = parseInt(E, 16);
5380
- } else {
5381
- console.error("Invalid RSA public key");
5382
- }
5383
- };
5384
- RSAKey2.prototype.encrypt = function(text, paddingFunction) {
5385
- if (typeof paddingFunction === "undefined") {
5386
- paddingFunction = pkcs1pad2;
5387
- }
5388
- var maxLength = this.n.bitLength() + 7 >> 3;
5389
- var m = paddingFunction(text, maxLength);
5390
- if (m == null) {
5391
- return null;
5392
- }
5393
- var c = this.doPublic(m);
5394
- if (c == null) {
5395
- return null;
5396
- }
5397
- var h = c.toString(16);
5398
- var length = h.length;
5399
- for (var i = 0; i < maxLength * 2 - length; i++) {
5400
- h = "0" + h;
5401
- }
5402
- return h;
5403
- };
5404
- RSAKey2.prototype.setPrivate = function(N, E, D) {
5405
- if (N != null && E != null && N.length > 0 && E.length > 0) {
5406
- this.n = parseBigInt(N, 16);
5407
- this.e = parseInt(E, 16);
5408
- this.d = parseBigInt(D, 16);
5409
- } else {
5410
- console.error("Invalid RSA private key");
5411
- }
5412
- };
5413
- RSAKey2.prototype.setPrivateEx = function(N, E, D, P, Q, DP, DQ, C) {
5414
- if (N != null && E != null && N.length > 0 && E.length > 0) {
5415
- this.n = parseBigInt(N, 16);
5416
- this.e = parseInt(E, 16);
5417
- this.d = parseBigInt(D, 16);
5418
- this.p = parseBigInt(P, 16);
5419
- this.q = parseBigInt(Q, 16);
5420
- this.dmp1 = parseBigInt(DP, 16);
5421
- this.dmq1 = parseBigInt(DQ, 16);
5422
- this.coeff = parseBigInt(C, 16);
5423
- } else {
5424
- console.error("Invalid RSA private key");
5425
- }
5426
- };
5427
- RSAKey2.prototype.generate = function(B, E) {
5428
- var rng = new SecureRandom();
5429
- var qs = B >> 1;
5430
- this.e = parseInt(E, 16);
5431
- var ee = new BigInteger(E, 16);
5432
- for (; ; ) {
5433
- for (; ; ) {
5434
- this.p = new BigInteger(B - qs, 1, rng);
5435
- if (this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) {
5436
- break;
5437
- }
5438
- }
5439
- for (; ; ) {
5440
- this.q = new BigInteger(qs, 1, rng);
5441
- if (this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) {
5442
- break;
5443
- }
5444
- }
5445
- if (this.p.compareTo(this.q) <= 0) {
5446
- var t = this.p;
5447
- this.p = this.q;
5448
- this.q = t;
5449
- }
5450
- var p1 = this.p.subtract(BigInteger.ONE);
5451
- var q1 = this.q.subtract(BigInteger.ONE);
5452
- var phi = p1.multiply(q1);
5453
- if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
5454
- this.n = this.p.multiply(this.q);
5455
- this.d = ee.modInverse(phi);
5456
- this.dmp1 = this.d.mod(p1);
5457
- this.dmq1 = this.d.mod(q1);
5458
- this.coeff = this.q.modInverse(this.p);
5459
- break;
5460
- }
5461
- }
5462
- };
5463
- RSAKey2.prototype.decrypt = function(ctext) {
5464
- var c = parseBigInt(ctext, 16);
5465
- var m = this.doPrivate(c);
5466
- if (m == null) {
5467
- return null;
5468
- }
5469
- return pkcs1unpad2(m, this.n.bitLength() + 7 >> 3);
5470
- };
5471
- RSAKey2.prototype.generateAsync = function(B, E, callback) {
5472
- var rng = new SecureRandom();
5473
- var qs = B >> 1;
5474
- this.e = parseInt(E, 16);
5475
- var ee = new BigInteger(E, 16);
5476
- var rsa = this;
5477
- var loop1 = function() {
5478
- var loop4 = function() {
5479
- if (rsa.p.compareTo(rsa.q) <= 0) {
5480
- var t = rsa.p;
5481
- rsa.p = rsa.q;
5482
- rsa.q = t;
5483
- }
5484
- var p1 = rsa.p.subtract(BigInteger.ONE);
5485
- var q1 = rsa.q.subtract(BigInteger.ONE);
5486
- var phi = p1.multiply(q1);
5487
- if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
5488
- rsa.n = rsa.p.multiply(rsa.q);
5489
- rsa.d = ee.modInverse(phi);
5490
- rsa.dmp1 = rsa.d.mod(p1);
5491
- rsa.dmq1 = rsa.d.mod(q1);
5492
- rsa.coeff = rsa.q.modInverse(rsa.p);
5493
- setTimeout(function() {
5494
- callback();
5495
- }, 0);
5496
- } else {
5497
- setTimeout(loop1, 0);
5498
- }
5499
- };
5500
- var loop3 = function() {
5501
- rsa.q = nbi();
5502
- rsa.q.fromNumberAsync(qs, 1, rng, function() {
5503
- rsa.q.subtract(BigInteger.ONE).gcda(ee, function(r) {
5504
- if (r.compareTo(BigInteger.ONE) == 0 && rsa.q.isProbablePrime(10)) {
5505
- setTimeout(loop4, 0);
5506
- } else {
5507
- setTimeout(loop3, 0);
5508
- }
5509
- });
5510
- });
5511
- };
5512
- var loop2 = function() {
5513
- rsa.p = nbi();
5514
- rsa.p.fromNumberAsync(B - qs, 1, rng, function() {
5515
- rsa.p.subtract(BigInteger.ONE).gcda(ee, function(r) {
5516
- if (r.compareTo(BigInteger.ONE) == 0 && rsa.p.isProbablePrime(10)) {
5517
- setTimeout(loop3, 0);
5518
- } else {
5519
- setTimeout(loop2, 0);
5520
- }
5521
- });
5522
- });
5523
- };
5524
- setTimeout(loop2, 0);
5525
- };
5526
- setTimeout(loop1, 0);
5527
- };
5528
- RSAKey2.prototype.sign = function(text, digestMethod, digestName) {
5529
- var header = getDigestHeader(digestName);
5530
- var digest = header + digestMethod(text).toString();
5531
- var maxLength = this.n.bitLength() / 4;
5532
- var m = pkcs1pad1(digest, maxLength);
5533
- if (m == null) {
5534
- return null;
5535
- }
5536
- var c = this.doPrivate(m);
5537
- if (c == null) {
5538
- return null;
5539
- }
5540
- var h = c.toString(16);
5541
- var length = h.length;
5542
- for (var i = 0; i < maxLength - length; i++) {
5543
- h = "0" + h;
5544
- }
5545
- return h;
5546
- };
5547
- RSAKey2.prototype.verify = function(text, signature, digestMethod) {
5548
- var c = parseBigInt(signature, 16);
5549
- var m = this.doPublic(c);
5550
- if (m == null) {
5551
- return null;
5552
- }
5553
- var unpadded = m.toString(16).replace(/^1f+00/, "");
5554
- var digest = removeDigestHeader(unpadded);
5555
- return digest == digestMethod(text).toString();
5556
- };
5557
- return RSAKey2;
5558
- })()
5559
- );
5560
- function pkcs1unpad2(d, n) {
5561
- var b = d.toByteArray();
5562
- var i = 0;
5563
- while (i < b.length && b[i] == 0) {
5564
- ++i;
5565
- }
5566
- if (b.length - i != n - 1 || b[i] != 2) {
5567
- return null;
5568
- }
5569
- ++i;
5570
- while (b[i] != 0) {
5571
- if (++i >= b.length) {
5572
- return null;
5573
- }
5574
- }
5575
- var ret = "";
5576
- while (++i < b.length) {
5577
- var c = b[i] & 255;
5578
- if (c < 128) {
5579
- ret += String.fromCharCode(c);
5580
- } else if (c > 191 && c < 224) {
5581
- ret += String.fromCharCode((c & 31) << 6 | b[i + 1] & 63);
5582
- ++i;
5583
- } else {
5584
- ret += String.fromCharCode((c & 15) << 12 | (b[i + 1] & 63) << 6 | b[i + 2] & 63);
5585
- i += 2;
5586
- }
5587
- }
5588
- return ret;
5589
- }
5590
- var DIGEST_HEADERS = {
5591
- md2: "3020300c06082a864886f70d020205000410",
5592
- md5: "3020300c06082a864886f70d020505000410",
5593
- sha1: "3021300906052b0e03021a05000414",
5594
- sha224: "302d300d06096086480165030402040500041c",
5595
- sha256: "3031300d060960864801650304020105000420",
5596
- sha384: "3041300d060960864801650304020205000430",
5597
- sha512: "3051300d060960864801650304020305000440",
5598
- ripemd160: "3021300906052b2403020105000414"
5599
- };
5600
- function getDigestHeader(name) {
5601
- return DIGEST_HEADERS[name] || "";
5602
- }
5603
- function removeDigestHeader(str) {
5604
- for (var name_1 in DIGEST_HEADERS) {
5605
- if (DIGEST_HEADERS.hasOwnProperty(name_1)) {
5606
- var header = DIGEST_HEADERS[name_1];
5607
- var len = header.length;
5608
- if (str.substring(0, len) == header) {
5609
- return str.substring(len);
5610
- }
5611
- }
5612
- }
5613
- return str;
5614
- }
5615
- function extendClass(subc, superc, overrides) {
5616
- if (!superc || !subc) {
5617
- throw new Error("extend failed, please check that all dependencies are included.");
5618
- }
5619
- var F = function() {
5620
- };
5621
- F.prototype = superc.prototype;
5622
- subc.prototype = new F();
5623
- subc.prototype.constructor = subc;
5624
- subc.superclass = superc.prototype;
5625
- if (superc.prototype.constructor == Object.prototype.constructor) {
5626
- superc.prototype.constructor = superc;
5627
- }
5628
- }
5629
- /**
5630
- * @fileOverview
5631
- * @name asn1-1.0.js
5632
- * @author Kenji Urushima kenji.urushima@gmail.com
5633
- * @version asn1 1.0.13 (2017-Jun-02)
5634
- * @since jsrsasign 2.1
5635
- * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
5636
- */
5637
- var KJUR = {};
5638
- if (typeof KJUR.asn1 == "undefined" || !KJUR.asn1)
5639
- KJUR.asn1 = {};
5640
- KJUR.asn1.ASN1Util = new function() {
5641
- this.integerToByteHex = function(i) {
5642
- var h = i.toString(16);
5643
- if (h.length % 2 == 1)
5644
- h = "0" + h;
5645
- return h;
5646
- };
5647
- this.bigIntToMinTwosComplementsHex = function(bigIntegerValue) {
5648
- var h = bigIntegerValue.toString(16);
5649
- if (h.substring(0, 1) != "-") {
5650
- if (h.length % 2 == 1) {
5651
- h = "0" + h;
5652
- } else {
5653
- if (!h.match(/^[0-7]/)) {
5654
- h = "00" + h;
5655
- }
5656
- }
5657
- } else {
5658
- var hPos = h.substring(1);
5659
- var xorLen = hPos.length;
5660
- if (xorLen % 2 == 1) {
5661
- xorLen += 1;
5662
- } else {
5663
- if (!h.match(/^[0-7]/)) {
5664
- xorLen += 2;
5665
- }
5666
- }
5667
- var hMask = "";
5668
- for (var i = 0; i < xorLen; i++) {
5669
- hMask += "f";
5670
- }
5671
- var biMask = new BigInteger(hMask, 16);
5672
- var biNeg = biMask.xor(bigIntegerValue).add(BigInteger.ONE);
5673
- h = biNeg.toString(16).replace(/^-/, "");
5674
- }
5675
- return h;
5676
- };
5677
- this.getPEMStringFromHex = function(dataHex, pemHeader) {
5678
- return hextopem(dataHex, pemHeader);
5679
- };
5680
- this.newObject = function(param) {
5681
- var _KJUR = KJUR, _KJUR_asn1 = _KJUR.asn1, _DERBoolean = _KJUR_asn1.DERBoolean, _DERInteger = _KJUR_asn1.DERInteger, _DERBitString = _KJUR_asn1.DERBitString, _DEROctetString = _KJUR_asn1.DEROctetString, _DERNull = _KJUR_asn1.DERNull, _DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier, _DEREnumerated = _KJUR_asn1.DEREnumerated, _DERUTF8String = _KJUR_asn1.DERUTF8String, _DERNumericString = _KJUR_asn1.DERNumericString, _DERPrintableString = _KJUR_asn1.DERPrintableString, _DERTeletexString = _KJUR_asn1.DERTeletexString, _DERIA5String = _KJUR_asn1.DERIA5String, _DERUTCTime = _KJUR_asn1.DERUTCTime, _DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime, _DERSequence = _KJUR_asn1.DERSequence, _DERSet = _KJUR_asn1.DERSet, _DERTaggedObject = _KJUR_asn1.DERTaggedObject, _newObject = _KJUR_asn1.ASN1Util.newObject;
5682
- var keys = Object.keys(param);
5683
- if (keys.length != 1)
5684
- throw "key of param shall be only one.";
5685
- var key = keys[0];
5686
- if (":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":" + key + ":") == -1)
5687
- throw "undefined key: " + key;
5688
- if (key == "bool")
5689
- return new _DERBoolean(param[key]);
5690
- if (key == "int")
5691
- return new _DERInteger(param[key]);
5692
- if (key == "bitstr")
5693
- return new _DERBitString(param[key]);
5694
- if (key == "octstr")
5695
- return new _DEROctetString(param[key]);
5696
- if (key == "null")
5697
- return new _DERNull(param[key]);
5698
- if (key == "oid")
5699
- return new _DERObjectIdentifier(param[key]);
5700
- if (key == "enum")
5701
- return new _DEREnumerated(param[key]);
5702
- if (key == "utf8str")
5703
- return new _DERUTF8String(param[key]);
5704
- if (key == "numstr")
5705
- return new _DERNumericString(param[key]);
5706
- if (key == "prnstr")
5707
- return new _DERPrintableString(param[key]);
5708
- if (key == "telstr")
5709
- return new _DERTeletexString(param[key]);
5710
- if (key == "ia5str")
5711
- return new _DERIA5String(param[key]);
5712
- if (key == "utctime")
5713
- return new _DERUTCTime(param[key]);
5714
- if (key == "gentime")
5715
- return new _DERGeneralizedTime(param[key]);
5716
- if (key == "seq") {
5717
- var paramList = param[key];
5718
- var a = [];
5719
- for (var i = 0; i < paramList.length; i++) {
5720
- var asn1Obj = _newObject(paramList[i]);
5721
- a.push(asn1Obj);
5722
- }
5723
- return new _DERSequence({ "array": a });
5724
- }
5725
- if (key == "set") {
5726
- var paramList = param[key];
5727
- var a = [];
5728
- for (var i = 0; i < paramList.length; i++) {
5729
- var asn1Obj = _newObject(paramList[i]);
5730
- a.push(asn1Obj);
5731
- }
5732
- return new _DERSet({ "array": a });
5733
- }
5734
- if (key == "tag") {
5735
- var tagParam = param[key];
5736
- if (Object.prototype.toString.call(tagParam) === "[object Array]" && tagParam.length == 3) {
5737
- var obj = _newObject(tagParam[2]);
5738
- return new _DERTaggedObject({
5739
- tag: tagParam[0],
5740
- explicit: tagParam[1],
5741
- obj
5742
- });
5743
- } else {
5744
- var newParam = {};
5745
- if (tagParam.explicit !== void 0)
5746
- newParam.explicit = tagParam.explicit;
5747
- if (tagParam.tag !== void 0)
5748
- newParam.tag = tagParam.tag;
5749
- if (tagParam.obj === void 0)
5750
- throw "obj shall be specified for 'tag'.";
5751
- newParam.obj = _newObject(tagParam.obj);
5752
- return new _DERTaggedObject(newParam);
5753
- }
5754
- }
5755
- };
5756
- this.jsonToASN1HEX = function(param) {
5757
- var asn1Obj = this.newObject(param);
5758
- return asn1Obj.getEncodedHex();
5759
- };
5760
- }();
5761
- KJUR.asn1.ASN1Util.oidHexToInt = function(hex) {
5762
- var s = "";
5763
- var i01 = parseInt(hex.substring(0, 2), 16);
5764
- var i0 = Math.floor(i01 / 40);
5765
- var i1 = i01 % 40;
5766
- var s = i0 + "." + i1;
5767
- var binbuf = "";
5768
- for (var i = 2; i < hex.length; i += 2) {
5769
- var value = parseInt(hex.substring(i, i + 2), 16);
5770
- var bin = ("00000000" + value.toString(2)).slice(-8);
5771
- binbuf = binbuf + bin.substring(1, 8);
5772
- if (bin.substring(0, 1) == "0") {
5773
- var bi = new BigInteger(binbuf, 2);
5774
- s = s + "." + bi.toString(10);
5775
- binbuf = "";
5776
- }
5777
- }
5778
- return s;
5779
- };
5780
- KJUR.asn1.ASN1Util.oidIntToHex = function(oidString) {
5781
- var itox = function(i2) {
5782
- var h2 = i2.toString(16);
5783
- if (h2.length == 1)
5784
- h2 = "0" + h2;
5785
- return h2;
5786
- };
5787
- var roidtox = function(roid) {
5788
- var h2 = "";
5789
- var bi = new BigInteger(roid, 10);
5790
- var b = bi.toString(2);
5791
- var padLen = 7 - b.length % 7;
5792
- if (padLen == 7)
5793
- padLen = 0;
5794
- var bPad = "";
5795
- for (var i2 = 0; i2 < padLen; i2++)
5796
- bPad += "0";
5797
- b = bPad + b;
5798
- for (var i2 = 0; i2 < b.length - 1; i2 += 7) {
5799
- var b8 = b.substring(i2, i2 + 7);
5800
- if (i2 != b.length - 7)
5801
- b8 = "1" + b8;
5802
- h2 += itox(parseInt(b8, 2));
5803
- }
5804
- return h2;
5805
- };
5806
- if (!oidString.match(/^[0-9.]+$/)) {
5807
- throw "malformed oid string: " + oidString;
5808
- }
5809
- var h = "";
5810
- var a = oidString.split(".");
5811
- var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
5812
- h += itox(i0);
5813
- a.splice(0, 2);
5814
- for (var i = 0; i < a.length; i++) {
5815
- h += roidtox(a[i]);
5816
- }
5817
- return h;
5818
- };
5819
- KJUR.asn1.ASN1Object = function() {
5820
- var hV = "";
5821
- this.getLengthHexFromValue = function() {
5822
- if (typeof this.hV == "undefined" || this.hV == null) {
5823
- throw "this.hV is null or undefined.";
5824
- }
5825
- if (this.hV.length % 2 == 1) {
5826
- throw "value hex must be even length: n=" + hV.length + ",v=" + this.hV;
5827
- }
5828
- var n = this.hV.length / 2;
5829
- var hN = n.toString(16);
5830
- if (hN.length % 2 == 1) {
5831
- hN = "0" + hN;
5832
- }
5833
- if (n < 128) {
5834
- return hN;
5835
- } else {
5836
- var hNlen = hN.length / 2;
5837
- if (hNlen > 15) {
5838
- throw "ASN.1 length too long to represent by 8x: n = " + n.toString(16);
5839
- }
5840
- var head = 128 + hNlen;
5841
- return head.toString(16) + hN;
5842
- }
5843
- };
5844
- this.getEncodedHex = function() {
5845
- if (this.hTLV == null || this.isModified) {
5846
- this.hV = this.getFreshValueHex();
5847
- this.hL = this.getLengthHexFromValue();
5848
- this.hTLV = this.hT + this.hL + this.hV;
5849
- this.isModified = false;
5850
- }
5851
- return this.hTLV;
5852
- };
5853
- this.getValueHex = function() {
5854
- this.getEncodedHex();
5855
- return this.hV;
5856
- };
5857
- this.getFreshValueHex = function() {
5858
- return "";
5859
- };
5860
- };
5861
- KJUR.asn1.DERAbstractString = function(params) {
5862
- KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
5863
- this.getString = function() {
5864
- return this.s;
5865
- };
5866
- this.setString = function(newS) {
5867
- this.hTLV = null;
5868
- this.isModified = true;
5869
- this.s = newS;
5870
- this.hV = stohex(this.s);
5871
- };
5872
- this.setStringHex = function(newHexString) {
5873
- this.hTLV = null;
5874
- this.isModified = true;
5875
- this.s = null;
5876
- this.hV = newHexString;
5877
- };
5878
- this.getFreshValueHex = function() {
5879
- return this.hV;
5880
- };
5881
- if (typeof params != "undefined") {
5882
- if (typeof params == "string") {
5883
- this.setString(params);
5884
- } else if (typeof params["str"] != "undefined") {
5885
- this.setString(params["str"]);
5886
- } else if (typeof params["hex"] != "undefined") {
5887
- this.setStringHex(params["hex"]);
5888
- }
5889
- }
5890
- };
5891
- extendClass(KJUR.asn1.DERAbstractString, KJUR.asn1.ASN1Object);
5892
- KJUR.asn1.DERAbstractTime = function(params) {
5893
- KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);
5894
- this.localDateToUTC = function(d) {
5895
- utc = d.getTime() + d.getTimezoneOffset() * 6e4;
5896
- var utcDate = new Date(utc);
5897
- return utcDate;
5898
- };
5899
- this.formatDate = function(dateObject, type, withMillis) {
5900
- var pad = this.zeroPadding;
5901
- var d = this.localDateToUTC(dateObject);
5902
- var year = String(d.getFullYear());
5903
- if (type == "utc")
5904
- year = year.substring(2, 4);
5905
- var month = pad(String(d.getMonth() + 1), 2);
5906
- var day = pad(String(d.getDate()), 2);
5907
- var hour = pad(String(d.getHours()), 2);
5908
- var min = pad(String(d.getMinutes()), 2);
5909
- var sec = pad(String(d.getSeconds()), 2);
5910
- var s = year + month + day + hour + min + sec;
5911
- if (withMillis === true) {
5912
- var millis = d.getMilliseconds();
5913
- if (millis != 0) {
5914
- var sMillis = pad(String(millis), 3);
5915
- sMillis = sMillis.replace(/[0]+$/, "");
5916
- s = s + "." + sMillis;
5917
- }
5918
- }
5919
- return s + "Z";
5920
- };
5921
- this.zeroPadding = function(s, len) {
5922
- if (s.length >= len)
5923
- return s;
5924
- return new Array(len - s.length + 1).join("0") + s;
5925
- };
5926
- this.getString = function() {
5927
- return this.s;
5928
- };
5929
- this.setString = function(newS) {
5930
- this.hTLV = null;
5931
- this.isModified = true;
5932
- this.s = newS;
5933
- this.hV = stohex(newS);
5934
- };
5935
- this.setByDateValue = function(year, month, day, hour, min, sec) {
5936
- var dateObject = new Date(Date.UTC(year, month - 1, day, hour, min, sec, 0));
5937
- this.setByDate(dateObject);
5938
- };
5939
- this.getFreshValueHex = function() {
5940
- return this.hV;
5941
- };
5942
- };
5943
- extendClass(KJUR.asn1.DERAbstractTime, KJUR.asn1.ASN1Object);
5944
- KJUR.asn1.DERAbstractStructured = function(params) {
5945
- KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
5946
- this.setByASN1ObjectArray = function(asn1ObjectArray) {
5947
- this.hTLV = null;
5948
- this.isModified = true;
5949
- this.asn1Array = asn1ObjectArray;
5950
- };
5951
- this.appendASN1Object = function(asn1Object) {
5952
- this.hTLV = null;
5953
- this.isModified = true;
5954
- this.asn1Array.push(asn1Object);
5955
- };
5956
- this.asn1Array = new Array();
5957
- if (typeof params != "undefined") {
5958
- if (typeof params["array"] != "undefined") {
5959
- this.asn1Array = params["array"];
5960
- }
5961
- }
5962
- };
5963
- extendClass(KJUR.asn1.DERAbstractStructured, KJUR.asn1.ASN1Object);
5964
- KJUR.asn1.DERBoolean = function() {
5965
- KJUR.asn1.DERBoolean.superclass.constructor.call(this);
5966
- this.hT = "01";
5967
- this.hTLV = "0101ff";
5968
- };
5969
- extendClass(KJUR.asn1.DERBoolean, KJUR.asn1.ASN1Object);
5970
- KJUR.asn1.DERInteger = function(params) {
5971
- KJUR.asn1.DERInteger.superclass.constructor.call(this);
5972
- this.hT = "02";
5973
- this.setByBigInteger = function(bigIntegerValue) {
5974
- this.hTLV = null;
5975
- this.isModified = true;
5976
- this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
5977
- };
5978
- this.setByInteger = function(intValue) {
5979
- var bi = new BigInteger(String(intValue), 10);
5980
- this.setByBigInteger(bi);
5981
- };
5982
- this.setValueHex = function(newHexString) {
5983
- this.hV = newHexString;
5984
- };
5985
- this.getFreshValueHex = function() {
5986
- return this.hV;
5987
- };
5988
- if (typeof params != "undefined") {
5989
- if (typeof params["bigint"] != "undefined") {
5990
- this.setByBigInteger(params["bigint"]);
5991
- } else if (typeof params["int"] != "undefined") {
5992
- this.setByInteger(params["int"]);
5993
- } else if (typeof params == "number") {
5994
- this.setByInteger(params);
5995
- } else if (typeof params["hex"] != "undefined") {
5996
- this.setValueHex(params["hex"]);
5997
- }
5998
- }
5999
- };
6000
- extendClass(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object);
6001
- KJUR.asn1.DERBitString = function(params) {
6002
- if (params !== void 0 && typeof params.obj !== "undefined") {
6003
- var o = KJUR.asn1.ASN1Util.newObject(params.obj);
6004
- params.hex = "00" + o.getEncodedHex();
6005
- }
6006
- KJUR.asn1.DERBitString.superclass.constructor.call(this);
6007
- this.hT = "03";
6008
- this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) {
6009
- this.hTLV = null;
6010
- this.isModified = true;
6011
- this.hV = newHexStringIncludingUnusedBits;
6012
- };
6013
- this.setUnusedBitsAndHexValue = function(unusedBits, hValue) {
6014
- if (unusedBits < 0 || 7 < unusedBits) {
6015
- throw "unused bits shall be from 0 to 7: u = " + unusedBits;
6016
- }
6017
- var hUnusedBits = "0" + unusedBits;
6018
- this.hTLV = null;
6019
- this.isModified = true;
6020
- this.hV = hUnusedBits + hValue;
6021
- };
6022
- this.setByBinaryString = function(binaryString) {
6023
- binaryString = binaryString.replace(/0+$/, "");
6024
- var unusedBits = 8 - binaryString.length % 8;
6025
- if (unusedBits == 8)
6026
- unusedBits = 0;
6027
- for (var i = 0; i <= unusedBits; i++) {
6028
- binaryString += "0";
6029
- }
6030
- var h = "";
6031
- for (var i = 0; i < binaryString.length - 1; i += 8) {
6032
- var b = binaryString.substring(i, i + 8);
6033
- var x = parseInt(b, 2).toString(16);
6034
- if (x.length == 1)
6035
- x = "0" + x;
6036
- h += x;
6037
- }
6038
- this.hTLV = null;
6039
- this.isModified = true;
6040
- this.hV = "0" + unusedBits + h;
6041
- };
6042
- this.setByBooleanArray = function(booleanArray) {
6043
- var s = "";
6044
- for (var i = 0; i < booleanArray.length; i++) {
6045
- if (booleanArray[i] == true) {
6046
- s += "1";
6047
- } else {
6048
- s += "0";
6049
- }
6050
- }
6051
- this.setByBinaryString(s);
6052
- };
6053
- this.newFalseArray = function(nLength) {
6054
- var a = new Array(nLength);
6055
- for (var i = 0; i < nLength; i++) {
6056
- a[i] = false;
6057
- }
6058
- return a;
6059
- };
6060
- this.getFreshValueHex = function() {
6061
- return this.hV;
6062
- };
6063
- if (typeof params != "undefined") {
6064
- if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
6065
- this.setHexValueIncludingUnusedBits(params);
6066
- } else if (typeof params["hex"] != "undefined") {
6067
- this.setHexValueIncludingUnusedBits(params["hex"]);
6068
- } else if (typeof params["bin"] != "undefined") {
6069
- this.setByBinaryString(params["bin"]);
6070
- } else if (typeof params["array"] != "undefined") {
6071
- this.setByBooleanArray(params["array"]);
6072
- }
6073
- }
6074
- };
6075
- extendClass(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
6076
- KJUR.asn1.DEROctetString = function(params) {
6077
- if (params !== void 0 && typeof params.obj !== "undefined") {
6078
- var o = KJUR.asn1.ASN1Util.newObject(params.obj);
6079
- params.hex = o.getEncodedHex();
6080
- }
6081
- KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
6082
- this.hT = "04";
6083
- };
6084
- extendClass(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
6085
- KJUR.asn1.DERNull = function() {
6086
- KJUR.asn1.DERNull.superclass.constructor.call(this);
6087
- this.hT = "05";
6088
- this.hTLV = "0500";
6089
- };
6090
- extendClass(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
6091
- KJUR.asn1.DERObjectIdentifier = function(params) {
6092
- var itox = function(i) {
6093
- var h = i.toString(16);
6094
- if (h.length == 1)
6095
- h = "0" + h;
6096
- return h;
6097
- };
6098
- var roidtox = function(roid) {
6099
- var h = "";
6100
- var bi = new BigInteger(roid, 10);
6101
- var b = bi.toString(2);
6102
- var padLen = 7 - b.length % 7;
6103
- if (padLen == 7)
6104
- padLen = 0;
6105
- var bPad = "";
6106
- for (var i = 0; i < padLen; i++)
6107
- bPad += "0";
6108
- b = bPad + b;
6109
- for (var i = 0; i < b.length - 1; i += 7) {
6110
- var b8 = b.substring(i, i + 7);
6111
- if (i != b.length - 7)
6112
- b8 = "1" + b8;
6113
- h += itox(parseInt(b8, 2));
6114
- }
6115
- return h;
6116
- };
6117
- KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
6118
- this.hT = "06";
6119
- this.setValueHex = function(newHexString) {
6120
- this.hTLV = null;
6121
- this.isModified = true;
6122
- this.s = null;
6123
- this.hV = newHexString;
6124
- };
6125
- this.setValueOidString = function(oidString) {
6126
- if (!oidString.match(/^[0-9.]+$/)) {
6127
- throw "malformed oid string: " + oidString;
6128
- }
6129
- var h = "";
6130
- var a = oidString.split(".");
6131
- var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
6132
- h += itox(i0);
6133
- a.splice(0, 2);
6134
- for (var i = 0; i < a.length; i++) {
6135
- h += roidtox(a[i]);
6136
- }
6137
- this.hTLV = null;
6138
- this.isModified = true;
6139
- this.s = null;
6140
- this.hV = h;
6141
- };
6142
- this.setValueName = function(oidName) {
6143
- var oid = KJUR.asn1.x509.OID.name2oid(oidName);
6144
- if (oid !== "") {
6145
- this.setValueOidString(oid);
6146
- } else {
6147
- throw "DERObjectIdentifier oidName undefined: " + oidName;
6148
- }
6149
- };
6150
- this.getFreshValueHex = function() {
6151
- return this.hV;
6152
- };
6153
- if (params !== void 0) {
6154
- if (typeof params === "string") {
6155
- if (params.match(/^[0-2].[0-9.]+$/)) {
6156
- this.setValueOidString(params);
6157
- } else {
6158
- this.setValueName(params);
6159
- }
6160
- } else if (params.oid !== void 0) {
6161
- this.setValueOidString(params.oid);
6162
- } else if (params.hex !== void 0) {
6163
- this.setValueHex(params.hex);
6164
- } else if (params.name !== void 0) {
6165
- this.setValueName(params.name);
6166
- }
6167
- }
6168
- };
6169
- extendClass(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
6170
- KJUR.asn1.DEREnumerated = function(params) {
6171
- KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
6172
- this.hT = "0a";
6173
- this.setByBigInteger = function(bigIntegerValue) {
6174
- this.hTLV = null;
6175
- this.isModified = true;
6176
- this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
6177
- };
6178
- this.setByInteger = function(intValue) {
6179
- var bi = new BigInteger(String(intValue), 10);
6180
- this.setByBigInteger(bi);
6181
- };
6182
- this.setValueHex = function(newHexString) {
6183
- this.hV = newHexString;
6184
- };
6185
- this.getFreshValueHex = function() {
6186
- return this.hV;
6187
- };
6188
- if (typeof params != "undefined") {
6189
- if (typeof params["int"] != "undefined") {
6190
- this.setByInteger(params["int"]);
6191
- } else if (typeof params == "number") {
6192
- this.setByInteger(params);
6193
- } else if (typeof params["hex"] != "undefined") {
6194
- this.setValueHex(params["hex"]);
6195
- }
6196
- }
6197
- };
6198
- extendClass(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
6199
- KJUR.asn1.DERUTF8String = function(params) {
6200
- KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
6201
- this.hT = "0c";
6202
- };
6203
- extendClass(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
6204
- KJUR.asn1.DERNumericString = function(params) {
6205
- KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
6206
- this.hT = "12";
6207
- };
6208
- extendClass(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
6209
- KJUR.asn1.DERPrintableString = function(params) {
6210
- KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
6211
- this.hT = "13";
6212
- };
6213
- extendClass(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
6214
- KJUR.asn1.DERTeletexString = function(params) {
6215
- KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
6216
- this.hT = "14";
6217
- };
6218
- extendClass(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
6219
- KJUR.asn1.DERIA5String = function(params) {
6220
- KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
6221
- this.hT = "16";
6222
- };
6223
- extendClass(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
6224
- KJUR.asn1.DERUTCTime = function(params) {
6225
- KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
6226
- this.hT = "17";
6227
- this.setByDate = function(dateObject) {
6228
- this.hTLV = null;
6229
- this.isModified = true;
6230
- this.date = dateObject;
6231
- this.s = this.formatDate(this.date, "utc");
6232
- this.hV = stohex(this.s);
6233
- };
6234
- this.getFreshValueHex = function() {
6235
- if (typeof this.date == "undefined" && typeof this.s == "undefined") {
6236
- this.date = /* @__PURE__ */ new Date();
6237
- this.s = this.formatDate(this.date, "utc");
6238
- this.hV = stohex(this.s);
6239
- }
6240
- return this.hV;
6241
- };
6242
- if (params !== void 0) {
6243
- if (params.str !== void 0) {
6244
- this.setString(params.str);
6245
- } else if (typeof params == "string" && params.match(/^[0-9]{12}Z$/)) {
6246
- this.setString(params);
6247
- } else if (params.hex !== void 0) {
6248
- this.setStringHex(params.hex);
6249
- } else if (params.date !== void 0) {
6250
- this.setByDate(params.date);
6251
- }
6252
- }
6253
- };
6254
- extendClass(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
6255
- KJUR.asn1.DERGeneralizedTime = function(params) {
6256
- KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
6257
- this.hT = "18";
6258
- this.withMillis = false;
6259
- this.setByDate = function(dateObject) {
6260
- this.hTLV = null;
6261
- this.isModified = true;
6262
- this.date = dateObject;
6263
- this.s = this.formatDate(this.date, "gen", this.withMillis);
6264
- this.hV = stohex(this.s);
6265
- };
6266
- this.getFreshValueHex = function() {
6267
- if (this.date === void 0 && this.s === void 0) {
6268
- this.date = /* @__PURE__ */ new Date();
6269
- this.s = this.formatDate(this.date, "gen", this.withMillis);
6270
- this.hV = stohex(this.s);
6271
- }
6272
- return this.hV;
6273
- };
6274
- if (params !== void 0) {
6275
- if (params.str !== void 0) {
6276
- this.setString(params.str);
6277
- } else if (typeof params == "string" && params.match(/^[0-9]{14}Z$/)) {
6278
- this.setString(params);
6279
- } else if (params.hex !== void 0) {
6280
- this.setStringHex(params.hex);
6281
- } else if (params.date !== void 0) {
6282
- this.setByDate(params.date);
6283
- }
6284
- if (params.millis === true) {
6285
- this.withMillis = true;
6286
- }
6287
- }
6288
- };
6289
- extendClass(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
6290
- KJUR.asn1.DERSequence = function(params) {
6291
- KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
6292
- this.hT = "30";
6293
- this.getFreshValueHex = function() {
6294
- var h = "";
6295
- for (var i = 0; i < this.asn1Array.length; i++) {
6296
- var asn1Obj = this.asn1Array[i];
6297
- h += asn1Obj.getEncodedHex();
6298
- }
6299
- this.hV = h;
6300
- return this.hV;
6301
- };
6302
- };
6303
- extendClass(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
6304
- KJUR.asn1.DERSet = function(params) {
6305
- KJUR.asn1.DERSet.superclass.constructor.call(this, params);
6306
- this.hT = "31";
6307
- this.sortFlag = true;
6308
- this.getFreshValueHex = function() {
6309
- var a = new Array();
6310
- for (var i = 0; i < this.asn1Array.length; i++) {
6311
- var asn1Obj = this.asn1Array[i];
6312
- a.push(asn1Obj.getEncodedHex());
6313
- }
6314
- if (this.sortFlag == true)
6315
- a.sort();
6316
- this.hV = a.join("");
6317
- return this.hV;
6318
- };
6319
- if (typeof params != "undefined") {
6320
- if (typeof params.sortflag != "undefined" && params.sortflag == false)
6321
- this.sortFlag = false;
6322
- }
6323
- };
6324
- extendClass(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
6325
- KJUR.asn1.DERTaggedObject = function(params) {
6326
- KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
6327
- this.hT = "a0";
6328
- this.hV = "";
6329
- this.isExplicit = true;
6330
- this.asn1Object = null;
6331
- this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
6332
- this.hT = tagNoHex;
6333
- this.isExplicit = isExplicitFlag;
6334
- this.asn1Object = asn1Object;
6335
- if (this.isExplicit) {
6336
- this.hV = this.asn1Object.getEncodedHex();
6337
- this.hTLV = null;
6338
- this.isModified = true;
6339
- } else {
6340
- this.hV = null;
6341
- this.hTLV = asn1Object.getEncodedHex();
6342
- this.hTLV = this.hTLV.replace(/^../, tagNoHex);
6343
- this.isModified = false;
6344
- }
6345
- };
6346
- this.getFreshValueHex = function() {
6347
- return this.hV;
6348
- };
6349
- if (typeof params != "undefined") {
6350
- if (typeof params["tag"] != "undefined") {
6351
- this.hT = params["tag"];
6352
- }
6353
- if (typeof params["explicit"] != "undefined") {
6354
- this.isExplicit = params["explicit"];
6355
- }
6356
- if (typeof params["obj"] != "undefined") {
6357
- this.asn1Object = params["obj"];
6358
- this.setASN1Object(this.isExplicit, this.hT, this.asn1Object);
6359
- }
6360
- }
6361
- };
6362
- extendClass(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
6363
- var __extends = /* @__PURE__ */ (function() {
6364
- var extendStatics = function(d, b) {
6365
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
6366
- d2.__proto__ = b2;
6367
- } || function(d2, b2) {
6368
- for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
6369
- };
6370
- return extendStatics(d, b);
6371
- };
6372
- return function(d, b) {
6373
- if (typeof b !== "function" && b !== null)
6374
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6375
- extendStatics(d, b);
6376
- function __() {
6377
- this.constructor = d;
6378
- }
6379
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6380
- };
6381
- })();
6382
- var JSEncryptRSAKey = (
6383
- /** @class */
6384
- (function(_super) {
6385
- __extends(JSEncryptRSAKey2, _super);
6386
- function JSEncryptRSAKey2(key) {
6387
- var _this = _super.call(this) || this;
6388
- if (key) {
6389
- if (typeof key === "string") {
6390
- _this.parseKey(key);
6391
- } else if (JSEncryptRSAKey2.hasPrivateKeyProperty(key) || JSEncryptRSAKey2.hasPublicKeyProperty(key)) {
6392
- _this.parsePropertiesFrom(key);
6393
- }
6394
- }
6395
- return _this;
6396
- }
6397
- JSEncryptRSAKey2.prototype.parseKey = function(pem) {
6398
- try {
6399
- var modulus = 0;
6400
- var public_exponent = 0;
6401
- var reHex = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/;
6402
- var der = reHex.test(pem) ? Hex.decode(pem) : Base64.unarmor(pem);
6403
- var asn1 = ASN1.decode(der);
6404
- if (asn1.sub.length === 3) {
6405
- asn1 = asn1.sub[2].sub[0];
6406
- }
6407
- if (asn1.sub.length === 9) {
6408
- modulus = asn1.sub[1].getHexStringValue();
6409
- this.n = parseBigInt(modulus, 16);
6410
- public_exponent = asn1.sub[2].getHexStringValue();
6411
- this.e = parseInt(public_exponent, 16);
6412
- var private_exponent = asn1.sub[3].getHexStringValue();
6413
- this.d = parseBigInt(private_exponent, 16);
6414
- var prime1 = asn1.sub[4].getHexStringValue();
6415
- this.p = parseBigInt(prime1, 16);
6416
- var prime2 = asn1.sub[5].getHexStringValue();
6417
- this.q = parseBigInt(prime2, 16);
6418
- var exponent1 = asn1.sub[6].getHexStringValue();
6419
- this.dmp1 = parseBigInt(exponent1, 16);
6420
- var exponent2 = asn1.sub[7].getHexStringValue();
6421
- this.dmq1 = parseBigInt(exponent2, 16);
6422
- var coefficient = asn1.sub[8].getHexStringValue();
6423
- this.coeff = parseBigInt(coefficient, 16);
6424
- } else if (asn1.sub.length === 2) {
6425
- if (asn1.sub[0].sub) {
6426
- var bit_string = asn1.sub[1];
6427
- var sequence = bit_string.sub[0];
6428
- modulus = sequence.sub[0].getHexStringValue();
6429
- this.n = parseBigInt(modulus, 16);
6430
- public_exponent = sequence.sub[1].getHexStringValue();
6431
- this.e = parseInt(public_exponent, 16);
6432
- } else {
6433
- modulus = asn1.sub[0].getHexStringValue();
6434
- this.n = parseBigInt(modulus, 16);
6435
- public_exponent = asn1.sub[1].getHexStringValue();
6436
- this.e = parseInt(public_exponent, 16);
6437
- }
6438
- } else {
6439
- return false;
6440
- }
6441
- return true;
6442
- } catch (ex) {
6443
- return false;
6444
- }
6445
- };
6446
- JSEncryptRSAKey2.prototype.getPrivateBaseKey = function() {
6447
- var options = {
6448
- array: [
6449
- new KJUR.asn1.DERInteger({ int: 0 }),
6450
- new KJUR.asn1.DERInteger({ bigint: this.n }),
6451
- new KJUR.asn1.DERInteger({ int: this.e }),
6452
- new KJUR.asn1.DERInteger({ bigint: this.d }),
6453
- new KJUR.asn1.DERInteger({ bigint: this.p }),
6454
- new KJUR.asn1.DERInteger({ bigint: this.q }),
6455
- new KJUR.asn1.DERInteger({ bigint: this.dmp1 }),
6456
- new KJUR.asn1.DERInteger({ bigint: this.dmq1 }),
6457
- new KJUR.asn1.DERInteger({ bigint: this.coeff })
6458
- ]
6459
- };
6460
- var seq = new KJUR.asn1.DERSequence(options);
6461
- return seq.getEncodedHex();
6462
- };
6463
- JSEncryptRSAKey2.prototype.getPrivateBaseKeyB64 = function() {
6464
- return hex2b64(this.getPrivateBaseKey());
6465
- };
6466
- JSEncryptRSAKey2.prototype.getPublicBaseKey = function() {
6467
- var first_sequence = new KJUR.asn1.DERSequence({
6468
- array: [
6469
- new KJUR.asn1.DERObjectIdentifier({ oid: "1.2.840.113549.1.1.1" }),
6470
- // RSA Encryption pkcs #1 oid
6471
- new KJUR.asn1.DERNull()
6472
- ]
6473
- });
6474
- var second_sequence = new KJUR.asn1.DERSequence({
6475
- array: [
6476
- new KJUR.asn1.DERInteger({ bigint: this.n }),
6477
- new KJUR.asn1.DERInteger({ int: this.e })
6478
- ]
6479
- });
6480
- var bit_string = new KJUR.asn1.DERBitString({
6481
- hex: "00" + second_sequence.getEncodedHex()
6482
- });
6483
- var seq = new KJUR.asn1.DERSequence({
6484
- array: [first_sequence, bit_string]
6485
- });
6486
- return seq.getEncodedHex();
6487
- };
6488
- JSEncryptRSAKey2.prototype.getPublicBaseKeyB64 = function() {
6489
- return hex2b64(this.getPublicBaseKey());
6490
- };
6491
- JSEncryptRSAKey2.wordwrap = function(str, width) {
6492
- width = width || 64;
6493
- if (!str) {
6494
- return str;
6495
- }
6496
- var regex = "(.{1," + width + "})( +|$\n?)|(.{1," + width + "})";
6497
- return str.match(RegExp(regex, "g")).join("\n");
6498
- };
6499
- JSEncryptRSAKey2.prototype.getPrivateKey = function() {
6500
- var key = "-----BEGIN RSA PRIVATE KEY-----\n";
6501
- key += JSEncryptRSAKey2.wordwrap(this.getPrivateBaseKeyB64()) + "\n";
6502
- key += "-----END RSA PRIVATE KEY-----";
6503
- return key;
6504
- };
6505
- JSEncryptRSAKey2.prototype.getPublicKey = function() {
6506
- var key = "-----BEGIN PUBLIC KEY-----\n";
6507
- key += JSEncryptRSAKey2.wordwrap(this.getPublicBaseKeyB64()) + "\n";
6508
- key += "-----END PUBLIC KEY-----";
6509
- return key;
6510
- };
6511
- JSEncryptRSAKey2.hasPublicKeyProperty = function(obj) {
6512
- obj = obj || {};
6513
- return obj.hasOwnProperty("n") && obj.hasOwnProperty("e");
6514
- };
6515
- JSEncryptRSAKey2.hasPrivateKeyProperty = function(obj) {
6516
- obj = obj || {};
6517
- return obj.hasOwnProperty("n") && obj.hasOwnProperty("e") && obj.hasOwnProperty("d") && obj.hasOwnProperty("p") && obj.hasOwnProperty("q") && obj.hasOwnProperty("dmp1") && obj.hasOwnProperty("dmq1") && obj.hasOwnProperty("coeff");
6518
- };
6519
- JSEncryptRSAKey2.prototype.parsePropertiesFrom = function(obj) {
6520
- this.n = obj.n;
6521
- this.e = obj.e;
6522
- if (obj.hasOwnProperty("d")) {
6523
- this.d = obj.d;
6524
- this.p = obj.p;
6525
- this.q = obj.q;
6526
- this.dmp1 = obj.dmp1;
6527
- this.dmq1 = obj.dmq1;
6528
- this.coeff = obj.coeff;
6529
- }
6530
- };
6531
- return JSEncryptRSAKey2;
6532
- })(RSAKey)
6533
- );
6534
- var _a;
6535
- var version = typeof process !== "undefined" ? (_a = process.env) === null || _a === void 0 ? void 0 : _a.npm_package_version : void 0;
6536
- var JSEncrypt = (
6537
- /** @class */
6538
- (function() {
6539
- function JSEncrypt2(options) {
6540
- if (options === void 0) {
6541
- options = {};
6542
- }
6543
- this.default_key_size = options.default_key_size ? parseInt(options.default_key_size, 10) : 1024;
6544
- this.default_public_exponent = options.default_public_exponent || "010001";
6545
- this.log = options.log || false;
6546
- this.key = options.key || null;
6547
- }
6548
- JSEncrypt2.prototype.setKey = function(key) {
6549
- if (key) {
6550
- if (this.log && this.key) {
6551
- console.warn("A key was already set, overriding existing.");
6552
- }
6553
- this.key = new JSEncryptRSAKey(key);
6554
- } else if (!this.key && this.log) {
6555
- console.error("A key was not set.");
6556
- }
6557
- };
6558
- JSEncrypt2.prototype.setPrivateKey = function(privkey) {
6559
- this.setKey(privkey);
6560
- };
6561
- JSEncrypt2.prototype.setPublicKey = function(pubkey) {
6562
- this.setKey(pubkey);
6563
- };
6564
- JSEncrypt2.prototype.decrypt = function(str) {
6565
- try {
6566
- return this.getKey().decrypt(b64tohex(str));
6567
- } catch (ex) {
6568
- return false;
6569
- }
6570
- };
6571
- JSEncrypt2.prototype.encrypt = function(str) {
6572
- try {
6573
- return hex2b64(this.getKey().encrypt(str));
6574
- } catch (ex) {
6575
- return false;
6576
- }
6577
- };
6578
- JSEncrypt2.prototype.encryptOAEP = function(str) {
6579
- try {
6580
- return hex2b64(this.getKey().encrypt(str, oaep_pad));
6581
- } catch (ex) {
6582
- return false;
6583
- }
6584
- };
6585
- JSEncrypt2.prototype.sign = function(str, digestMethod, digestName) {
6586
- if (digestMethod === void 0) {
6587
- digestMethod = function(raw) {
6588
- return raw;
6589
- };
6590
- }
6591
- if (digestName === void 0) {
6592
- digestName = "";
6593
- }
6594
- try {
6595
- return hex2b64(this.getKey().sign(str, digestMethod, digestName));
6596
- } catch (ex) {
6597
- return false;
6598
- }
6599
- };
6600
- JSEncrypt2.prototype.signSha256 = function(str) {
6601
- return this.sign(str, function(text) {
6602
- return rstr2hex(rstr_sha256(text));
6603
- }, "sha256");
6604
- };
6605
- JSEncrypt2.prototype.verify = function(str, signature, digestMethod) {
6606
- if (digestMethod === void 0) {
6607
- digestMethod = function(raw) {
6608
- return raw;
6609
- };
6610
- }
6611
- try {
6612
- return this.getKey().verify(str, b64tohex(signature), digestMethod);
6613
- } catch (ex) {
6614
- return false;
6615
- }
6616
- };
6617
- JSEncrypt2.prototype.verifySha256 = function(str, signature) {
6618
- return this.verify(str, signature, function(text) {
6619
- return rstr2hex(rstr_sha256(text));
6620
- });
6621
- };
6622
- JSEncrypt2.prototype.getKey = function(cb) {
6623
- if (!this.key) {
6624
- this.key = new JSEncryptRSAKey();
6625
- if (cb && {}.toString.call(cb) === "[object Function]") {
6626
- this.key.generateAsync(this.default_key_size, this.default_public_exponent, cb);
6627
- return;
6628
- }
6629
- this.key.generate(this.default_key_size, this.default_public_exponent);
6630
- }
6631
- return this.key;
6632
- };
6633
- JSEncrypt2.prototype.getPrivateKey = function() {
6634
- return this.getKey().getPrivateKey();
6635
- };
6636
- JSEncrypt2.prototype.getPrivateKeyB64 = function() {
6637
- return this.getKey().getPrivateBaseKeyB64();
6638
- };
6639
- JSEncrypt2.prototype.getPublicKey = function() {
6640
- return this.getKey().getPublicKey();
6641
- };
6642
- JSEncrypt2.prototype.getPublicKeyB64 = function() {
6643
- return this.getKey().getPublicBaseKeyB64();
6644
- };
6645
- JSEncrypt2.version = version;
6646
- return JSEncrypt2;
6647
- })()
6648
- );
6649
- const DefaultGetLoginKeyData = {
6650
- data: {
6651
- key: ""
6652
- }
6653
- };
6654
- const getLoginKeyApi = () => __async(null, null, function* () {
6655
- let result = __spreadValues({
6656
- status: 200,
6657
- message: ""
6658
- }, DefaultGetLoginKeyData);
6659
- try {
6660
- const response = yield get(`/mbuhx0as4kui`, {
6661
- ajax: 1,
6662
- render: getRender(),
6663
- json: 1
6664
- });
6665
- const output = response.data;
6666
- result.data = {
6667
- key: output.key
6668
- };
6669
- } catch (error) {
6670
- const extendedError = error;
6671
- result = __spreadValues({
6672
- status: extendedError.status || 500,
6673
- message: error.message
6674
- }, DefaultGetLoginKeyData);
6675
- }
6676
- return result;
6677
- });
6678
- const DefaultLoginData = {
6679
- data: {
6680
- msg: "",
6681
- accessToken: "",
6682
- fullName: "",
6683
- unreadMailCount: "",
6684
- status: "",
6685
- username: "",
6686
- walletAmount: "",
6687
- captcha: ""
6688
- }
6689
- };
6690
- const loginApi = (username, password, gdCode, domain, isApp, slideVerificationFlag, publicKey, loginToken) => __async(null, null, function* () {
6691
- var _a2, _b, _c, _d, _e, _f, _g, _h;
6692
- let result = __spreadValues({
6693
- status: 200,
6694
- message: ""
6695
- }, DefaultLoginData);
6696
- const usernameInput = username;
6697
- const passwordInput = password;
6698
- const gdCodeInput = gdCode;
6699
- const isAppInput = isApp;
6700
- try {
6701
- let extraParams = void 0;
6702
- if (slideVerificationFlag) {
6703
- const getLoginKeyData = yield getLoginKeyApi();
6704
- extraParams = getLoginKeyData.data;
6705
- }
6706
- const _encrypt = new JSEncrypt();
6707
- _encrypt.setPublicKey(publicKey);
6708
- let domainInput = domain.host.split(":")[0];
6709
- const encryptedDomain = _encrypt.encrypt(domainInput.trim());
6710
- if (encryptedDomain && domainInput.length < 53) {
6711
- domainInput = encryptedDomain;
6712
- } else {
6713
- domainInput = domainInput.trim();
6714
- }
6715
- const dataArray = {};
6716
- dataArray.fr_username = _encrypt.encrypt(usernameInput.trim());
6717
- dataArray.fr_password = _encrypt.encrypt(passwordInput.trim());
6718
- dataArray.fr_gdcode = gdCodeInput;
6719
- dataArray.isApp = isAppInput;
6720
- dataArray.domain = domainInput;
6721
- dataArray._token = loginToken;
6722
- dataArray.json = 1;
6723
- dataArray.encrypt = 1;
6724
- if (extraParams) {
6725
- Object.assign(dataArray, extraParams);
6726
- }
6727
- const response = yield post(`/kdink8anl8z3`, dataArray, {
6728
- render: getRender(),
6729
- json: 1
6730
- });
6731
- const output = response.data;
6732
- result.data = {
6733
- msg: (_a2 = output.msg) != null ? _a2 : "",
6734
- accessToken: (_b = output.access_token) != null ? _b : "",
6735
- fullName: (_c = output.fullname) != null ? _c : "",
6736
- unreadMailCount: (_d = output.news) != null ? _d : "",
6737
- status: (_e = output.status) != null ? _e : "",
6738
- username: (_f = output.username) != null ? _f : "",
6739
- walletAmount: (_g = output.wallet) != null ? _g : "",
6740
- captcha: (_h = output.captcha) != null ? _h : ""
6741
- };
6742
- } catch (error) {
6743
- const extendedError = error;
6744
- result = __spreadValues({
6745
- status: extendedError.status || 500,
6746
- message: error.message
6747
- }, DefaultLoginData);
6748
- }
6749
- return result;
6750
- });
6751
- const DefaultGetWinnerListData = {
6752
- data: []
6753
- };
6754
- const getWinnerListApi = () => __async(null, null, function* () {
6755
- var _a2;
6756
- let result = __spreadValues({
6757
- status: 200,
6758
- message: ""
6759
- }, DefaultGetWinnerListData);
6760
- try {
6761
- const response = yield get(`/apis/getWinnerList`, {
6762
- render: getRender(),
6763
- json: 1
6764
- });
6765
- const output = response.data;
6766
- result.data = (_a2 = output.results.notifications) != null ? _a2 : [];
6767
- } catch (error) {
6768
- const extendedError = error;
6769
- result = __spreadValues({
6770
- status: extendedError.status || 500,
6771
- message: error.message
6772
- }, DefaultGetWinnerListData);
6773
- }
6774
- return result;
6775
- });
6776
- const DefaultAnnouncementData = {
6777
- data: []
6778
- };
6779
- const announcementApi = () => __async(null, null, function* () {
6780
- let result = __spreadValues({
6781
- status: 200,
6782
- message: ""
6783
- }, DefaultAnnouncementData);
6784
- try {
6785
- const response = yield get(`/apis/announcements`, {
6786
- render: getRender(),
6787
- json: 1
6788
- });
6789
- const output = response.data;
6790
- result = {
6791
- status: output.code,
6792
- message: output.message,
6793
- data: output.results.data.map((item) => {
6794
- return {
6795
- alert: item.announcement_alert == "1",
6796
- show: item.announcement_show == "1",
6797
- status: item.announcement_status == "1",
6798
- announcementId: item.announcement_index,
6799
- content: item.announcement_content,
6800
- dateCreated: item.announcement_datecreated
6801
- };
6802
- })
6803
- };
6804
- } catch (error) {
6805
- const extendedError = error;
6806
- result = __spreadValues({
6807
- status: extendedError.status || 500,
6808
- message: error.message
6809
- }, DefaultAnnouncementData);
6810
- }
6811
- return result;
6812
- });
6813
- const DefaultGetJackpotTotalData = {
6814
- data: 0
6815
- };
6816
- const getJackpotTotalApi = () => __async(null, null, function* () {
6817
- var _a2;
6818
- let result = __spreadValues({
6819
- status: 200,
6820
- message: ""
6821
- }, DefaultGetJackpotTotalData);
6822
- try {
6823
- const response = yield get(`/getJackpotTotal`, {
6824
- render: getRender(),
6825
- json: 1
6826
- });
6827
- const output = response.data;
6828
- result.data = (_a2 = output.total) != null ? _a2 : 0;
6829
2637
  } catch (error) {
6830
2638
  const extendedError = error;
6831
2639
  result = __spreadValues({
6832
2640
  status: extendedError.status || 500,
6833
2641
  message: error.message
6834
- }, DefaultGetJackpotTotalData);
2642
+ }, DefaultProfileData);
6835
2643
  }
6836
2644
  return result;
6837
2645
  });
6838
2646
  export {
6839
- GameType,
6840
2647
  announcementApi,
6841
2648
  api,
6842
2649
  cmsListApi,
6843
- csLinkApi,
6844
- currentLangApi,
6845
- eGameApi,
6846
- fishGamesApi,
2650
+ footerInfoApi,
2651
+ getCashWalletApi,
6847
2652
  getJackpotTotalApi,
6848
2653
  getLocaleApi,
6849
- getLoginKeyApi,
6850
- getSettingApi,
2654
+ getMessageApi,
6851
2655
  getWinnerListApi,
6852
- homeApi,
6853
- hotGamesApi,
6854
2656
  loginApi,
6855
- promotionApi,
6856
- trialGamesApi
2657
+ messageApi,
2658
+ mobileBannerApi,
2659
+ profileApi
6857
2660
  };