├── .eslintignore ├── .eslintrc ├── .gitignore ├── .prettierrc ├── .release-it.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── commitlint.config.js ├── lefthook.yml ├── package.json ├── src ├── Constants.ts ├── MFS.ts ├── MasterPass.ts ├── Types.ts ├── Utils.ts └── index.ts ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | # Node 2 | node_modules 3 | 4 | # Build 5 | dist 6 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "react-app", 4 | "prettier/@typescript-eslint", 5 | "plugin:prettier/recommended" 6 | ], 7 | "settings": { 8 | "react": { 9 | "version": "999.999.999" 10 | } 11 | }, 12 | "rules": { 13 | "no-console": "error", 14 | "prettier/prettier": [ 15 | "error", 16 | { 17 | "quoteProps": "consistent", 18 | "singleQuote": true, 19 | "semi": false, 20 | "tabWidth": 4, 21 | "trailingComma": "es5", 22 | "useTabs": false, 23 | "arrowParens": "avoid" 24 | } 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | dist 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "quoteProps": "consistent", 3 | "singleQuote": true, 4 | "semi": false, 5 | "tabWidth": 4, 6 | "trailingComma": "es5", 7 | "useTabs": false, 8 | "arrowParens": "avoid" 9 | } 10 | -------------------------------------------------------------------------------- /.release-it.json: -------------------------------------------------------------------------------- 1 | { 2 | "git": { 3 | "commitMessage": "chore: release v${version}", 4 | "tagName": "v${version}" 5 | }, 6 | "github": { 7 | "release": true 8 | }, 9 | "npm": { 10 | "publish": true 11 | }, 12 | "plugins": { 13 | "@release-it/conventional-changelog": { 14 | "preset": "angular", 15 | "infile": "CHANGELOG.md" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # [1.0.0](https://github.com/macellan/masterpass-sdk/compare/0.1.6...1.0.0) (2024-03-14) 4 | 5 | 6 | 7 | ## [0.1.8](https://github.com/macellan/masterpass-sdk/compare/0.1.7...0.1.8) (2024-02-20) 8 | 9 | 10 | ### Bug Fixes 11 | 12 | * **Types:** update type of installmentCount value ([f5698a8](https://github.com/macellan/masterpass-sdk/commit/f5698a8553e66261e2b789b284709c2c8d29ece1)) 13 | 14 | 15 | 16 | ## [0.1.7](https://github.com/macellan/masterpass-sdk/compare/0.1.6...0.1.7) (2024-01-24) 17 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | [INSERT CONTACT METHOD]. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series of 86 | actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or permanent 93 | ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within the 113 | community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.1, available at 119 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 120 | 121 | Community Impact Guidelines were inspired by 122 | [Mozilla's code of conduct enforcement ladder][mozilla coc]. 123 | 124 | For answers to common questions about this code of conduct, see the FAQ at 125 | [https://www.contributor-covenant.org/faq][faq]. Translations are available at 126 | [https://www.contributor-covenant.org/translations][translations]. 127 | 128 | [homepage]: https://www.contributor-covenant.org 129 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 130 | [mozilla coc]: https://github.com/mozilla/diversity 131 | [faq]: https://www.contributor-covenant.org/faq 132 | [translations]: https://www.contributor-covenant.org/translations 133 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are always welcome, no matter how large or small! 4 | 5 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md). 6 | 7 | ## Development workflow 8 | 9 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 10 | 11 | ```sh 12 | yarn 13 | ``` 14 | 15 | Make sure your code passes Prettier and ESLint. Run the following to verify: 16 | 17 | ```sh 18 | yarn lint 19 | ``` 20 | 21 | To fix formatting errors, run the following: 22 | 23 | ```sh 24 | yarn lint --fix 25 | ``` 26 | 27 | ### Commit message convention 28 | 29 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 30 | 31 | - `feat`: new features, e.g. add new method to the module. 32 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 33 | - `docs`: changes into documentation, e.g. add usage example for the module. 34 | - `style`: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.) 35 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 36 | - `perf`: improvements to code performance, e.g. optimize an algorithm to speed up processing. 37 | - `test`: adding or updating tests, e.g. add integration tests using detox. 38 | - `build`: changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm). 39 | - `chore`: tooling changes, e.g. change CI config. 40 | - `ci`: changes to our CI configuration files and scripts (examples: GitHub Actions, CircleCI). 41 | - `revert`: reverts a previous commit 42 | 43 | Our pre-commit hooks verify that your commit message matches this format when committing. 44 | 45 | ### Branch names convention 46 | 47 | We use the following branche names convention related to conventional commits: 48 | 49 | - `master` is the production branch 50 | - `feat/` is the name of the feature branch 51 | - `fix/` is the name of the fix branch 52 | - `docs/` is the name of the docs branch 53 | - `style/` is the name of the style branch 54 | - `refactor/` is the name of the refactor branch 55 | - `perf/` is the name of the perf branch 56 | - `test/` is the name of the test branch 57 | - `build/` is the name of the build branch 58 | - `chore/` is the name of the chore branch 59 | - `ci/` is the name of the ci branch 60 | - `revert/` is the name of the revert branch 61 | 62 | ### Linting and tests 63 | 64 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 65 | 66 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 67 | 68 | Our pre-commit hooks verify that the linter and tests pass when committing. 69 | 70 | ### Publishing to npm 71 | 72 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. 73 | 74 | To publish new versions, run the following: 75 | 76 | ```sh 77 | yarn release 78 | ``` 79 | 80 | ### Scripts 81 | 82 | The `package.json` file contains various scripts for common tasks: 83 | 84 | - `yarn start`: watch and build the library in development mode. 85 | - `yarn build`: build the library for production to the `dist` folder. 86 | - `yarn test`: run unit tests with Jest. 87 | - `yarn lint`: lint files with ESLint. 88 | - `yarn release`: release a new version of the library. 89 | 90 | ### Sending a pull request 91 | 92 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). 93 | 94 | When you're sending a pull request: 95 | 96 | - Prefer small pull requests focused on one change. 97 | - Verify that linters and tests are passing. 98 | - Review the documentation to make sure it looks good. 99 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Macellan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Macellan - MasterPass SDK 2 | 3 | The Masterpass SDK provides a comprehensive set of features to interact with Masterpass services. This module includes utilities for handling various Masterpass-related tasks such as user registration, card management, transaction validation, and making purchases. 4 | 5 | ## Features 6 | 7 | - 🛠️ **Ease of Use** : Simplifies interactions with the MasterPass Web SDK by removing the need to work with iframes and handling complex setups, presenting a straightforward API to accelerate development processes. 8 | 9 | - 🌍 **Framework Agnostic**: The SDK is compatible with any JavaScript framework such as React, React Native, Vue, Angular, or Vanilla JavaScript, providing a versatile solution regardless of the technological stack. 10 | 11 | - 💅 **Type Safety**: Fully supports TypeScript, offering a type-safe environment that helps in preventing many common bugs that can occur during development, ensuring more stable code. 12 | 13 | ## Installation 14 | 15 | ```bash 16 | npm install @macellan/masterpass-sdk 17 | ``` 18 | 19 | ```bash 20 | yarn add @macellan/masterpass-sdk 21 | ``` 22 | 23 | ## Usage 24 | 25 | ```ts 26 | MasterPassSDK.setAddress('MASTERPASS_SERVICE_URL') 27 | MasterPassSDK.setClientId('MASTERPASS_CLIENT_ID') 28 | 29 | const registerResponse = await MasterPassSDK.register({ 30 | msisdn: '1234567890', // Mobile number 31 | token: 'SOME_AUTH_TOKEN', // Authentication token received from your backend server 32 | rtaPan: '4512345678901234', // Real-time PAN (Primary Account Number) of the card 33 | expiryDate: '1224', // MMYY format 34 | accountAliasName: 'My Card', // A user-friendly name for the card 35 | sendSms: 'N', // Whether to send confirmation via SMS 36 | sendSmsLanguage: 'ENG', // Language of the SMS (often as language codes such as "ENG" for English) 37 | referenceNo: 'REF123456789', // Unique reference for the transaction 38 | }) 39 | 40 | const listCardsResponse = await MasterPassSDK.listCards( 41 | '1234567890', // Mobile number 42 | 'SOME_AUTH_TOKEN' // Authentication token received from your backend server 43 | ) 44 | ``` 45 | 46 | ## API Reference 47 | 48 | - `setAddress(serviceUrl: string): void` 49 | 50 | - Sets the address of the MasterPass service endpoint. 51 | 52 | - `setClientId(clientId: string): void` 53 | 54 | - Sets the client ID for interaction with MasterPass services. 55 | 56 | - `checkMasterPass(data: CheckMasterPassData): Promise` 57 | 58 | - Checks the status with MasterPass using provided data. 59 | - **Parameters:** 60 | - `data: CheckMasterPassData` - Object containing user ID, token, etc. 61 | 62 | - `listCards(msisdn: string, token: string): Promise` 63 | 64 | - Lists all linked cards associated with the given mobile number. 65 | - **Parameters:** 66 | - `msisdn: string` - Mobile number. 67 | - `token: string` - Authentication token. 68 | 69 | - `register(data: RegisterData): Promise` 70 | 71 | - Registers a new card with MasterPass. 72 | - **Parameters:** 73 | - `data: RegisterData` - Registration data like msisdn, token, etc. 74 | 75 | - `validateTransaction(data: ValidateTransactionData): Promise` 76 | 77 | - Validates a transaction with the provided data. 78 | - **Parameters:** 79 | - `data: ValidateTransactionData` - Data for transaction validation. 80 | 81 | - `deleteCard(data: DeleteCardData): Promise` 82 | 83 | - Deletes a card from the MasterPass database. 84 | - **Parameters:** 85 | - `data: DeleteCardData` - Information of the card to be deleted. 86 | 87 | * `getLastToken(): string` 88 | 89 | - Retrieves the last stored token. 90 | 91 | - `resendOtp(sendSmsLanguage: string): Promise` 92 | 93 | - Resends the OTP for user verification. 94 | - **Parameters:** 95 | - `sendSmsLanguage: string` - Language code for the SMS. 96 | 97 | - `linkCardToClient(data: LinkCardToClientData): Promise` 98 | 99 | - Links a card to a MasterPass client. 100 | - **Parameters:** 101 | - `data: LinkCardToClientData` - Data required for linking a card. 102 | 103 | - `purchase(data: PurchaseData): Promise` 104 | 105 | - Processes a purchase transaction. 106 | - **Parameters:** 107 | - `data: PurchaseData` - Data required for the purchase. 108 | 109 | - `purchaseAndRegister(data: PurchaseAndRegisterData): Promise` 110 | 111 | - Combines the actions of purchase and registration in a single step. 112 | - **Parameters:** 113 | - `data: PurchaseAndRegisterData` - Data for purchase and registration. 114 | 115 | - `directPurchase(data: DirectPurchaseData): Promise` 116 | - Initiates a direct purchase without a pre-linked card. 117 | - **Parameters:** 118 | - `data: DirectPurchaseData` - Data required for direct purchase. 119 | 120 | * `setAdditionalParameters(data: object): void` 121 | 122 | - Sets additional parameters for configuration. 123 | - **Parameters:** 124 | - `data: object` - Parameters to be set. 125 | 126 | ## Contributing 127 | 128 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. 129 | 130 | ## License 131 | 132 | This project is licensed under the [MIT License](LICENSE). 133 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: ['@commitlint/config-conventional'] } 2 | -------------------------------------------------------------------------------- /lefthook.yml: -------------------------------------------------------------------------------- 1 | pre-commit: 2 | parallel: true 3 | commands: 4 | lint: 5 | files: git diff --name-only @{push} 6 | glob: '*.{js,ts,jsx,tsx}' 7 | run: yarn lint {files} 8 | types: 9 | files: git diff --name-only @{push} 10 | glob: '*.{js,ts,jsx,tsx}' 11 | run: yarn tsc --noEmit 12 | commit-msg: 13 | parallel: true 14 | commands: 15 | commitlint: 16 | run: yarn commitlint --edit 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@macellan/masterpass-sdk", 3 | "author": "Onur Özkaya", 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "main": "dist/index.js", 7 | "typings": "dist/index.d.ts", 8 | "files": [ 9 | "dist", 10 | "src" 11 | ], 12 | "engines": { 13 | "node": ">=10" 14 | }, 15 | "publishConfig": { 16 | "access": "public", 17 | "registry": "https://registry.npmjs.org" 18 | }, 19 | "homepage": "https://github.com/macellan/masterpass-sdk", 20 | "scripts": { 21 | "start": "tsdx watch", 22 | "build": "tsdx build", 23 | "test": "tsdx test", 24 | "lint": "tsdx lint", 25 | "prepare": "tsdx build", 26 | "prepack": "yarn build", 27 | "size": "size-limit", 28 | "analyze": "size-limit --why", 29 | "release": "release-it" 30 | }, 31 | "module": "dist/masterpass-sdk.esm.js", 32 | "peerDependencies": { 33 | "axios": "*" 34 | }, 35 | "size-limit": [ 36 | { 37 | "path": "dist/masterpass-sdk.cjs.production.min.js", 38 | "limit": "10 KB" 39 | }, 40 | { 41 | "path": "dist/masterpass-sdk.esm.js", 42 | "limit": "10 KB" 43 | } 44 | ], 45 | "devDependencies": { 46 | "@commitlint/cli": "^17.6.6", 47 | "@commitlint/config-conventional": "^17.6.6", 48 | "@release-it/conventional-changelog": "^8.0.1", 49 | "@size-limit/preset-small-lib": "^8.2.6", 50 | "axios": "^1.4.0", 51 | "lefthook": "^1.4.3", 52 | "release-it": "^17.1.1", 53 | "size-limit": "^8.2.6", 54 | "tsdx": "^0.14.1", 55 | "tslib": "^2.5.3", 56 | "typescript": "^5.1.3" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Constants.ts: -------------------------------------------------------------------------------- 1 | import { DefaultMethodDataConstants } from './Types' 2 | 3 | const DefaultMethodData: DefaultMethodDataConstants = { 4 | register: { 5 | actionType: 'A', 6 | eActionType: 'A', 7 | cardTypeFlag: '05', 8 | cpinFlag: 'Y', 9 | defaultAccount: 'Y', 10 | mmrpConfig: '110010', 11 | identityVerificationFlag: 'Y', 12 | mobileAccountConfig: 'MWA', 13 | timeZone: '+01', 14 | uiChannelType: '06', 15 | }, 16 | validateTransaction: { 17 | pinType: 'otp', 18 | }, 19 | purchase: { 20 | macroMerchantId: '', 21 | orderNo: '', 22 | paymentType: '', 23 | rewardName: '', 24 | cvc: '', 25 | sendSms: 'N', 26 | aav: 'aav', 27 | clientIp: '', 28 | encCPin: '0', 29 | encPassword: '', 30 | sendSmsMerchant: 'Y', 31 | password: '', 32 | }, 33 | } 34 | 35 | const ResponseCodes = { 36 | SUCCESS_EMPTY: '', 37 | SUCCESS: '0000', 38 | VALIDATE_OTP: '5001', 39 | VALIDATE_MPIN: '5002', 40 | VALIDATE_DEVICE: '5008', 41 | VALIDATE_3D_SECURE: '5010', 42 | PIN_DETERMINATION: '5015', 43 | } 44 | 45 | export default { 46 | DefaultMethodData: DefaultMethodData, 47 | ResponseCodes: ResponseCodes, 48 | } 49 | -------------------------------------------------------------------------------- /src/MFS.ts: -------------------------------------------------------------------------------- 1 | /*! mfs-client 24-02-2021 */ 2 | 3 | // @ts-nocheck 4 | /* eslint-disable */ 5 | 6 | import axios from 'axios' 7 | import type { MasterPassSDKMethods } from './Types' 8 | 9 | var SDK: MasterPassSDKMethods = {} 10 | 11 | var dbits, 12 | canary = 0xdeadbeefcafe, 13 | j_lm = 15715070 == (16777215 & canary) 14 | function BigInteger(t, e, r) { 15 | null != t && 16 | ('number' == typeof t 17 | ? this.fromNumber(t, e, r) 18 | : null == e && 'string' != typeof t 19 | ? this.fromString(t, 256) 20 | : this.fromString(t, e)) 21 | } 22 | function nbi() { 23 | return new BigInteger(null) 24 | } 25 | function am1(t, e, r, n, o, i) { 26 | for (; 0 <= --i; ) { 27 | var s = e * this[t++] + r[n] + o 28 | ;(o = Math.floor(s / 67108864)), (r[n++] = 67108863 & s) 29 | } 30 | return o 31 | } 32 | function am2(t, e, r, n, o, i) { 33 | for (var s = 32767 & e, a = e >> 15; 0 <= --i; ) { 34 | var u = 32767 & this[t], 35 | c = this[t++] >> 15, 36 | l = a * u + c * s 37 | ;(o = 38 | ((u = s * u + ((32767 & l) << 15) + r[n] + (1073741823 & o)) >>> 30) + 39 | (l >>> 15) + 40 | a * c + 41 | (o >>> 30)), 42 | (r[n++] = 1073741823 & u) 43 | } 44 | return o 45 | } 46 | function am3(t, e, r, n, o, i) { 47 | for (var s = 16383 & e, a = e >> 14; 0 <= --i; ) { 48 | var u = 16383 & this[t], 49 | c = this[t++] >> 14, 50 | l = a * u + c * s 51 | ;(o = 52 | ((u = s * u + ((16383 & l) << 14) + r[n] + o) >> 28) + (l >> 14) + a * c), 53 | (r[n++] = 268435455 & u) 54 | } 55 | return o 56 | } 57 | ;(dbits = 58 | j_lm && 'Microsoft Internet Explorer' == navigator.appName 59 | ? ((BigInteger.prototype.am = am2), 30) 60 | : j_lm && 'Netscape' != navigator.appName 61 | ? ((BigInteger.prototype.am = am1), 26) 62 | : ((BigInteger.prototype.am = am3), 28)), 63 | (BigInteger.prototype.DB = dbits), 64 | (BigInteger.prototype.DM = (1 << dbits) - 1), 65 | (BigInteger.prototype.DV = 1 << dbits) 66 | var BI_FP = 52 67 | ;(BigInteger.prototype.FV = Math.pow(2, BI_FP)), 68 | (BigInteger.prototype.F1 = BI_FP - dbits), 69 | (BigInteger.prototype.F2 = 2 * dbits - BI_FP) 70 | for ( 71 | var BI_RM = '0123456789abcdefghijklmnopqrstuvwxyz', 72 | BI_RC = new Array(), 73 | rr = '0'.charCodeAt(0), 74 | vv = 0; 75 | vv <= 9; 76 | ++vv 77 | ) 78 | BI_RC[rr++] = vv 79 | for (rr = 'a'.charCodeAt(0), vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv 80 | for (rr = 'A'.charCodeAt(0), vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv 81 | function int2char(t) { 82 | return BI_RM.charAt(t) 83 | } 84 | function intAt(t, e) { 85 | e = BI_RC[t.charCodeAt(e)] 86 | return null == e ? -1 : e 87 | } 88 | function bnpCopyTo(t) { 89 | for (var e = this.t - 1; 0 <= e; --e) t[e] = this[e] 90 | ;(t.t = this.t), (t.s = this.s) 91 | } 92 | function bnpFromInt(t) { 93 | ;(this.t = 1), 94 | (this.s = t < 0 ? -1 : 0), 95 | 0 < t ? (this[0] = t) : t < -1 ? (this[0] = t + this.DV) : (this.t = 0) 96 | } 97 | function nbv(t) { 98 | var e = nbi() 99 | return e.fromInt(t), e 100 | } 101 | function bnpFromString(t, e) { 102 | var r 103 | if (16 == e) r = 4 104 | else if (8 == e) r = 3 105 | else if (256 == e) r = 8 106 | else if (2 == e) r = 1 107 | else if (32 == e) r = 5 108 | else { 109 | if (4 != e) return void this.fromRadix(t, e) 110 | r = 2 111 | } 112 | ;(this.t = 0), (this.s = 0) 113 | for (var n = t.length, o = !1, i = 0; 0 <= --n; ) { 114 | var s = 8 == r ? 255 & t[n] : intAt(t, n) 115 | s < 0 116 | ? '-' == t.charAt(n) && (o = !0) 117 | : ((o = !1), 118 | 0 == i 119 | ? (this[this.t++] = s) 120 | : i + r > this.DB 121 | ? ((this[this.t - 1] |= (s & ((1 << (this.DB - i)) - 1)) << i), 122 | (this[this.t++] = s >> (this.DB - i))) 123 | : (this[this.t - 1] |= s << i), 124 | (i += r) >= this.DB && (i -= this.DB)) 125 | } 126 | 8 == r && 127 | 0 != (128 & t[0]) && 128 | ((this.s = -1), 129 | 0 < i && (this[this.t - 1] |= ((1 << (this.DB - i)) - 1) << i)), 130 | this.clamp(), 131 | o && BigInteger.ZERO.subTo(this, this) 132 | } 133 | function bnpClamp() { 134 | for (var t = this.s & this.DM; 0 < this.t && this[this.t - 1] == t; ) --this.t 135 | } 136 | function bnToString(t) { 137 | if (this.s < 0) return '-' + this.negate().toString(t) 138 | var e 139 | if (16 == t) e = 4 140 | else if (8 == t) e = 3 141 | else if (2 == t) e = 1 142 | else if (32 == t) e = 5 143 | else { 144 | if (4 != t) return this.toRadix(t) 145 | e = 2 146 | } 147 | var r, 148 | n = (1 << e) - 1, 149 | o = !1, 150 | i = '', 151 | s = this.t, 152 | a = this.DB - ((s * this.DB) % e) 153 | if (0 < s--) 154 | for ( 155 | a < this.DB && 0 < (r = this[s] >> a) && ((o = !0), (i = int2char(r))); 156 | 0 <= s; 157 | 158 | ) 159 | a < e 160 | ? ((r = (this[s] & ((1 << a) - 1)) << (e - a)), 161 | (r |= this[--s] >> (a += this.DB - e))) 162 | : ((r = (this[s] >> (a -= e)) & n), a <= 0 && ((a += this.DB), --s)), 163 | (o = 0 < r ? !0 : o) && (i += int2char(r)) 164 | return o ? i : '0' 165 | } 166 | function bnNegate() { 167 | var t = nbi() 168 | return BigInteger.ZERO.subTo(this, t), t 169 | } 170 | function bnAbs() { 171 | return this.s < 0 ? this.negate() : this 172 | } 173 | function bnCompareTo(t) { 174 | var e = this.s - t.s 175 | if (0 != e) return e 176 | var r = this.t 177 | if (0 != (e = r - t.t)) return this.s < 0 ? -e : e 178 | for (; 0 <= --r; ) if (0 != (e = this[r] - t[r])) return e 179 | return 0 180 | } 181 | function nbits(t) { 182 | var e, 183 | r = 1 184 | return ( 185 | 0 != (e = t >>> 16) && ((t = e), (r += 16)), 186 | 0 != (e = t >> 8) && ((t = e), (r += 8)), 187 | 0 != (e = t >> 4) && ((t = e), (r += 4)), 188 | 0 != (e = t >> 2) && ((t = e), (r += 2)), 189 | 0 != (e = t >> 1) && ((t = e), (r += 1)), 190 | r 191 | ) 192 | } 193 | function bnBitLength() { 194 | return this.t <= 0 195 | ? 0 196 | : this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM)) 197 | } 198 | function bnpDLShiftTo(t, e) { 199 | for (var r = this.t - 1; 0 <= r; --r) e[r + t] = this[r] 200 | for (r = t - 1; 0 <= r; --r) e[r] = 0 201 | ;(e.t = this.t + t), (e.s = this.s) 202 | } 203 | function bnpDRShiftTo(t, e) { 204 | for (var r = t; r < this.t; ++r) e[r - t] = this[r] 205 | ;(e.t = Math.max(this.t - t, 0)), (e.s = this.s) 206 | } 207 | function bnpLShiftTo(t, e) { 208 | for ( 209 | var r = t % this.DB, 210 | n = this.DB - r, 211 | o = (1 << n) - 1, 212 | i = Math.floor(t / this.DB), 213 | s = (this.s << r) & this.DM, 214 | a = this.t - 1; 215 | 0 <= a; 216 | --a 217 | ) 218 | (e[a + i + 1] = (this[a] >> n) | s), (s = (this[a] & o) << r) 219 | for (a = i - 1; 0 <= a; --a) e[a] = 0 220 | ;(e[i] = s), (e.t = this.t + i + 1), (e.s = this.s), e.clamp() 221 | } 222 | function bnpRShiftTo(t, e) { 223 | e.s = this.s 224 | var r = Math.floor(t / this.DB) 225 | if (r >= this.t) e.t = 0 226 | else { 227 | var n = t % this.DB, 228 | o = this.DB - n, 229 | i = (1 << n) - 1 230 | e[0] = this[r] >> n 231 | for (var s = r + 1; s < this.t; ++s) 232 | (e[s - r - 1] |= (this[s] & i) << o), (e[s - r] = this[s] >> n) 233 | 0 < n && (e[this.t - r - 1] |= (this.s & i) << o), 234 | (e.t = this.t - r), 235 | e.clamp() 236 | } 237 | } 238 | function bnpSubTo(t, e) { 239 | for (var r = 0, n = 0, o = Math.min(t.t, this.t); r < o; ) 240 | (n += this[r] - t[r]), (e[r++] = n & this.DM), (n >>= this.DB) 241 | if (t.t < this.t) { 242 | for (n -= t.s; r < this.t; ) 243 | (n += this[r]), (e[r++] = n & this.DM), (n >>= this.DB) 244 | n += this.s 245 | } else { 246 | for (n += this.s; r < t.t; ) 247 | (n -= t[r]), (e[r++] = n & this.DM), (n >>= this.DB) 248 | n -= t.s 249 | } 250 | ;(e.s = n < 0 ? -1 : 0), 251 | n < -1 ? (e[r++] = this.DV + n) : 0 < n && (e[r++] = n), 252 | (e.t = r), 253 | e.clamp() 254 | } 255 | function bnpMultiplyTo(t, e) { 256 | var r = this.abs(), 257 | n = t.abs(), 258 | o = r.t 259 | for (e.t = o + n.t; 0 <= --o; ) e[o] = 0 260 | for (o = 0; o < n.t; ++o) e[o + r.t] = r.am(0, n[o], e, o, 0, r.t) 261 | ;(e.s = 0), e.clamp(), this.s != t.s && BigInteger.ZERO.subTo(e, e) 262 | } 263 | function bnpSquareTo(t) { 264 | for (var e = this.abs(), r = (t.t = 2 * e.t); 0 <= --r; ) t[r] = 0 265 | for (r = 0; r < e.t - 1; ++r) { 266 | var n = e.am(r, e[r], t, 2 * r, 0, 1) 267 | ;(t[r + e.t] += e.am(r + 1, 2 * e[r], t, 2 * r + 1, n, e.t - r - 1)) >= 268 | e.DV && ((t[r + e.t] -= e.DV), (t[r + e.t + 1] = 1)) 269 | } 270 | 0 < t.t && (t[t.t - 1] += e.am(r, e[r], t, 2 * r, 0, 1)), (t.s = 0), t.clamp() 271 | } 272 | function bnpDivRemTo(t, e, r) { 273 | var n = t.abs() 274 | if (!(n.t <= 0)) { 275 | var o = this.abs() 276 | if (o.t < n.t) 277 | return null != e && e.fromInt(0), void (null != r && this.copyTo(r)) 278 | null == r && (r = nbi()) 279 | var i = nbi(), 280 | s = this.s, 281 | a = t.s, 282 | t = this.DB - nbits(n[n.t - 1]) 283 | 0 < t ? (n.lShiftTo(t, i), o.lShiftTo(t, r)) : (n.copyTo(i), o.copyTo(r)) 284 | var u = i.t, 285 | c = i[u - 1] 286 | if (0 != c) { 287 | var o = c * (1 << this.F1) + (1 < u ? i[u - 2] >> this.F2 : 0), 288 | l = this.FV / o, 289 | p = (1 << this.F1) / o, 290 | f = 1 << this.F2, 291 | h = r.t, 292 | d = h - u, 293 | y = null == e ? nbi() : e 294 | for ( 295 | i.dlShiftTo(d, y), 296 | 0 <= r.compareTo(y) && ((r[r.t++] = 1), r.subTo(y, r)), 297 | BigInteger.ONE.dlShiftTo(u, y), 298 | y.subTo(i, i); 299 | i.t < u; 300 | 301 | ) 302 | i[i.t++] = 0 303 | for (; 0 <= --d; ) { 304 | var m = 305 | r[--h] == c ? this.DM : Math.floor(r[h] * l + (r[h - 1] + f) * p) 306 | if ((r[h] += i.am(0, m, r, d, 0, u)) < m) 307 | for (i.dlShiftTo(d, y), r.subTo(y, r); r[h] < --m; ) r.subTo(y, r) 308 | } 309 | null != e && (r.drShiftTo(u, e), s != a && BigInteger.ZERO.subTo(e, e)), 310 | (r.t = u), 311 | r.clamp(), 312 | 0 < t && r.rShiftTo(t, r), 313 | s < 0 && BigInteger.ZERO.subTo(r, r) 314 | } 315 | } 316 | } 317 | function bnMod(t) { 318 | var e = nbi() 319 | return ( 320 | this.abs().divRemTo(t, null, e), 321 | this.s < 0 && 0 < e.compareTo(BigInteger.ZERO) && t.subTo(e, e), 322 | e 323 | ) 324 | } 325 | function Classic(t) { 326 | this.m = t 327 | } 328 | function cConvert(t) { 329 | return t.s < 0 || 0 <= t.compareTo(this.m) ? t.mod(this.m) : t 330 | } 331 | function cRevert(t) { 332 | return t 333 | } 334 | function cReduce(t) { 335 | t.divRemTo(this.m, null, t) 336 | } 337 | function cMulTo(t, e, r) { 338 | t.multiplyTo(e, r), this.reduce(r) 339 | } 340 | function cSqrTo(t, e) { 341 | t.squareTo(e), this.reduce(e) 342 | } 343 | function bnpInvDigit() { 344 | if (this.t < 1) return 0 345 | var t = this[0] 346 | if (0 == (1 & t)) return 0 347 | var e = 3 & t 348 | return 0 < 349 | (e = 350 | ((e = 351 | ((e = 352 | ((e = (e * (2 - (15 & t) * e)) & 15) * (2 - (255 & t) * e)) & 255) * 353 | (2 - (((65535 & t) * e) & 65535))) & 354 | 65535) * 355 | (2 - ((t * e) % this.DV))) % 356 | this.DV) 357 | ? this.DV - e 358 | : -e 359 | } 360 | function Montgomery(t) { 361 | ;(this.m = t), 362 | (this.mp = t.invDigit()), 363 | (this.mpl = 32767 & this.mp), 364 | (this.mph = this.mp >> 15), 365 | (this.um = (1 << (t.DB - 15)) - 1), 366 | (this.mt2 = 2 * t.t) 367 | } 368 | function montConvert(t) { 369 | var e = nbi() 370 | return ( 371 | t.abs().dlShiftTo(this.m.t, e), 372 | e.divRemTo(this.m, null, e), 373 | t.s < 0 && 0 < e.compareTo(BigInteger.ZERO) && this.m.subTo(e, e), 374 | e 375 | ) 376 | } 377 | function montRevert(t) { 378 | var e = nbi() 379 | return t.copyTo(e), this.reduce(e), e 380 | } 381 | function montReduce(t) { 382 | for (; t.t <= this.mt2; ) t[t.t++] = 0 383 | for (var e = 0; e < this.m.t; ++e) { 384 | var r = 32767 & t[e], 385 | n = 386 | (r * this.mpl + 387 | (((r * this.mph + (t[e] >> 15) * this.mpl) & this.um) << 15)) & 388 | t.DM 389 | for ( 390 | t[(r = e + this.m.t)] += this.m.am(0, n, t, e, 0, this.m.t); 391 | t[r] >= t.DV; 392 | 393 | ) 394 | (t[r] -= t.DV), t[++r]++ 395 | } 396 | t.clamp(), 397 | t.drShiftTo(this.m.t, t), 398 | 0 <= t.compareTo(this.m) && t.subTo(this.m, t) 399 | } 400 | function montSqrTo(t, e) { 401 | t.squareTo(e), this.reduce(e) 402 | } 403 | function montMulTo(t, e, r) { 404 | t.multiplyTo(e, r), this.reduce(r) 405 | } 406 | function bnpIsEven() { 407 | return 0 == (0 < this.t ? 1 & this[0] : this.s) 408 | } 409 | function bnpExp(t, e) { 410 | if (4294967295 < t || t < 1) return BigInteger.ONE 411 | var r, 412 | n = nbi(), 413 | o = nbi(), 414 | i = e.convert(this), 415 | s = nbits(t) - 1 416 | for (i.copyTo(n); 0 <= --s; ) 417 | e.sqrTo(n, o), 418 | 0 < (t & (1 << s)) ? e.mulTo(o, i, n) : ((r = n), (n = o), (o = r)) 419 | return e.revert(n) 420 | } 421 | function bnModPowInt(t, e) { 422 | e = new (t < 256 || e.isEven() ? Classic : Montgomery)(e) 423 | return this.exp(t, e) 424 | } 425 | function Arcfour() { 426 | ;(this.i = 0), (this.j = 0), (this.S = new Array()) 427 | } 428 | function ARC4init(t) { 429 | for (var e, r, n = 0; n < 256; ++n) this.S[n] = n 430 | for (n = e = 0; n < 256; ++n) 431 | (e = (e + this.S[n] + t[n % t.length]) & 255), 432 | (r = this.S[n]), 433 | (this.S[n] = this.S[e]), 434 | (this.S[e] = r) 435 | ;(this.i = 0), (this.j = 0) 436 | } 437 | function ARC4next() { 438 | var t 439 | return ( 440 | (this.i = (this.i + 1) & 255), 441 | (this.j = (this.j + this.S[this.i]) & 255), 442 | (t = this.S[this.i]), 443 | (this.S[this.i] = this.S[this.j]), 444 | (this.S[this.j] = t), 445 | this.S[(t + this.S[this.i]) & 255] 446 | ) 447 | } 448 | function prng_newstate() { 449 | return new Arcfour() 450 | } 451 | ;(Classic.prototype.convert = cConvert), 452 | (Classic.prototype.revert = cRevert), 453 | (Classic.prototype.reduce = cReduce), 454 | (Classic.prototype.mulTo = cMulTo), 455 | (Classic.prototype.sqrTo = cSqrTo), 456 | (Montgomery.prototype.convert = montConvert), 457 | (Montgomery.prototype.revert = montRevert), 458 | (Montgomery.prototype.reduce = montReduce), 459 | (Montgomery.prototype.mulTo = montMulTo), 460 | (Montgomery.prototype.sqrTo = montSqrTo), 461 | (BigInteger.prototype.copyTo = bnpCopyTo), 462 | (BigInteger.prototype.fromInt = bnpFromInt), 463 | (BigInteger.prototype.fromString = bnpFromString), 464 | (BigInteger.prototype.clamp = bnpClamp), 465 | (BigInteger.prototype.dlShiftTo = bnpDLShiftTo), 466 | (BigInteger.prototype.drShiftTo = bnpDRShiftTo), 467 | (BigInteger.prototype.lShiftTo = bnpLShiftTo), 468 | (BigInteger.prototype.rShiftTo = bnpRShiftTo), 469 | (BigInteger.prototype.subTo = bnpSubTo), 470 | (BigInteger.prototype.multiplyTo = bnpMultiplyTo), 471 | (BigInteger.prototype.squareTo = bnpSquareTo), 472 | (BigInteger.prototype.divRemTo = bnpDivRemTo), 473 | (BigInteger.prototype.invDigit = bnpInvDigit), 474 | (BigInteger.prototype.isEven = bnpIsEven), 475 | (BigInteger.prototype.exp = bnpExp), 476 | (BigInteger.prototype.toString = bnToString), 477 | (BigInteger.prototype.negate = bnNegate), 478 | (BigInteger.prototype.abs = bnAbs), 479 | (BigInteger.prototype.compareTo = bnCompareTo), 480 | (BigInteger.prototype.bitLength = bnBitLength), 481 | (BigInteger.prototype.mod = bnMod), 482 | (BigInteger.prototype.modPowInt = bnModPowInt), 483 | (BigInteger.ZERO = nbv(0)), 484 | (BigInteger.ONE = nbv(1)), 485 | (Arcfour.prototype.init = ARC4init), 486 | (Arcfour.prototype.next = ARC4next) 487 | var rng_state, 488 | rng_psize = 256 489 | function rng_seed_int(t) { 490 | ;(rng_pool[rng_pptr++] ^= 255 & t), 491 | (rng_pool[rng_pptr++] ^= (t >> 8) & 255), 492 | (rng_pool[rng_pptr++] ^= (t >> 16) & 255), 493 | (rng_pool[rng_pptr++] ^= (t >> 24) & 255), 494 | rng_psize <= rng_pptr && (rng_pptr -= rng_psize) 495 | } 496 | function rng_seed_time() { 497 | rng_seed_int(new Date().getTime()) 498 | } 499 | if (null == rng_pool) { 500 | var rng_pool = new Array(), 501 | rng_pptr = 0 502 | if (window.crypto && window.crypto.getRandomValues) { 503 | var ua = new Uint8Array(32) 504 | for (window.crypto.getRandomValues(ua), t = 0; t < 32; ++t) 505 | rng_pool[rng_pptr++] = ua[t] 506 | } 507 | if ( 508 | 'Netscape' == navigator.appName && 509 | navigator.appVersion < '5' && 510 | window.crypto 511 | ) 512 | for (var z = window.crypto.random(32), t = 0; t < z.length; ++t) 513 | rng_pool[rng_pptr++] = 255 & z.charCodeAt(t) 514 | for (; rng_pptr < rng_psize; ) 515 | (t = Math.floor(65536 * Math.random())), 516 | (rng_pool[rng_pptr++] = t >>> 8), 517 | (rng_pool[rng_pptr++] = 255 & t) 518 | ;(rng_pptr = 0), rng_seed_time() 519 | } 520 | function rng_get_byte() { 521 | if (null == rng_state) { 522 | for ( 523 | rng_seed_time(), 524 | (rng_state = prng_newstate()).init(rng_pool), 525 | rng_pptr = 0; 526 | rng_pptr < rng_pool.length; 527 | ++rng_pptr 528 | ) 529 | rng_pool[rng_pptr] = 0 530 | rng_pptr = 0 531 | } 532 | return rng_state.next() 533 | } 534 | function rng_get_bytes(t) { 535 | for (var e = 0; e < t.length; ++e) t[e] = rng_get_byte() 536 | } 537 | function SecureRandom() {} 538 | function parseBigInt(t, e) { 539 | return new BigInteger(t, e) 540 | } 541 | function linebrk(t, e) { 542 | for (var r = '', n = 0; n + e < t.length; ) 543 | (r += t.substring(n, n + e) + '\n'), (n += e) 544 | return r + t.substring(n, t.length) 545 | } 546 | function byte2Hex(t) { 547 | return t < 16 ? '0' + t.toString(16) : t.toString(16) 548 | } 549 | function pkcs1pad2(t, e) { 550 | if (e < t.length + 11) return alert('Message too long for RSA'), null 551 | for (var r = new Array(), n = t.length - 1; 0 <= n && 0 < e; ) { 552 | var o = t.charCodeAt(n--) 553 | o < 128 554 | ? (r[--e] = o) 555 | : 127 < o && o < 2048 556 | ? ((r[--e] = (63 & o) | 128), (r[--e] = (o >> 6) | 192)) 557 | : ((r[--e] = (63 & o) | 128), 558 | (r[--e] = ((o >> 6) & 63) | 128), 559 | (r[--e] = (o >> 12) | 224)) 560 | } 561 | r[--e] = 0 562 | for (var i = new SecureRandom(), s = new Array(); 2 < e; ) { 563 | for (s[0] = 0; 0 == s[0]; ) i.nextBytes(s) 564 | r[--e] = s[0] 565 | } 566 | return (r[--e] = 2), (r[--e] = 0), new BigInteger(r) 567 | } 568 | function RSAKey() { 569 | ;(this.n = null), 570 | (this.e = 0), 571 | (this.d = null), 572 | (this.p = null), 573 | (this.q = null), 574 | (this.dmp1 = null), 575 | (this.dmq1 = null), 576 | (this.coeff = null) 577 | } 578 | function RSASetPublic(t, e) { 579 | null != t && null != e && 0 < t.length && 0 < e.length 580 | ? ((this.n = parseBigInt(t, 16)), (this.e = parseInt(e, 16))) 581 | : alert('Invalid RSA public key') 582 | } 583 | function RSADoPublic(t) { 584 | return t.modPowInt(this.e, this.n) 585 | } 586 | function RSAEncrypt(t) { 587 | t = pkcs1pad2(t, (this.n.bitLength() + 7) >> 3) 588 | if (null == t) return null 589 | t = this.doPublic(t) 590 | if (null == t) return null 591 | t = t.toString(16) 592 | return 0 == (1 & t.length) ? t : '0' + t 593 | } 594 | ;(SecureRandom.prototype.nextBytes = rng_get_bytes), 595 | (RSAKey.prototype.doPublic = RSADoPublic), 596 | (RSAKey.prototype.setPublic = RSASetPublic), 597 | (RSAKey.prototype.encrypt = RSAEncrypt) 598 | var b64map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', 599 | b64padchar = '=' 600 | function hex2b64(t) { 601 | for (var e, r = '', n = 0; n + 3 <= t.length; n += 3) 602 | (e = parseInt(t.substring(n, n + 3), 16)), 603 | (r += b64map.charAt(e >> 6) + b64map.charAt(63 & e)) 604 | for ( 605 | n + 1 == t.length 606 | ? ((e = parseInt(t.substring(n, n + 1), 16)), 607 | (r += b64map.charAt(e << 2))) 608 | : n + 2 == t.length && 609 | ((e = parseInt(t.substring(n, n + 2), 16)), 610 | (r += b64map.charAt(e >> 2) + b64map.charAt((3 & e) << 4))); 611 | 0 < (3 & r.length); 612 | 613 | ) 614 | r += b64padchar 615 | return r 616 | } 617 | function b64tohex(t) { 618 | for ( 619 | var e, r = '', n = 0, o = 0; 620 | o < t.length && t.charAt(o) != b64padchar; 621 | ++o 622 | ) 623 | (v = b64map.indexOf(t.charAt(o))), 624 | v < 0 || 625 | (n = 626 | 0 == n 627 | ? ((r += int2char(v >> 2)), (e = 3 & v), 1) 628 | : 1 == n 629 | ? ((r += int2char((e << 2) | (v >> 4))), (e = 15 & v), 2) 630 | : 2 == n 631 | ? ((r += int2char(e)), (r += int2char(v >> 2)), (e = 3 & v), 3) 632 | : ((r += int2char((e << 2) | (v >> 4))), 633 | (r += int2char(15 & v)), 634 | 0)) 635 | return 1 == n && (r += int2char(e << 2)), r 636 | } 637 | 638 | ;(function () { 639 | return (function n(o, i, s) { 640 | function a(e, t) { 641 | if (!i[e]) { 642 | if (!o[e]) { 643 | var r = 'function' == typeof require && require 644 | if (!t && r) return r(e, !0) 645 | if (u) return u(e, !0) 646 | throw ( 647 | (((r = new Error("Cannot find module '" + e + "'")).code = 648 | 'MODULE_NOT_FOUND'), 649 | r) 650 | ) 651 | } 652 | ;(r = i[e] = { exports: {} }), 653 | o[e][0].call( 654 | r.exports, 655 | function (t) { 656 | return a(o[e][1][t] || t) 657 | }, 658 | r, 659 | r.exports, 660 | n, 661 | o, 662 | i, 663 | s 664 | ) 665 | } 666 | return i[e].exports 667 | } 668 | for ( 669 | var u = 'function' == typeof require && require, t = 0; 670 | t < s.length; 671 | t++ 672 | ) 673 | a(s[t]) 674 | return a 675 | })( 676 | { 677 | 1: [ 678 | function (t, e, r) { 679 | 'use strict' 680 | function n(t) { 681 | if (t) 682 | return (function (t) { 683 | for (var e in n.prototype) t[e] = n.prototype[e] 684 | return t 685 | })(t) 686 | } 687 | void 0 !== e && (e.exports = n), 688 | (n.prototype.on = n.prototype.addEventListener = 689 | function (t, e) { 690 | return ( 691 | (this._callbacks = this._callbacks || {}), 692 | (this._callbacks['$' + t] = 693 | this._callbacks['$' + t] || []).push(e), 694 | this 695 | ) 696 | }), 697 | (n.prototype.once = function (t, e) { 698 | function r() { 699 | this.off(t, r), e.apply(this, arguments) 700 | } 701 | return (r.fn = e), this.on(t, r), this 702 | }), 703 | (n.prototype.off = 704 | n.prototype.removeListener = 705 | n.prototype.removeAllListeners = 706 | n.prototype.removeEventListener = 707 | function (t, e) { 708 | if ( 709 | ((this._callbacks = this._callbacks || {}), 710 | 0 == arguments.length) 711 | ) 712 | return (this._callbacks = {}), this 713 | var r, 714 | n = this._callbacks['$' + t] 715 | if (!n) return this 716 | if (1 == arguments.length) 717 | return delete this._callbacks['$' + t], this 718 | for (var o = 0; o < n.length; o++) 719 | if ((r = n[o]) === e || r.fn === e) { 720 | n.splice(o, 1) 721 | break 722 | } 723 | return 0 === n.length && delete this._callbacks['$' + t], this 724 | }), 725 | (n.prototype.emit = function (t) { 726 | this._callbacks = this._callbacks || {} 727 | for ( 728 | var e = new Array(arguments.length - 1), 729 | r = this._callbacks['$' + t], 730 | n = 1; 731 | n < arguments.length; 732 | n++ 733 | ) 734 | e[n - 1] = arguments[n] 735 | if (r) 736 | for (var n = 0, o = (r = r.slice(0)).length; n < o; ++n) 737 | r[n].apply(this, e) 738 | return this 739 | }), 740 | (n.prototype.listeners = function (t) { 741 | return ( 742 | (this._callbacks = this._callbacks || {}), 743 | this._callbacks['$' + t] || [] 744 | ) 745 | }), 746 | (n.prototype.hasListeners = function (t) { 747 | return !!this.listeners(t).length 748 | }) 749 | }, 750 | {}, 751 | ], 752 | 2: [ 753 | function (t, e, r) { 754 | 'use strict' 755 | function l(t) { 756 | return (l = 757 | 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator 758 | ? function (t) { 759 | return typeof t 760 | } 761 | : function (t) { 762 | return t && 763 | 'function' == typeof Symbol && 764 | t.constructor === Symbol && 765 | t !== Symbol.prototype 766 | ? 'symbol' 767 | : typeof t 768 | })(t) 769 | } 770 | ;(((e.exports = n).default = n).stable = o), (n.stableStringify = o) 771 | var p = [], 772 | f = [] 773 | function n(t, e, r) { 774 | for ( 775 | !(function t(e, r, n, o) { 776 | var i 777 | if ('object' === l(e) && null !== e) { 778 | for (i = 0; i < n.length; i++) 779 | if (n[i] === e) { 780 | var s = Object.getOwnPropertyDescriptor(o, r) 781 | return void (void 0 !== s.get 782 | ? s.configurable 783 | ? (Object.defineProperty(o, r, { 784 | value: '[Circular]', 785 | }), 786 | p.push([o, r, e, s])) 787 | : f.push([e, r]) 788 | : ((o[r] = '[Circular]'), p.push([o, r, e]))) 789 | } 790 | if ((n.push(e), Array.isArray(e))) 791 | for (i = 0; i < e.length; i++) t(e[i], i, n, e) 792 | else { 793 | var a = Object.keys(e) 794 | for (i = 0; i < a.length; i++) { 795 | var u = a[i] 796 | t(e[u], u, n, e) 797 | } 798 | } 799 | n.pop() 800 | } 801 | })(t, '', [], void 0), 802 | r = 803 | 0 === f.length 804 | ? JSON.stringify(t, e, r) 805 | : JSON.stringify(t, i(e), r); 806 | 0 !== p.length; 807 | 808 | ) { 809 | var n = p.pop() 810 | 4 === n.length 811 | ? Object.defineProperty(n[0], n[1], n[3]) 812 | : (n[0][n[1]] = n[2]) 813 | } 814 | return r 815 | } 816 | function h(t, e) { 817 | return t < e ? -1 : e < t ? 1 : 0 818 | } 819 | function o(t, e, r) { 820 | for ( 821 | t = 822 | (function t(e, r, n, o) { 823 | var i 824 | if ('object' === l(e) && null !== e) { 825 | for (i = 0; i < n.length; i++) 826 | if (n[i] === e) { 827 | var s = Object.getOwnPropertyDescriptor(o, r) 828 | return void (void 0 !== s.get 829 | ? s.configurable 830 | ? (Object.defineProperty(o, r, { 831 | value: '[Circular]', 832 | }), 833 | p.push([o, r, e, s])) 834 | : f.push([e, r]) 835 | : ((o[r] = '[Circular]'), p.push([o, r, e]))) 836 | } 837 | if ('function' != typeof e.toJSON) { 838 | if ((n.push(e), Array.isArray(e))) 839 | for (i = 0; i < e.length; i++) t(e[i], i, n, e) 840 | else { 841 | var a = {}, 842 | u = Object.keys(e).sort(h) 843 | for (i = 0; i < u.length; i++) { 844 | var c = u[i] 845 | t(e[c], c, n, e), (a[c] = e[c]) 846 | } 847 | if (void 0 === o) return a 848 | p.push([o, r, e]), (o[r] = a) 849 | } 850 | n.pop() 851 | } 852 | } 853 | })(t, '', [], void 0) || t, 854 | r = 855 | 0 === f.length 856 | ? JSON.stringify(t, e, r) 857 | : JSON.stringify(t, i(e), r); 858 | 0 !== p.length; 859 | 860 | ) { 861 | var n = p.pop() 862 | 4 === n.length 863 | ? Object.defineProperty(n[0], n[1], n[3]) 864 | : (n[0][n[1]] = n[2]) 865 | } 866 | return r 867 | } 868 | function i(o) { 869 | return ( 870 | (o = 871 | void 0 !== o 872 | ? o 873 | : function (t, e) { 874 | return e 875 | }), 876 | function (t, e) { 877 | if (0 < f.length) 878 | for (var r = 0; r < f.length; r++) { 879 | var n = f[r] 880 | if (n[1] === t && n[0] === e) { 881 | ;(e = '[Circular]'), f.splice(r, 1) 882 | break 883 | } 884 | } 885 | return o.call(this, t, e) 886 | } 887 | ) 888 | } 889 | }, 890 | {}, 891 | ], 892 | 3: [ 893 | function (t, e, r) { 894 | 'use strict' 895 | var n = String.prototype.replace, 896 | o = /%20/g, 897 | i = t('./utils'), 898 | t = { RFC1738: 'RFC1738', RFC3986: 'RFC3986' } 899 | e.exports = i.assign( 900 | { 901 | default: t.RFC3986, 902 | formatters: { 903 | RFC1738: function (t) { 904 | return n.call(t, o, '+') 905 | }, 906 | RFC3986: function (t) { 907 | return String(t) 908 | }, 909 | }, 910 | }, 911 | t 912 | ) 913 | }, 914 | { './utils': 7 }, 915 | ], 916 | 4: [ 917 | function (t, e, r) { 918 | 'use strict' 919 | var n = t('./stringify'), 920 | o = t('./parse'), 921 | t = t('./formats') 922 | e.exports = { formats: t, parse: o, stringify: n } 923 | }, 924 | { './formats': 3, './parse': 5, './stringify': 6 }, 925 | ], 926 | 5: [ 927 | function (t, e, r) { 928 | 'use strict' 929 | function p(t, e) { 930 | return t && 'string' == typeof t && e.comma && -1 < t.indexOf(',') 931 | ? t.split(',') 932 | : t 933 | } 934 | function u(t, e) { 935 | var r, 936 | n, 937 | o, 938 | i, 939 | s = {}, 940 | a = e.ignoreQueryPrefix ? t.replace(/^\?/, '') : t, 941 | t = e.parameterLimit === 1 / 0 ? void 0 : e.parameterLimit, 942 | u = a.split(e.delimiter, t), 943 | c = -1, 944 | l = e.charset 945 | if (e.charsetSentinel) 946 | for (r = 0; r < u.length; ++r) 947 | 0 === u[r].indexOf('utf8=') && 948 | ('utf8=%E2%9C%93' === u[r] 949 | ? (l = 'utf-8') 950 | : 'utf8=%26%2310003%3B' === u[r] && (l = 'iso-8859-1'), 951 | (c = r), 952 | (r = u.length)) 953 | for (r = 0; r < u.length; ++r) 954 | r !== c && 955 | ((i = 956 | -1 === 957 | (i = 958 | -1 === (i = (n = u[r]).indexOf(']=')) 959 | ? n.indexOf('=') 960 | : i + 1) 961 | ? ((o = e.decoder(n, y.decoder, l, 'key')), 962 | e.strictNullHandling ? null : '') 963 | : ((o = e.decoder(n.slice(0, i), y.decoder, l, 'key')), 964 | f.maybeMap(p(n.slice(i + 1), e), function (t) { 965 | return e.decoder(t, y.decoder, l, 'value') 966 | }))) && 967 | e.interpretNumericEntities && 968 | 'iso-8859-1' === l && 969 | (i = i.replace(/&#(\d+);/g, function (t, e) { 970 | return String.fromCharCode(parseInt(e, 10)) 971 | })), 972 | -1 < n.indexOf('[]=') && (i = d(i) ? [i] : i), 973 | h.call(s, o) ? (s[o] = f.combine(s[o], i)) : (s[o] = i)) 974 | return s 975 | } 976 | function c(t, e, r, n) { 977 | if (t) { 978 | var o = r.allowDots ? t.replace(/\.([^.[]+)/g, '[$1]') : t, 979 | i = /(\[[^[\]]*])/g, 980 | s = 0 < r.depth && /(\[[^[\]]*])/.exec(o), 981 | t = s ? o.slice(0, s.index) : o, 982 | a = [] 983 | if (t) { 984 | if ( 985 | !r.plainObjects && 986 | h.call(Object.prototype, t) && 987 | !r.allowPrototypes 988 | ) 989 | return 990 | a.push(t) 991 | } 992 | for ( 993 | var u = 0; 994 | 0 < r.depth && null !== (s = i.exec(o)) && u < r.depth; 995 | 996 | ) { 997 | if ( 998 | ((u += 1), 999 | !r.plainObjects && 1000 | h.call(Object.prototype, s[1].slice(1, -1)) && 1001 | !r.allowPrototypes) 1002 | ) 1003 | return 1004 | a.push(s[1]) 1005 | } 1006 | return ( 1007 | s && a.push('[' + o.slice(s.index) + ']'), 1008 | (function (t, e, r, n) { 1009 | for (var o = n ? e : p(e, r), i = t.length - 1; 0 <= i; --i) { 1010 | var s, 1011 | a, 1012 | u, 1013 | c = t[i] 1014 | '[]' === c && r.parseArrays 1015 | ? (s = [].concat(o)) 1016 | : ((s = r.plainObjects ? Object.create(null) : {}), 1017 | (a = 1018 | '[' === c.charAt(0) && ']' === c.charAt(c.length - 1) 1019 | ? c.slice(1, -1) 1020 | : c), 1021 | (u = parseInt(a, 10)), 1022 | r.parseArrays || '' !== a 1023 | ? !isNaN(u) && 1024 | c !== a && 1025 | String(u) === a && 1026 | 0 <= u && 1027 | r.parseArrays && 1028 | u <= r.arrayLimit 1029 | ? ((s = [])[u] = o) 1030 | : (s[a] = o) 1031 | : (s = { 0: o })), 1032 | (o = s) 1033 | } 1034 | return o 1035 | })(a, e, r, n) 1036 | ) 1037 | } 1038 | } 1039 | var f = t('./utils'), 1040 | h = Object.prototype.hasOwnProperty, 1041 | d = Array.isArray, 1042 | y = { 1043 | allowDots: !1, 1044 | allowPrototypes: !1, 1045 | arrayLimit: 20, 1046 | charset: 'utf-8', 1047 | charsetSentinel: !1, 1048 | comma: !1, 1049 | decoder: f.decode, 1050 | delimiter: '&', 1051 | depth: 5, 1052 | ignoreQueryPrefix: !1, 1053 | interpretNumericEntities: !1, 1054 | parameterLimit: 1e3, 1055 | parseArrays: !0, 1056 | plainObjects: !1, 1057 | strictNullHandling: !1, 1058 | } 1059 | e.exports = function (t, e) { 1060 | var r = (function (t) { 1061 | if (!t) return y 1062 | if ( 1063 | null !== t.decoder && 1064 | void 0 !== t.decoder && 1065 | 'function' != typeof t.decoder 1066 | ) 1067 | throw new TypeError('Decoder has to be a function.') 1068 | if ( 1069 | void 0 !== t.charset && 1070 | 'utf-8' !== t.charset && 1071 | 'iso-8859-1' !== t.charset 1072 | ) 1073 | throw new TypeError( 1074 | 'The charset option must be either utf-8, iso-8859-1, or undefined' 1075 | ) 1076 | var e = (void 0 === t.charset ? y : t).charset 1077 | return { 1078 | allowDots: void 0 === t.allowDots ? y.allowDots : !!t.allowDots, 1079 | allowPrototypes: ('boolean' == typeof t.allowPrototypes ? t : y) 1080 | .allowPrototypes, 1081 | arrayLimit: ('number' == typeof t.arrayLimit ? t : y) 1082 | .arrayLimit, 1083 | charset: e, 1084 | charsetSentinel: ('boolean' == typeof t.charsetSentinel ? t : y) 1085 | .charsetSentinel, 1086 | comma: ('boolean' == typeof t.comma ? t : y).comma, 1087 | decoder: ('function' == typeof t.decoder ? t : y).decoder, 1088 | delimiter: ('string' == typeof t.delimiter || 1089 | f.isRegExp(t.delimiter) 1090 | ? t 1091 | : y 1092 | ).delimiter, 1093 | depth: 1094 | 'number' == typeof t.depth || !1 === t.depth 1095 | ? +t.depth 1096 | : y.depth, 1097 | ignoreQueryPrefix: !0 === t.ignoreQueryPrefix, 1098 | interpretNumericEntities: ('boolean' == 1099 | typeof t.interpretNumericEntities 1100 | ? t 1101 | : y 1102 | ).interpretNumericEntities, 1103 | parameterLimit: ('number' == typeof t.parameterLimit ? t : y) 1104 | .parameterLimit, 1105 | parseArrays: !1 !== t.parseArrays, 1106 | plainObjects: ('boolean' == typeof t.plainObjects ? t : y) 1107 | .plainObjects, 1108 | strictNullHandling: ('boolean' == typeof t.strictNullHandling 1109 | ? t 1110 | : y 1111 | ).strictNullHandling, 1112 | } 1113 | })(e) 1114 | if ('' === t || null == t) 1115 | return r.plainObjects ? Object.create(null) : {} 1116 | for ( 1117 | var n = 'string' == typeof t ? u(t, r) : t, 1118 | o = r.plainObjects ? Object.create(null) : {}, 1119 | i = Object.keys(n), 1120 | s = 0; 1121 | s < i.length; 1122 | ++s 1123 | ) 1124 | var a = i[s], 1125 | a = c(a, n[a], r, 'string' == typeof t), 1126 | o = f.merge(o, a, r) 1127 | return f.compact(o) 1128 | } 1129 | }, 1130 | { './utils': 7 }, 1131 | ], 1132 | 6: [ 1133 | function (t, e, r) { 1134 | 'use strict' 1135 | function v(t) { 1136 | return (v = 1137 | 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator 1138 | ? function (t) { 1139 | return typeof t 1140 | } 1141 | : function (t) { 1142 | return t && 1143 | 'function' == typeof Symbol && 1144 | t.constructor === Symbol && 1145 | t !== Symbol.prototype 1146 | ? 'symbol' 1147 | : typeof t 1148 | })(t) 1149 | } 1150 | function T(t, e) { 1151 | n.apply(t, w(e) ? e : [e]) 1152 | } 1153 | function _(t, e, r, n, o, i, s, a, u, c, l, p, f) { 1154 | var h = t 1155 | if ( 1156 | ('function' == typeof s 1157 | ? (h = s(e, h)) 1158 | : h instanceof Date 1159 | ? (h = c(h)) 1160 | : 'comma' === r && 1161 | w(h) && 1162 | (h = S.maybeMap(h, function (t) { 1163 | return t instanceof Date ? c(t) : t 1164 | }).join(',')), 1165 | null === h) 1166 | ) { 1167 | if (n) return i && !p ? i(e, D.encoder, f, 'key') : e 1168 | h = '' 1169 | } 1170 | if ( 1171 | ((t = h), 1172 | 'string' == typeof t || 1173 | 'number' == typeof t || 1174 | 'boolean' == typeof t || 1175 | 'symbol' === v(t) || 1176 | 'bigint' == typeof t || 1177 | S.isBuffer(h)) 1178 | ) 1179 | return i 1180 | ? [ 1181 | l(p ? e : i(e, D.encoder, f, 'key')) + 1182 | '=' + 1183 | l(i(h, D.encoder, f, 'value')), 1184 | ] 1185 | : [l(e) + '=' + l(String(h))] 1186 | var d, 1187 | y = [] 1188 | if (void 0 === h) return y 1189 | d = w(s) ? s : ((t = Object.keys(h)), a ? t.sort(a) : t) 1190 | for (var m = 0; m < d.length; ++m) { 1191 | var g = d[m], 1192 | b = h[g] 1193 | ;(o && null === b) || 1194 | ((g = w(h) 1195 | ? 'function' == typeof r 1196 | ? r(e, g) 1197 | : e 1198 | : e + (u ? '.' + g : '[' + g + ']')), 1199 | T(y, _(b, g, r, n, o, i, s, a, u, c, l, p, f))) 1200 | } 1201 | return y 1202 | } 1203 | var S = t('./utils'), 1204 | c = t('./formats'), 1205 | l = Object.prototype.hasOwnProperty, 1206 | p = { 1207 | brackets: function (t) { 1208 | return t + '[]' 1209 | }, 1210 | comma: 'comma', 1211 | indices: function (t, e) { 1212 | return t + '[' + e + ']' 1213 | }, 1214 | repeat: function (t) { 1215 | return t 1216 | }, 1217 | }, 1218 | w = Array.isArray, 1219 | n = Array.prototype.push, 1220 | o = Date.prototype.toISOString, 1221 | t = c.default, 1222 | D = { 1223 | addQueryPrefix: !1, 1224 | allowDots: !1, 1225 | charset: 'utf-8', 1226 | charsetSentinel: !1, 1227 | delimiter: '&', 1228 | encode: !0, 1229 | encoder: S.encode, 1230 | encodeValuesOnly: !1, 1231 | format: t, 1232 | formatter: c.formatters[t], 1233 | indices: !1, 1234 | serializeDate: function (t) { 1235 | return o.call(t) 1236 | }, 1237 | skipNulls: !1, 1238 | strictNullHandling: !1, 1239 | } 1240 | e.exports = function (t, e) { 1241 | var r = t, 1242 | n = (function (t) { 1243 | if (!t) return D 1244 | if ( 1245 | null !== t.encoder && 1246 | void 0 !== t.encoder && 1247 | 'function' != typeof t.encoder 1248 | ) 1249 | throw new TypeError('Encoder has to be a function.') 1250 | var e = t.charset || D.charset 1251 | if ( 1252 | void 0 !== t.charset && 1253 | 'utf-8' !== t.charset && 1254 | 'iso-8859-1' !== t.charset 1255 | ) 1256 | throw new TypeError( 1257 | 'The charset option must be either utf-8, iso-8859-1, or undefined' 1258 | ) 1259 | var r = c.default 1260 | if (void 0 !== t.format) { 1261 | if (!l.call(c.formatters, t.format)) 1262 | throw new TypeError('Unknown format option provided.') 1263 | r = t.format 1264 | } 1265 | var n = c.formatters[r], 1266 | r = D.filter 1267 | return ( 1268 | ('function' != typeof t.filter && !w(t.filter)) || 1269 | (r = t.filter), 1270 | { 1271 | addQueryPrefix: ('boolean' == typeof t.addQueryPrefix 1272 | ? t 1273 | : D 1274 | ).addQueryPrefix, 1275 | allowDots: 1276 | void 0 === t.allowDots ? D.allowDots : !!t.allowDots, 1277 | charset: e, 1278 | charsetSentinel: ('boolean' == typeof t.charsetSentinel 1279 | ? t 1280 | : D 1281 | ).charsetSentinel, 1282 | delimiter: (void 0 === t.delimiter ? D : t).delimiter, 1283 | encode: ('boolean' == typeof t.encode ? t : D).encode, 1284 | encoder: ('function' == typeof t.encoder ? t : D).encoder, 1285 | encodeValuesOnly: ('boolean' == typeof t.encodeValuesOnly 1286 | ? t 1287 | : D 1288 | ).encodeValuesOnly, 1289 | filter: r, 1290 | formatter: n, 1291 | serializeDate: ('function' == typeof t.serializeDate 1292 | ? t 1293 | : D 1294 | ).serializeDate, 1295 | skipNulls: ('boolean' == typeof t.skipNulls ? t : D) 1296 | .skipNulls, 1297 | sort: 'function' == typeof t.sort ? t.sort : null, 1298 | strictNullHandling: ('boolean' == 1299 | typeof t.strictNullHandling 1300 | ? t 1301 | : D 1302 | ).strictNullHandling, 1303 | } 1304 | ) 1305 | })(e) 1306 | 'function' == typeof n.filter 1307 | ? (r = (0, n.filter)('', r)) 1308 | : w(n.filter) && (s = n.filter) 1309 | var o = [] 1310 | if ('object' !== v(r) || null === r) return '' 1311 | t = 1312 | e && e.arrayFormat in p 1313 | ? e.arrayFormat 1314 | : !(e && 'indices' in e) || e.indices 1315 | ? 'indices' 1316 | : 'repeat' 1317 | var i = p[t], 1318 | s = s || Object.keys(r) 1319 | n.sort && s.sort(n.sort) 1320 | for (var a = 0; a < s.length; ++a) { 1321 | var u = s[a] 1322 | ;(n.skipNulls && null === r[u]) || 1323 | T( 1324 | o, 1325 | _( 1326 | r[u], 1327 | u, 1328 | i, 1329 | n.strictNullHandling, 1330 | n.skipNulls, 1331 | n.encode ? n.encoder : null, 1332 | n.filter, 1333 | n.sort, 1334 | n.allowDots, 1335 | n.serializeDate, 1336 | n.formatter, 1337 | n.encodeValuesOnly, 1338 | n.charset 1339 | ) 1340 | ) 1341 | } 1342 | ;(e = o.join(n.delimiter)), (t = !0 === n.addQueryPrefix ? '?' : '') 1343 | return ( 1344 | n.charsetSentinel && 1345 | ('iso-8859-1' === n.charset 1346 | ? (t += 'utf8=%26%2310003%3B&') 1347 | : (t += 'utf8=%E2%9C%93&')), 1348 | 0 < e.length ? t + e : '' 1349 | ) 1350 | } 1351 | }, 1352 | { './formats': 3, './utils': 7 }, 1353 | ], 1354 | 7: [ 1355 | function (t, e, r) { 1356 | 'use strict' 1357 | function l(t) { 1358 | return (l = 1359 | 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator 1360 | ? function (t) { 1361 | return typeof t 1362 | } 1363 | : function (t) { 1364 | return t && 1365 | 'function' == typeof Symbol && 1366 | t.constructor === Symbol && 1367 | t !== Symbol.prototype 1368 | ? 'symbol' 1369 | : typeof t 1370 | })(t) 1371 | } 1372 | function s(t, e) { 1373 | for ( 1374 | var r = e && e.plainObjects ? Object.create(null) : {}, n = 0; 1375 | n < t.length; 1376 | ++n 1377 | ) 1378 | void 0 !== t[n] && (r[n] = t[n]) 1379 | return r 1380 | } 1381 | function a(n, o, i) { 1382 | if (!o) return n 1383 | if ('object' !== l(o)) { 1384 | if (p(n)) n.push(o) 1385 | else { 1386 | if (!n || 'object' !== l(n)) return [n, o] 1387 | ;((i && (i.plainObjects || i.allowPrototypes)) || 1388 | !u.call(Object.prototype, o)) && 1389 | (n[o] = !0) 1390 | } 1391 | return n 1392 | } 1393 | if (!n || 'object' !== l(n)) return [n].concat(o) 1394 | var t = n 1395 | return ( 1396 | p(n) && !p(o) && (t = s(n, i)), 1397 | p(n) && p(o) 1398 | ? (o.forEach(function (t, e) { 1399 | var r 1400 | u.call(n, e) 1401 | ? (r = n[e]) && 1402 | 'object' === l(r) && 1403 | t && 1404 | 'object' === l(t) 1405 | ? (n[e] = a(r, t, i)) 1406 | : n.push(t) 1407 | : (n[e] = t) 1408 | }), 1409 | n) 1410 | : Object.keys(o).reduce(function (t, e) { 1411 | var r = o[e] 1412 | return u.call(t, e) ? (t[e] = a(t[e], r, i)) : (t[e] = r), t 1413 | }, t) 1414 | ) 1415 | } 1416 | var u = Object.prototype.hasOwnProperty, 1417 | p = Array.isArray, 1418 | c = (function () { 1419 | for (var t = [], e = 0; e < 256; ++e) 1420 | t.push( 1421 | '%' + ((e < 16 ? '0' : '') + e.toString(16)).toUpperCase() 1422 | ) 1423 | return t 1424 | })() 1425 | e.exports = { 1426 | arrayToObject: s, 1427 | assign: function (t, r) { 1428 | return Object.keys(r).reduce(function (t, e) { 1429 | return (t[e] = r[e]), t 1430 | }, t) 1431 | }, 1432 | combine: function (t, e) { 1433 | return [].concat(t, e) 1434 | }, 1435 | compact: function (t) { 1436 | for ( 1437 | var e = [{ obj: { o: t }, prop: 'o' }], r = [], n = 0; 1438 | n < e.length; 1439 | ++n 1440 | ) 1441 | for ( 1442 | var o = e[n], i = o.obj[o.prop], s = Object.keys(i), a = 0; 1443 | a < s.length; 1444 | ++a 1445 | ) { 1446 | var u = s[a], 1447 | c = i[u] 1448 | 'object' === l(c) && 1449 | null !== c && 1450 | -1 === r.indexOf(c) && 1451 | (e.push({ obj: i, prop: u }), r.push(c)) 1452 | } 1453 | return ( 1454 | (function (t) { 1455 | for (; 1 < t.length; ) { 1456 | var e = t.pop(), 1457 | r = e.obj[e.prop] 1458 | if (p(r)) { 1459 | for (var n = [], o = 0; o < r.length; ++o) 1460 | void 0 !== r[o] && n.push(r[o]) 1461 | e.obj[e.prop] = n 1462 | } 1463 | } 1464 | })(e), 1465 | t 1466 | ) 1467 | }, 1468 | decode: function (t, e, r) { 1469 | var n = t.replace(/\+/g, ' ') 1470 | if ('iso-8859-1' === r) 1471 | return n.replace(/%[0-9a-f]{2}/gi, unescape) 1472 | try { 1473 | return decodeURIComponent(n) 1474 | } catch (t) { 1475 | return n 1476 | } 1477 | }, 1478 | encode: function (t, e, r) { 1479 | if (0 === t.length) return t 1480 | var n = t 1481 | if ( 1482 | ('symbol' === l(t) 1483 | ? (n = Symbol.prototype.toString.call(t)) 1484 | : 'string' != typeof t && (n = String(t)), 1485 | 'iso-8859-1' === r) 1486 | ) 1487 | return escape(n).replace(/%u[0-9a-f]{4}/gi, function (t) { 1488 | return '%26%23' + parseInt(t.slice(2), 16) + '%3B' 1489 | }) 1490 | for (var o = '', i = 0; i < n.length; ++i) { 1491 | var s = n.charCodeAt(i) 1492 | 45 === s || 1493 | 46 === s || 1494 | 95 === s || 1495 | 126 === s || 1496 | (48 <= s && s <= 57) || 1497 | (65 <= s && s <= 90) || 1498 | (97 <= s && s <= 122) 1499 | ? (o += n.charAt(i)) 1500 | : s < 128 1501 | ? (o += c[s]) 1502 | : s < 2048 1503 | ? (o += c[192 | (s >> 6)] + c[128 | (63 & s)]) 1504 | : s < 55296 || 57344 <= s 1505 | ? (o += 1506 | c[224 | (s >> 12)] + 1507 | c[128 | ((s >> 6) & 63)] + 1508 | c[128 | (63 & s)]) 1509 | : ((i += 1), 1510 | (s = 1511 | 65536 + (((1023 & s) << 10) | (1023 & n.charCodeAt(i)))), 1512 | (o += 1513 | c[240 | (s >> 18)] + 1514 | c[128 | ((s >> 12) & 63)] + 1515 | c[128 | ((s >> 6) & 63)] + 1516 | c[128 | (63 & s)])) 1517 | } 1518 | return o 1519 | }, 1520 | isBuffer: function (t) { 1521 | return ( 1522 | !(!t || 'object' !== l(t)) && 1523 | !!( 1524 | t.constructor && 1525 | t.constructor.isBuffer && 1526 | t.constructor.isBuffer(t) 1527 | ) 1528 | ) 1529 | }, 1530 | isRegExp: function (t) { 1531 | return '[object RegExp]' === Object.prototype.toString.call(t) 1532 | }, 1533 | maybeMap: function (t, e) { 1534 | if (p(t)) { 1535 | for (var r = [], n = 0; n < t.length; n += 1) r.push(e(t[n])) 1536 | return r 1537 | } 1538 | return e(t) 1539 | }, 1540 | merge: a, 1541 | } 1542 | }, 1543 | {}, 1544 | ], 1545 | 8: [ 1546 | function (t, e, r) { 1547 | 'use strict' 1548 | function n(t) { 1549 | return ( 1550 | (function (t) { 1551 | if (Array.isArray(t)) return o(t) 1552 | })(t) || 1553 | (function (t) { 1554 | if ( 1555 | 'undefined' != typeof Symbol && 1556 | Symbol.iterator in Object(t) 1557 | ) 1558 | return Array.from(t) 1559 | })(t) || 1560 | (function (t, e) { 1561 | if (!t) return 1562 | if ('string' == typeof t) return o(t, e) 1563 | var r = Object.prototype.toString.call(t).slice(8, -1) 1564 | 'Object' === r && t.constructor && (r = t.constructor.name) 1565 | if ('Map' === r || 'Set' === r) return Array.from(t) 1566 | if ( 1567 | 'Arguments' === r || 1568 | /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) 1569 | ) 1570 | return o(t, e) 1571 | })(t) || 1572 | (function () { 1573 | throw new TypeError( 1574 | 'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' 1575 | ) 1576 | })() 1577 | ) 1578 | } 1579 | function o(t, e) { 1580 | ;(null == e || e > t.length) && (e = t.length) 1581 | for (var r = 0, n = new Array(e); r < e; r++) n[r] = t[r] 1582 | return n 1583 | } 1584 | function i() { 1585 | this._defaults = [] 1586 | } 1587 | ;[ 1588 | 'use', 1589 | 'on', 1590 | 'once', 1591 | 'set', 1592 | 'query', 1593 | 'type', 1594 | 'accept', 1595 | 'auth', 1596 | 'withCredentials', 1597 | 'sortQuery', 1598 | 'retry', 1599 | 'ok', 1600 | 'redirects', 1601 | 'timeout', 1602 | 'buffer', 1603 | 'serialize', 1604 | 'parse', 1605 | 'ca', 1606 | 'key', 1607 | 'pfx', 1608 | 'cert', 1609 | 'disableTLSCerts', 1610 | ].forEach(function (n) { 1611 | i.prototype[n] = function () { 1612 | for ( 1613 | var t = arguments.length, e = new Array(t), r = 0; 1614 | r < t; 1615 | r++ 1616 | ) 1617 | e[r] = arguments[r] 1618 | return this._defaults.push({ fn: n, args: e }), this 1619 | } 1620 | }), 1621 | (i.prototype._setDefaults = function (e) { 1622 | this._defaults.forEach(function (t) { 1623 | e[t.fn].apply(e, n(t.args)) 1624 | }) 1625 | }), 1626 | (e.exports = i) 1627 | }, 1628 | {}, 1629 | ], 1630 | 9: [ 1631 | function (t, e, r) { 1632 | 'use strict' 1633 | function n(t) { 1634 | return (n = 1635 | 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator 1636 | ? function (t) { 1637 | return typeof t 1638 | } 1639 | : function (t) { 1640 | return t && 1641 | 'function' == typeof Symbol && 1642 | t.constructor === Symbol && 1643 | t !== Symbol.prototype 1644 | ? 'symbol' 1645 | : typeof t 1646 | })(t) 1647 | } 1648 | e.exports = function (t) { 1649 | return null !== t && 'object' === n(t) 1650 | } 1651 | }, 1652 | {}, 1653 | ], 1654 | 10: [ 1655 | function (t, e, r) { 1656 | 'use strict' 1657 | function n(t) { 1658 | return (n = 1659 | 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator 1660 | ? function (t) { 1661 | return typeof t 1662 | } 1663 | : function (t) { 1664 | return t && 1665 | 'function' == typeof Symbol && 1666 | t.constructor === Symbol && 1667 | t !== Symbol.prototype 1668 | ? 'symbol' 1669 | : typeof t 1670 | })(t) 1671 | } 1672 | var o = 1673 | 'undefined' != typeof window 1674 | ? window 1675 | : 'undefined' == typeof self 1676 | ? void console.warn( 1677 | 'Using browser-only version of superagent in non-browser environment' 1678 | ) 1679 | : self, 1680 | i = t('component-emitter'), 1681 | s = t('fast-safe-stringify'), 1682 | a = t('qs'), 1683 | u = t('./request-base'), 1684 | c = t('./is-object'), 1685 | l = t('./response-base'), 1686 | p = t('./agent-base') 1687 | function f() {} 1688 | e.exports = function (t, e) { 1689 | return 'function' == typeof e 1690 | ? new r.Request('GET', t).end(e) 1691 | : 1 === arguments.length 1692 | ? new r.Request('GET', t) 1693 | : new r.Request(t, e) 1694 | } 1695 | var h = (r = e.exports) 1696 | ;(r.Request = v), 1697 | (h.getXHR = function () { 1698 | if ( 1699 | o.XMLHttpRequest && 1700 | (!o.location || 1701 | 'file:' !== o.location.protocol || 1702 | !o.ActiveXObject) 1703 | ) 1704 | return new XMLHttpRequest() 1705 | try { 1706 | return new ActiveXObject('Microsoft.XMLHTTP') 1707 | } catch (t) {} 1708 | try { 1709 | return new ActiveXObject('Msxml2.XMLHTTP.6.0') 1710 | } catch (t) {} 1711 | try { 1712 | return new ActiveXObject('Msxml2.XMLHTTP.3.0') 1713 | } catch (t) {} 1714 | try { 1715 | return new ActiveXObject('Msxml2.XMLHTTP') 1716 | } catch (t) {} 1717 | throw new Error( 1718 | 'Browser-only version of superagent could not find XHR' 1719 | ) 1720 | }) 1721 | var d = ''.trim 1722 | ? function (t) { 1723 | return t.trim() 1724 | } 1725 | : function (t) { 1726 | return t.replace(/(^\s*|\s*$)/g, '') 1727 | } 1728 | function y(t) { 1729 | if (!c(t)) return t 1730 | var e, 1731 | r = [] 1732 | for (e in t) 1733 | Object.prototype.hasOwnProperty.call(t, e) && 1734 | !(function e(r, n, t) { 1735 | if (void 0 === t) return 1736 | if (null === t) return void r.push(encodeURI(n)) 1737 | if (Array.isArray(t)) 1738 | t.forEach(function (t) { 1739 | e(r, n, t) 1740 | }) 1741 | else if (c(t)) 1742 | for (var o in t) 1743 | Object.prototype.hasOwnProperty.call(t, o) && 1744 | e(r, ''.concat(n, '[').concat(o, ']'), t[o]) 1745 | else r.push(encodeURI(n) + '=' + encodeURIComponent(t)) 1746 | })(r, e, t[e]) 1747 | return r.join('&') 1748 | } 1749 | function m(t) { 1750 | for ( 1751 | var e, r, n = {}, o = t.split('&'), i = 0, s = o.length; 1752 | i < s; 1753 | ++i 1754 | ) 1755 | -1 === (r = (e = o[i]).indexOf('=')) 1756 | ? (n[decodeURIComponent(e)] = '') 1757 | : (n[decodeURIComponent(e.slice(0, r))] = decodeURIComponent( 1758 | e.slice(r + 1) 1759 | )) 1760 | return n 1761 | } 1762 | function g(t) { 1763 | return /[/+]json($|[^-\w])/i.test(t) 1764 | } 1765 | function b(t) { 1766 | ;(this.req = t), 1767 | (this.xhr = this.req.xhr), 1768 | (this.text = 1769 | ('HEAD' !== this.req.method && 1770 | ('' === this.xhr.responseType || 1771 | 'text' === this.xhr.responseType)) || 1772 | void 0 === this.xhr.responseType 1773 | ? this.xhr.responseText 1774 | : null), 1775 | (this.statusText = this.req.xhr.statusText) 1776 | var e = this.xhr.status 1777 | 1223 === e && (e = 204), 1778 | this._setStatusProperties(e), 1779 | (this.headers = (function (t) { 1780 | for ( 1781 | var e, 1782 | r, 1783 | n, 1784 | o = t.split(/\r?\n/), 1785 | i = {}, 1786 | s = 0, 1787 | a = o.length; 1788 | s < a; 1789 | ++s 1790 | ) 1791 | -1 !== (n = (e = o[s]).indexOf(':')) && 1792 | ((r = e.slice(0, n).toLowerCase()), 1793 | (n = d(e.slice(n + 1))), 1794 | (i[r] = n)) 1795 | return i 1796 | })(this.xhr.getAllResponseHeaders())), 1797 | (this.header = this.headers), 1798 | (this.header['content-type'] = 1799 | this.xhr.getResponseHeader('content-type')), 1800 | this._setHeaderProperties(this.header), 1801 | null === this.text && t._responseType 1802 | ? (this.body = this.xhr.response) 1803 | : (this.body = 1804 | 'HEAD' === this.req.method 1805 | ? null 1806 | : this._parseBody(this.text || this.xhr.response)) 1807 | } 1808 | function v(t, e) { 1809 | var n = this 1810 | ;(this._query = this._query || []), 1811 | (this.method = t), 1812 | (this.url = e), 1813 | (this.header = {}), 1814 | (this._header = {}), 1815 | this.on('end', function () { 1816 | var e, 1817 | r = null, 1818 | t = null 1819 | try { 1820 | t = new b(n) 1821 | } catch (t) { 1822 | return ( 1823 | ((r = new Error( 1824 | 'Parser is unable to parse the response' 1825 | )).parse = !0), 1826 | (r.original = t), 1827 | n.xhr 1828 | ? ((r.rawResponse = 1829 | void 0 === n.xhr.responseType 1830 | ? n.xhr.responseText 1831 | : n.xhr.response), 1832 | (r.status = n.xhr.status || null), 1833 | (r.statusCode = r.status)) 1834 | : ((r.rawResponse = null), (r.status = null)), 1835 | n.callback(r) 1836 | ) 1837 | } 1838 | n.emit('response', t) 1839 | try { 1840 | n._isResponseOK(t) || 1841 | (e = new Error( 1842 | t.statusText || t.text || 'Unsuccessful HTTP response' 1843 | )) 1844 | } catch (t) { 1845 | e = t 1846 | } 1847 | e 1848 | ? ((e.original = r), 1849 | (e.response = t), 1850 | (e.status = t.status), 1851 | n.callback(e, t)) 1852 | : n.callback(null, t) 1853 | }) 1854 | } 1855 | function T(t, e, r) { 1856 | t = h('DELETE', t) 1857 | return ( 1858 | 'function' == typeof e && ((r = e), (e = null)), 1859 | e && t.send(e), 1860 | r && t.end(r), 1861 | t 1862 | ) 1863 | } 1864 | ;(h.serializeObject = y), 1865 | (h.parseString = m), 1866 | (h.types = { 1867 | 'html': 'text/html', 1868 | 'json': 'application/json', 1869 | 'xml': 'text/xml', 1870 | 'urlencoded': 'application/x-www-form-urlencoded', 1871 | 'form': 'application/x-www-form-urlencoded', 1872 | 'form-data': 'application/x-www-form-urlencoded', 1873 | }), 1874 | (h.serialize = { 1875 | 'application/x-www-form-urlencoded': a.stringify, 1876 | 'application/json': s, 1877 | }), 1878 | (h.parse = { 1879 | 'application/x-www-form-urlencoded': m, 1880 | 'application/json': JSON.parse, 1881 | }), 1882 | l(b.prototype), 1883 | (b.prototype._parseBody = function (t) { 1884 | var e = h.parse[this.type] 1885 | return this.req._parser 1886 | ? this.req._parser(this, t) 1887 | : (e = !e && g(this.type) ? h.parse['application/json'] : e) && 1888 | t && 1889 | (0 < t.length || t instanceof Object) 1890 | ? e(t) 1891 | : null 1892 | }), 1893 | (b.prototype.toError = function () { 1894 | var t = this.req, 1895 | e = t.method, 1896 | r = t.url, 1897 | t = 'cannot ' 1898 | .concat(e, ' ') 1899 | .concat(r, ' (') 1900 | .concat(this.status, ')'), 1901 | t = new Error(t) 1902 | return (t.status = this.status), (t.method = e), (t.url = r), t 1903 | }), 1904 | (h.Response = b), 1905 | i(v.prototype), 1906 | u(v.prototype), 1907 | (v.prototype.type = function (t) { 1908 | return this.set('Content-Type', h.types[t] || t), this 1909 | }), 1910 | (v.prototype.accept = function (t) { 1911 | return this.set('Accept', h.types[t] || t), this 1912 | }), 1913 | (v.prototype.auth = function (t, e, r) { 1914 | 'object' === n((e = 1 === arguments.length ? '' : e)) && 1915 | null !== e && 1916 | ((r = e), (e = '')), 1917 | (r = r || { 1918 | type: 'function' == typeof btoa ? 'basic' : 'auto', 1919 | }) 1920 | return this._auth(t, e, r, function (t) { 1921 | if ('function' == typeof btoa) return btoa(t) 1922 | throw new Error('Cannot use basic auth, btoa is not a function') 1923 | }) 1924 | }), 1925 | (v.prototype.query = function (t) { 1926 | return ( 1927 | (t = 'string' != typeof t ? y(t) : t) && this._query.push(t), 1928 | this 1929 | ) 1930 | }), 1931 | (v.prototype.attach = function (t, e, r) { 1932 | if (e) { 1933 | if (this._data) 1934 | throw new Error("superagent can't mix .send() and .attach()") 1935 | this._getFormData().append(t, e, r || e.name) 1936 | } 1937 | return this 1938 | }), 1939 | (v.prototype._getFormData = function () { 1940 | return ( 1941 | this._formData || (this._formData = new o.FormData()), 1942 | this._formData 1943 | ) 1944 | }), 1945 | (v.prototype.callback = function (t, e) { 1946 | if (this._shouldRetry(t, e)) return this._retry() 1947 | var r = this._callback 1948 | this.clearTimeout(), 1949 | t && 1950 | (this._maxRetries && (t.retries = this._retries - 1), 1951 | this.emit('error', t)), 1952 | r(t, e) 1953 | }), 1954 | (v.prototype.crossDomainError = function () { 1955 | var t = new Error( 1956 | 'Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.' 1957 | ) 1958 | ;(t.crossDomain = !0), 1959 | (t.status = this.status), 1960 | (t.method = this.method), 1961 | (t.url = this.url), 1962 | this.callback(t) 1963 | }), 1964 | (v.prototype.buffer = 1965 | v.prototype.ca = 1966 | v.prototype.agent = 1967 | function () { 1968 | return ( 1969 | console.warn( 1970 | 'This is not supported in browser version of superagent' 1971 | ), 1972 | this 1973 | ) 1974 | }), 1975 | (v.prototype.pipe = v.prototype.write = 1976 | function () { 1977 | throw new Error( 1978 | 'Streaming is not supported in browser version of superagent' 1979 | ) 1980 | }), 1981 | (v.prototype._isHost = function (t) { 1982 | return ( 1983 | t && 1984 | 'object' === n(t) && 1985 | !Array.isArray(t) && 1986 | '[object Object]' !== Object.prototype.toString.call(t) 1987 | ) 1988 | }), 1989 | (v.prototype.end = function (t) { 1990 | this._endCalled && 1991 | console.warn( 1992 | 'Warning: .end() was called twice. This is not supported in superagent' 1993 | ), 1994 | (this._endCalled = !0), 1995 | (this._callback = t || f), 1996 | this._finalizeQueryString(), 1997 | this._end() 1998 | }), 1999 | (v.prototype._setUploadTimeout = function () { 2000 | var t = this 2001 | this._uploadTimeout && 2002 | !this._uploadTimeoutTimer && 2003 | (this._uploadTimeoutTimer = setTimeout(function () { 2004 | t._timeoutError( 2005 | 'Upload timeout of ', 2006 | t._uploadTimeout, 2007 | 'ETIMEDOUT' 2008 | ) 2009 | }, this._uploadTimeout)) 2010 | }), 2011 | (v.prototype._end = function () { 2012 | if (this._aborted) 2013 | return this.callback( 2014 | new Error( 2015 | 'The request has been aborted even before .end() was called' 2016 | ) 2017 | ) 2018 | var r = this 2019 | this.xhr = h.getXHR() 2020 | var n = this.xhr, 2021 | t = this._formData || this._data 2022 | this._setTimeouts(), 2023 | (n.onreadystatechange = function () { 2024 | var e, 2025 | t = n.readyState 2026 | if ( 2027 | (2 <= t && 2028 | r._responseTimeoutTimer && 2029 | clearTimeout(r._responseTimeoutTimer), 2030 | 4 === t) 2031 | ) { 2032 | try { 2033 | e = n.status 2034 | } catch (t) { 2035 | e = 0 2036 | } 2037 | if (!e) 2038 | return r.timedout || r._aborted 2039 | ? void 0 2040 | : r.crossDomainError() 2041 | r.emit('end') 2042 | } 2043 | }) 2044 | function e(t, e) { 2045 | 0 < e.total && 2046 | ((e.percent = (e.loaded / e.total) * 100), 2047 | 100 === e.percent && clearTimeout(r._uploadTimeoutTimer)), 2048 | (e.direction = t), 2049 | r.emit('progress', e) 2050 | } 2051 | var o, i, s 2052 | if (this.hasListeners('progress')) 2053 | try { 2054 | n.addEventListener('progress', e.bind(null, 'download')), 2055 | n.upload && 2056 | n.upload.addEventListener( 2057 | 'progress', 2058 | e.bind(null, 'upload') 2059 | ) 2060 | } catch (t) {} 2061 | n.upload && this._setUploadTimeout() 2062 | try { 2063 | this.username && this.password 2064 | ? n.open( 2065 | this.method, 2066 | this.url, 2067 | !0, 2068 | this.username, 2069 | this.password 2070 | ) 2071 | : n.open(this.method, this.url, !0) 2072 | } catch (t) { 2073 | return this.callback(t) 2074 | } 2075 | for (s in (this._withCredentials && (n.withCredentials = !0), 2076 | this._formData || 2077 | 'GET' === this.method || 2078 | 'HEAD' === this.method || 2079 | 'string' == typeof t || 2080 | this._isHost(t) || 2081 | ((o = this._header['content-type']), 2082 | (i = 2083 | !(i = 2084 | this._serializer || 2085 | h.serialize[o ? o.split(';')[0] : '']) && g(o) 2086 | ? h.serialize['application/json'] 2087 | : i) && (t = i(t))), 2088 | this.header)) 2089 | null !== this.header[s] && 2090 | Object.prototype.hasOwnProperty.call(this.header, s) && 2091 | n.setRequestHeader(s, this.header[s]) 2092 | this._responseType && (n.responseType = this._responseType), 2093 | this.emit('request', this), 2094 | n.send(void 0 === t ? null : t) 2095 | }), 2096 | (h.agent = function () { 2097 | return new p() 2098 | }), 2099 | ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE'].forEach( 2100 | function (r) { 2101 | p.prototype[r.toLowerCase()] = function (t, e) { 2102 | t = new h.Request(r, t) 2103 | return this._setDefaults(t), e && t.end(e), t 2104 | } 2105 | } 2106 | ), 2107 | (p.prototype.del = p.prototype.delete), 2108 | (h.get = function (t, e, r) { 2109 | t = h('GET', t) 2110 | return ( 2111 | 'function' == typeof e && ((r = e), (e = null)), 2112 | e && t.query(e), 2113 | r && t.end(r), 2114 | t 2115 | ) 2116 | }), 2117 | (h.head = function (t, e, r) { 2118 | t = h('HEAD', t) 2119 | return ( 2120 | 'function' == typeof e && ((r = e), (e = null)), 2121 | e && t.query(e), 2122 | r && t.end(r), 2123 | t 2124 | ) 2125 | }), 2126 | (h.options = function (t, e, r) { 2127 | t = h('OPTIONS', t) 2128 | return ( 2129 | 'function' == typeof e && ((r = e), (e = null)), 2130 | e && t.send(e), 2131 | r && t.end(r), 2132 | t 2133 | ) 2134 | }), 2135 | (h.del = T), 2136 | (h.delete = T), 2137 | (h.patch = function (t, e, r) { 2138 | t = h('PATCH', t) 2139 | return ( 2140 | 'function' == typeof e && ((r = e), (e = null)), 2141 | e && t.send(e), 2142 | r && t.end(r), 2143 | t 2144 | ) 2145 | }), 2146 | (h.post = function (t, e, r) { 2147 | t = h('POST', t) 2148 | return ( 2149 | 'function' == typeof e && ((r = e), (e = null)), 2150 | e && t.send(e), 2151 | r && t.end(r), 2152 | t 2153 | ) 2154 | }), 2155 | (h.put = function (t, e, r) { 2156 | t = h('PUT', t) 2157 | return ( 2158 | 'function' == typeof e && ((r = e), (e = null)), 2159 | e && t.send(e), 2160 | r && t.end(r), 2161 | t 2162 | ) 2163 | }) 2164 | }, 2165 | { 2166 | './agent-base': 8, 2167 | './is-object': 9, 2168 | './request-base': 11, 2169 | './response-base': 12, 2170 | 'component-emitter': 1, 2171 | 'fast-safe-stringify': 2, 2172 | 'qs': 4, 2173 | }, 2174 | ], 2175 | 11: [ 2176 | function (t, e, r) { 2177 | 'use strict' 2178 | function n(t) { 2179 | return (n = 2180 | 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator 2181 | ? function (t) { 2182 | return typeof t 2183 | } 2184 | : function (t) { 2185 | return t && 2186 | 'function' == typeof Symbol && 2187 | t.constructor === Symbol && 2188 | t !== Symbol.prototype 2189 | ? 'symbol' 2190 | : typeof t 2191 | })(t) 2192 | } 2193 | var o = t('./is-object') 2194 | function i(t) { 2195 | if (t) 2196 | return (function (t) { 2197 | for (var e in i.prototype) 2198 | Object.prototype.hasOwnProperty.call(i.prototype, e) && 2199 | (t[e] = i.prototype[e]) 2200 | return t 2201 | })(t) 2202 | } 2203 | ;((e.exports = i).prototype.clearTimeout = function () { 2204 | return ( 2205 | clearTimeout(this._timer), 2206 | clearTimeout(this._responseTimeoutTimer), 2207 | clearTimeout(this._uploadTimeoutTimer), 2208 | delete this._timer, 2209 | delete this._responseTimeoutTimer, 2210 | delete this._uploadTimeoutTimer, 2211 | this 2212 | ) 2213 | }), 2214 | (i.prototype.parse = function (t) { 2215 | return (this._parser = t), this 2216 | }), 2217 | (i.prototype.responseType = function (t) { 2218 | return (this._responseType = t), this 2219 | }), 2220 | (i.prototype.serialize = function (t) { 2221 | return (this._serializer = t), this 2222 | }), 2223 | (i.prototype.timeout = function (t) { 2224 | if (!t || 'object' !== n(t)) 2225 | return ( 2226 | (this._timeout = t), 2227 | (this._responseTimeout = 0), 2228 | (this._uploadTimeout = 0), 2229 | this 2230 | ) 2231 | for (var e in t) 2232 | if (Object.prototype.hasOwnProperty.call(t, e)) 2233 | switch (e) { 2234 | case 'deadline': 2235 | this._timeout = t.deadline 2236 | break 2237 | case 'response': 2238 | this._responseTimeout = t.response 2239 | break 2240 | case 'upload': 2241 | this._uploadTimeout = t.upload 2242 | break 2243 | default: 2244 | console.warn('Unknown timeout option', e) 2245 | } 2246 | return this 2247 | }), 2248 | (i.prototype.retry = function (t, e) { 2249 | return ( 2250 | (t = 0 === arguments.length || !0 === t ? 1 : t) <= 0 && 2251 | (t = 0), 2252 | (this._maxRetries = t), 2253 | (this._retries = 0), 2254 | (this._retryCallback = e), 2255 | this 2256 | ) 2257 | }) 2258 | var s = new Set([ 2259 | 'ETIMEDOUT', 2260 | 'ECONNRESET', 2261 | 'EADDRINUSE', 2262 | 'ECONNREFUSED', 2263 | 'EPIPE', 2264 | 'ENOTFOUND', 2265 | 'ENETUNREACH', 2266 | 'EAI_AGAIN', 2267 | ]), 2268 | a = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]) 2269 | ;(i.prototype._shouldRetry = function (t, e) { 2270 | if (!this._maxRetries || this._retries++ >= this._maxRetries) 2271 | return !1 2272 | if (this._retryCallback) 2273 | try { 2274 | var r = this._retryCallback(t, e) 2275 | if (!0 === r) return !0 2276 | if (!1 === r) return !1 2277 | } catch (t) { 2278 | console.error(t) 2279 | } 2280 | if (e && e.status && a.has(e.status)) return !0 2281 | if (t) { 2282 | if (t.code && s.has(t.code)) return !0 2283 | if (t.timeout && 'ECONNABORTED' === t.code) return !0 2284 | if (t.crossDomain) return !0 2285 | } 2286 | return !1 2287 | }), 2288 | (i.prototype._retry = function () { 2289 | return ( 2290 | this.clearTimeout(), 2291 | this.req && ((this.req = null), (this.req = this.request())), 2292 | (this._aborted = !1), 2293 | (this.timedout = !1), 2294 | (this.timedoutError = null), 2295 | this._end() 2296 | ) 2297 | }), 2298 | (i.prototype.then = function (t, e) { 2299 | var o, 2300 | i = this 2301 | return ( 2302 | this._fullfilledPromise || 2303 | ((o = this)._endCalled && 2304 | console.warn( 2305 | 'Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises' 2306 | ), 2307 | (this._fullfilledPromise = new Promise(function (r, n) { 2308 | o.on('abort', function () { 2309 | var t 2310 | ;(i._maxRetries && i._maxRetries > i._retries) || 2311 | (i.timedout && i.timedoutError 2312 | ? n(i.timedoutError) 2313 | : (((t = new Error('Aborted')).code = 'ABORTED'), 2314 | (t.status = i.status), 2315 | (t.method = i.method), 2316 | (t.url = i.url), 2317 | n(t))) 2318 | }), 2319 | o.end(function (t, e) { 2320 | t ? n(t) : r(e) 2321 | }) 2322 | }))), 2323 | this._fullfilledPromise.then(t, e) 2324 | ) 2325 | }), 2326 | (i.prototype.catch = function (t) { 2327 | return this.then(void 0, t) 2328 | }), 2329 | (i.prototype.use = function (t) { 2330 | return t(this), this 2331 | }), 2332 | (i.prototype.ok = function (t) { 2333 | if ('function' != typeof t) throw new Error('Callback required') 2334 | return (this._okCallback = t), this 2335 | }), 2336 | (i.prototype._isResponseOK = function (t) { 2337 | return ( 2338 | !!t && 2339 | (this._okCallback 2340 | ? this._okCallback(t) 2341 | : 200 <= t.status && t.status < 300) 2342 | ) 2343 | }), 2344 | (i.prototype.getHeader = i.prototype.get = 2345 | function (t) { 2346 | return this._header[t.toLowerCase()] 2347 | }), 2348 | (i.prototype.set = function (t, e) { 2349 | if (o(t)) { 2350 | for (var r in t) 2351 | Object.prototype.hasOwnProperty.call(t, r) && 2352 | this.set(r, t[r]) 2353 | return this 2354 | } 2355 | return ( 2356 | (this._header[t.toLowerCase()] = e), (this.header[t] = e), this 2357 | ) 2358 | }), 2359 | (i.prototype.unset = function (t) { 2360 | return ( 2361 | delete this._header[t.toLowerCase()], 2362 | delete this.header[t], 2363 | this 2364 | ) 2365 | }), 2366 | (i.prototype.field = function (t, e) { 2367 | if (null == t) 2368 | throw new Error('.field(name, val) name can not be empty') 2369 | if (this._data) 2370 | throw new Error( 2371 | ".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()" 2372 | ) 2373 | if (o(t)) { 2374 | for (var r in t) 2375 | Object.prototype.hasOwnProperty.call(t, r) && 2376 | this.field(r, t[r]) 2377 | return this 2378 | } 2379 | if (Array.isArray(e)) { 2380 | for (var n in e) 2381 | Object.prototype.hasOwnProperty.call(e, n) && 2382 | this.field(t, e[n]) 2383 | return this 2384 | } 2385 | if (null == e) 2386 | throw new Error('.field(name, val) val can not be empty') 2387 | return ( 2388 | 'boolean' == typeof e && (e = String(e)), 2389 | this._getFormData().append(t, e), 2390 | this 2391 | ) 2392 | }), 2393 | (i.prototype.abort = function () { 2394 | return ( 2395 | this._aborted || 2396 | ((this._aborted = !0), 2397 | this.xhr && this.xhr.abort(), 2398 | this.req && this.req.abort(), 2399 | this.clearTimeout(), 2400 | this.emit('abort')), 2401 | this 2402 | ) 2403 | }), 2404 | (i.prototype._auth = function (t, e, r, n) { 2405 | switch (r.type) { 2406 | case 'basic': 2407 | this.set( 2408 | 'Authorization', 2409 | 'Basic '.concat(n(''.concat(t, ':').concat(e))) 2410 | ) 2411 | break 2412 | case 'auto': 2413 | ;(this.username = t), (this.password = e) 2414 | break 2415 | case 'bearer': 2416 | this.set('Authorization', 'Bearer '.concat(t)) 2417 | } 2418 | return this 2419 | }), 2420 | (i.prototype.withCredentials = function (t) { 2421 | return void 0 === t && (t = !0), (this._withCredentials = t), this 2422 | }), 2423 | (i.prototype.redirects = function (t) { 2424 | return (this._maxRedirects = t), this 2425 | }), 2426 | (i.prototype.maxResponseSize = function (t) { 2427 | if ('number' != typeof t) throw new TypeError('Invalid argument') 2428 | return (this._maxResponseSize = t), this 2429 | }), 2430 | (i.prototype.toJSON = function () { 2431 | return { 2432 | method: this.method, 2433 | url: this.url, 2434 | data: this._data, 2435 | headers: this._header, 2436 | } 2437 | }), 2438 | (i.prototype.send = function (t) { 2439 | var e = o(t), 2440 | r = this._header['content-type'] 2441 | if (this._formData) 2442 | throw new Error( 2443 | ".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()" 2444 | ) 2445 | if (e && !this._data) 2446 | Array.isArray(t) 2447 | ? (this._data = []) 2448 | : this._isHost(t) || (this._data = {}) 2449 | else if (t && this._data && this._isHost(this._data)) 2450 | throw new Error("Can't merge these send calls") 2451 | if (e && o(this._data)) 2452 | for (var n in t) 2453 | Object.prototype.hasOwnProperty.call(t, n) && 2454 | (this._data[n] = t[n]) 2455 | else 2456 | 'string' == typeof t 2457 | ? (r || this.type('form'), 2458 | (r = 2459 | (r = this._header['content-type']) && 2460 | r.toLowerCase().trim()), 2461 | (this._data = 2462 | 'application/x-www-form-urlencoded' === r 2463 | ? this._data 2464 | ? ''.concat(this._data, '&').concat(t) 2465 | : t 2466 | : (this._data || '') + t)) 2467 | : (this._data = t) 2468 | return !e || this._isHost(t) || r || this.type('json'), this 2469 | }), 2470 | (i.prototype.sortQuery = function (t) { 2471 | return (this._sort = void 0 === t || t), this 2472 | }), 2473 | (i.prototype._finalizeQueryString = function () { 2474 | var t, 2475 | e = this._query.join('&') 2476 | e && (this.url += (this.url.includes('?') ? '&' : '?') + e), 2477 | (this._query.length = 0), 2478 | !this._sort || 2479 | (0 <= (t = this.url.indexOf('?')) && 2480 | ((e = this.url.slice(t + 1).split('&')), 2481 | 'function' == typeof this._sort 2482 | ? e.sort(this._sort) 2483 | : e.sort(), 2484 | (this.url = this.url.slice(0, t) + '?' + e.join('&')))) 2485 | }), 2486 | (i.prototype._appendQueryString = function () { 2487 | console.warn('Unsupported') 2488 | }), 2489 | (i.prototype._timeoutError = function (t, e, r) { 2490 | this._aborted || 2491 | (((t = new Error(''.concat(t + e, 'ms exceeded'))).timeout = e), 2492 | (t.code = 'ECONNABORTED'), 2493 | (t.errno = r), 2494 | (this.timedout = !0), 2495 | (this.timedoutError = t), 2496 | this.abort(), 2497 | this.callback(t)) 2498 | }), 2499 | (i.prototype._setTimeouts = function () { 2500 | var t = this 2501 | this._timeout && 2502 | !this._timer && 2503 | (this._timer = setTimeout(function () { 2504 | t._timeoutError('Timeout of ', t._timeout, 'ETIME') 2505 | }, this._timeout)), 2506 | this._responseTimeout && 2507 | !this._responseTimeoutTimer && 2508 | (this._responseTimeoutTimer = setTimeout(function () { 2509 | t._timeoutError( 2510 | 'Response timeout of ', 2511 | t._responseTimeout, 2512 | 'ETIMEDOUT' 2513 | ) 2514 | }, this._responseTimeout)) 2515 | }) 2516 | }, 2517 | { './is-object': 9 }, 2518 | ], 2519 | 12: [ 2520 | function (t, e, r) { 2521 | 'use strict' 2522 | var o = t('./utils') 2523 | function n(t) { 2524 | if (t) 2525 | return (function (t) { 2526 | for (var e in n.prototype) 2527 | Object.prototype.hasOwnProperty.call(n.prototype, e) && 2528 | (t[e] = n.prototype[e]) 2529 | return t 2530 | })(t) 2531 | } 2532 | ;((e.exports = n).prototype.get = function (t) { 2533 | return this.header[t.toLowerCase()] 2534 | }), 2535 | (n.prototype._setHeaderProperties = function (t) { 2536 | var e = t['content-type'] || '' 2537 | this.type = o.type(e) 2538 | var r, 2539 | n = o.params(e) 2540 | for (r in n) 2541 | Object.prototype.hasOwnProperty.call(n, r) && (this[r] = n[r]) 2542 | this.links = {} 2543 | try { 2544 | t.link && (this.links = o.parseLinks(t.link)) 2545 | } catch (t) {} 2546 | }), 2547 | (n.prototype._setStatusProperties = function (t) { 2548 | var e = (t / 100) | 0 2549 | ;(this.statusCode = t), 2550 | (this.status = this.statusCode), 2551 | (this.statusType = e), 2552 | (this.info = 1 == e), 2553 | (this.ok = 2 == e), 2554 | (this.redirect = 3 == e), 2555 | (this.clientError = 4 == e), 2556 | (this.serverError = 5 == e), 2557 | (this.error = (4 == e || 5 == e) && this.toError()), 2558 | (this.created = 201 === t), 2559 | (this.accepted = 202 === t), 2560 | (this.noContent = 204 === t), 2561 | (this.badRequest = 400 === t), 2562 | (this.unauthorized = 401 === t), 2563 | (this.notAcceptable = 406 === t), 2564 | (this.forbidden = 403 === t), 2565 | (this.notFound = 404 === t), 2566 | (this.unprocessableEntity = 422 === t) 2567 | }) 2568 | }, 2569 | { './utils': 13 }, 2570 | ], 2571 | 13: [ 2572 | function (t, e, r) { 2573 | 'use strict' 2574 | function i(t, e) { 2575 | var r 2576 | if ('undefined' == typeof Symbol || null == t[Symbol.iterator]) { 2577 | if ( 2578 | Array.isArray(t) || 2579 | (r = (function (t, e) { 2580 | if (!t) return 2581 | if ('string' == typeof t) return a(t, e) 2582 | var r = Object.prototype.toString.call(t).slice(8, -1) 2583 | 'Object' === r && t.constructor && (r = t.constructor.name) 2584 | if ('Map' === r || 'Set' === r) return Array.from(t) 2585 | if ( 2586 | 'Arguments' === r || 2587 | /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) 2588 | ) 2589 | return a(t, e) 2590 | })(t)) || 2591 | (e && t && 'number' == typeof t.length) 2592 | ) { 2593 | r && (t = r) 2594 | var n = 0, 2595 | e = function () {} 2596 | return { 2597 | s: e, 2598 | n: function () { 2599 | return n >= t.length 2600 | ? { done: !0 } 2601 | : { done: !1, value: t[n++] } 2602 | }, 2603 | e: function (t) { 2604 | throw t 2605 | }, 2606 | f: e, 2607 | } 2608 | } 2609 | throw new TypeError( 2610 | 'Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' 2611 | ) 2612 | } 2613 | var o, 2614 | i = !0, 2615 | s = !1 2616 | return { 2617 | s: function () { 2618 | r = t[Symbol.iterator]() 2619 | }, 2620 | n: function () { 2621 | var t = r.next() 2622 | return (i = t.done), t 2623 | }, 2624 | e: function (t) { 2625 | ;(s = !0), (o = t) 2626 | }, 2627 | f: function () { 2628 | try { 2629 | i || null == r.return || r.return() 2630 | } finally { 2631 | if (s) throw o 2632 | } 2633 | }, 2634 | } 2635 | } 2636 | function a(t, e) { 2637 | ;(null == e || e > t.length) && (e = t.length) 2638 | for (var r = 0, n = new Array(e); r < e; r++) n[r] = t[r] 2639 | return n 2640 | } 2641 | ;(r.type = function (t) { 2642 | return t.split(/ *; */).shift() 2643 | }), 2644 | (r.params = function (t) { 2645 | var e = {}, 2646 | r = i(t.split(/ *; */)) 2647 | try { 2648 | for (r.s(); !(o = r.n()).done; ) { 2649 | var n = o.value.split(/ *= */), 2650 | o = n.shift(), 2651 | n = n.shift() 2652 | o && n && (e[o] = n) 2653 | } 2654 | } catch (t) { 2655 | r.e(t) 2656 | } finally { 2657 | r.f() 2658 | } 2659 | return e 2660 | }), 2661 | (r.parseLinks = function (t) { 2662 | var e = {}, 2663 | r = i(t.split(/ *, */)) 2664 | try { 2665 | for (r.s(); !(o = r.n()).done; ) { 2666 | var n = o.value.split(/ *; */), 2667 | o = n[0].slice(1, -1) 2668 | e[n[1].split(/ *= */)[1].slice(1, -1)] = o 2669 | } 2670 | } catch (t) { 2671 | r.e(t) 2672 | } finally { 2673 | r.f() 2674 | } 2675 | return e 2676 | }), 2677 | (r.cleanHeader = function (t, e) { 2678 | return ( 2679 | delete t['content-type'], 2680 | delete t['content-length'], 2681 | delete t['transfer-encoding'], 2682 | delete t.host, 2683 | e && (delete t.authorization, delete t.cookie), 2684 | t 2685 | ) 2686 | }) 2687 | }, 2688 | {}, 2689 | ], 2690 | }, 2691 | {}, 2692 | [10] 2693 | )(10) 2694 | }) 2695 | 2696 | function initMFS() { 2697 | var j = 'https://test.masterpassturkiye.com/MasterpassJsonServerHandler/v2', 2698 | L = '', 2699 | F = new RSAKey() 2700 | F.setPublic( 2701 | 'F619C53A37BAB059C583DA9AC4E2920FFC9D57E00885E82F7A0863DEAC43CE06374E45A1417DAC907C6CAC0AF1DDF1D7152192FED7A1D9255C97BC27E420E0742B95ED3C53C62995F42CB6EEDB7B1FBDD3E4F4A4AA935650DA81E763CA7074690032F6A6AF72802CC50394C2AFA5C9450A990E6F969A38571C8BC9E381125D2BEEC348AF919D7374FF10DC3E0B4367566CE929AD6EA323A475A677EB41C20B42D44E82E8A53DD52334D927394FCADF09', 2702 | '03' 2703 | ), 2704 | (SDK = (function () { 2705 | function o(t, e, r) { 2706 | for (var n = r.length - 1; 0 <= n; n--) { 2707 | var o = r[n] 2708 | e[o] = (function (t, e) { 2709 | var tValue = t[e] 2710 | 2711 | for (var r = Object.keys(t), n = r.length - 1; 0 <= n; n--) { 2712 | if (r[n] == e) { 2713 | if ( 2714 | 'cardAliasName' == e || 2715 | 'accountAliasName' == e || 2716 | 'cardHolderName' == e || 2717 | 'listAccountName' == e || 2718 | 'productId' == e || 2719 | 'senderAliasName' == e || 2720 | 'recipientAliasName' == e 2721 | ) 2722 | return encodeURIComponent(tValue) 2723 | if ('validationCode' == e) { 2724 | if (I) return F.encrypt(tValue) 2725 | if (N) { 2726 | var i = tValue.replace('.', '').replace(',', '') 2727 | return 3 == i.length ? i : i.concat('0') 2728 | } 2729 | } 2730 | if ('rtaPan' == e || 'pan' == e) 2731 | return P(tValue) ? F.encrypt(tValue) : '' 2732 | if ('cvv' == e || 'cvc' == e) 2733 | return 3 != tValue.length && 4 != tValue.length 2734 | ? '' 2735 | : F.encrypt(tValue) 2736 | if ('installmentCount' == e && '' !== tValue && !isNaN(tValue)) 2737 | return parseFloat(tValue) 2738 | if (typeof tValue === 'boolean' && !tValue) continue 2739 | return tValue 2740 | } 2741 | } 2742 | return null 2743 | })(t, o) 2744 | } 2745 | ;(e.fp = L), (e.additionalParams = u) 2746 | } 2747 | function i(t, e, n) { 2748 | t.clientId = s 2749 | var r = (r = new Date().toJSON()).replace(/"/g, '') 2750 | ;(t.dateTime = r), 2751 | (t.version = '36.2'), 2752 | (t.clientType = '1'), 2753 | axios 2754 | .post(j + e, t) 2755 | .then(response => response.data) 2756 | .then(function (e) { 2757 | var r = (function (t) { 2758 | var r = {} 2759 | if (e.hasOwnProperty('Data')) { 2760 | ;(r.referenceNo = 2761 | e.Data.Body.Fault.Detail.ServiceFaultDetail.RefNo), 2762 | (r.responseCode = 2763 | e.Data.Body.Fault.Detail.ServiceFaultDetail.ResponseCode), 2764 | (r.responseDescription = 2765 | e.Data.Body.Fault.Detail.ServiceFaultDetail.ResponseDesc), 2766 | (r.url3D = 2767 | e.Data.Body.Fault.Detail.ServiceFaultDetail.Url3D), 2768 | (r.url3DSuccess = 2769 | e.Data.Body.Fault.Detail.ServiceFaultDetail.Url3DSuccess), 2770 | (r.url3DError = 2771 | e.Data.Body.Fault.Detail.ServiceFaultDetail.Url3DError), 2772 | (r.urlLoan = 2773 | e.Data.Body.Fault.Detail.ServiceFaultDetail.UrlLoan), 2774 | (r.urlLoanSuccess = 2775 | e.Data.Body.Fault.Detail.ServiceFaultDetail.UrlLoanSuccess), 2776 | (r.urlLoanError = 2777 | e.Data.Body.Fault.Detail.ServiceFaultDetail.UrlLoanError), 2778 | (r.newMsisdn = 2779 | e.Data.Body.Fault.Detail.ServiceFaultDetail.NewMsisdn), 2780 | (r.internalResponseCode = 2781 | e.Data.Body.Fault.Detail.ServiceFaultDetail.InternalResponseCode), 2782 | (r.internalResponseDescription = 2783 | e.Data.Body.Fault.Detail.ServiceFaultDetail.InternalResponseMessage) 2784 | var n = e.Data.Body.Fault.Detail.ServiceFaultDetail.Token, 2785 | o = '' 2786 | if (e.Data.Body.hasOwnProperty('Response')) { 2787 | ;(o = e.Data.Body.Response.Result.TransactionBody.Token), 2788 | (r.token = o) 2789 | t = '' 2790 | e.Data.Body.Response.Result.TransactionBody.hasOwnProperty( 2791 | 'RefNo' 2792 | ) && 2793 | '' !== 2794 | e.Data.Body.Response.Result.TransactionBody.RefNo && 2795 | (t = e.Data.Body.Response.Result.TransactionBody.RefNo), 2796 | e.Data.Body.Fault.Detail.ServiceFaultDetail.hasOwnProperty( 2797 | 'RefNo' 2798 | ) && 2799 | '' !== 2800 | e.Data.Body.Fault.Detail.ServiceFaultDetail.RefNo && 2801 | (t = e.Data.Body.Fault.Detail.ServiceFaultDetail.RefNo), 2802 | (r.transactionId = t) 2803 | t = '' 2804 | e.Data.Body.Response.Result.TransactionBody.hasOwnProperty( 2805 | 'CardUniqueId' 2806 | ) && 2807 | '' !== 2808 | e.Data.Body.Response.Result.TransactionBody 2809 | .CardUniqueId && 2810 | (t = 2811 | e.Data.Body.Response.Result.TransactionBody 2812 | .CardUniqueId), 2813 | (r.cardUniqueId = t), 2814 | e.Data.Body.Response.Result.TransactionBody.hasOwnProperty( 2815 | 'AccountList' 2816 | ) && 2817 | '' !== 2818 | e.Data.Body.Response.Result.TransactionBody 2819 | .AccountList && 2820 | (r.AccountList = 2821 | e.Data.Body.Response.Result.TransactionBody.AccountList) 2822 | var i = 2823 | e.Data.Body.Response.Result.TransactionBody.ListItems 2824 | try { 2825 | i && 0 !== i.ListItem && (r.cards = i.ListItem) 2826 | } catch (t) {} 2827 | try { 2828 | i && 0 !== i.BankList && (r.banks = i.BankList) 2829 | } catch (t) {} 2830 | ;(r.accountStatus = 2831 | e.Data.Body.Response.Result.TransactionBody.AccountStatus), 2832 | (r.amount = 2833 | e.Data.Body.Response.Result.TransactionBody.Amount), 2834 | (r.orderNo = 2835 | e.Data.Body.Response.Result.TransactionBody.OrderNo), 2836 | (r.installmentCount = 2837 | e.Data.Body.Response.Result.TransactionBody.InstallmentCount) 2838 | } 2839 | n && 0 !== n.length ? (a = n) : (r.token = o) 2840 | } 2841 | return r 2842 | })(e) 2843 | n(200, r) 2844 | }) 2845 | .catch(error => n(500, error)) 2846 | } 2847 | var s, 2848 | a, 2849 | u, 2850 | c, 2851 | n = [ 2852 | 'actionType', 2853 | 'clientIp', 2854 | 'delinkReason', 2855 | 'eActionType', 2856 | 'cardTypeFlag', 2857 | 'cpinFlag', 2858 | 'defaultAccount', 2859 | 'mmrpConfig', 2860 | 'identityVerificationFlag', 2861 | 'mobileAccountConfig', 2862 | 'msisdn', 2863 | 'referenceNo', 2864 | 'sendSms', 2865 | 'sendSmsLanguage', 2866 | 'timeZone', 2867 | 'uiChannelType', 2868 | 'rtaPan', 2869 | 'expiryDate', 2870 | 'accountAliasName', 2871 | 'cvc', 2872 | 'homeAddress', 2873 | 'homeCity', 2874 | 'homeState', 2875 | 'homeCountryCode', 2876 | 'homePostalCode', 2877 | 'firstName', 2878 | 'lastName', 2879 | 'email', 2880 | 'cardHolderName', 2881 | 'token', 2882 | ], 2883 | l = [ 2884 | 'msisdn', 2885 | 'referenceNo', 2886 | 'sendSms', 2887 | 'sendSmsLanguage', 2888 | 'accountAliasName', 2889 | 'token', 2890 | ], 2891 | p = [ 2892 | 'validationCode', 2893 | 'sendSms', 2894 | 'sendSmsLanguage', 2895 | 'referenceNo', 2896 | 'token', 2897 | ], 2898 | f = [ 2899 | 'aav', 2900 | 'amount', 2901 | 'clientIp', 2902 | 'encCPin', 2903 | 'encPassword', 2904 | 'listAccountName', 2905 | 'msisdn', 2906 | 'password', 2907 | 'referenceNo', 2908 | 'sendSms', 2909 | 'sendSmsLanguage', 2910 | 'sendSmsMerchant', 2911 | 'userId', 2912 | 'token', 2913 | 'rewardName', 2914 | 'rewardValue', 2915 | 'moneyCardInvoiceAmount', 2916 | 'moneyCardMigrosDiscountAmount', 2917 | 'moneyCardPaymentAmount', 2918 | 'moneyCardExtraDiscountAmount', 2919 | 'moneyCardProductBasedDiscountAmount', 2920 | 'installmentCount', 2921 | 'cvc', 2922 | 'macroMerchantId', 2923 | 'orderNo', 2924 | 'paymentType', 2925 | ], 2926 | h = [ 2927 | 'msisdn', 2928 | 'encPan', 2929 | 'token', 2930 | 'referenceNo', 2931 | 'sendSms', 2932 | 'sendSmsLanguage', 2933 | 'cvv', 2934 | ], 2935 | d = ['userId', 'token', 'referenceNo', 'sendSms', 'sendSmsLanguage'], 2936 | y = [ 2937 | 'msisdn', 2938 | 'cardAliasName', 2939 | 'token', 2940 | 'referenceNo', 2941 | 'sendSms', 2942 | 'sendSmsLanguage', 2943 | ], 2944 | m = [ 2945 | 'msisdn', 2946 | 'cardAliasName', 2947 | 'token', 2948 | 'referenceNo', 2949 | 'sendSms', 2950 | 'sendSmsLanguage', 2951 | ], 2952 | g = [ 2953 | 'token', 2954 | 'msisdn', 2955 | 'sendSmsLanguage', 2956 | 'fP', 2957 | 'amount', 2958 | 'expiryDate', 2959 | 'rtaPan', 2960 | 'cardHolderName', 2961 | 'cvc', 2962 | 'macroMerchantId', 2963 | 'orderNo', 2964 | 'paymentType', 2965 | 'installmentCount', 2966 | 'rewardName', 2967 | 'rewardValue', 2968 | ], 2969 | b = [ 2970 | 'sendSmsLanguage', 2971 | 'msisdn', 2972 | 'token', 2973 | 'cardAliasName', 2974 | 'fP', 2975 | 'referenceNo', 2976 | 'sendSms', 2977 | ], 2978 | v = [ 2979 | 'token', 2980 | 'msisdn', 2981 | 'oldValue', 2982 | 'theNewValue', 2983 | 'valueType', 2984 | 'sendSmsLanguage', 2985 | 'fP', 2986 | 'referenceNo', 2987 | 'sendSms', 2988 | ], 2989 | T = [ 2990 | 'token', 2991 | 'msisdn', 2992 | 'sendSmsLanguage', 2993 | 'fP', 2994 | 'referenceNo', 2995 | 'sendSms', 2996 | ], 2997 | _ = [ 2998 | 'msisdn', 2999 | 'accountAliasName', 3000 | 'token', 3001 | 'referenceNo', 3002 | 'sendSms', 3003 | 'sendSmsLanguage', 3004 | 'fP', 3005 | 'amount', 3006 | 'actionType', 3007 | 'firstName', 3008 | 'lastName', 3009 | 'gender', 3010 | 'expiryDate', 3011 | 'rtaPan', 3012 | 'cardHolderName', 3013 | 'orderNo', 3014 | 'merchantId', 3015 | 'rewardName', 3016 | 'rewardValue', 3017 | 'moneyCardInvoiceAmount', 3018 | 'moneyCardMigrosDiscountAmount', 3019 | 'moneyCardPaymentAmount', 3020 | 'moneyCardExtraDiscountAmount', 3021 | 'moneyCardProductBasedDiscountAmount', 3022 | 'installmentCount', 3023 | 'cvc', 3024 | 'macroMerchantId', 3025 | 'orderNo', 3026 | 'paymentType', 3027 | ], 3028 | S = ['msisdn', 'token', 'referenceNo', 'sendSms', 'sendSmsLanguage'], 3029 | w = [ 3030 | 'msisdn', 3031 | 'token', 3032 | 'listAccountName', 3033 | 'amount', 3034 | 'endDate', 3035 | 'actionType', 3036 | 'referenceNo', 3037 | 'sendSms', 3038 | 'sendSmsLanguage', 3039 | 'productId', 3040 | ], 3041 | D = [ 3042 | 'aav', 3043 | 'amount', 3044 | 'clientIp', 3045 | 'encCPin', 3046 | 'encPassword', 3047 | 'moneySendType', 3048 | 'senderAliasName', 3049 | 'recipientAliasName', 3050 | 'msisdn', 3051 | 'password', 3052 | 'referenceNo', 3053 | 'sendSms', 3054 | 'sendSmsLanguage', 3055 | 'sendSmsMerchant', 3056 | 'userId', 3057 | 'token', 3058 | 'rewardName', 3059 | 'rewardValue', 3060 | 'moneyCardInvoiceAmount', 3061 | 'installmentCount', 3062 | 'cvc', 3063 | 'macroMerchantId', 3064 | 'orderNo', 3065 | 'paymentType', 3066 | ], 3067 | A = [ 3068 | 'language', 3069 | 'referenceNo', 3070 | 'cvc', 3071 | 'pan', 3072 | 'client_token', 3073 | 'action_type', 3074 | 'token', 3075 | ], 3076 | C = ['msisdn', 'token', 'language', 'referenceNo'], 3077 | R = [ 3078 | 'referenceNo', 3079 | 'language', 3080 | 'msisdn', 3081 | 'amount', 3082 | 'client_token', 3083 | 'fP', 3084 | 'macroMerchantId', 3085 | 'orderNo', 3086 | 'basketInfo', 3087 | 'campaignCode', 3088 | 'loanBankIca', 3089 | 'bankIca', 3090 | ], 3091 | B = [ 3092 | 'referenceNo', 3093 | 'language', 3094 | 'token', 3095 | 'fP', 3096 | 'identityNumber', 3097 | 'transactionType', 3098 | ], 3099 | E = [ 3100 | 'referenceNo', 3101 | 'language', 3102 | 'token', 3103 | 'fP', 3104 | 'installmentId', 3105 | 'installmentCount', 3106 | 'loanType', 3107 | ], 3108 | O = ['referenceNo', 'language', 'token', 'fP', 'loanType', 'loanRrn'], 3109 | I = !1, 3110 | N = !1, 3111 | P = 3112 | ((c = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]), 3113 | function (t) { 3114 | for (var e, r = t.length, n = 1, o = 0; r; ) 3115 | (e = parseInt(t.charAt(--r), 10)), (o += (n ^= 1) ? c[e] : e) 3116 | return o && o % 10 == 0 3117 | }) 3118 | return { 3119 | setClientId: function (t) { 3120 | s = t 3121 | }, 3122 | listCards: function (t, e, r) { 3123 | var n = {} 3124 | ;(n.msisdn = t), 3125 | (n.token = e), 3126 | (n.referenceNo = '00000000'), 3127 | (n.listType = 'ACCOUNT'), 3128 | (n.sendSms = 'Y'), 3129 | (n.clientIp = ''), 3130 | (n.sendSmsLanguage = 'eng'), 3131 | i(n, '/listManagement', r) 3132 | }, 3133 | register: function (t, e) { 3134 | var r = {} 3135 | o(t, r, n), i(r, '/register', e) 3136 | }, 3137 | purchase: function (t, e) { 3138 | var r = {} 3139 | o(t, r, f), i(r, '/remotePurchaseOther', e) 3140 | }, 3141 | commit: function (t) { 3142 | var e = { 3143 | referenceNo: '00000000', 3144 | sendSms: 'N', 3145 | sendSmsLanguage: 'eng', 3146 | } 3147 | ;(e.token = t), i(e, '/commitTransaction', function () {}) 3148 | }, 3149 | deleteCard: function (t, e) { 3150 | var r = {} 3151 | o(t, r, l), i(r, '/deleteCard', e) 3152 | }, 3153 | validateTransaction: function (t, e) { 3154 | var r = t['pinType'] 3155 | ;(I = 'mpin' == r || 'cvv' == r), 'rta' == r && (N = !0) 3156 | r = {} 3157 | ;(r.validationRefNo = a), o(t, r, p), i(r, '/validateTransaction', e) 3158 | }, 3159 | forgotPassword: function (t, e) { 3160 | var r = {} 3161 | o(t, r, h), i(r, '/forgotPassword', e) 3162 | }, 3163 | setAddress: function (t) { 3164 | j = t 3165 | }, 3166 | checkMasterPass: function (t, e) { 3167 | var r = {} 3168 | o(t, r, d), i(r, '/checkMasterPassEndUser', e) 3169 | }, 3170 | linkCardToClient: function (t, e) { 3171 | var r = {} 3172 | o(t, r, m), i(r, '/linkCardToClient', e) 3173 | }, 3174 | addCardToMasterPass: function (t, e) { 3175 | var r = {} 3176 | o(t, r, y), i(r, '/addCardToMasterPass', e) 3177 | }, 3178 | purchaseAndRegister: function (t, e) { 3179 | var r = {} 3180 | ;(r.validationRefNo = a), o(t, r, _), i(r, '/purchaseAndRegister', e) 3181 | }, 3182 | directPurchase: function (t, e) { 3183 | var r = {} 3184 | o(t, r, g), i(r, '/directPurchase', e) 3185 | }, 3186 | resendOtp: function (t, e, r) { 3187 | var n = {} 3188 | ;(n.validationRefNo = t), 3189 | (n.referenceNo = '00000000'), 3190 | (n.sendSms = 'N'), 3191 | (n.sendSmsLanguage = e), 3192 | i(n, '/resendOtp', r) 3193 | }, 3194 | completeRegistration: function (t, e, r) { 3195 | var n = {} 3196 | ;(n.token2 = e), o(t, n, b), i(n, '/completeRegistration', r) 3197 | }, 3198 | setFingerprint: function (t) { 3199 | L = t 3200 | }, 3201 | setToken: function (t) { 3202 | a = t 3203 | }, 3204 | getLastToken: function () { 3205 | return a 3206 | }, 3207 | updateUser: function (t, e) { 3208 | var r = {} 3209 | o(t, r, v), i(r, '/updateUser', e) 3210 | }, 3211 | verifyPin: function (t, e) { 3212 | var r = {} 3213 | o(t, r, T), i(r, '/verifyPin', e) 3214 | }, 3215 | parseQrCode: function (t, e) { 3216 | var r = {} 3217 | o(t, r, S), i(r, '/QrPaymentVerify', e) 3218 | }, 3219 | initiateRecurringPayment: function (t, e) { 3220 | var r = {} 3221 | o(t, r, w), i(r, '/initiateManageRecurringPayment', e) 3222 | }, 3223 | setAdditionalParameters: function (t) { 3224 | u = t 3225 | }, 3226 | moneySend: function (t, e) { 3227 | var r = {} 3228 | o(t, r, D), i(r, '/initiateMoneySend', e) 3229 | }, 3230 | getCardUniqueId: function (t, e, r) { 3231 | var n = {} 3232 | P(t) ? (n.rtaPan = F.encrypt(t)) : (n.rtaPan = ''), 3233 | (n.token = e), 3234 | (n.referenceNo = '00000000'), 3235 | (n.sendSms = 'N'), 3236 | (n.clientIp = ''), 3237 | (n.sendSmsLanguage = 'eng'), 3238 | i(n, '/getCardUniqueId', r) 3239 | }, 3240 | listCardAccounts: function (t, e) { 3241 | var r = {} 3242 | o(t, r, A), i(r, '/ListAccountByCardOwner ', e) 3243 | }, 3244 | deleteCardAccount: function (t, e) { 3245 | var r = {} 3246 | o(t, r, C), i(r, '/deletecardbycardowner', e) 3247 | }, 3248 | getDigitalLoanUrl: function (t, e) { 3249 | var r = {} 3250 | o(t, r, R), i(r, '/digitalLoanUrl', e) 3251 | }, 3252 | initiateTcknValidation: function (t, e) { 3253 | var r = {} 3254 | o(t, r, B), i(r, '/initiateTcknValidation', e) 3255 | }, 3256 | completeLoan: function (t, e) { 3257 | var r = {} 3258 | o(t, r, E), i(r, '/completeLoan', e) 3259 | }, 3260 | initiateLoanPayment: function (t, e) { 3261 | var r = {} 3262 | o(t, r, O), i(r, '/initiateLoanPayment', e) 3263 | }, 3264 | } 3265 | })()) 3266 | } 3267 | 3268 | initMFS(this) 3269 | 3270 | export default SDK 3271 | -------------------------------------------------------------------------------- /src/MasterPass.ts: -------------------------------------------------------------------------------- 1 | import MFS from './MFS' 2 | import Constants from './Constants' 3 | import Utils from './Utils' 4 | import { 5 | CheckMasterPassFunction, 6 | DeleteCardFunction, 7 | DirectPurchaseFunction, 8 | GetLastTokenFunction, 9 | LinkCardToClientFunction, 10 | ListCardsFunction, 11 | PurchaseFunction, 12 | PurchaseAndRegisterFunction, 13 | RegisterFunction, 14 | ResendOtpFunction, 15 | SetAddressFunction, 16 | SetClientIdFunction, 17 | ValidateTransactionFunction, 18 | } from './Types' 19 | 20 | export default class MasterPass { 21 | // MasterPass Utils Methods 22 | public static Utils = Utils 23 | 24 | // MasterPass Constants 25 | public static Constants = Constants 26 | 27 | // Set Adress Method 28 | public static setAddress: SetAddressFunction = MFS.setAddress 29 | 30 | // Set Client Id Method 31 | public static setClientId: SetClientIdFunction = MFS.setClientId 32 | 33 | // Get Last Token Method 34 | public static getLastToken: GetLastTokenFunction = MFS.getLastToken 35 | 36 | // Check MasterPass Method 37 | public static checkMasterPass: CheckMasterPassFunction = async data => 38 | new Promise((resolve, reject) => { 39 | MFS.checkMasterPass(data, (status, response) => { 40 | return Utils.mfsResponseHandler( 41 | status, 42 | response, 43 | resolve, 44 | reject 45 | ) 46 | }) 47 | }) 48 | 49 | // List Cards Method 50 | public static listCards: ListCardsFunction = async (msisdn, token) => 51 | new Promise((resolve, reject) => { 52 | MFS.listCards(msisdn, token, (status, response) => { 53 | return Utils.mfsResponseHandler( 54 | status, 55 | response, 56 | resolve, 57 | reject 58 | ) 59 | }) 60 | }) 61 | 62 | // Register Method 63 | public static register: RegisterFunction = async data => 64 | new Promise((resolve, reject) => { 65 | const combined = { 66 | ...Constants.DefaultMethodData.register, 67 | ...data, 68 | } 69 | 70 | MFS.register(combined, (status, response) => { 71 | return Utils.mfsResponseHandler( 72 | status, 73 | response, 74 | resolve, 75 | reject 76 | ) 77 | }) 78 | }) 79 | 80 | // Validate Transaction Method 81 | public static validateTransaction: ValidateTransactionFunction = async data => 82 | new Promise((resolve, reject) => { 83 | const combined = { 84 | ...Constants.DefaultMethodData.validateTransaction, 85 | ...data, 86 | } 87 | 88 | MFS.validateTransaction(combined, (status, response) => { 89 | return Utils.mfsResponseHandler( 90 | status, 91 | response, 92 | resolve, 93 | reject 94 | ) 95 | }) 96 | }) 97 | 98 | // Delete Card Method 99 | public static deleteCard: DeleteCardFunction = async data => 100 | new Promise((resolve, reject) => { 101 | MFS.deleteCard(data, (status, response) => { 102 | return Utils.mfsResponseHandler( 103 | status, 104 | response, 105 | resolve, 106 | reject 107 | ) 108 | }) 109 | }) 110 | 111 | // Resend Otp Method 112 | public static resendOtp: ResendOtpFunction = async sendSMsLanguage => 113 | new Promise((resolve, reject) => { 114 | const lastToken = MFS.getLastToken() 115 | 116 | MFS.resendOtp(lastToken, sendSMsLanguage, (status, response) => { 117 | return Utils.mfsResponseHandler( 118 | status, 119 | response, 120 | resolve, 121 | reject 122 | ) 123 | }) 124 | }) 125 | 126 | // Link Card To Client Method 127 | public static linkCardToClient: LinkCardToClientFunction = async data => 128 | new Promise((resolve, reject) => { 129 | MFS.linkCardToClient(data, (status, response) => { 130 | return Utils.mfsResponseHandler( 131 | status, 132 | response, 133 | resolve, 134 | reject 135 | ) 136 | }) 137 | }) 138 | 139 | // Purchase Method 140 | public static purchase: PurchaseFunction = async data => 141 | new Promise((resolve, reject) => { 142 | const combined = { 143 | ...Constants.DefaultMethodData.purchase, 144 | ...data, 145 | } 146 | 147 | MFS.purchase(combined, (status, response) => { 148 | return Utils.mfsResponseHandler( 149 | status, 150 | response, 151 | resolve, 152 | reject 153 | ) 154 | }) 155 | }) 156 | 157 | // Purchase And Register Method 158 | public static purchaseAndRegister: PurchaseAndRegisterFunction = async data => 159 | new Promise((resolve, reject) => { 160 | MFS.purchaseAndRegister(data, (status, response) => { 161 | return Utils.mfsResponseHandler( 162 | status, 163 | response, 164 | resolve, 165 | reject 166 | ) 167 | }) 168 | }) 169 | 170 | // Direct Purchase Method 171 | public static directPurchase: DirectPurchaseFunction = async data => 172 | new Promise((resolve, reject) => { 173 | MFS.directPurchase(data, (status, response) => { 174 | return Utils.mfsResponseHandler( 175 | status, 176 | response, 177 | resolve, 178 | reject 179 | ) 180 | }) 181 | }) 182 | 183 | // SetAdditionalParameters Method 184 | public static setAdditionalParameters = MFS.setAdditionalParameters 185 | } 186 | -------------------------------------------------------------------------------- /src/Types.ts: -------------------------------------------------------------------------------- 1 | export type MFSStatus = 200 | 500 2 | 3 | export type CallbackFunction = (status: MFSStatus, response: T) => void 4 | 5 | export type MasterPassBoolean = 'Y' | 'N' 6 | 7 | export interface MFSBaseResponse { 8 | referenceNo: string 9 | responseCode: string 10 | responseDescription: string 11 | newMsisdn: string 12 | internalResponseCode: string 13 | internalResponseDescription: string 14 | transactionId: string 15 | cardUniqueId: string 16 | } 17 | 18 | export type MFSSetAddressFunction = (serviceUrl: string) => void 19 | 20 | export type SetAddressFunction = (serviceUrl: string) => void 21 | 22 | export type MFSSetClientIdFunction = (clientId: string) => void 23 | 24 | export type SetClientIdFunction = (serviceUrl: string) => void 25 | 26 | export interface CheckMasterPassData { 27 | userId: string 28 | token: string 29 | referenceNo: string 30 | sendSms: MasterPassBoolean 31 | sendSmsLanguage: string 32 | } 33 | 34 | export interface CheckMasterPassResponse extends MFSBaseResponse { 35 | accountStatus: string 36 | amount: string 37 | orderNo: string 38 | token: string 39 | url3D: string 40 | url3DError: string 41 | url3DSuccess: string 42 | urlLoan: string 43 | urlLoanError: string 44 | urlLoanSuccess: string 45 | } 46 | 47 | export type MFSCheckMasterPassFunction = ( 48 | data: CheckMasterPassData, 49 | callback: CallbackFunction 50 | ) => void 51 | 52 | export type CheckMasterPassFunction = ( 53 | data: CheckMasterPassData 54 | ) => Promise 55 | 56 | export interface MasterPassCard { 57 | Name: string 58 | PromtCpin: MasterPassBoolean 59 | Value1: string 60 | Value2: string 61 | IsMasterPassMember: MasterPassBoolean 62 | CardStatus: string 63 | BankIca: string 64 | LoyaltyCode: string 65 | ProductName: string 66 | UniqueId: string 67 | EftCode: string 68 | } 69 | 70 | export interface ListCardsResponse extends MFSBaseResponse { 71 | cards: MasterPassCard[] 72 | } 73 | 74 | export type MFSListCardsFunction = ( 75 | msisdn: string, 76 | token: string, 77 | callback: CallbackFunction 78 | ) => void 79 | 80 | export type ListCardsFunction = ( 81 | msisdn: string, 82 | token: string 83 | ) => Promise 84 | 85 | export interface RegisterData { 86 | actionType?: string 87 | clientIp?: string 88 | delinkReason?: string 89 | eActionType?: string 90 | cardTypeFlag?: string 91 | cpinFlag?: MasterPassBoolean 92 | defaultAccount?: MasterPassBoolean 93 | mmrpConfig?: string 94 | identityVerificationFlag?: MasterPassBoolean 95 | mobileAccountConfig?: string 96 | msisdn: string 97 | referenceNo: string 98 | sendSms: MasterPassBoolean 99 | sendSmsLanguage: string 100 | timeZone?: string 101 | uiChannelType?: string 102 | rtaPan: string 103 | expiryDate: string 104 | accountAliasName: string 105 | cvc?: string 106 | homeAddress?: string 107 | homeCity?: string 108 | homeState?: string 109 | homeCountryCode?: string 110 | homePostalCode?: string 111 | firstName?: string 112 | lastName?: string 113 | email?: string 114 | cardHolderName?: string 115 | token: string 116 | } 117 | 118 | export interface RegisterResponse extends MFSBaseResponse { 119 | url3D: string 120 | url3DSuccess: string 121 | url3DError: string 122 | } 123 | 124 | export type MFSRegisterFunction = ( 125 | data: RegisterData, 126 | callback: CallbackFunction 127 | ) => void 128 | 129 | export type RegisterFunction = (data: RegisterData) => Promise 130 | 131 | export interface ValidateTransactionData { 132 | validationCode: string 133 | token: string 134 | referenceNo: string 135 | sendSms: MasterPassBoolean 136 | sendSmsLanguage: string 137 | pinType?: string 138 | } 139 | 140 | export interface ValidateTransactionResponse extends MFSBaseResponse { 141 | token: string 142 | url3D: string | undefined 143 | url3DError: string | undefined 144 | url3DSuccess: string | undefined 145 | } 146 | 147 | export type MFSValidateTransactionFunction = ( 148 | data: ValidateTransactionData, 149 | callback: CallbackFunction 150 | ) => void 151 | 152 | export type ValidateTransactionFunction = ( 153 | data: ValidateTransactionData 154 | ) => Promise 155 | 156 | export interface DeleteCardData { 157 | accountAliasName: string 158 | msisdn: string 159 | token: string 160 | referenceNo: string 161 | sendSmsLanguage: string 162 | sendSms: MasterPassBoolean 163 | } 164 | 165 | export interface DeleteCardResponse extends MFSBaseResponse {} 166 | 167 | export type MFSDeleteCardFunction = ( 168 | data: DeleteCardData, 169 | callback: CallbackFunction 170 | ) => void 171 | 172 | export type DeleteCardFunction = ( 173 | data: DeleteCardData 174 | ) => Promise 175 | 176 | export interface ResendOtpResponse extends MFSBaseResponse {} 177 | 178 | export type MFSResendOtpFunction = ( 179 | lastToken: string, 180 | sendSmsLanguage: string, 181 | callback: CallbackFunction 182 | ) => void 183 | 184 | export type MFSGetLastTokenFunction = () => string 185 | 186 | export type GetLastTokenFunction = () => string 187 | 188 | export type ResendOtpFunction = ( 189 | sendSmsLanguage: string 190 | ) => Promise 191 | 192 | export interface LinkCardToClientData { 193 | msisdn: string 194 | token: string 195 | referenceNo: string 196 | sendSms: MasterPassBoolean 197 | sendSmsLanguage: string 198 | cardAliasName?: string 199 | } 200 | 201 | export interface LinkCardToClientResponse extends MFSBaseResponse {} 202 | 203 | export type MFSLinkCardToClientFunction = ( 204 | data: LinkCardToClientData, 205 | callback: CallbackFunction 206 | ) => void 207 | 208 | export type LinkCardToClientFunction = ( 209 | data: LinkCardToClientData 210 | ) => Promise 211 | 212 | export interface PurchaseData { 213 | aav?: string 214 | amount: string 215 | clientIp?: string 216 | encCPin?: string 217 | encPassword?: string 218 | listAccountName: string 219 | msisdn: string 220 | password?: string 221 | referenceNo: string 222 | sendSms?: MasterPassBoolean 223 | sendSmsLanguage: string 224 | sendSmsMerchant?: MasterPassBoolean 225 | userId?: string 226 | token: string 227 | rewardName?: string 228 | rewardValue?: string 229 | moneyCardInvoiceAmount?: string 230 | moneyCardMigrosDiscountAmount?: string 231 | moneyCardPaymentAmount?: string 232 | moneyCardExtraDiscountAmount?: string 233 | moneyCardProductBasedDiscountAmount?: string 234 | installmentCount?: number 235 | cvc?: string 236 | macroMerchantId?: string 237 | orderNo?: string 238 | paymentType?: string 239 | } 240 | 241 | export interface PurchaseResponse extends MFSBaseResponse { 242 | accountStatus: string | undefined 243 | amount: string | undefined 244 | installmentCount: number | undefined 245 | orderNo: string | undefined 246 | token: string 247 | url3D: string 248 | url3DError: string 249 | url3DSuccess: string 250 | urlLoan: string | null 251 | urlLoanError: string | null 252 | urlLoanSuccess: string | null 253 | } 254 | 255 | export type MFSPurchaseFunction = ( 256 | data: PurchaseData, 257 | callback: CallbackFunction 258 | ) => void 259 | 260 | export type PurchaseFunction = (data: PurchaseData) => Promise 261 | 262 | export interface PurchaseAndRegisterData { 263 | msisdn: string 264 | accountAliasName: string 265 | token: string 266 | referenceNo: string 267 | sendSms?: MasterPassBoolean 268 | sendSmsLanguage: string 269 | fP?: string 270 | amount: string 271 | actionType?: string 272 | firstName?: string 273 | lastName?: string 274 | gender?: string 275 | expiryDate: string 276 | rtaPan: string 277 | cardHolderName?: string 278 | orderNo?: string 279 | merchantId?: string 280 | rewardName?: string 281 | rewardValue?: string 282 | moneyCardInvoiceAmount?: string 283 | moneyCardMigrosDiscountAmount?: string 284 | moneyCardPaymentAmount?: string 285 | moneyCardExtraDiscountAmount?: string 286 | moneyCardProductBasedDiscountAmount?: string 287 | installmentCount?: number 288 | cvc: string 289 | macroMerchantId?: string 290 | paymentType?: string 291 | } 292 | 293 | export interface PurchaseAndRegisterResponse extends MFSBaseResponse { 294 | url3D: string 295 | url3DSuccess: string 296 | url3DError: string 297 | } 298 | 299 | export type MFSPurchaseAndRegisterFunction = ( 300 | data: PurchaseAndRegisterData, 301 | callback: CallbackFunction 302 | ) => void 303 | 304 | export type PurchaseAndRegisterFunction = ( 305 | data: PurchaseAndRegisterData 306 | ) => Promise 307 | 308 | export interface DirectPurchaseData { 309 | token: string 310 | msisdn: string 311 | sendSmsLanguage: string 312 | fP?: string 313 | amount: string 314 | expiryDate: string 315 | rtaPan: string 316 | cardHolderName?: string 317 | cvc: string 318 | macroMerchantId?: string 319 | orderNo?: string 320 | paymentType?: string 321 | installmentCount?: number 322 | rewardName?: string 323 | rewardValue?: string 324 | } 325 | 326 | export interface DirectPurchaseResponse extends MFSBaseResponse { 327 | url3D: string 328 | url3DSuccess: string 329 | url3DError: string 330 | urlLoan: string | null 331 | urlLoanSuccess: string | null 332 | urlLoanError: string | null 333 | token: string 334 | } 335 | 336 | export type MFSDirectPurchaseFunction = ( 337 | data: DirectPurchaseData, 338 | callback: CallbackFunction 339 | ) => void 340 | 341 | export type DirectPurchaseFunction = ( 342 | data: DirectPurchaseData 343 | ) => Promise 344 | 345 | export type MFSSetAdditionalParameters = (data: object) => void 346 | 347 | export type SetAdditionalParameters = (data: object) => void 348 | 349 | export interface MasterPassSDKMethods { 350 | setAddress: MFSSetAddressFunction 351 | setClientId: MFSSetClientIdFunction 352 | checkMasterPass: MFSCheckMasterPassFunction 353 | listCards: MFSListCardsFunction 354 | register: MFSRegisterFunction 355 | validateTransaction: MFSValidateTransactionFunction 356 | deleteCard: MFSDeleteCardFunction 357 | getLastToken: MFSGetLastTokenFunction 358 | resendOtp: MFSResendOtpFunction 359 | linkCardToClient: MFSLinkCardToClientFunction 360 | purchase: MFSPurchaseFunction 361 | purchaseAndRegister: MFSPurchaseAndRegisterFunction 362 | directPurchase: MFSDirectPurchaseFunction 363 | setAdditionalParameters: MFSSetAdditionalParameters 364 | } 365 | 366 | export type AccountType = 'not-user' | 'unlinked' | 'registered' | 'unknown' 367 | 368 | export type ParseAccountStatusFunction = (accountStatus: string) => AccountType 369 | 370 | export type MFSResponseHandlerFunction = ( 371 | status: MFSStatus, 372 | response: MFSBaseResponse, 373 | resolve: Function, 374 | reject: Function 375 | ) => Promise 376 | 377 | export interface DefaultMethodDataConstants { 378 | register: Partial 379 | validateTransaction: Partial 380 | purchase: Partial 381 | } 382 | -------------------------------------------------------------------------------- /src/Utils.ts: -------------------------------------------------------------------------------- 1 | import Constants from './Constants' 2 | import { ParseAccountStatusFunction, MFSResponseHandlerFunction } from './Types' 3 | 4 | const mfsResponseHandler: MFSResponseHandlerFunction = ( 5 | status, 6 | response, 7 | resolve, 8 | reject 9 | ) => { 10 | if (status !== 200) { 11 | return reject({ 12 | status: 'unknown', 13 | message: 'Connection Error', 14 | response: {}, 15 | }) 16 | } 17 | 18 | if ( 19 | response.responseCode === Constants.ResponseCodes.SUCCESS_EMPTY || 20 | response.responseCode === Constants.ResponseCodes.SUCCESS || 21 | response.responseCode === Constants.ResponseCodes.VALIDATE_OTP || 22 | response.responseCode === Constants.ResponseCodes.VALIDATE_MPIN || 23 | response.responseCode === Constants.ResponseCodes.VALIDATE_DEVICE || 24 | response.responseCode === Constants.ResponseCodes.VALIDATE_3D_SECURE || 25 | response.responseCode === Constants.ResponseCodes.PIN_DETERMINATION 26 | ) { 27 | return resolve(response) 28 | } 29 | 30 | reject({ 31 | status: response.responseCode, 32 | message: response.responseDescription, 33 | data: { ...response, message: response.responseDescription }, 34 | }) 35 | } 36 | 37 | const parseAccountStatus: ParseAccountStatusFunction = accountStatus => { 38 | if (accountStatus.substring(0, 6) === '000000') return 'not-user' 39 | if (accountStatus.substring(1, 6) === '11000') return 'unlinked' 40 | if (accountStatus.substring(1, 6) === '11100') return 'registered' 41 | return 'unknown' 42 | } 43 | 44 | export default { 45 | mfsResponseHandler: mfsResponseHandler, 46 | parseAccountStatus: parseAccountStatus, 47 | } 48 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export { default as MasterPassSDK } from './MasterPass' 2 | export * from './Types' 3 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs 3 | "include": ["src", "types"], 4 | "compilerOptions": { 5 | "module": "esnext", 6 | "lib": ["dom", "esnext"], 7 | "importHelpers": true, 8 | // output .d.ts declaration files for consumers 9 | "declaration": true, 10 | // output .js.map sourcemap files for consumers 11 | "sourceMap": true, 12 | // match output dir to input dir. e.g. dist/index instead of dist/src/index 13 | "rootDir": "./src", 14 | // stricter type-checking for stronger correctness. Recommended by TS 15 | "strict": true, 16 | // linter checks for common issues 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": true, 19 | // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | // use Node's module resolution algorithm, instead of the legacy TS one 23 | "moduleResolution": "node", 24 | // transpile JSX to React.createElement 25 | "jsx": "react", 26 | // interop between ESM and CJS modules. Recommended by TS 27 | "esModuleInterop": true, 28 | // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS 29 | "skipLibCheck": true, 30 | // error out if import and file system have a casing mismatch. Recommended by TS 31 | "forceConsistentCasingInFileNames": true, 32 | // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc` 33 | "noEmit": true 34 | } 35 | } 36 | --------------------------------------------------------------------------------