globalpayments-api 1.4.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/package.json +3 -4
- package/lib/src/Builders/AuthorizationBuilder.d.ts +0 -325
- package/lib/src/Builders/AuthorizationBuilder.js +0 -599
- package/lib/src/Builders/BaseBuilder/ValidationClause.d.ts +0 -14
- package/lib/src/Builders/BaseBuilder/ValidationClause.js +0 -61
- package/lib/src/Builders/BaseBuilder/ValidationTarget.d.ts +0 -16
- package/lib/src/Builders/BaseBuilder/ValidationTarget.js +0 -28
- package/lib/src/Builders/BaseBuilder/Validations.d.ts +0 -11
- package/lib/src/Builders/BaseBuilder/Validations.js +0 -56
- package/lib/src/Builders/BaseBuilder.d.ts +0 -11
- package/lib/src/Builders/BaseBuilder.js +0 -16
- package/lib/src/Builders/ManagementBuilder.d.ts +0 -103
- package/lib/src/Builders/ManagementBuilder.js +0 -227
- package/lib/src/Builders/RecurringBuilder.d.ts +0 -13
- package/lib/src/Builders/RecurringBuilder.js +0 -47
- package/lib/src/Builders/ReportBuilder.d.ts +0 -8
- package/lib/src/Builders/ReportBuilder.js +0 -36
- package/lib/src/Builders/TransactionBuilder.d.ts +0 -10
- package/lib/src/Builders/TransactionBuilder.js +0 -46
- package/lib/src/Builders/TransactionReportBuilder.d.ts +0 -15
- package/lib/src/Builders/TransactionReportBuilder.js +0 -79
- package/lib/src/Builders/index.d.ts +0 -7
- package/lib/src/Builders/index.js +0 -19
- package/lib/src/Entities/Address.d.ts +0 -13
- package/lib/src/Entities/Address.js +0 -19
- package/lib/src/Entities/BatchSummary.d.ts +0 -6
- package/lib/src/Entities/BatchSummary.js +0 -9
- package/lib/src/Entities/Customer.d.ts +0 -64
- package/lib/src/Entities/Customer.js +0 -47
- package/lib/src/Entities/EcommerceInfo.d.ts +0 -12
- package/lib/src/Entities/EcommerceInfo.js +0 -14
- package/lib/src/Entities/EncryptionData.d.ts +0 -6
- package/lib/src/Entities/EncryptionData.js +0 -9
- package/lib/src/Entities/Enums.d.ts +0 -230
- package/lib/src/Entities/Enums.js +0 -267
- package/lib/src/Entities/Errors.d.ts +0 -23
- package/lib/src/Entities/Errors.js +0 -106
- package/lib/src/Entities/HostedPaymentData.d.ts +0 -10
- package/lib/src/Entities/HostedPaymentData.js +0 -10
- package/lib/src/Entities/RecurringEntity.d.ts +0 -14
- package/lib/src/Entities/RecurringEntity.js +0 -86
- package/lib/src/Entities/Schedule.d.ts +0 -47
- package/lib/src/Entities/Schedule.js +0 -253
- package/lib/src/Entities/Transaction.d.ts +0 -76
- package/lib/src/Entities/Transaction.js +0 -108
- package/lib/src/Entities/TransactionSummary.d.ts +0 -61
- package/lib/src/Entities/TransactionSummary.js +0 -9
- package/lib/src/Entities/index.d.ts +0 -12
- package/lib/src/Entities/index.js +0 -24
- package/lib/src/Gateways/Gateway.d.ts +0 -10
- package/lib/src/Gateways/Gateway.js +0 -42
- package/lib/src/Gateways/IPaymentGateway.d.ts +0 -8
- package/lib/src/Gateways/IPaymentGateway.js +0 -2
- package/lib/src/Gateways/IRecurringService.d.ts +0 -6
- package/lib/src/Gateways/IRecurringService.js +0 -2
- package/lib/src/Gateways/PayPlanConnector.d.ts +0 -42
- package/lib/src/Gateways/PayPlanConnector.js +0 -552
- package/lib/src/Gateways/PorticoConnector.d.ts +0 -44
- package/lib/src/Gateways/PorticoConnector.js +0 -1018
- package/lib/src/Gateways/RealexConnector.d.ts +0 -30
- package/lib/src/Gateways/RealexConnector.js +0 -523
- package/lib/src/Gateways/RestGateway.d.ts +0 -6
- package/lib/src/Gateways/RestGateway.js +0 -31
- package/lib/src/Gateways/XmlGateway.d.ts +0 -6
- package/lib/src/Gateways/XmlGateway.js +0 -38
- package/lib/src/Gateways/https-wrapper.d.ts +0 -3
- package/lib/src/Gateways/https-wrapper.js +0 -35
- package/lib/src/Gateways/index.d.ts +0 -7
- package/lib/src/Gateways/index.js +0 -19
- package/lib/src/HostedPaymentConfig.d.ts +0 -12
- package/lib/src/HostedPaymentConfig.js +0 -9
- package/lib/src/PaymentMethods/Cash.d.ts +0 -8
- package/lib/src/PaymentMethods/Cash.js +0 -36
- package/lib/src/PaymentMethods/Credit.d.ts +0 -85
- package/lib/src/PaymentMethods/Credit.js +0 -106
- package/lib/src/PaymentMethods/CreditCardData.d.ts +0 -19
- package/lib/src/PaymentMethods/CreditCardData.js +0 -51
- package/lib/src/PaymentMethods/CreditTrackData.d.ts +0 -7
- package/lib/src/PaymentMethods/CreditTrackData.js +0 -27
- package/lib/src/PaymentMethods/Debit.d.ts +0 -40
- package/lib/src/PaymentMethods/Debit.js +0 -70
- package/lib/src/PaymentMethods/DebitTrackData.d.ts +0 -7
- package/lib/src/PaymentMethods/DebitTrackData.js +0 -27
- package/lib/src/PaymentMethods/EBT.d.ts +0 -48
- package/lib/src/PaymentMethods/EBT.js +0 -88
- package/lib/src/PaymentMethods/EBTCardData.d.ts +0 -16
- package/lib/src/PaymentMethods/EBTCardData.js +0 -32
- package/lib/src/PaymentMethods/EBTTrackData.d.ts +0 -8
- package/lib/src/PaymentMethods/EBTTrackData.js +0 -27
- package/lib/src/PaymentMethods/ECheck.d.ts +0 -32
- package/lib/src/PaymentMethods/ECheck.js +0 -40
- package/lib/src/PaymentMethods/GiftCard.d.ts +0 -131
- package/lib/src/PaymentMethods/GiftCard.js +0 -205
- package/lib/src/PaymentMethods/Interfaces.d.ts +0 -55
- package/lib/src/PaymentMethods/Interfaces.js +0 -2
- package/lib/src/PaymentMethods/PaymentMethod.d.ts +0 -19
- package/lib/src/PaymentMethods/PaymentMethod.js +0 -114
- package/lib/src/PaymentMethods/RecurringPaymentMethod.d.ts +0 -23
- package/lib/src/PaymentMethods/RecurringPaymentMethod.js +0 -77
- package/lib/src/PaymentMethods/TransactionReference.d.ts +0 -10
- package/lib/src/PaymentMethods/TransactionReference.js +0 -12
- package/lib/src/PaymentMethods/index.d.ts +0 -15
- package/lib/src/PaymentMethods/index.js +0 -27
- package/lib/src/Services/BatchService.d.ts +0 -4
- package/lib/src/Services/BatchService.js +0 -17
- package/lib/src/Services/CheckService.d.ts +0 -6
- package/lib/src/Services/CheckService.js +0 -20
- package/lib/src/Services/CreditService.d.ts +0 -12
- package/lib/src/Services/CreditService.js +0 -54
- package/lib/src/Services/DebitService.d.ts +0 -7
- package/lib/src/Services/DebitService.js +0 -28
- package/lib/src/Services/EBTService.d.ts +0 -8
- package/lib/src/Services/EBTService.js +0 -32
- package/lib/src/Services/GiftService.d.ts +0 -16
- package/lib/src/Services/GiftService.js +0 -54
- package/lib/src/Services/HostedService.d.ts +0 -9
- package/lib/src/Services/HostedService.js +0 -59
- package/lib/src/Services/RecurringService.d.ts +0 -8
- package/lib/src/Services/RecurringService.js +0 -27
- package/lib/src/Services/ReportingService.d.ts +0 -6
- package/lib/src/Services/ReportingService.js +0 -19
- package/lib/src/Services/index.d.ts +0 -9
- package/lib/src/Services/index.js +0 -21
- package/lib/src/ServicesConfig.d.ts +0 -23
- package/lib/src/ServicesConfig.js +0 -50
- package/lib/src/ServicesContainer.d.ts +0 -11
- package/lib/src/ServicesContainer.js +0 -73
- package/lib/src/Utils/GenerationUtils.d.ts +0 -5
- package/lib/src/Utils/GenerationUtils.js +0 -36
- package/lib/src/Utils/InputValidation.d.ts +0 -12
- package/lib/src/Utils/InputValidation.js +0 -72
- package/lib/src/Utils/Sha1.d.ts +0 -6
- package/lib/src/Utils/Sha1.js +0 -225
- package/lib/src/Utils/StringUtils.d.ts +0 -6
- package/lib/src/Utils/StringUtils.js +0 -53
- package/lib/src/Utils/index.d.ts +0 -2
- package/lib/src/Utils/index.js +0 -14
- package/lib/src/index.d.ts +0 -11
- package/lib/src/index.js +0 -27
- package/lib/test/Data/TestCards.d.ts +0 -24
- package/lib/test/Data/TestCards.js +0 -232
- package/lib/test/Data/TestChecks.d.ts +0 -4
- package/lib/test/Data/TestChecks.js +0 -32
- package/lib/test/Data/index.d.ts +0 -2
- package/lib/test/Data/index.js +0 -14
- package/lib/test/Integration/Gateways/PorticoConnector/AchTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/AchTest.js +0 -112
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.js +0 -483
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.js +0 -83
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.js +0 -1720
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.js +0 -83
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.js +0 -1757
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.js +0 -682
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.js +0 -2218
- package/lib/test/Integration/Gateways/PorticoConnector/CreditTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/CreditTest.js +0 -708
- package/lib/test/Integration/Gateways/PorticoConnector/DebitTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/DebitTest.js +0 -151
- package/lib/test/Integration/Gateways/PorticoConnector/EbtTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/EbtTest.js +0 -171
- package/lib/test/Integration/Gateways/PorticoConnector/EcommerceTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/EcommerceTest.js +0 -192
- package/lib/test/Integration/Gateways/PorticoConnector/GiftTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/GiftTest.js +0 -377
- package/lib/test/Integration/Gateways/PorticoConnector/RecurringTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/RecurringTest.js +0 -196
- package/lib/test/Integration/Gateways/PorticoConnector/ReportingTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/PorticoConnector/ReportingTest.js +0 -47
- package/lib/test/Integration/Gateways/RealexConnector/Certification/AuthTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/AuthTest.js +0 -4373
- package/lib/test/Integration/Gateways/RealexConnector/Certification/AvsTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/AvsTest.js +0 -758
- package/lib/test/Integration/Gateways/RealexConnector/Certification/CreditTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/CreditTest.js +0 -2399
- package/lib/test/Integration/Gateways/RealexConnector/Certification/HoldTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/HoldTest.js +0 -1656
- package/lib/test/Integration/Gateways/RealexConnector/Certification/ManualTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/ManualTest.js +0 -5650
- package/lib/test/Integration/Gateways/RealexConnector/Certification/OtbTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/OtbTest.js +0 -1985
- package/lib/test/Integration/Gateways/RealexConnector/Certification/RebateTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/RebateTest.js +0 -2369
- package/lib/test/Integration/Gateways/RealexConnector/Certification/ReleaseTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/ReleaseTest.js +0 -1703
- package/lib/test/Integration/Gateways/RealexConnector/Certification/SettleTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/SettleTest.js +0 -2053
- package/lib/test/Integration/Gateways/RealexConnector/Certification/ValidationTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/ValidationTest.js +0 -2469
- package/lib/test/Integration/Gateways/RealexConnector/Certification/VerifyEnrolledTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/VerifyEnrolledTest.js +0 -3116
- package/lib/test/Integration/Gateways/RealexConnector/Certification/VoidTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/Certification/VoidTest.js +0 -2031
- package/lib/test/Integration/Gateways/RealexConnector/CreditTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/CreditTest.js +0 -322
- package/lib/test/Integration/Gateways/RealexConnector/HppTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/HppTest.js +0 -98
- package/lib/test/Integration/Gateways/RealexConnector/RecurringTest.d.ts +0 -1
- package/lib/test/Integration/Gateways/RealexConnector/RecurringTest.js +0 -263
- package/lib/test/Integration/Services/CheckServiceTest.d.ts +0 -1
- package/lib/test/Integration/Services/CheckServiceTest.js +0 -98
- package/lib/test/Integration/Services/CreditServiceTest.d.ts +0 -1
- package/lib/test/Integration/Services/CreditServiceTest.js +0 -313
- package/lib/test/Integration/Services/DebitServiceTest.d.ts +0 -1
- package/lib/test/Integration/Services/DebitServiceTest.js +0 -154
- package/lib/test/Integration/Services/EBTServiceTest.d.ts +0 -1
- package/lib/test/Integration/Services/EBTServiceTest.js +0 -135
- package/lib/test/Unit/Builders/AuthorizationBuilder/ValidationTest.d.ts +0 -1
- package/lib/test/Unit/Builders/AuthorizationBuilder/ValidationTest.js +0 -161
- package/lib/test/Unit/Builders/ReportBuilder/ValidationTest.d.ts +0 -1
- package/lib/test/Unit/Builders/ReportBuilder/ValidationTest.js +0 -139
- package/lib/test/Unit/Gateways/PorticoConnector/InputValidationTest.d.ts +0 -1
- package/lib/test/Unit/Gateways/PorticoConnector/InputValidationTest.js +0 -202
- package/lib/test/Unit/Gateways/RealexConnector/CreditTest.d.ts +0 -1
- package/lib/test/Unit/Gateways/RealexConnector/CreditTest.js +0 -29
- package/logger.txt +0 -4
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecurringService = void 0;
|
|
4
|
-
var __1 = require("../");
|
|
5
|
-
var RecurringService = /** @class */ (function () {
|
|
6
|
-
function RecurringService() {
|
|
7
|
-
}
|
|
8
|
-
RecurringService.create = function (entity) {
|
|
9
|
-
return new __1.RecurringBuilder(__1.TransactionType.Create, entity).execute();
|
|
10
|
-
};
|
|
11
|
-
RecurringService.delete = function (entity, _force) {
|
|
12
|
-
if (_force === void 0) { _force = false; }
|
|
13
|
-
return new __1.RecurringBuilder(__1.TransactionType.Delete, entity).execute();
|
|
14
|
-
};
|
|
15
|
-
RecurringService.edit = function (entity) {
|
|
16
|
-
return new __1.RecurringBuilder(__1.TransactionType.Edit, entity).execute();
|
|
17
|
-
};
|
|
18
|
-
RecurringService.get = function (key) {
|
|
19
|
-
var entity = key;
|
|
20
|
-
return new __1.RecurringBuilder(__1.TransactionType.Fetch, entity).execute();
|
|
21
|
-
};
|
|
22
|
-
RecurringService.search = function (enity) {
|
|
23
|
-
return new __1.RecurringBuilder(__1.TransactionType.Search, enity);
|
|
24
|
-
};
|
|
25
|
-
return RecurringService;
|
|
26
|
-
}());
|
|
27
|
-
exports.RecurringService = RecurringService;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { TransactionReportBuilder, TransactionSummary } from "../";
|
|
2
|
-
export declare class ReportingService {
|
|
3
|
-
static activity(): TransactionReportBuilder<TransactionSummary[]>;
|
|
4
|
-
static transactionDetail(transactionId?: string): TransactionReportBuilder<TransactionSummary>;
|
|
5
|
-
static findTransactions(): TransactionReportBuilder<TransactionSummary[]>;
|
|
6
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReportingService = void 0;
|
|
4
|
-
var __1 = require("../");
|
|
5
|
-
var ReportingService = /** @class */ (function () {
|
|
6
|
-
function ReportingService() {
|
|
7
|
-
}
|
|
8
|
-
ReportingService.activity = function () {
|
|
9
|
-
return new __1.TransactionReportBuilder(__1.ReportType.Activity);
|
|
10
|
-
};
|
|
11
|
-
ReportingService.transactionDetail = function (transactionId) {
|
|
12
|
-
return new __1.TransactionReportBuilder(__1.ReportType.TransactionDetail).withTransactionId(transactionId);
|
|
13
|
-
};
|
|
14
|
-
ReportingService.findTransactions = function () {
|
|
15
|
-
return new __1.TransactionReportBuilder(__1.ReportType.FindTransactions);
|
|
16
|
-
};
|
|
17
|
-
return ReportingService;
|
|
18
|
-
}());
|
|
19
|
-
exports.ReportingService = ReportingService;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./BatchService";
|
|
2
|
-
export * from "./CheckService";
|
|
3
|
-
export * from "./CreditService";
|
|
4
|
-
export * from "./DebitService";
|
|
5
|
-
export * from "./EBTService";
|
|
6
|
-
export * from "./GiftService";
|
|
7
|
-
export * from "./HostedService";
|
|
8
|
-
export * from "./RecurringService";
|
|
9
|
-
export * from "./ReportingService";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./BatchService"), exports);
|
|
14
|
-
__exportStar(require("./CheckService"), exports);
|
|
15
|
-
__exportStar(require("./CreditService"), exports);
|
|
16
|
-
__exportStar(require("./DebitService"), exports);
|
|
17
|
-
__exportStar(require("./EBTService"), exports);
|
|
18
|
-
__exportStar(require("./GiftService"), exports);
|
|
19
|
-
__exportStar(require("./HostedService"), exports);
|
|
20
|
-
__exportStar(require("./RecurringService"), exports);
|
|
21
|
-
__exportStar(require("./ReportingService"), exports);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { HostedPaymentConfig } from "./";
|
|
2
|
-
export declare class ServicesConfig {
|
|
3
|
-
siteId: string;
|
|
4
|
-
licenseId: string;
|
|
5
|
-
deviceId: string;
|
|
6
|
-
username: string;
|
|
7
|
-
password: string;
|
|
8
|
-
developerId: string;
|
|
9
|
-
versionNumber: string;
|
|
10
|
-
secretApiKey: string;
|
|
11
|
-
sdkNameVersion: string;
|
|
12
|
-
accountId: string;
|
|
13
|
-
merchantId: string;
|
|
14
|
-
sharedSecret: string;
|
|
15
|
-
channel: string;
|
|
16
|
-
rebatePassword: string;
|
|
17
|
-
refundPassword: string;
|
|
18
|
-
hostedPaymentConfig: HostedPaymentConfig;
|
|
19
|
-
serviceUrl: string;
|
|
20
|
-
timeout: number;
|
|
21
|
-
constructor();
|
|
22
|
-
validate(): void;
|
|
23
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServicesConfig = void 0;
|
|
4
|
-
var _1 = require("./");
|
|
5
|
-
var ServicesConfig = /** @class */ (function () {
|
|
6
|
-
function ServicesConfig() {
|
|
7
|
-
this.timeout = 65000;
|
|
8
|
-
}
|
|
9
|
-
ServicesConfig.prototype.validate = function () {
|
|
10
|
-
// portico api key
|
|
11
|
-
if (this.secretApiKey) {
|
|
12
|
-
if (this.siteId ||
|
|
13
|
-
this.licenseId ||
|
|
14
|
-
this.deviceId ||
|
|
15
|
-
this.username ||
|
|
16
|
-
this.password) {
|
|
17
|
-
throw new _1.ConfigurationError("Configuration contains both secret api key and legacy credentials. These are mutually exclusive.");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// portico legacy
|
|
21
|
-
if (this.siteId ||
|
|
22
|
-
this.licenseId ||
|
|
23
|
-
this.deviceId ||
|
|
24
|
-
this.username ||
|
|
25
|
-
this.password) {
|
|
26
|
-
if (!(this.siteId &&
|
|
27
|
-
this.licenseId &&
|
|
28
|
-
this.deviceId &&
|
|
29
|
-
this.username &&
|
|
30
|
-
this.password)) {
|
|
31
|
-
throw new _1.ConfigurationError("Site, License, Device, Username and Password should all have a values for this configuration.");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// realex
|
|
35
|
-
if (this.merchantId || this.sharedSecret) {
|
|
36
|
-
if (!this.merchantId) {
|
|
37
|
-
throw new _1.ConfigurationError("MerchantId is required for this configuration.");
|
|
38
|
-
}
|
|
39
|
-
if (!this.sharedSecret) {
|
|
40
|
-
throw new _1.ConfigurationError("SharedSecret is required for this configuration.");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// service url
|
|
44
|
-
if (!this.serviceUrl) {
|
|
45
|
-
throw new _1.ConfigurationError("Service URL could not be determined from the credentials provided. Please specify an endpoint.");
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
return ServicesConfig;
|
|
49
|
-
}());
|
|
50
|
-
exports.ServicesConfig = ServicesConfig;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IPaymentGateway, IRecurringService, ServicesConfig } from "./";
|
|
2
|
-
export declare class ServicesContainer {
|
|
3
|
-
private static _instance;
|
|
4
|
-
private _gateway;
|
|
5
|
-
private _recurring;
|
|
6
|
-
static instance(): ServicesContainer;
|
|
7
|
-
static configure(config: ServicesConfig): void;
|
|
8
|
-
constructor(gateway?: IPaymentGateway, recurring?: IRecurringService);
|
|
9
|
-
getClient(): IPaymentGateway;
|
|
10
|
-
getRecurringClient(): IRecurringService;
|
|
11
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServicesContainer = void 0;
|
|
4
|
-
var _1 = require("./");
|
|
5
|
-
var ServicesContainer = /** @class */ (function () {
|
|
6
|
-
function ServicesContainer(gateway, recurring) {
|
|
7
|
-
if (gateway) {
|
|
8
|
-
this._gateway = gateway;
|
|
9
|
-
}
|
|
10
|
-
if (recurring) {
|
|
11
|
-
this._recurring = recurring;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
ServicesContainer.instance = function () {
|
|
15
|
-
if (ServicesContainer._instance === null) {
|
|
16
|
-
throw new _1.ApiError("Services container not configured.");
|
|
17
|
-
}
|
|
18
|
-
return ServicesContainer._instance;
|
|
19
|
-
};
|
|
20
|
-
ServicesContainer.configure = function (config) {
|
|
21
|
-
config.validate();
|
|
22
|
-
if (config.merchantId && config.merchantId !== "") {
|
|
23
|
-
var gateway = new _1.RealexConnector();
|
|
24
|
-
gateway.merchantId = config.merchantId;
|
|
25
|
-
gateway.sharedSecret = config.sharedSecret;
|
|
26
|
-
gateway.accountId = config.accountId;
|
|
27
|
-
gateway.channel = config.channel;
|
|
28
|
-
gateway.rebatePassword = config.rebatePassword;
|
|
29
|
-
gateway.refundPassword = config.refundPassword;
|
|
30
|
-
gateway.timeout = config.timeout;
|
|
31
|
-
gateway.serviceUrl = config.serviceUrl;
|
|
32
|
-
gateway.hostedPaymentConfig = config.hostedPaymentConfig;
|
|
33
|
-
gateway.channel = config.channel;
|
|
34
|
-
ServicesContainer._instance = new ServicesContainer(gateway, gateway);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
var gateway = new _1.PorticoConnector();
|
|
38
|
-
gateway.siteId = config.siteId;
|
|
39
|
-
gateway.licenseId = config.licenseId;
|
|
40
|
-
gateway.deviceId = config.deviceId;
|
|
41
|
-
gateway.username = config.username;
|
|
42
|
-
gateway.password = config.password;
|
|
43
|
-
gateway.secretApiKey = config.secretApiKey;
|
|
44
|
-
gateway.developerId = config.developerId;
|
|
45
|
-
gateway.versionNumber = config.versionNumber;
|
|
46
|
-
gateway.sdkNameVersion = config.sdkNameVersion;
|
|
47
|
-
gateway.timeout = config.timeout;
|
|
48
|
-
gateway.serviceUrl =
|
|
49
|
-
config.serviceUrl + "/Hps.Exchange.PosGateway/PosGatewayService.asmx";
|
|
50
|
-
var payplan = new _1.PayPlanConnector();
|
|
51
|
-
payplan.siteId = config.siteId;
|
|
52
|
-
payplan.licenseId = config.licenseId;
|
|
53
|
-
payplan.deviceId = config.deviceId;
|
|
54
|
-
payplan.username = config.username;
|
|
55
|
-
payplan.password = config.password;
|
|
56
|
-
payplan.secretApiKey = config.secretApiKey;
|
|
57
|
-
payplan.developerId = config.developerId;
|
|
58
|
-
payplan.versionNumber = config.versionNumber;
|
|
59
|
-
payplan.timeout = config.timeout;
|
|
60
|
-
payplan.serviceUrl = config.serviceUrl
|
|
61
|
-
+ (config.serviceUrl.includes('cert.') ? "/Portico.PayPlan.v2/" : "/payplan.v2/");
|
|
62
|
-
ServicesContainer._instance = new ServicesContainer(gateway, payplan);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
ServicesContainer.prototype.getClient = function () {
|
|
66
|
-
return this._gateway;
|
|
67
|
-
};
|
|
68
|
-
ServicesContainer.prototype.getRecurringClient = function () {
|
|
69
|
-
return this._recurring;
|
|
70
|
-
};
|
|
71
|
-
return ServicesContainer;
|
|
72
|
-
}());
|
|
73
|
-
exports.ServicesContainer = ServicesContainer;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GenerationUtils = void 0;
|
|
4
|
-
var Sha1_1 = require("./Sha1");
|
|
5
|
-
var __1 = require("../");
|
|
6
|
-
var GenerationUtils = /** @class */ (function () {
|
|
7
|
-
function GenerationUtils() {
|
|
8
|
-
}
|
|
9
|
-
GenerationUtils.generateHash = function (toHash, secret) {
|
|
10
|
-
var toHashFirstPass = Sha1_1.hex_sha1(toHash);
|
|
11
|
-
if (!secret) {
|
|
12
|
-
return toHashFirstPass;
|
|
13
|
-
}
|
|
14
|
-
var toHashSecondPass = toHashFirstPass + "." + secret;
|
|
15
|
-
return Sha1_1.hex_sha1(toHashSecondPass);
|
|
16
|
-
};
|
|
17
|
-
GenerationUtils.generateTimestamp = function () {
|
|
18
|
-
var date = new Date();
|
|
19
|
-
return (date.getUTCFullYear().toString() +
|
|
20
|
-
__1.StringUtils.leftPad((date.getUTCMonth() + 1).toString(), 2, "0") +
|
|
21
|
-
__1.StringUtils.leftPad(date.getUTCDate().toString(), 2, "0") +
|
|
22
|
-
__1.StringUtils.leftPad(date.getUTCHours().toString(), 2, "0") +
|
|
23
|
-
__1.StringUtils.leftPad(date.getUTCMinutes().toString(), 2, "0") +
|
|
24
|
-
__1.StringUtils.leftPad(date.getUTCSeconds().toString(), 2, "0"));
|
|
25
|
-
};
|
|
26
|
-
GenerationUtils.generateOrderId = function () {
|
|
27
|
-
var id = __1.StringUtils.uuid();
|
|
28
|
-
return Buffer.from(id, "ascii")
|
|
29
|
-
.toString("base64")
|
|
30
|
-
.replace("=", "")
|
|
31
|
-
.replace("+", "-")
|
|
32
|
-
.replace("/", "_");
|
|
33
|
-
};
|
|
34
|
-
return GenerationUtils;
|
|
35
|
-
}());
|
|
36
|
-
exports.GenerationUtils = GenerationUtils;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface IInputTypeLengths {
|
|
2
|
-
city: number;
|
|
3
|
-
email: number;
|
|
4
|
-
firstName: number;
|
|
5
|
-
lastName: number;
|
|
6
|
-
phoneNumber: number;
|
|
7
|
-
postalCode: number;
|
|
8
|
-
province: number;
|
|
9
|
-
}
|
|
10
|
-
export declare type GatewayType = "portico" | "realex";
|
|
11
|
-
export declare function validateAmount(_gateway: GatewayType, amount: string | number, _impliedDecimal?: boolean): string;
|
|
12
|
-
export declare function validateInput(gateway: GatewayType, inputType: keyof IInputTypeLengths, input: string | undefined): string;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateInput = exports.validateAmount = void 0;
|
|
4
|
-
;
|
|
5
|
-
var inputFieldMaxLength = {
|
|
6
|
-
portico: {
|
|
7
|
-
city: 20,
|
|
8
|
-
email: 100,
|
|
9
|
-
firstName: 26,
|
|
10
|
-
lastName: 26,
|
|
11
|
-
phoneNumber: 20,
|
|
12
|
-
postalCode: 9,
|
|
13
|
-
province: 20,
|
|
14
|
-
},
|
|
15
|
-
// todo: Use actual values
|
|
16
|
-
realex: {
|
|
17
|
-
city: 0,
|
|
18
|
-
email: 0,
|
|
19
|
-
firstName: 0,
|
|
20
|
-
lastName: 0,
|
|
21
|
-
phoneNumber: 0,
|
|
22
|
-
postalCode: 0,
|
|
23
|
-
province: 0,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
var inputLabels = {
|
|
27
|
-
city: "City",
|
|
28
|
-
email: "Email address",
|
|
29
|
-
firstName: "First name",
|
|
30
|
-
lastName: "Last name",
|
|
31
|
-
phoneNumber: "Phone number",
|
|
32
|
-
postalCode: "Zip/postal code",
|
|
33
|
-
province: "State/province",
|
|
34
|
-
};
|
|
35
|
-
var inputLengthErrorMessage = function (label) { return label + " length greater than the configured gateway's maximum length"; };
|
|
36
|
-
function validateAmount(_gateway, amount, _impliedDecimal) {
|
|
37
|
-
if (_impliedDecimal === void 0) { _impliedDecimal = false; }
|
|
38
|
-
if (!amount || amount < 0) {
|
|
39
|
-
throw new Error("Amount must be greater than or equal to 0");
|
|
40
|
-
}
|
|
41
|
-
return parseFloat((Math.round(amount * 100) / 100).toString()).toFixed(2);
|
|
42
|
-
}
|
|
43
|
-
exports.validateAmount = validateAmount;
|
|
44
|
-
function validateInput(gateway, inputType, input) {
|
|
45
|
-
if (!input) {
|
|
46
|
-
return "";
|
|
47
|
-
}
|
|
48
|
-
input = input.trim();
|
|
49
|
-
var label = inputLabels[inputType];
|
|
50
|
-
switch (inputType) {
|
|
51
|
-
case "email":
|
|
52
|
-
if (!/^[^\s@]+@[^\s@]+$/.test(input)) {
|
|
53
|
-
throw new Error(label + " is in wrong format");
|
|
54
|
-
}
|
|
55
|
-
break;
|
|
56
|
-
case "phoneNumber":
|
|
57
|
-
input = input.replace(/\D+/g, "");
|
|
58
|
-
break;
|
|
59
|
-
case "postalCode":
|
|
60
|
-
input = input.replace(/[^0-9A-Za-z]/g, "");
|
|
61
|
-
break;
|
|
62
|
-
default:
|
|
63
|
-
}
|
|
64
|
-
if (!label) {
|
|
65
|
-
label = "Input";
|
|
66
|
-
}
|
|
67
|
-
if (input.length > inputFieldMaxLength[gateway][inputType]) {
|
|
68
|
-
throw new Error(inputLengthErrorMessage(label));
|
|
69
|
-
}
|
|
70
|
-
return input;
|
|
71
|
-
}
|
|
72
|
-
exports.validateInput = validateInput;
|
package/lib/src/Utils/Sha1.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function hex_sha1(s: string): string;
|
|
2
|
-
export declare function b64_sha1(s: string): string;
|
|
3
|
-
export declare function str_sha1(s: string): string;
|
|
4
|
-
export declare function hex_hmac_sha1(key: string, data: string): string;
|
|
5
|
-
export declare function b64_hmac_sha1(key: string, data: string): string;
|
|
6
|
-
export declare function str_hmac_sha1(key: string, data: string): string;
|
package/lib/src/Utils/Sha1.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* A TypeScript implementation of the Secure Hash Algorithm, SHA-1, as defined
|
|
4
|
-
* in FIPS PUB 180-1
|
|
5
|
-
*
|
|
6
|
-
* This file is derived from JavaScript MD5 project ( http://pajhome.org.uk/crypt/md5/ )
|
|
7
|
-
* and is modified for oauth-typescript project.
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2000-2002 Paul Johnston.
|
|
10
|
-
* (Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet)
|
|
11
|
-
* Copyright 2015 NOBUOKA Yu.
|
|
12
|
-
*
|
|
13
|
-
* Licensed under the BSD License.
|
|
14
|
-
*
|
|
15
|
-
* 1. Redistributions of source code must retain the above copyright notice,
|
|
16
|
-
* this list of conditions and the following disclaimer.
|
|
17
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
18
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
19
|
-
* and/or other materials provided with the distribution.
|
|
20
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
21
|
-
* may be used to endorse or promote products derived from this software
|
|
22
|
-
* without specific prior written permission.
|
|
23
|
-
*
|
|
24
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
25
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
26
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
27
|
-
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
28
|
-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
29
|
-
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
30
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
31
|
-
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
32
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
33
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
-
*/
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.str_hmac_sha1 = exports.b64_hmac_sha1 = exports.hex_hmac_sha1 = exports.str_sha1 = exports.b64_sha1 = exports.hex_sha1 = void 0;
|
|
37
|
-
/*
|
|
38
|
-
* Configurable constiables. You may need to tweak these to be compatible with
|
|
39
|
-
* the server-side, but the defaults work in most cases.
|
|
40
|
-
*/
|
|
41
|
-
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
|
42
|
-
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
|
43
|
-
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
|
|
44
|
-
/*
|
|
45
|
-
* These are the functions you'll usually want to call
|
|
46
|
-
* They take string arguments and return either hex or base-64 encoded strings
|
|
47
|
-
*/
|
|
48
|
-
function hex_sha1(s) {
|
|
49
|
-
return binb2hex(core_sha1(str2binb(s), s.length * chrsz));
|
|
50
|
-
}
|
|
51
|
-
exports.hex_sha1 = hex_sha1;
|
|
52
|
-
function b64_sha1(s) {
|
|
53
|
-
return binb2b64(core_sha1(str2binb(s), s.length * chrsz));
|
|
54
|
-
}
|
|
55
|
-
exports.b64_sha1 = b64_sha1;
|
|
56
|
-
function str_sha1(s) {
|
|
57
|
-
return binb2str(core_sha1(str2binb(s), s.length * chrsz));
|
|
58
|
-
}
|
|
59
|
-
exports.str_sha1 = str_sha1;
|
|
60
|
-
function hex_hmac_sha1(key, data) {
|
|
61
|
-
return binb2hex(core_hmac_sha1(key, data));
|
|
62
|
-
}
|
|
63
|
-
exports.hex_hmac_sha1 = hex_hmac_sha1;
|
|
64
|
-
function b64_hmac_sha1(key, data) {
|
|
65
|
-
return binb2b64(core_hmac_sha1(key, data));
|
|
66
|
-
}
|
|
67
|
-
exports.b64_hmac_sha1 = b64_hmac_sha1;
|
|
68
|
-
function str_hmac_sha1(key, data) {
|
|
69
|
-
return binb2str(core_hmac_sha1(key, data));
|
|
70
|
-
}
|
|
71
|
-
exports.str_hmac_sha1 = str_hmac_sha1;
|
|
72
|
-
/*
|
|
73
|
-
* Calculate the SHA-1 of an array of big-endian words, and a bit length
|
|
74
|
-
*/
|
|
75
|
-
function core_sha1(x, len) {
|
|
76
|
-
/* append padding */
|
|
77
|
-
x[len >> 5] |= 0x80 << (24 - len % 32);
|
|
78
|
-
x[(((len + 64) >> 9) << 4) + 15] = len;
|
|
79
|
-
var w = Array(80);
|
|
80
|
-
var a = 1732584193;
|
|
81
|
-
var b = -271733879;
|
|
82
|
-
var c = -1732584194;
|
|
83
|
-
var d = 271733878;
|
|
84
|
-
var e = -1009589776;
|
|
85
|
-
for (var i = 0; i < x.length; i += 16) {
|
|
86
|
-
var olda = a;
|
|
87
|
-
var oldb = b;
|
|
88
|
-
var oldc = c;
|
|
89
|
-
var oldd = d;
|
|
90
|
-
var olde = e;
|
|
91
|
-
for (var j = 0; j < 80; j++) {
|
|
92
|
-
if (j < 16) {
|
|
93
|
-
w[j] = x[i + j];
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
|
|
97
|
-
}
|
|
98
|
-
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
|
|
99
|
-
e = d;
|
|
100
|
-
d = c;
|
|
101
|
-
c = rol(b, 30);
|
|
102
|
-
b = a;
|
|
103
|
-
a = t;
|
|
104
|
-
}
|
|
105
|
-
a = safe_add(a, olda);
|
|
106
|
-
b = safe_add(b, oldb);
|
|
107
|
-
c = safe_add(c, oldc);
|
|
108
|
-
d = safe_add(d, oldd);
|
|
109
|
-
e = safe_add(e, olde);
|
|
110
|
-
}
|
|
111
|
-
return Array(a, b, c, d, e);
|
|
112
|
-
}
|
|
113
|
-
/*
|
|
114
|
-
* Perform the appropriate triplet combination function for the current
|
|
115
|
-
* iteration
|
|
116
|
-
*/
|
|
117
|
-
function sha1_ft(t, b, c, d) {
|
|
118
|
-
if (t < 20) {
|
|
119
|
-
return (b & c) | (~b & d);
|
|
120
|
-
}
|
|
121
|
-
if (t < 40) {
|
|
122
|
-
return b ^ c ^ d;
|
|
123
|
-
}
|
|
124
|
-
if (t < 60) {
|
|
125
|
-
return (b & c) | (b & d) | (c & d);
|
|
126
|
-
}
|
|
127
|
-
return b ^ c ^ d;
|
|
128
|
-
}
|
|
129
|
-
/*
|
|
130
|
-
* Determine the appropriate additive constant for the current iteration
|
|
131
|
-
*/
|
|
132
|
-
function sha1_kt(t) {
|
|
133
|
-
return t < 20
|
|
134
|
-
? 1518500249
|
|
135
|
-
: t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
|
|
136
|
-
}
|
|
137
|
-
/*
|
|
138
|
-
* Calculate the HMAC-SHA1 of a key and some data
|
|
139
|
-
*/
|
|
140
|
-
function core_hmac_sha1(key, data) {
|
|
141
|
-
var bkey = str2binb(key);
|
|
142
|
-
if (bkey.length > 16) {
|
|
143
|
-
bkey = core_sha1(bkey, key.length * chrsz);
|
|
144
|
-
}
|
|
145
|
-
var ipad = Array(16);
|
|
146
|
-
var opad = Array(16);
|
|
147
|
-
for (var i = 0; i < 16; i++) {
|
|
148
|
-
ipad[i] = bkey[i] ^ 0x36363636;
|
|
149
|
-
opad[i] = bkey[i] ^ 0x5c5c5c5c;
|
|
150
|
-
}
|
|
151
|
-
var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
|
|
152
|
-
return core_sha1(opad.concat(hash), 512 + 160);
|
|
153
|
-
}
|
|
154
|
-
/*
|
|
155
|
-
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
|
156
|
-
* to work around bugs in some JS interpreters.
|
|
157
|
-
*/
|
|
158
|
-
function safe_add(x, y) {
|
|
159
|
-
var lsw = (x & 0xffff) + (y & 0xffff);
|
|
160
|
-
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
161
|
-
return (msw << 16) | (lsw & 0xffff);
|
|
162
|
-
}
|
|
163
|
-
/*
|
|
164
|
-
* Bitwise rotate a 32-bit number to the left.
|
|
165
|
-
*/
|
|
166
|
-
function rol(num, cnt) {
|
|
167
|
-
return (num << cnt) | (num >>> (32 - cnt));
|
|
168
|
-
}
|
|
169
|
-
/*
|
|
170
|
-
* Convert an 8-bit or 16-bit string to an array of big-endian words
|
|
171
|
-
* In 8-bit function, characters >255 have their hi-byte silently ignored.
|
|
172
|
-
*/
|
|
173
|
-
function str2binb(str) {
|
|
174
|
-
var bin = Array();
|
|
175
|
-
var mask = (1 << chrsz) - 1;
|
|
176
|
-
for (var i = 0; i < str.length * chrsz; i += chrsz) {
|
|
177
|
-
bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i % 32);
|
|
178
|
-
}
|
|
179
|
-
return bin;
|
|
180
|
-
}
|
|
181
|
-
/*
|
|
182
|
-
* Convert an array of big-endian words to a string
|
|
183
|
-
*/
|
|
184
|
-
function binb2str(bin) {
|
|
185
|
-
var str = "";
|
|
186
|
-
var mask = (1 << chrsz) - 1;
|
|
187
|
-
for (var i = 0; i < bin.length * 32; i += chrsz) {
|
|
188
|
-
str += String.fromCharCode((bin[i >> 5] >>> (32 - chrsz - i % 32)) & mask);
|
|
189
|
-
}
|
|
190
|
-
return str;
|
|
191
|
-
}
|
|
192
|
-
/*
|
|
193
|
-
* Convert an array of big-endian words to a hex string.
|
|
194
|
-
*/
|
|
195
|
-
function binb2hex(binarray) {
|
|
196
|
-
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
|
197
|
-
var str = "";
|
|
198
|
-
for (var i = 0; i < binarray.length * 4; i++) {
|
|
199
|
-
str +=
|
|
200
|
-
hex_tab.charAt((binarray[i >> 2] >> ((3 - i % 4) * 8 + 4)) & 0xf) +
|
|
201
|
-
hex_tab.charAt((binarray[i >> 2] >> ((3 - i % 4) * 8)) & 0xf);
|
|
202
|
-
}
|
|
203
|
-
return str;
|
|
204
|
-
}
|
|
205
|
-
/*
|
|
206
|
-
* Convert an array of big-endian words to a base-64 string
|
|
207
|
-
*/
|
|
208
|
-
function binb2b64(binarray) {
|
|
209
|
-
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
210
|
-
var str = "";
|
|
211
|
-
for (var i = 0; i < binarray.length * 4; i += 3) {
|
|
212
|
-
var triplet = (((binarray[i >> 2] >> (8 * (3 - i % 4))) & 0xff) << 16) |
|
|
213
|
-
(((binarray[(i + 1) >> 2] >> (8 * (3 - (i + 1) % 4))) & 0xff) << 8) |
|
|
214
|
-
((binarray[(i + 2) >> 2] >> (8 * (3 - (i + 2) % 4))) & 0xff);
|
|
215
|
-
for (var j = 0; j < 4; j++) {
|
|
216
|
-
if (i * 8 + j * 6 > binarray.length * 32) {
|
|
217
|
-
str += b64pad;
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
str += tab.charAt((triplet >> (6 * (3 - j))) & 0x3f);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return str;
|
|
225
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StringUtils = void 0;
|
|
4
|
-
var StringUtils = /** @class */ (function () {
|
|
5
|
-
function StringUtils() {
|
|
6
|
-
}
|
|
7
|
-
StringUtils.leftPad = function (source, length, padString) {
|
|
8
|
-
if (!source) {
|
|
9
|
-
return source;
|
|
10
|
-
}
|
|
11
|
-
var pad = padString.repeat(length);
|
|
12
|
-
return pad.substring(0, pad.length - source.length) + source;
|
|
13
|
-
};
|
|
14
|
-
StringUtils.uuid = function () {
|
|
15
|
-
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
|
|
16
|
-
var uuid = "";
|
|
17
|
-
var ii;
|
|
18
|
-
for (ii = 0; ii < 32; ii += 1) {
|
|
19
|
-
switch (ii) {
|
|
20
|
-
case 8:
|
|
21
|
-
case 20:
|
|
22
|
-
uuid += "-";
|
|
23
|
-
uuid += ((Math.random() * 16) | 0).toString(16);
|
|
24
|
-
break;
|
|
25
|
-
case 12:
|
|
26
|
-
uuid += "-";
|
|
27
|
-
uuid += "4";
|
|
28
|
-
break;
|
|
29
|
-
case 16:
|
|
30
|
-
uuid += "-";
|
|
31
|
-
uuid += ((Math.random() * 4) | 8).toString(16);
|
|
32
|
-
break;
|
|
33
|
-
default:
|
|
34
|
-
uuid += ((Math.random() * 16) | 0).toString(16);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return uuid;
|
|
38
|
-
};
|
|
39
|
-
StringUtils.btoa = function (t) {
|
|
40
|
-
if (Buffer.from) {
|
|
41
|
-
return Buffer.from(t, "ascii").toString("base64");
|
|
42
|
-
}
|
|
43
|
-
return new Buffer(t, "ascii").toString("base64");
|
|
44
|
-
};
|
|
45
|
-
StringUtils.atob = function (t) {
|
|
46
|
-
if (Buffer.from) {
|
|
47
|
-
return Buffer.from(t, "base64").toString("ascii");
|
|
48
|
-
}
|
|
49
|
-
return new Buffer(t, "base64").toString("ascii");
|
|
50
|
-
};
|
|
51
|
-
return StringUtils;
|
|
52
|
-
}());
|
|
53
|
-
exports.StringUtils = StringUtils;
|
package/lib/src/Utils/index.d.ts
DELETED