New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tikkie-checkout

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tikkie-checkout - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

8

lib/client.d.ts

@@ -5,8 +5,12 @@ import { TikkieCheckoutConfig } from './config';

import { CreateOrder } from './models/createOrder';
export interface TikkieCheckoutClientOptions {
apiKey: string;
merchantToken: string;
useSandbox?: boolean;
}
export declare class TikkieCheckoutClient {
config: TikkieCheckoutConfig;
constructor(config: TikkieCheckoutConfig);
authenticate(): Promise<void>;
constructor(config: TikkieCheckoutClientOptions);
createOrder(data: CreateOrder): Promise<CreatedOrder>;
getOrder(orderToken: string): Promise<Order>;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("./config");
const defaultTikkieCheckoutClientOptions = {
useSandbox: false,
};
Object.defineProperty(exports, "__esModule", { value: true });
class TikkieCheckoutClient {
constructor(config) {
this.config = config;
const { apiKey, merchantToken, useSandbox } = Object.assign(Object.assign({}, defaultTikkieCheckoutClientOptions), config);
this.config = new config_1.TikkieCheckoutConfig(apiKey, merchantToken, useSandbox);
}
authenticate() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.config.getAccessToken();
}
catch (err) {
throw err;
}
});
}
createOrder(data) {

@@ -27,0 +13,0 @@ return this.config.postRequest('/v1/tikkie/fastcheckout/orders', data);

@@ -1,4 +0,2 @@

import { AccessToken } from './accessToken';
export declare class TikkieCheckoutConfig {
accessToken: AccessToken;
apiKey: string;

@@ -8,11 +6,5 @@ merchantToken: string;

apiUrl: string;
tokenAudience: string;
privateKey: string;
algorithm: string;
constructor(apiKey: string, merchantToken: string, useSandbox?: boolean);
loadPrivateKey(path: string, algorithm?: string): void;
loadPrivateKeyFromString(privateKey: string, algorithm?: string): void;
createHeaders(): Record<string, string>;
getJsonWebToken(): string;
getAccessToken(): Promise<string>;
request<T>(method: 'GET' | 'POST', endpoint: string, options?: {

@@ -19,0 +11,0 @@ query: {

@@ -12,13 +12,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const url_1 = require("url");
const querystring = require("query-string");
const node_fetch_1 = require("node-fetch");
const jsonwebtoken_1 = require("jsonwebtoken");
const accessToken_1 = require("./accessToken");
const error_1 = require("./error");
const PRODUCTION_API_URL = 'https://api.abnamro.com';
const PRODUCTION_TOKEN_AUDIENCE = 'https://auth.abnamro.com/oauth/token';
const SANDBOX_API_URL = 'https://api-sandbox.abnamro.com';
const SANDBOX_TOKEN_AUDIENCE = 'https://auth-sandbox.abnamro.com/oauth/token';
class TikkieCheckoutConfig {

@@ -30,13 +24,3 @@ constructor(apiKey, merchantToken, useSandbox = false) {

this.apiUrl = useSandbox ? SANDBOX_API_URL : PRODUCTION_API_URL;
this.tokenAudience = useSandbox
? SANDBOX_TOKEN_AUDIENCE
: PRODUCTION_TOKEN_AUDIENCE;
}
loadPrivateKey(path, algorithm = 'RS256') {
this.loadPrivateKeyFromString(fs.readFileSync(path, 'utf8'), algorithm);
}
loadPrivateKeyFromString(privateKey, algorithm = 'RS256') {
this.privateKey = privateKey;
this.algorithm = algorithm;
}
createHeaders() {

@@ -49,43 +33,2 @@ const headers = {};

}
getJsonWebToken() {
return jsonwebtoken_1.default.sign({}, this.privateKey, {
algorithm: this.algorithm,
expiresIn: '3m',
notBefore: '-1m',
issuer: 'node-tikkie-checkout',
subject: this.apiKey,
audience: this.tokenAudience,
});
}
getAccessToken() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.accessToken || this.accessToken.hasExpired()) {
try {
const body = new url_1.URLSearchParams();
body.append('client_assertion_type', 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer');
body.append('client_assertion', this.getJsonWebToken());
body.append('grant_type', 'client_credentials');
body.append('scope', 'tikkie');
const headers = this.createHeaders();
headers['Content-Type'] = 'application/x-www-form-urlencoded';
const response = yield node_fetch_1.default(`${this.apiUrl}/v1/oauth/token`, {
method: 'POST',
headers,
body,
});
const result = yield response.json();
if (response.status >= 200 && response.status <= 399) {
this.accessToken = new accessToken_1.AccessToken(result);
}
else {
throw new error_1.TikkieErrorCollection(result.errors);
}
}
catch (err) {
throw err;
}
}
return this.accessToken.token;
});
}
request(method, endpoint, options = { query: null, data: null }) {

@@ -95,12 +38,2 @@ return __awaiter(this, void 0, void 0, function* () {

const headers = this.createHeaders();
if (!this.useSandbox) {
let token;
try {
token = yield this.getAccessToken();
}
catch (err) {
throw err;
}
headers.Authorization = `Bearer ${token}`;
}
if (method === 'POST' && options.data) {

@@ -107,0 +40,0 @@ headers['Content-Type'] = 'application/json';

@@ -1,4 +0,3 @@

export * from './accessToken';
export * from './error';
export * from './client';
export * from './config';

@@ -6,3 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./accessToken"));
__export(require("./error"));

@@ -9,0 +8,0 @@ __export(require("./client"));

{
"name": "tikkie-checkout",
"description": "TypeScript implementation of the Tikkie Fast Checkout API.",
"version": "1.0.9",
"version": "1.0.10",
"license": "MIT",

@@ -35,3 +35,2 @@ "author": "Toon van Strijp <toonvanstrijp@gmail.com> (https://www.toonvanstrijp.com)",

"dependencies": {
"jsonwebtoken": "^8.5.1",
"node-fetch": "^2.6.0",

@@ -42,3 +41,2 @@ "query-string": "^6.9.0",

"devDependencies": {
"@types/jsonwebtoken": "^8.3.5",
"@types/node": "^13.1.1",

@@ -45,0 +43,0 @@ "@types/node-fetch": "^2.5.4",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc