@houlak/plexo-sdk 0.1.10 → 0.1.12
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/lib/sdk/PaymentGatewayClient.js +3 -3
- package/lib/sdk/PaymentGatewayMock.js +3 -3
- package/lib/sdk/helpers/signature/signatureHelper.js +18 -18
- package/lib/sdk/mocks/mocks.js +19 -19
- package/lib/sdk/models/GenericSignedObject.d.ts +2 -2
- package/lib/sdk/models/GenericSignedObject.js +2 -2
- package/lib/sdk/models/InstrumentCallback.d.ts +3 -3
- package/lib/sdk/models/InstrumentCallback.js +3 -3
- package/lib/sdk/models/InstrumentWithMetadata.d.ts +3 -3
- package/lib/sdk/models/InstrumentWithMetadata.js +3 -3
- package/lib/sdk/models/PaymentInstrument.d.ts +11 -11
- package/lib/sdk/models/StateObject.d.ts +2 -2
- package/lib/sdk/models/StateObject.js +2 -2
- package/lib/sdk/models/TransactionCallback.d.ts +1 -1
- package/lib/sdk/models/TransactionCallback.js +1 -1
- package/package.json +1 -1
|
@@ -66,7 +66,7 @@ var requestToPlexo = function (endpoint, request) { return __awaiter(void 0, voi
|
|
|
66
66
|
request: request,
|
|
67
67
|
};
|
|
68
68
|
stateObject = {
|
|
69
|
-
|
|
69
|
+
Fingerprint: '',
|
|
70
70
|
utcUnixTimeExpiration: Date.parse(new Date().toString()),
|
|
71
71
|
object: object,
|
|
72
72
|
};
|
|
@@ -326,7 +326,7 @@ var PaymentGatewayClient = /** @class */ (function () {
|
|
|
326
326
|
var verify;
|
|
327
327
|
return __generator(this, function (_a) {
|
|
328
328
|
switch (_a.label) {
|
|
329
|
-
case 0: return [4 /*yield*/, signatureHelper_1.SignatureHelper.getPlexoSignature(serverSignedInstrumentCallback.
|
|
329
|
+
case 0: return [4 /*yield*/, signatureHelper_1.SignatureHelper.getPlexoSignature(serverSignedInstrumentCallback.Object.Fingerprint, serverSignedInstrumentCallback)];
|
|
330
330
|
case 1:
|
|
331
331
|
verify = _a.sent();
|
|
332
332
|
return [2 /*return*/, verify];
|
|
@@ -341,7 +341,7 @@ var PaymentGatewayClient = /** @class */ (function () {
|
|
|
341
341
|
switch (_a.label) {
|
|
342
342
|
case 0:
|
|
343
343
|
logger_lib_1.default.debug("SERVER SIGNED CALLBACK --> ".concat(JSON.stringify(serverSignedTransactionCallback)));
|
|
344
|
-
return [4 /*yield*/, signatureHelper_1.SignatureHelper.getPlexoSignature(serverSignedTransactionCallback.
|
|
344
|
+
return [4 /*yield*/, signatureHelper_1.SignatureHelper.getPlexoSignature(serverSignedTransactionCallback.Object.Fingerprint, serverSignedTransactionCallback)];
|
|
345
345
|
case 1:
|
|
346
346
|
verify = _a.sent();
|
|
347
347
|
return [2 /*return*/, verify];
|
|
@@ -276,7 +276,7 @@ var PaymentGatewayMock = /** @class */ (function () {
|
|
|
276
276
|
return __generator(this, function (_a) {
|
|
277
277
|
return [2 /*return*/, {
|
|
278
278
|
resultCode: IndexSDK_1.ResultCodes.Ok,
|
|
279
|
-
response: __assign(__assign({}, mocks_1.mocks.paymentInstrumentMock), {
|
|
279
|
+
response: __assign(__assign({}, mocks_1.mocks.paymentInstrumentMock), { Issuer: __assign(__assign({}, mocks_1.mocks.paymentInstrumentMock.Issuer), { issuerId: request.issuerId }) }),
|
|
280
280
|
}];
|
|
281
281
|
});
|
|
282
282
|
});
|
|
@@ -296,7 +296,7 @@ var PaymentGatewayMock = /** @class */ (function () {
|
|
|
296
296
|
return __generator(this, function (_a) {
|
|
297
297
|
return [2 /*return*/, {
|
|
298
298
|
resultCode: IndexSDK_1.ResultCodes.Ok,
|
|
299
|
-
response: __assign(__assign({}, mocks_1.mocks.instrumentCallbackMock), serverSignedInstrumentCallback.
|
|
299
|
+
response: __assign(__assign({}, mocks_1.mocks.instrumentCallbackMock), serverSignedInstrumentCallback.Object),
|
|
300
300
|
}];
|
|
301
301
|
});
|
|
302
302
|
});
|
|
@@ -306,7 +306,7 @@ var PaymentGatewayMock = /** @class */ (function () {
|
|
|
306
306
|
return __generator(this, function (_a) {
|
|
307
307
|
return [2 /*return*/, {
|
|
308
308
|
resultCode: IndexSDK_1.ResultCodes.Ok,
|
|
309
|
-
response: __assign(__assign({}, mocks_1.mocks.transactionCallbackMock), serverSignedTransactionCallback.
|
|
309
|
+
response: __assign(__assign({}, mocks_1.mocks.transactionCallbackMock), serverSignedTransactionCallback.Object),
|
|
310
310
|
}];
|
|
311
311
|
});
|
|
312
312
|
});
|
|
@@ -197,16 +197,16 @@ var getSignatureFromPlexo = function (objectToSign) { return __awaiter(void 0, v
|
|
|
197
197
|
.map(function (line) { return line.trim(); })
|
|
198
198
|
.join('');
|
|
199
199
|
signedObject = {
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
Object: objectToSign,
|
|
201
|
+
Signature: '',
|
|
202
202
|
};
|
|
203
203
|
thumbnail = getFingerprint(stringifiedCert, 'sha1', 'base64', 'hex').toUpperCase();
|
|
204
|
-
objectToSign.
|
|
204
|
+
objectToSign.Fingerprint = thumbnail;
|
|
205
205
|
canonizedObject = (0, exports.canonizeJson)(objectToSign);
|
|
206
206
|
objectoToPascalKeys = toPascalKeys(canonizedObject);
|
|
207
207
|
signKey = generateSignature(objectoToPascalKeys, privateKey);
|
|
208
|
-
signedObject.
|
|
209
|
-
signedObject.
|
|
208
|
+
signedObject.Signature = signKey;
|
|
209
|
+
signedObject.Object = canonizedObject;
|
|
210
210
|
return [2 /*return*/, signedObject];
|
|
211
211
|
}
|
|
212
212
|
});
|
|
@@ -217,11 +217,11 @@ var getSignatureFromCallback = function (response) { return __awaiter(void 0, vo
|
|
|
217
217
|
switch (_a.label) {
|
|
218
218
|
case 0:
|
|
219
219
|
object = {
|
|
220
|
-
client: response.response.
|
|
220
|
+
client: response.response.Client,
|
|
221
221
|
request: response,
|
|
222
222
|
};
|
|
223
223
|
stateObject = {
|
|
224
|
-
|
|
224
|
+
Fingerprint: '',
|
|
225
225
|
utcUnixTimeExpiration: Date.parse(new Date().toString()),
|
|
226
226
|
object: object,
|
|
227
227
|
};
|
|
@@ -230,15 +230,15 @@ var getSignatureFromCallback = function (response) { return __awaiter(void 0, vo
|
|
|
230
230
|
objectSignature = _a.sent();
|
|
231
231
|
serverResponse = {
|
|
232
232
|
response: {
|
|
233
|
-
|
|
233
|
+
Object: {
|
|
234
234
|
object: {
|
|
235
|
-
client: objectSignature.
|
|
235
|
+
client: objectSignature.Object.object.client,
|
|
236
236
|
resultCode: response.resultCode,
|
|
237
237
|
},
|
|
238
|
-
|
|
239
|
-
utcUnixTimeExpiration: objectSignature.
|
|
238
|
+
Fingerprint: objectSignature.Object.Fingerprint,
|
|
239
|
+
utcUnixTimeExpiration: objectSignature.Object.utcUnixTimeExpiration,
|
|
240
240
|
},
|
|
241
|
-
|
|
241
|
+
Signature: objectSignature.Signature,
|
|
242
242
|
},
|
|
243
243
|
resultCode: response.resultCode,
|
|
244
244
|
errorMessage: response.errorMessage,
|
|
@@ -255,7 +255,6 @@ var getPlexoKey = function (fingerprint) { return __awaiter(void 0, void 0, void
|
|
|
255
255
|
case 0: return [4 /*yield*/, client.get("/Key/".concat(fingerprint))];
|
|
256
256
|
case 1:
|
|
257
257
|
plexoResponse = _a.sent();
|
|
258
|
-
logger_lib_1.default.debug("GET PLEXO KEY RESPONSE --> ".concat(JSON.stringify(plexoResponse)));
|
|
259
258
|
if (plexoResponse.status !== 200) {
|
|
260
259
|
throw new Error("Invalid or outdated Fingerprint, server returns: ".concat(plexoResponse.data.Object.Object.ErrorMessage));
|
|
261
260
|
}
|
|
@@ -269,28 +268,29 @@ var getPlexoSignature = function (fingerprint, response) { return __awaiter(void
|
|
|
269
268
|
switch (_a.label) {
|
|
270
269
|
case 0:
|
|
271
270
|
_a.trys.push([0, 2, , 3]);
|
|
272
|
-
logger_lib_1.default.
|
|
271
|
+
logger_lib_1.default.info("FINGERPRINT TO GET PLEXO SIGNATURE --> ".concat(fingerprint));
|
|
273
272
|
return [4 /*yield*/, getPlexoKey(fingerprint)];
|
|
274
273
|
case 1:
|
|
275
274
|
plexoResponse = _a.sent();
|
|
275
|
+
logger_lib_1.default.info("FINGERPRINT RESPONSE");
|
|
276
276
|
return [3 /*break*/, 3];
|
|
277
277
|
case 2:
|
|
278
278
|
err_1 = _a.sent();
|
|
279
279
|
logger_lib_1.default.error({ err: err_1 }, 'Error getting plexo certificate');
|
|
280
280
|
serverResponse = {
|
|
281
|
-
response: response.
|
|
281
|
+
response: response.Object.object,
|
|
282
282
|
resultCode: __1.ResultCodes.InvalidFingerprint,
|
|
283
283
|
errorMessage: err_1,
|
|
284
284
|
};
|
|
285
285
|
return [2 /*return*/, serverResponse];
|
|
286
286
|
case 3:
|
|
287
287
|
key = "-----BEGIN CERTIFICATE-----\n".concat(plexoResponse.Object.Object.Response.Key, "\n-----END CERTIFICATE-----");
|
|
288
|
-
objectBuffer = new util_1.TextEncoder().encode((0, stringifyWithFloats_1.stringifyAmountsWithFloats)(response.
|
|
288
|
+
objectBuffer = new util_1.TextEncoder().encode((0, stringifyWithFloats_1.stringifyAmountsWithFloats)(response.Object));
|
|
289
289
|
verifySignature = (0, crypto_1.createVerify)('SHA512')
|
|
290
290
|
.update(objectBuffer)
|
|
291
|
-
.verify(key, response.
|
|
291
|
+
.verify(key, response.Signature, 'base64');
|
|
292
292
|
serverResponse = {
|
|
293
|
-
response: response.
|
|
293
|
+
response: response.Object.object,
|
|
294
294
|
resultCode: verifySignature ? __1.ResultCodes.Ok : __1.ResultCodes.InvalidSignature,
|
|
295
295
|
errorMessage: verifySignature ? "Signature do not match" : 'Success',
|
|
296
296
|
};
|
package/lib/sdk/mocks/mocks.js
CHANGED
|
@@ -49,16 +49,16 @@ var issuerMock = {
|
|
|
49
49
|
fields: [fieldMock],
|
|
50
50
|
};
|
|
51
51
|
var paymentInstrumentMock = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
InstrumentToken: 'token',
|
|
53
|
+
Name: 'mockedInstrument',
|
|
54
|
+
Issuer: issuerMock,
|
|
55
|
+
SupportedCurrencies: [currencyMock],
|
|
56
|
+
Status: IndexSDK_1.CardStatus.Ok,
|
|
57
|
+
InstrumentExpirationUTC: 1919276061,
|
|
58
|
+
CreditLimits: [amountLimitMock],
|
|
59
|
+
AdditionalRequirements: [timeLimitMock],
|
|
60
|
+
InstrumentInformation: null,
|
|
61
|
+
SessionCreationId: 'MockedId',
|
|
62
62
|
};
|
|
63
63
|
var financialInclusionMock = {
|
|
64
64
|
isApplied: true,
|
|
@@ -138,9 +138,9 @@ var issuerProcessorMock = {
|
|
|
138
138
|
paymentProcessors: [paymentProcessorMock],
|
|
139
139
|
};
|
|
140
140
|
var clientSignedResponseMock = {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
Signature: 'signature',
|
|
142
|
+
Object: {
|
|
143
|
+
Fingerprint: 'fingerprint',
|
|
144
144
|
utcUnixTimeExpiration: 1919276061,
|
|
145
145
|
object: {
|
|
146
146
|
client: 'PlexoMock',
|
|
@@ -148,13 +148,13 @@ var clientSignedResponseMock = {
|
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
150
|
};
|
|
151
|
-
var transactionCallbackMock = __assign(__assign({}, transactionMock), {
|
|
151
|
+
var transactionCallbackMock = __assign(__assign({}, transactionMock), { Client: 'PlexoMock' });
|
|
152
152
|
var instrumentCallbackMock = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
Action: IndexSDK_1.ActionType.RegisterInstrument,
|
|
154
|
+
Client: 'PlexoMock',
|
|
155
|
+
SessionId: (0, crypto_1.randomUUID)(),
|
|
156
|
+
OptionalMetadata: 'metadata',
|
|
157
|
+
PaymentInstrument: paymentInstrumentMock,
|
|
158
158
|
};
|
|
159
159
|
exports.mocks = {
|
|
160
160
|
currencyMock: currencyMock,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GenericStateObject } from './GenericStateObject';
|
|
2
2
|
export declare class GenericSignedObject<T> {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object: GenericStateObject<T>;
|
|
4
|
+
Signature: string;
|
|
5
5
|
constructor(Object: GenericStateObject<T>, Signature: string);
|
|
6
6
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GenericSignedObject = void 0;
|
|
4
4
|
var GenericSignedObject = /** @class */ (function () {
|
|
5
5
|
function GenericSignedObject(Object, Signature) {
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
6
|
+
this.Object = Object;
|
|
7
|
+
this.Signature = Signature;
|
|
8
8
|
}
|
|
9
9
|
return GenericSignedObject;
|
|
10
10
|
}());
|
|
@@ -2,8 +2,8 @@ import { PaymentInstrument as PaymentInstrumentModel } from '..';
|
|
|
2
2
|
import { ActionType } from './ActionType';
|
|
3
3
|
import { InstrumentWithMetadata } from './InstrumentWithMetadata';
|
|
4
4
|
export declare class InstrumentCallback extends InstrumentWithMetadata {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
SessionId: string;
|
|
6
|
+
Client: string;
|
|
7
|
+
Action: ActionType;
|
|
8
8
|
constructor(SessionId: string, Client: string, Action: ActionType, PaymentInstrument: PaymentInstrumentModel, OptionalMetadata: string);
|
|
9
9
|
}
|
|
@@ -21,9 +21,9 @@ var InstrumentCallback = /** @class */ (function (_super) {
|
|
|
21
21
|
__extends(InstrumentCallback, _super);
|
|
22
22
|
function InstrumentCallback(SessionId, Client, Action, PaymentInstrument, OptionalMetadata) {
|
|
23
23
|
var _this = _super.call(this, PaymentInstrument, OptionalMetadata) || this;
|
|
24
|
-
_this.
|
|
25
|
-
_this.
|
|
26
|
-
_this.
|
|
24
|
+
_this.SessionId = SessionId;
|
|
25
|
+
_this.Client = Client;
|
|
26
|
+
_this.Action = Action;
|
|
27
27
|
return _this;
|
|
28
28
|
}
|
|
29
29
|
return InstrumentCallback;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PaymentInstrument } from './PaymentInstrument';
|
|
2
2
|
export declare class InstrumentWithMetadata {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(
|
|
3
|
+
PaymentInstrument: PaymentInstrument;
|
|
4
|
+
OptionalMetadata: string;
|
|
5
|
+
constructor(InstrumentPayment: PaymentInstrument, OptionalMetadata: string);
|
|
6
6
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InstrumentWithMetadata = void 0;
|
|
4
4
|
var InstrumentWithMetadata = /** @class */ (function () {
|
|
5
|
-
function InstrumentWithMetadata(
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
5
|
+
function InstrumentWithMetadata(InstrumentPayment, OptionalMetadata) {
|
|
6
|
+
this.PaymentInstrument = InstrumentPayment;
|
|
7
|
+
this.OptionalMetadata = OptionalMetadata;
|
|
8
8
|
}
|
|
9
9
|
return InstrumentWithMetadata;
|
|
10
10
|
}());
|
|
@@ -4,15 +4,15 @@ import { Currency } from './Currency';
|
|
|
4
4
|
import { IssuerInfo } from './IssuerInfo';
|
|
5
5
|
import { TimeLimit } from './TimeLimit';
|
|
6
6
|
export declare type PaymentInstrument = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
InstrumentToken: string;
|
|
8
|
+
Name: string;
|
|
9
|
+
Issuer: IssuerInfo;
|
|
10
|
+
SupportedCurrencies: Currency[];
|
|
11
|
+
Status: CardStatus;
|
|
12
|
+
InstrumentExpirationUTC: number;
|
|
13
|
+
AnonInstrumentUsageTimeLimit?: number;
|
|
14
|
+
CreditLimits: AmountLimit[];
|
|
15
|
+
AdditionalRequirements: TimeLimit[];
|
|
16
|
+
InstrumentInformation: any;
|
|
17
|
+
SessionCreationId: string;
|
|
18
18
|
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StateObject = void 0;
|
|
4
4
|
var StateObject = /** @class */ (function () {
|
|
5
|
-
function StateObject(
|
|
6
|
-
this.
|
|
5
|
+
function StateObject(Fingerprint, utcUnixTimeExpiration) {
|
|
6
|
+
this.Fingerprint = Fingerprint;
|
|
7
7
|
this.utcUnixTimeExpiration = utcUnixTimeExpiration;
|
|
8
8
|
}
|
|
9
9
|
return StateObject;
|
|
@@ -2,6 +2,6 @@ import { Commerce as CommerceModel, Currency as CurrencyModel, FinancialInclusio
|
|
|
2
2
|
import { PaymentCode as PaymentCodeModel } from './CodeAction';
|
|
3
3
|
import { Transaction } from './Transaction';
|
|
4
4
|
export declare class TransactionCallback extends Transaction {
|
|
5
|
-
|
|
5
|
+
Client: string;
|
|
6
6
|
constructor(Client: string, TransactionId: string, Commerce: CommerceModel, InstrumentToken: string, InstrumentName: string, Issuer: IssuerInfoModel, Amount: number, Installments: number, Currency: CurrencyModel, IsAnonymous: boolean, CurrentState: TransactionTypeModel, InvoiceNumber: string, FinancialInclusion: FinancialInclusionResultModel, Transactions: any, FieldInformation: any, IsAsyncPayment: boolean, PaymentCode: PaymentCodeModel, UTCUnixTimeExpiration: number);
|
|
7
7
|
}
|
|
@@ -21,7 +21,7 @@ var TransactionCallback = /** @class */ (function (_super) {
|
|
|
21
21
|
__extends(TransactionCallback, _super);
|
|
22
22
|
function TransactionCallback(Client, TransactionId, Commerce, InstrumentToken, InstrumentName, Issuer, Amount, Installments, Currency, IsAnonymous, CurrentState, InvoiceNumber, FinancialInclusion, Transactions, FieldInformation, IsAsyncPayment, PaymentCode, UTCUnixTimeExpiration) {
|
|
23
23
|
var _this = _super.call(this, TransactionId, Commerce, InstrumentToken, InstrumentName, Issuer, Amount, Installments, Currency, IsAnonymous, CurrentState, InvoiceNumber, FinancialInclusion, Transactions, FieldInformation, IsAsyncPayment, PaymentCode, UTCUnixTimeExpiration) || this;
|
|
24
|
-
_this.
|
|
24
|
+
_this.Client = Client;
|
|
25
25
|
return _this;
|
|
26
26
|
}
|
|
27
27
|
return TransactionCallback;
|