@houlak/plexo-sdk 0.1.5 → 0.1.6

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.
@@ -66,9 +66,9 @@ var requestToPlexo = function (endpoint, request) { return __awaiter(void 0, voi
66
66
  request: request,
67
67
  };
68
68
  stateObject = {
69
- fingerprint: '',
70
- utcUnixTimeExpiration: Date.parse(new Date().toString()),
71
- object: object,
69
+ Fingerprint: '',
70
+ UtcUnixTimeExpiration: Date.parse(new Date().toString()),
71
+ Object: object,
72
72
  };
73
73
  return [4 /*yield*/, signatureHelper_1.SignatureHelper.getSignatureFromPlexo(stateObject)];
74
74
  case 1:
@@ -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.object.fingerprint, 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];
@@ -339,7 +339,7 @@ var PaymentGatewayClient = /** @class */ (function () {
339
339
  var verify;
340
340
  return __generator(this, function (_a) {
341
341
  switch (_a.label) {
342
- case 0: return [4 /*yield*/, signatureHelper_1.SignatureHelper.getPlexoSignature(serverSignedTransactionCallback.object.fingerprint, serverSignedTransactionCallback)];
342
+ case 0: return [4 /*yield*/, signatureHelper_1.SignatureHelper.getPlexoSignature(serverSignedTransactionCallback.Object.Fingerprint, serverSignedTransactionCallback)];
343
343
  case 1:
344
344
  verify = _a.sent();
345
345
  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), { issuer: __assign(__assign({}, mocks_1.mocks.paymentInstrumentMock.issuer), { issuerId: request.issuerId }) }),
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.object),
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.object),
309
+ response: __assign(__assign({}, mocks_1.mocks.transactionCallbackMock), serverSignedTransactionCallback.Object),
310
310
  }];
311
311
  });
312
312
  });
@@ -5,6 +5,6 @@ export declare const SignatureHelper: {
5
5
  getCertificate: () => Promise<Certificate>;
6
6
  getSignatureFromPlexo: <T extends object>(objectToSign: GenericStateObject<T>) => Promise<GenericSignedObject<T>>;
7
7
  getSignatureFromCallback: (response: ServerResponse<InstrumentCallback | TransactionCallback>) => Promise<ServerResponse<ClientSignedResponse>>;
8
- getPlexoSignature: <T_1 extends object>(fingerprint: string, response: GenericSignedObject<T_1>) => Promise<ServerResponse<T_1>>;
8
+ getPlexoSignature: <T_1 extends object>(Fingerprint: string, response: GenericSignedObject<T_1>) => Promise<ServerResponse<T_1>>;
9
9
  toCamelKeys: <T_2 extends object>(object: T_2) => T_2;
10
10
  };
@@ -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
- object: objectToSign,
201
- signature: '',
200
+ Object: objectToSign,
201
+ Signature: '',
202
202
  };
203
203
  thumbnail = getFingerprint(stringifiedCert, 'sha1', 'base64', 'hex').toUpperCase();
204
- objectToSign.fingerprint = thumbnail;
204
+ objectToSign.Fingerprint = thumbnail;
205
205
  canonizedObject = (0, exports.canonizeJson)(objectToSign);
206
206
  objectoToPascalKeys = toPascalKeys(canonizedObject);
207
207
  signKey = generateSignature(objectoToPascalKeys, privateKey);
208
- signedObject.signature = signKey;
209
- signedObject.object = canonizedObject;
208
+ signedObject.Signature = signKey;
209
+ signedObject.Object = canonizedObject;
210
210
  return [2 /*return*/, signedObject];
211
211
  }
212
212
  });
@@ -217,28 +217,28 @@ 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.client,
220
+ client: response.response.Client,
221
221
  request: response,
222
222
  };
223
223
  stateObject = {
224
- fingerprint: '',
225
- utcUnixTimeExpiration: Date.parse(new Date().toString()),
226
- object: object,
224
+ Fingerprint: '',
225
+ UtcUnixTimeExpiration: Date.parse(new Date().toString()),
226
+ Object: object,
227
227
  };
228
228
  return [4 /*yield*/, getSignatureFromPlexo(stateObject)];
229
229
  case 1:
230
230
  objectSignature = _a.sent();
231
231
  serverResponse = {
232
232
  response: {
233
- object: {
234
- object: {
235
- client: objectSignature.object.object.client,
233
+ Object: {
234
+ Object: {
235
+ client: objectSignature.Object.Object.client,
236
236
  resultCode: response.resultCode,
237
237
  },
238
- fingerprint: objectSignature.object.fingerprint,
239
- utcUnixTimeExpiration: objectSignature.object.utcUnixTimeExpiration,
238
+ Fingerprint: objectSignature.Object.Fingerprint,
239
+ UtcUnixTimeExpiration: objectSignature.Object.UtcUnixTimeExpiration,
240
240
  },
241
- signature: objectSignature.signature,
241
+ Signature: objectSignature.Signature,
242
242
  },
243
243
  resultCode: response.resultCode,
244
244
  errorMessage: response.errorMessage,
@@ -262,13 +262,13 @@ var getPlexoKey = function (fingerprint) { return __awaiter(void 0, void 0, void
262
262
  }
263
263
  });
264
264
  }); };
265
- var getPlexoSignature = function (fingerprint, response) { return __awaiter(void 0, void 0, void 0, function () {
265
+ var getPlexoSignature = function (Fingerprint, response) { return __awaiter(void 0, void 0, void 0, function () {
266
266
  var serverResponse, plexoResponse, err_1, key, objectBuffer, verifySignature;
267
267
  return __generator(this, function (_a) {
268
268
  switch (_a.label) {
269
269
  case 0:
270
270
  _a.trys.push([0, 2, , 3]);
271
- return [4 /*yield*/, getPlexoKey(fingerprint)];
271
+ return [4 /*yield*/, getPlexoKey(Fingerprint)];
272
272
  case 1:
273
273
  plexoResponse = _a.sent();
274
274
  return [3 /*break*/, 3];
@@ -276,19 +276,19 @@ var getPlexoSignature = function (fingerprint, response) { return __awaiter(void
276
276
  err_1 = _a.sent();
277
277
  logger_lib_1.default.error({ err: err_1 }, 'Error getting plexo certificate');
278
278
  serverResponse = {
279
- response: response.object.object,
279
+ response: response.Object.Object,
280
280
  resultCode: __1.ResultCodes.InvalidFingerprint,
281
281
  errorMessage: err_1,
282
282
  };
283
283
  return [2 /*return*/, serverResponse];
284
284
  case 3:
285
285
  key = "-----BEGIN CERTIFICATE-----\n".concat(plexoResponse.Object.Object.Response.Key, "\n-----END CERTIFICATE-----");
286
- objectBuffer = new util_1.TextEncoder().encode((0, stringifyWithFloats_1.stringifyAmountsWithFloats)(response.object));
286
+ objectBuffer = new util_1.TextEncoder().encode((0, stringifyWithFloats_1.stringifyAmountsWithFloats)(response.Object));
287
287
  verifySignature = (0, crypto_1.createVerify)('SHA512')
288
288
  .update(objectBuffer)
289
- .verify(key, response.signature, 'base64');
289
+ .verify(key, response.Signature, 'base64');
290
290
  serverResponse = {
291
- response: response.object.object,
291
+ response: response.Object.Object,
292
292
  resultCode: verifySignature ? __1.ResultCodes.Ok : __1.ResultCodes.InvalidSignature,
293
293
  errorMessage: verifySignature ? "Signature do not match" : 'Success',
294
294
  };
@@ -49,16 +49,16 @@ var issuerMock = {
49
49
  fields: [fieldMock],
50
50
  };
51
51
  var paymentInstrumentMock = {
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',
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,23 +138,23 @@ var issuerProcessorMock = {
138
138
  paymentProcessors: [paymentProcessorMock],
139
139
  };
140
140
  var clientSignedResponseMock = {
141
- signature: 'signature',
142
- object: {
143
- fingerprint: 'fingerprint',
144
- utcUnixTimeExpiration: 1919276061,
145
- object: {
141
+ Signature: 'signature',
142
+ Object: {
143
+ Fingerprint: 'fingerprint',
144
+ UtcUnixTimeExpiration: 1919276061,
145
+ Object: {
146
146
  client: 'PlexoMock',
147
147
  resultCode: IndexSDK_1.ResultCodes.Ok,
148
148
  },
149
149
  },
150
150
  };
151
- var transactionCallbackMock = __assign(__assign({}, transactionMock), { client: 'PlexoMock' });
151
+ var transactionCallbackMock = __assign(__assign({}, transactionMock), { Client: 'PlexoMock' });
152
152
  var instrumentCallbackMock = {
153
- action: IndexSDK_1.ActionType.RegisterInstrument,
154
- client: 'PlexoMock',
155
- sessionId: (0, crypto_1.randomUUID)(),
156
- optionalMetadata: 'metadata',
157
- paymentInstrument: paymentInstrumentMock,
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
- object: GenericStateObject<T>;
4
- signature: string;
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.object = Object;
7
- this.signature = Signature;
6
+ this.Object = Object;
7
+ this.Signature = Signature;
8
8
  }
9
9
  return GenericSignedObject;
10
10
  }());
@@ -1,5 +1,5 @@
1
1
  import { StateObject } from './StateObject';
2
2
  export declare class GenericStateObject<T> extends StateObject {
3
- object: T;
3
+ Object: T;
4
4
  constructor(Object: T, Fingerprint: string, UTCUnixTimeExpiration: number);
5
5
  }
@@ -21,7 +21,7 @@ var GenericStateObject = /** @class */ (function (_super) {
21
21
  __extends(GenericStateObject, _super);
22
22
  function GenericStateObject(Object, Fingerprint, UTCUnixTimeExpiration) {
23
23
  var _this = _super.call(this, Fingerprint, UTCUnixTimeExpiration) || this;
24
- _this.object = Object;
24
+ _this.Object = Object;
25
25
  return _this;
26
26
  }
27
27
  return GenericStateObject;
@@ -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
- sessionId: string;
6
- client: string;
7
- action: ActionType;
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.sessionId = SessionId;
25
- _this.client = Client;
26
- _this.action = Action;
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
- paymentInstrument: PaymentInstrument;
4
- optionalMetadata: string;
5
- constructor(paymentInstrument: PaymentInstrument, optionalMetadata: string);
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(paymentInstrument, optionalMetadata) {
6
- this.paymentInstrument = paymentInstrument;
7
- this.optionalMetadata = optionalMetadata;
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
- 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;
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
  };
@@ -1,6 +1,6 @@
1
1
  import { StateObject } from './StateObject';
2
2
  export declare class SignedObject {
3
- object: StateObject;
4
- signature: string;
5
- constructor(object: StateObject, signature: string);
3
+ Object: StateObject;
4
+ Signature: string;
5
+ constructor(Object: StateObject, Signature: string);
6
6
  }
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SignedObject = void 0;
4
4
  var SignedObject = /** @class */ (function () {
5
- function SignedObject(object, signature) {
6
- this.object = object;
7
- this.signature = signature;
5
+ function SignedObject(Object, Signature) {
6
+ this.Object = Object;
7
+ this.Signature = Signature;
8
8
  }
9
9
  return SignedObject;
10
10
  }());
@@ -1,5 +1,5 @@
1
1
  export declare class StateObject {
2
- fingerprint: string;
3
- utcUnixTimeExpiration: number;
2
+ Fingerprint: string;
3
+ UtcUnixTimeExpiration: number;
4
4
  constructor(fingerprint: string, utcUnixTimeExpiration: number);
5
5
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StateObject = void 0;
4
4
  var StateObject = /** @class */ (function () {
5
5
  function StateObject(fingerprint, utcUnixTimeExpiration) {
6
- this.fingerprint = fingerprint;
7
- this.utcUnixTimeExpiration = utcUnixTimeExpiration;
6
+ this.Fingerprint = fingerprint;
7
+ this.UtcUnixTimeExpiration = utcUnixTimeExpiration;
8
8
  }
9
9
  return StateObject;
10
10
  }());
@@ -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
- client: string;
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.client = Client;
24
+ _this.Client = Client;
25
25
  return _this;
26
26
  }
27
27
  return TransactionCallback;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@houlak/plexo-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Node SDK for Plexo payment services",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",