@pixelpay/sdk-core 2.1.0 → 2.1.3-beta.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 +22 -0
- package/lib/base/Helpers.d.ts +1 -1
- package/lib/base/Helpers.js +4 -3
- package/lib/base/Helpers.js.map +1 -1
- package/lib/base/RequestBehaviour.d.ts +18 -1
- package/lib/base/RequestBehaviour.js +22 -2
- package/lib/base/RequestBehaviour.js.map +1 -1
- package/lib/base/ServiceBehaviour.d.ts +21 -1
- package/lib/base/ServiceBehaviour.js +95 -28
- package/lib/base/ServiceBehaviour.js.map +1 -1
- package/lib/browser/index.js +3 -3
- package/lib/entities/TransactionResult.d.ts +12 -0
- package/lib/entities/TransactionResult.js +12 -0
- package/lib/entities/TransactionResult.js.map +1 -1
- package/lib/exceptions/FailedEncryptionException.d.ts +2 -0
- package/lib/exceptions/FailedEncryptionException.js +26 -0
- package/lib/exceptions/FailedEncryptionException.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/libraries/CardinalManager.js +8 -8
- package/lib/requests/CardTokenization.d.ts +8 -1
- package/lib/requests/CardTokenization.js +34 -18
- package/lib/requests/CardTokenization.js.map +1 -1
- package/lib/requests/LookupTransaction.d.ts +18 -0
- package/lib/requests/LookupTransaction.js +46 -0
- package/lib/requests/LookupTransaction.js.map +1 -1
- package/lib/requests/PaymentTransaction.d.ts +8 -1
- package/lib/requests/PaymentTransaction.js +26 -13
- package/lib/requests/PaymentTransaction.js.map +1 -1
- package/lib/services/CardinalAuthentication.d.ts +4 -4
- package/lib/services/CardinalAuthentication.js +3 -3
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +1 -1
- package/tests/Tokenization.test.ts +12 -8
|
@@ -4,6 +4,10 @@ export default class TransactionResult {
|
|
|
4
4
|
* Transaction response type
|
|
5
5
|
*/
|
|
6
6
|
transaction_type: string;
|
|
7
|
+
/**
|
|
8
|
+
* Transaction redeemed points
|
|
9
|
+
*/
|
|
10
|
+
transaction_redeemed_points: number;
|
|
7
11
|
/**
|
|
8
12
|
* Approved amount on capture/sale
|
|
9
13
|
*/
|
|
@@ -72,6 +76,14 @@ export default class TransactionResult {
|
|
|
72
76
|
* Proccesor response message
|
|
73
77
|
*/
|
|
74
78
|
response_reason: string;
|
|
79
|
+
/**
|
|
80
|
+
* Transaction installment type
|
|
81
|
+
*/
|
|
82
|
+
installment_type: string;
|
|
83
|
+
/**
|
|
84
|
+
* Transaction installment value
|
|
85
|
+
*/
|
|
86
|
+
installment_months: string;
|
|
75
87
|
/**
|
|
76
88
|
* Payment unique identifier
|
|
77
89
|
*/
|
|
@@ -13,6 +13,10 @@ var TransactionResult = /** @class */ (function () {
|
|
|
13
13
|
* Transaction response type
|
|
14
14
|
*/
|
|
15
15
|
this.transaction_type = undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Transaction redeemed points
|
|
18
|
+
*/
|
|
19
|
+
this.transaction_redeemed_points = undefined;
|
|
16
20
|
/**
|
|
17
21
|
* Approved amount on capture/sale
|
|
18
22
|
*/
|
|
@@ -81,6 +85,14 @@ var TransactionResult = /** @class */ (function () {
|
|
|
81
85
|
* Proccesor response message
|
|
82
86
|
*/
|
|
83
87
|
this.response_reason = undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Transaction installment type
|
|
90
|
+
*/
|
|
91
|
+
this.installment_type = undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Transaction installment value
|
|
94
|
+
*/
|
|
95
|
+
this.installment_months = undefined;
|
|
84
96
|
/**
|
|
85
97
|
* Payment unique identifier
|
|
86
98
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionResult.js","sourceRoot":"","sources":["../../src/entities/TransactionResult.ts"],"names":[],"mappings":";;;;;AAAA,iFAA2D;AAC3D,iGAA2E;AAC3E,uFAAiE;AACj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AC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAA,IAAI;YACjD,IAAI,IAAI,IAAI,MAAM,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACnC;QACF,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAC;IACf,CAAC;IACF,wBAAC;AAAD,CAAC,
|
|
1
|
+
{"version":3,"file":"TransactionResult.js","sourceRoot":"","sources":["../../src/entities/TransactionResult.ts"],"names":[],"mappings":";;;;;AAAA,iFAA2D;AAC3D,iGAA2E;AAC3E,uFAAiE;AACjE,iFAA2D;AAG3D;IAAA;QACC;;WAEG;QACH,qBAAgB,GAAW,SAAS,CAAC;QAErC;;WAEG;QACH,gCAA2B,GAAW,SAAS,CAAC;QAEhD;;WAEG;QACH,gCAA2B,GAAW,SAAS,CAAC;QAEhD;;WAEG;QACH,uBAAkB,GAAW,SAAS,CAAC;QAEvC;;WAEG;QACH,qBAAgB,GAAW,SAAS,CAAC;QAErC;;WAEG;QACH,yBAAoB,GAAW,SAAS,CAAC;QAEzC;;WAEG;QACH,yBAAoB,GAAW,SAAS,CAAC;QAEzC;;WAEG;QACH,iBAAY,GAAW,SAAS,CAAC;QAEjC;;WAEG;QACH,iBAAY,GAAW,SAAS,CAAC;QAEjC;;WAEG;QACH,kBAAa,GAAW,SAAS,CAAC;QAElC;;WAEG;QACH,mBAAc,GAAW,SAAS,CAAC;QAEnC;;WAEG;QACH,0BAAqB,GAAW,SAAS,CAAC;QAE1C;;WAEG;QACH,qBAAgB,GAAW,SAAS,CAAC;QAErC;;WAEG;QACH,qBAAgB,GAAW,SAAS,CAAC;QAErC;;WAEG;QACH,sBAAiB,GAAY,SAAS,CAAC;QAEvC;;WAEG;QACH,wBAAmB,GAAY,SAAS,CAAC;QAEzC;;WAEG;QACH,kBAAa,GAAW,SAAS,CAAC;QAElC;;WAEG;QACH,kBAAa,GAAW,SAAS,CAAC;QAElC;;WAEG;QACH,oBAAe,GAAW,SAAS,CAAC;QAEpC;;WAEG;QACH,qBAAgB,GAAW,SAAS,CAAC;QAErC;;WAEG;QACH,uBAAkB,GAAW,SAAS,CAAC;QAEvC;;WAEG;QACH,iBAAY,GAAW,SAAS,CAAC;QAEjC;;WAEG;QACH,iBAAY,GAAW,SAAS,CAAC;IAgClC,CAAC;IA9BA;;;;;OAKG;IACI,kCAAgB,GAAvB,UAAwB,QAAkB;QACzC,OAAO,QAAQ,YAAY,yBAAe;eACtC,QAAQ,YAAY,iCAAuB;eAC3C,QAAQ,YAAY,4BAAkB;eACtC,QAAQ,YAAY,yBAAe,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACI,8BAAY,GAAnB,UAAoB,QAAkB;QACrC,IAAM,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAEvC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAA,IAAI;YACjD,IAAI,IAAI,IAAI,MAAM,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACnC;QACF,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAC;IACf,CAAC;IACF,wBAAC;AAAD,CAAC,AAlJD,IAkJC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var FailedEncryptionException = /** @class */ (function (_super) {
|
|
19
|
+
__extends(FailedEncryptionException, _super);
|
|
20
|
+
function FailedEncryptionException() {
|
|
21
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
22
|
+
}
|
|
23
|
+
return FailedEncryptionException;
|
|
24
|
+
}(Error));
|
|
25
|
+
exports.default = FailedEncryptionException;
|
|
26
|
+
//# sourceMappingURL=FailedEncryptionException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FailedEncryptionException.js","sourceRoot":"","sources":["../../src/exceptions/FailedEncryptionException.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;IAAuD,6CAAK;IAA5D;;IAEA,CAAC;IAAD,gCAAC;AAAD,CAAC,AAFD,CAAuD,KAAK,GAE3D"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import CardResult from './entities/CardResult';
|
|
2
2
|
import TransactionResult from './entities/TransactionResult';
|
|
3
|
+
import FailedEncryptionException from './exceptions/FailedEncryptionException';
|
|
3
4
|
import InvalidCredentialsException from './exceptions/InvalidCredentialsException';
|
|
4
5
|
import InvalidTransactionTypeException from './exceptions/InvalidTransactionTypeException';
|
|
5
6
|
import Billing from './models/Billing';
|
|
@@ -32,6 +33,7 @@ export declare const Entities: {
|
|
|
32
33
|
TransactionResult: typeof TransactionResult;
|
|
33
34
|
};
|
|
34
35
|
export declare const Exceptions: {
|
|
36
|
+
FailedEncryptionException: typeof FailedEncryptionException;
|
|
35
37
|
InvalidCredentialsException: typeof InvalidCredentialsException;
|
|
36
38
|
InvalidTransactionTypeException: typeof InvalidTransactionTypeException;
|
|
37
39
|
};
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Services = exports.Responses = exports.Resources = exports.Requests = exports.Models = exports.Exceptions = exports.Entities = void 0;
|
|
7
7
|
var CardResult_1 = __importDefault(require("./entities/CardResult"));
|
|
8
8
|
var TransactionResult_1 = __importDefault(require("./entities/TransactionResult"));
|
|
9
|
+
var FailedEncryptionException_1 = __importDefault(require("./exceptions/FailedEncryptionException"));
|
|
9
10
|
var InvalidCredentialsException_1 = __importDefault(require("./exceptions/InvalidCredentialsException"));
|
|
10
11
|
var InvalidTransactionTypeException_1 = __importDefault(require("./exceptions/InvalidTransactionTypeException"));
|
|
11
12
|
var Billing_1 = __importDefault(require("./models/Billing"));
|
|
@@ -39,6 +40,7 @@ exports.Entities = {
|
|
|
39
40
|
TransactionResult: TransactionResult_1.default,
|
|
40
41
|
};
|
|
41
42
|
exports.Exceptions = {
|
|
43
|
+
FailedEncryptionException: FailedEncryptionException_1.default,
|
|
42
44
|
InvalidCredentialsException: InvalidCredentialsException_1.default,
|
|
43
45
|
InvalidTransactionTypeException: InvalidTransactionTypeException_1.default,
|
|
44
46
|
};
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,qEAA+C;AAC/C,mFAA6D;AAE7D,yGAAmF;AACnF,iHAA2F;AAE3F,6DAAuC;AACvC,uDAAiC;AACjC,uDAAiC;AACjC,yDAAmC;AACnC,+DAAyC;AAEzC,+EAAyD;AACzD,qFAA+D;AAC/D,+EAAyD;AACzD,+EAAyD;AACzD,mFAA6D;AAE7D,iFAA2D;AAE3D,wEAAkD;AAClD,oEAA8C;AAE9C,4EAAsD;AACtD,gFAA0D;AAC1D,sFAAgE;AAChE,8FAAwE;AACxE,k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eof setupCompleteData.sessionId == 'undefined'
|
|
120
120
|
|| (typeof setupCompleteData.sessionId != 'undefined'
|
|
121
121
|
&& (!setupCompleteData.sessionId || setupCompleteData.sessionId == ''))) {
|
|
122
|
-
throw new Error(
|
|
122
|
+
throw new Error('Cardinal initial setup error.');
|
|
123
123
|
}
|
|
124
124
|
lookup = new LookupTransaction_1.default();
|
|
125
125
|
lookup.fromPaymentTransaction(manager.transaction);
|
|
@@ -135,7 +135,7 @@ var CardinalManager = /** @class */ (function () {
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
}); });
|
|
138
|
-
window.Cardinal.on(
|
|
138
|
+
window.Cardinal.on('payments.validated', function (data, jwt) { return __awaiter(_this, void 0, void 0, function () {
|
|
139
139
|
var lookup_continue, result, result, failure;
|
|
140
140
|
return __generator(this, function (_a) {
|
|
141
141
|
switch (_a.label) {
|
|
@@ -158,7 +158,7 @@ var CardinalManager = /** @class */ (function () {
|
|
|
158
158
|
resolve(result);
|
|
159
159
|
return [3 /*break*/, 6];
|
|
160
160
|
case 3:
|
|
161
|
-
if (!(data.ActionCode ==
|
|
161
|
+
if (!(data.ActionCode == 'NOACTION')) return [3 /*break*/, 5];
|
|
162
162
|
return [4 /*yield*/, manager.service.retryTransaction(manager.transaction)];
|
|
163
163
|
case 4:
|
|
164
164
|
result = _a.sent();
|
|
@@ -202,24 +202,24 @@ var CardinalManager = /** @class */ (function () {
|
|
|
202
202
|
container = document.querySelector('.pixelpay-modal-container');
|
|
203
203
|
break;
|
|
204
204
|
default:
|
|
205
|
-
throw new Error(
|
|
205
|
+
throw new Error('Unsupported inline mode found [' + details.data.mode + ']');
|
|
206
206
|
}
|
|
207
207
|
break;
|
|
208
208
|
default:
|
|
209
|
-
throw new Error(
|
|
209
|
+
throw new Error('Unsupported inline payment type found [' + details.paymentType + ']');
|
|
210
210
|
}
|
|
211
211
|
container.innerHTML = htmlTemplate;
|
|
212
212
|
resolve();
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
215
|
-
throw new Error(
|
|
215
|
+
throw new Error('Unable to process request due to invalid arguments');
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
catch (error) {
|
|
219
219
|
reject(error);
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
|
-
window.Cardinal.setup(
|
|
222
|
+
window.Cardinal.setup('init', { jwt: jwt_setup });
|
|
223
223
|
}
|
|
224
224
|
catch (err) {
|
|
225
225
|
CardinalManager.clearAllEvents();
|
|
@@ -238,7 +238,7 @@ var CardinalManager = /** @class */ (function () {
|
|
|
238
238
|
case 0:
|
|
239
239
|
this.transaction.authentication_identifier = this.identifier;
|
|
240
240
|
if (!response.success) return [3 /*break*/, 4];
|
|
241
|
-
if (!(response.action ==
|
|
241
|
+
if (!(response.action == 'continue')) return [3 /*break*/, 1];
|
|
242
242
|
window.Cardinal.continue('cca', {
|
|
243
243
|
AcsUrl: response.data.continue_url,
|
|
244
244
|
Payload: response.data.continue_payload,
|
|
@@ -62,11 +62,18 @@ export default class CardTokenization extends RequestBehaviour {
|
|
|
62
62
|
* @param billing
|
|
63
63
|
*/
|
|
64
64
|
setBilling(billing: Billing): void;
|
|
65
|
+
/**
|
|
66
|
+
* Check if current request needs encryption.
|
|
67
|
+
*
|
|
68
|
+
* @return
|
|
69
|
+
*/
|
|
70
|
+
isEncryptable(): boolean;
|
|
65
71
|
/**
|
|
66
72
|
* Encrypt fields with sensitive data.
|
|
67
73
|
*
|
|
68
74
|
* @param publicKey
|
|
69
75
|
* @return
|
|
76
|
+
* @throws FailedEncryptionException
|
|
70
77
|
*/
|
|
71
|
-
withEncryption(publicKey: string | null): string
|
|
78
|
+
withEncryption(publicKey: string | null): string;
|
|
72
79
|
}
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
var tweetnacl_util_1 = __importDefault(require("tweetnacl-util"));
|
|
22
22
|
var RequestBehaviour_1 = __importDefault(require("../base/RequestBehaviour"));
|
|
23
23
|
var Helpers_1 = __importDefault(require("../base/Helpers"));
|
|
24
|
+
var FailedEncryptionException_1 = __importDefault(require("../exceptions/FailedEncryptionException"));
|
|
24
25
|
var CardTokenization = /** @class */ (function (_super) {
|
|
25
26
|
__extends(CardTokenization, _super);
|
|
26
27
|
function CardTokenization() {
|
|
@@ -83,9 +84,13 @@ var CardTokenization = /** @class */ (function (_super) {
|
|
|
83
84
|
CardTokenization.prototype.setCard = function (card) {
|
|
84
85
|
this.number = Helpers_1.default.cleanString(card.number);
|
|
85
86
|
this.cvv2 = card.cvv2;
|
|
86
|
-
this.expire_month = ('00' + card.expire_month).slice(-2);
|
|
87
|
-
this.expire_year = String(card.expire_year);
|
|
88
87
|
this.cardholder = Helpers_1.default.trimValue(card.cardholder);
|
|
88
|
+
if (card.expire_month) {
|
|
89
|
+
this.expire_month = ('00' + card.expire_month).slice(-2);
|
|
90
|
+
}
|
|
91
|
+
if (card.expire_year) {
|
|
92
|
+
this.expire_year = String(card.expire_year);
|
|
93
|
+
}
|
|
89
94
|
};
|
|
90
95
|
/**
|
|
91
96
|
* Associate and mapping Billing model properties to transaction
|
|
@@ -100,32 +105,43 @@ var CardTokenization = /** @class */ (function (_super) {
|
|
|
100
105
|
this.zip = billing.zip;
|
|
101
106
|
this.phone = billing.phone;
|
|
102
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Check if current request needs encryption.
|
|
110
|
+
*
|
|
111
|
+
* @return
|
|
112
|
+
*/
|
|
113
|
+
CardTokenization.prototype.isEncryptable = function () {
|
|
114
|
+
return Boolean(this.number || this.cvv2 || this.expire_month || this.expire_year);
|
|
115
|
+
};
|
|
103
116
|
/**
|
|
104
117
|
* Encrypt fields with sensitive data.
|
|
105
118
|
*
|
|
106
119
|
* @param publicKey
|
|
107
120
|
* @return
|
|
121
|
+
* @throws FailedEncryptionException
|
|
108
122
|
*/
|
|
109
123
|
CardTokenization.prototype.withEncryption = function (publicKey) {
|
|
124
|
+
var _a;
|
|
110
125
|
if (!publicKey) {
|
|
111
|
-
|
|
126
|
+
throw new FailedEncryptionException_1.default('Could not process transaction without merchant public key.');
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
var keyPair = (_a = this.sdk_key_pair) !== null && _a !== void 0 ? _a : Helpers_1.default.getKeyPair();
|
|
130
|
+
var number = Helpers_1.default.encrypt(this.number, publicKey, keyPair);
|
|
131
|
+
var cvv2 = Helpers_1.default.encrypt(this.cvv2, publicKey, keyPair);
|
|
132
|
+
var expire_month = Helpers_1.default.encrypt(this.expire_month, publicKey, keyPair);
|
|
133
|
+
var expire_year = Helpers_1.default.encrypt(this.expire_year, publicKey, keyPair);
|
|
134
|
+
var sdk_public_key = tweetnacl_util_1.default.encodeBase64(keyPair.publicKey);
|
|
135
|
+
this.number = number;
|
|
136
|
+
this.cvv2 = cvv2;
|
|
137
|
+
this.expire_month = expire_month;
|
|
138
|
+
this.expire_year = expire_year;
|
|
139
|
+
this.sdk_key_pair = keyPair;
|
|
140
|
+
return sdk_public_key;
|
|
112
141
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var cvv2 = Helpers_1.default.encrypt(this.cvv2, publicKey, keyPair);
|
|
116
|
-
var expire_month = Helpers_1.default.encrypt(this.expire_month, publicKey, keyPair);
|
|
117
|
-
var expire_year = Helpers_1.default.encrypt(this.expire_year, publicKey, keyPair);
|
|
118
|
-
if (this.number === number
|
|
119
|
-
&& this.cvv2 === cvv2
|
|
120
|
-
&& this.expire_month === expire_month
|
|
121
|
-
&& this.expire_year === expire_year) {
|
|
122
|
-
return null;
|
|
142
|
+
catch (error) {
|
|
143
|
+
throw new FailedEncryptionException_1.default('Encryption process encountered an unexpected error.');
|
|
123
144
|
}
|
|
124
|
-
this.number = number;
|
|
125
|
-
this.cvv2 = cvv2;
|
|
126
|
-
this.expire_month = expire_month;
|
|
127
|
-
this.expire_year = expire_year;
|
|
128
|
-
return tweetnacl_util_1.default.encodeBase64(keyPair.publicKey);
|
|
129
145
|
};
|
|
130
146
|
return CardTokenization;
|
|
131
147
|
}(RequestBehaviour_1.default));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardTokenization.js","sourceRoot":"","sources":["../../src/requests/CardTokenization.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAAsC;AACtC,8EAAwD;AACxD,4DAAsC;
|
|
1
|
+
{"version":3,"file":"CardTokenization.js","sourceRoot":"","sources":["../../src/requests/CardTokenization.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAAsC;AACtC,8EAAwD;AACxD,4DAAsC;AAGtC,sGAAgF;AAEhF;IAA8C,oCAAgB;IAA9D;QAAA,qEAyIC;QAxIA;;WAEG;QACH,YAAM,GAAW,IAAI,CAAC;QAEtB;;WAEG;QACH,UAAI,GAAW,IAAI,CAAC;QAEpB;;WAEG;QACH,kBAAY,GAAW,IAAI,CAAC;QAE5B;;WAEG;QACH,iBAAW,GAAW,IAAI,CAAC;QAE3B;;WAEG;QACH,gBAAU,GAAW,IAAI,CAAC;QAE1B;;WAEG;QACH,aAAO,GAAW,IAAI,CAAC;QAEvB;;WAEG;QACH,aAAO,GAAW,IAAI,CAAC;QAEvB;;WAEG;QACH,WAAK,GAAW,IAAI,CAAC;QAErB;;WAEG;QACH,UAAI,GAAW,IAAI,CAAC;QAEpB;;WAEG;QACH,SAAG,GAAW,IAAI,CAAC;QAEnB;;WAEG;QACH,WAAK,GAAW,IAAI,CAAC;QAErB;;WAEG;QACH,WAAK,GAAW,IAAI,CAAC;;IA8EtB,CAAC;IA5EA;;;;OAIG;IACH,kCAAO,GAAP,UAAQ,IAAU;QACjB,IAAI,CAAC,MAAM,GAAG,iBAAO,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CA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CAAC,CAAC;YAChE,IAAM,IAAI,GAAG,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC5D,IAAM,YAAY,GAAG,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC5E,IAAM,WAAW,GAAG,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAE1E,IAAM,cAAc,GAAG,wBAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAEhE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;YACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAE/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAE5B,OAAO,cAAc,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,mCAAyB,CAAC,qDAAqD,CAAC,CAAC;SAC3F;IACF,CAAC;IACF,uBAAC;AAAD,CAAC,AAzID,CAA8C,0BAAgB,GAyI7D"}
|
|
@@ -57,6 +57,10 @@ export default class LookupTransaction extends RequestBehaviour {
|
|
|
57
57
|
* Order total amount
|
|
58
58
|
*/
|
|
59
59
|
order_amount: string;
|
|
60
|
+
/**
|
|
61
|
+
* Indicates the maximum number of authorizations for installment payments.
|
|
62
|
+
*/
|
|
63
|
+
installment: string;
|
|
60
64
|
/**
|
|
61
65
|
* Cardinal session reference
|
|
62
66
|
*/
|
|
@@ -113,4 +117,18 @@ export default class LookupTransaction extends RequestBehaviour {
|
|
|
113
117
|
* Check if required EMV fields were included by songbird. If not, they are added manually.
|
|
114
118
|
*/
|
|
115
119
|
setRequiredEMVFields(): void;
|
|
120
|
+
/**
|
|
121
|
+
* Check if current request needs encryption.
|
|
122
|
+
*
|
|
123
|
+
* @return
|
|
124
|
+
*/
|
|
125
|
+
isEncryptable(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Encrypt fields with sensitive data.
|
|
128
|
+
*
|
|
129
|
+
* @param publicKey
|
|
130
|
+
* @return
|
|
131
|
+
* @throws FailedEncryptionException
|
|
132
|
+
*/
|
|
133
|
+
withEncryption(publicKey: string | null): string;
|
|
116
134
|
}
|
|
@@ -18,7 +18,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var tweetnacl_util_1 = __importDefault(require("tweetnacl-util"));
|
|
22
|
+
var Helpers_1 = __importDefault(require("../base/Helpers"));
|
|
21
23
|
var RequestBehaviour_1 = __importDefault(require("../base/RequestBehaviour"));
|
|
24
|
+
var FailedEncryptionException_1 = __importDefault(require("../exceptions/FailedEncryptionException"));
|
|
25
|
+
var SaleTransaction_1 = __importDefault(require("./SaleTransaction"));
|
|
22
26
|
var LookupTransaction = /** @class */ (function (_super) {
|
|
23
27
|
__extends(LookupTransaction, _super);
|
|
24
28
|
function LookupTransaction() {
|
|
@@ -79,6 +83,10 @@ var LookupTransaction = /** @class */ (function (_super) {
|
|
|
79
83
|
* Order total amount
|
|
80
84
|
*/
|
|
81
85
|
_this.order_amount = null;
|
|
86
|
+
/**
|
|
87
|
+
* Indicates the maximum number of authorizations for installment payments.
|
|
88
|
+
*/
|
|
89
|
+
_this.installment = null;
|
|
82
90
|
/**
|
|
83
91
|
* Cardinal session reference
|
|
84
92
|
*/
|
|
@@ -147,6 +155,10 @@ var LookupTransaction = /** @class */ (function (_super) {
|
|
|
147
155
|
this.order_id = request.order_id;
|
|
148
156
|
this.order_currency = request.order_currency;
|
|
149
157
|
this.order_amount = request.order_amount;
|
|
158
|
+
if (request instanceof SaleTransaction_1.default) {
|
|
159
|
+
this.installment = request.installment_months;
|
|
160
|
+
}
|
|
161
|
+
this.sdk_key_pair = request.getSDKKeyPair();
|
|
150
162
|
};
|
|
151
163
|
/**
|
|
152
164
|
* Check if required EMV fields were included by songbird. If not, they are added manually.
|
|
@@ -176,6 +188,40 @@ var LookupTransaction = /** @class */ (function (_super) {
|
|
|
176
188
|
this.user_agent = navigator.userAgent;
|
|
177
189
|
}
|
|
178
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* Check if current request needs encryption.
|
|
193
|
+
*
|
|
194
|
+
* @return
|
|
195
|
+
*/
|
|
196
|
+
LookupTransaction.prototype.isEncryptable = function () {
|
|
197
|
+
return Boolean(this.card_number || this.card_expire);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Encrypt fields with sensitive data.
|
|
201
|
+
*
|
|
202
|
+
* @param publicKey
|
|
203
|
+
* @return
|
|
204
|
+
* @throws FailedEncryptionException
|
|
205
|
+
*/
|
|
206
|
+
LookupTransaction.prototype.withEncryption = function (publicKey) {
|
|
207
|
+
var _a;
|
|
208
|
+
if (!publicKey) {
|
|
209
|
+
throw new FailedEncryptionException_1.default('Could not process transaction without merchant public key.');
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
var keyPair = (_a = this.sdk_key_pair) !== null && _a !== void 0 ? _a : Helpers_1.default.getKeyPair();
|
|
213
|
+
var card_number = Helpers_1.default.encrypt(this.card_number, publicKey, keyPair);
|
|
214
|
+
var card_expire = Helpers_1.default.encrypt(this.card_expire, publicKey, keyPair);
|
|
215
|
+
var sdk_public_key = tweetnacl_util_1.default.encodeBase64(keyPair.publicKey);
|
|
216
|
+
this.card_number = card_number;
|
|
217
|
+
this.card_expire = card_expire;
|
|
218
|
+
this.sdk_key_pair = keyPair;
|
|
219
|
+
return sdk_public_key;
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
throw new FailedEncryptionException_1.default('Encryption process encountered an unexpected error.');
|
|
223
|
+
}
|
|
224
|
+
};
|
|
179
225
|
return LookupTransaction;
|
|
180
226
|
}(RequestBehaviour_1.default));
|
|
181
227
|
exports.default = LookupTransaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LookupTransaction.js","sourceRoot":"","sources":["../../src/requests/LookupTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8EAAwD;
|
|
1
|
+
{"version":3,"file":"LookupTransaction.js","sourceRoot":"","sources":["../../src/requests/LookupTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAAsC;AACtC,4DAAsC;AACtC,8EAAwD;AAExD,sGAAgF;AAChF,sEAAgD;AAEhD;IAA+C,qCAAgB;IAA/D;QAAA,qEAgPC;QA/OA;;WAEG;QACH,gBAAU,GAAW,IAAI,CAAC;QAE1B;;WAEG;QACH,iBAAW,GAAW,IAAI,CAAC;QAE3B;;WAEG;QACH,iBAAW,GAAW,IAAI,CAAC;QAE3B;;WAEG;QACH,qBAAe,GAAW,IAAI,CAAC;QAE/B;;WAEG;QACH,qBAAe,GAAW,IAAI,CAAC;QAE/B;;WAEG;QACH,mBAAa,GAAW,IAAI,CAAC;QAE7B;;WAEG;QACH,kBAAY,GAAW,IAAI,CAAC;QAE5B;;WAEG;QACH,iBAAW,GAAW,IAAI,CAAC;QAE3B;;WAEG;QACH,mBAAa,GAAW,IAAI,CAAC;QAE7B;;WAEG;QACH,mBAAa,GAAW,IAAI,CAAC;QAE7B;;WAEG;QACH,oBAAc,GAAW,IAAI,CAAC;QAE9B;;WAEG;QACH,cAAQ,GAAW,IAAI,CAAC;QAExB;;WAEG;QACH,oBAAc,GAAW,IAAI,CAAC;QAE9B;;WAEG;QACH,kBAAY,GAAW,IAAI,CAAC;QAE5B;;WAEG;QACH,iBAAW,GAAW,IAAI,CAAC;QAE3B;;WAEG;QACH,eAAS,GAAW,IAAI,CAAC;QAEzB;;WAEG;QACH,0BAAoB,GAAW,OAAO,CAAC;QAEv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U,EAAE;YACrB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC;SACtC;IACF,CAAC;IAED;;;;OAIG;IACH,yCAAa,GAAb;QACC,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;OAMG;IACH,0CAAc,GAAd,UAAe,SAAwB;;QACtC,IAAI,CAAC,SAAS,EAAE;YACf,MAAM,IAAI,mCAAyB,CAAC,4DAA4D,CAAC,CAAC;SAClG;QAED,IAAI;YACH,IAAM,OAAO,GAAG,MAAA,IAAI,CAAC,YAAY,mCAAI,iBAAO,CAAC,UAAU,EAAE,CAAC;YAE1D,IAAM,WAAW,GAAG,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC1E,IAAM,WAAW,GAAG,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAE1E,IAAM,cAAc,GAAG,wBAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAEhE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAE/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAE5B,OAAO,cAAc,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,mCAAyB,CAAC,qDAAqD,CAAC,CAAC;SAC3F;IACF,CAAC;IACF,wBAAC;AAAD,CAAC,AAhPD,CAA+C,0BAAgB,GAgP9D"}
|
|
@@ -136,11 +136,18 @@ export default class PaymentTransaction extends RequestBehaviour {
|
|
|
136
136
|
* Enable 3DS/EMV authentication request
|
|
137
137
|
*/
|
|
138
138
|
withAuthenticationRequest(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Check if current request needs encryption.
|
|
141
|
+
*
|
|
142
|
+
* @return
|
|
143
|
+
*/
|
|
144
|
+
isEncryptable(): boolean;
|
|
139
145
|
/**
|
|
140
146
|
* Encrypt fields with sensitive data.
|
|
141
147
|
*
|
|
142
148
|
* @param publicKey
|
|
143
149
|
* @return
|
|
150
|
+
* @throws FailedEncryptionException
|
|
144
151
|
*/
|
|
145
|
-
withEncryption(publicKey: string | null): string
|
|
152
|
+
withEncryption(publicKey: string | null): string;
|
|
146
153
|
}
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
var tweetnacl_util_1 = __importDefault(require("tweetnacl-util"));
|
|
22
22
|
var Helpers_1 = __importDefault(require("../base/Helpers"));
|
|
23
23
|
var RequestBehaviour_1 = __importDefault(require("../base/RequestBehaviour"));
|
|
24
|
+
var FailedEncryptionException_1 = __importDefault(require("../exceptions/FailedEncryptionException"));
|
|
24
25
|
var PaymentTransaction = /** @class */ (function (_super) {
|
|
25
26
|
__extends(PaymentTransaction, _super);
|
|
26
27
|
function PaymentTransaction() {
|
|
@@ -188,29 +189,41 @@ var PaymentTransaction = /** @class */ (function (_super) {
|
|
|
188
189
|
PaymentTransaction.prototype.withAuthenticationRequest = function () {
|
|
189
190
|
this.authentication_request = true;
|
|
190
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* Check if current request needs encryption.
|
|
194
|
+
*
|
|
195
|
+
* @return
|
|
196
|
+
*/
|
|
197
|
+
PaymentTransaction.prototype.isEncryptable = function () {
|
|
198
|
+
return Boolean(this.card_number || this.card_cvv || this.card_expire);
|
|
199
|
+
};
|
|
191
200
|
/**
|
|
192
201
|
* Encrypt fields with sensitive data.
|
|
193
202
|
*
|
|
194
203
|
* @param publicKey
|
|
195
204
|
* @return
|
|
205
|
+
* @throws FailedEncryptionException
|
|
196
206
|
*/
|
|
197
207
|
PaymentTransaction.prototype.withEncryption = function (publicKey) {
|
|
208
|
+
var _a;
|
|
198
209
|
if (!publicKey) {
|
|
199
|
-
|
|
210
|
+
throw new FailedEncryptionException_1.default('Could not process transaction without merchant public key.');
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
var keyPair = (_a = this.sdk_key_pair) !== null && _a !== void 0 ? _a : Helpers_1.default.getKeyPair();
|
|
214
|
+
var card_number = Helpers_1.default.encrypt(this.card_number, publicKey, keyPair);
|
|
215
|
+
var card_cvv = Helpers_1.default.encrypt(this.card_cvv, publicKey, keyPair);
|
|
216
|
+
var card_expire = Helpers_1.default.encrypt(this.card_expire, publicKey, keyPair);
|
|
217
|
+
var sdk_public_key = tweetnacl_util_1.default.encodeBase64(keyPair.publicKey);
|
|
218
|
+
this.card_number = card_number;
|
|
219
|
+
this.card_cvv = card_cvv;
|
|
220
|
+
this.card_expire = card_expire;
|
|
221
|
+
this.sdk_key_pair = keyPair;
|
|
222
|
+
return sdk_public_key;
|
|
200
223
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var card_cvv = Helpers_1.default.encrypt(this.card_cvv, publicKey, keyPair);
|
|
204
|
-
var card_expire = Helpers_1.default.encrypt(this.card_expire, publicKey, keyPair);
|
|
205
|
-
if (this.card_number === card_number
|
|
206
|
-
&& this.card_cvv === card_cvv
|
|
207
|
-
&& this.card_expire === card_expire) {
|
|
208
|
-
return null;
|
|
224
|
+
catch (error) {
|
|
225
|
+
throw new FailedEncryptionException_1.default('Encryption process encountered an unexpected error.');
|
|
209
226
|
}
|
|
210
|
-
this.card_number = card_number;
|
|
211
|
-
this.card_cvv = card_cvv;
|
|
212
|
-
this.card_expire = card_expire;
|
|
213
|
-
return tweetnacl_util_1.default.encodeBase64(keyPair.publicKey);
|
|
214
227
|
};
|
|
215
228
|
return PaymentTransaction;
|
|
216
229
|
}(RequestBehaviour_1.default));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentTransaction.js","sourceRoot":"","sources":["../../src/requests/PaymentTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAAsC;AAKt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WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC1E,IAAM,QAAQ,GAAG,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACpE,IAAM,WAAW,GAAG,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAE1E,IAAM,cAAc,GAAG,wBAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAEhE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAE/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAE5B,OAAO,cAAc,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,mCAAyB,CAAC,qDAAqD,CAAC,CAAC;SAC3F;IACF,CAAC;IACF,yBAAC;AAAD,CAAC,AA1OD,CAAgD,0BAAgB,GA0O/D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Response from
|
|
2
|
-
import ServiceBehaviour from
|
|
3
|
-
import LookupTransaction from
|
|
1
|
+
import Response from '../base/Response';
|
|
2
|
+
import ServiceBehaviour from '../base/ServiceBehaviour';
|
|
3
|
+
import LookupTransaction from '../requests/LookupTransaction';
|
|
4
4
|
import LookupContinueTransaction from '../requests/LookupContinueTransaction';
|
|
5
|
-
import PaymentTransaction from
|
|
5
|
+
import PaymentTransaction from '../requests/PaymentTransaction';
|
|
6
6
|
export default class CardinalAuthentication extends ServiceBehaviour {
|
|
7
7
|
/**
|
|
8
8
|
* Stored running transaction to prevent duplicates
|
|
@@ -37,13 +37,13 @@ var CardinalAuthentication = /** @class */ (function (_super) {
|
|
|
37
37
|
* Send an authentication lookup transaction
|
|
38
38
|
*/
|
|
39
39
|
CardinalAuthentication.prototype.authenticationLookup = function (transaction) {
|
|
40
|
-
return this.post(
|
|
40
|
+
return this.post('api/v2/cardinal/authentication/lookup', transaction);
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Send and validate authentication continue transaction
|
|
44
44
|
*/
|
|
45
45
|
CardinalAuthentication.prototype.authenticationContinue = function (transaction) {
|
|
46
|
-
return this.post(
|
|
46
|
+
return this.post('api/v2/cardinal/authentication/continue', transaction);
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
49
|
* Send payment transaction by type (Sale/Auth)
|
|
@@ -54,7 +54,7 @@ var CardinalAuthentication = /** @class */ (function (_super) {
|
|
|
54
54
|
}
|
|
55
55
|
if (!(transaction instanceof SaleTransaction_1.default) && !(transaction instanceof AuthTransaction_1.default)) {
|
|
56
56
|
this.free();
|
|
57
|
-
throw new InvalidTransactionTypeException_1.default(
|
|
57
|
+
throw new InvalidTransactionTypeException_1.default('The request payment type is invalid.');
|
|
58
58
|
}
|
|
59
59
|
var url = "api/v2/transaction/".concat(transaction instanceof SaleTransaction_1.default ? 'sale' : 'auth');
|
|
60
60
|
CardinalAuthentication.runningTransaction = this.post(url, transaction).finally(this.free);
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.1.0";
|
|
1
|
+
declare const _default: "2.1.3-beta.0";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,cAAc,CAAC"}
|