Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

paypal-rest-api

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paypal-rest-api - npm Package Compare versions

Comparing version 0.0.43 to 0.0.44

8

lib/abstracts/api/index.d.ts
import * as joi from "joi";
import { Client, RequestOptions } from "../../client";
import { IApiPaths, IApiSchemas, IPathReplacers, UpdateRequest } from "./types";
import { IApiSchemas, IPathReplacers, UpdateRequest } from "./types";
export * from "./types";

@@ -9,6 +9,6 @@ export declare abstract class Api {

private _paths;
constructor(_client: Client, _schemas: IApiSchemas, _paths: IApiPaths);
constructor(_client: Client, _schemas: IApiSchemas, _paths: any);
readonly client: Client;
readonly schemas: IApiSchemas;
readonly paths: IApiPaths;
readonly paths: any;
get(id: string, options?: Partial<RequestOptions>): Promise<any>;

@@ -20,4 +20,4 @@ create(options?: Partial<RequestOptions>): Promise<any>;

update(id: string, payload: UpdateRequest | any, options?: Partial<RequestOptions>): Promise<any>;
parsePath(path: string, replacers: IPathReplacers): string;
protected schemaValidate(what: any, schema: joi.Schema, additional?: joi.ValidationOptions): any;
protected parsePath(path: string, replacers: IPathReplacers): string;
}

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

}
parsePath(path, replacers) {
const rpath = path.replace("{id}", replacers.id);
return rpath;
}
schemaValidate(what, schema, additional = {}) {

@@ -99,7 +103,3 @@ const validate = joi.validate(what, schema, additional);

}
parsePath(path, replacers) {
const rpath = path.replace("{id}", replacers.id);
return rpath;
}
}
exports.Api = Api;

@@ -5,6 +5,7 @@ import { IConfigureOptions } from "../";

export declare class Client {
private config;
private _config;
oauth: Oauth;
constructor(config: IConfigureOptions);
constructor(_config: IConfigureOptions);
config: IConfigureOptions;
request(options: Partial<RequestOptions>): Promise<any>;
}

@@ -17,6 +17,12 @@ "use strict";

class Client {
constructor(config) {
this.config = config;
this.oauth = new oauth_1.Oauth(this, config.client_id, config.client_secret);
constructor(_config) {
this._config = _config;
this.oauth = new oauth_1.Oauth(this, this.config.client_id, this.config.client_secret);
}
get config() {
return this._config;
}
set config(config) {
this._config = config;
}
request(options) {

@@ -23,0 +29,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -16,3 +16,3 @@ import * as joi from "joi";

};
private token;
token: IAccessToken;
constructor(client: Client, _clientId: string, _clientSecret: string);

@@ -19,0 +19,0 @@ clientId: string;

@@ -24,2 +24,3 @@ import * as joi from "joi";

simulate(options?: Partial<RequestOptions>): Promise<any>;
private logResend(webhookEvent);
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,14 +26,34 @@ const abstracts_1 = require("../abstracts");

verify(options = {}) {
options.uri = WebhookEventApi.paths.verify;
options = this.schemaValidate(options, WebhookEventApi.schemas.verify);
const stringy = JSON.stringify({
auth_algo: options.body.auth_algo,
cert_url: options.body.cert_url,
transmission_id: options.body.transmission_id,
transmission_sig: options.body.transmission_sig,
transmission_time: options.body.transmission_time,
webhook_id: options.body.webhook_id,
return __awaiter(this, void 0, void 0, function* () {
options.uri = WebhookEventApi.paths.verify;
options = this.schemaValidate(options, WebhookEventApi.schemas.verify);
let parsedEvent;
try {
parsedEvent = JSON.parse(options.body.webhook_event);
}
catch (err) {
throw new Error("Webhook event is malformed");
}
const stringy = JSON.stringify({
auth_algo: options.body.auth_algo,
cert_url: options.body.cert_url,
transmission_id: options.body.transmission_id,
transmission_sig: options.body.transmission_sig,
transmission_time: options.body.transmission_time,
webhook_id: options.body.webhook_id,
});
options.body = stringy.slice(0, -1) + `,"webhook_event":${options.body.webhook_event}` + "}";
try {
const response = yield this.client.request(options);
const parsedResponse = JSON.parse(response.body);
if (parsedResponse.verification_status !== "SUCCESS") {
throw parsedResponse;
}
return parsedResponse;
}
catch (err) {
this.logResend(parsedEvent);
throw err;
}
});
options.body = stringy.slice(0, -1) + `,"webhook_event":${options.body.webhook_event}` + "}";
return this.client.request(options);
}

@@ -37,2 +65,7 @@ simulate(options = {}) {

}
logResend(webhookEvent) {
if (process.env.NODE_ENV === "development") {
console.log(`Webhook Resend: curl -X POST -v -H "Content-Type:application/json" -H "Authorization: Bearer ${this.client.oauth.token.access_token}" -d '{}' ${this.client.config.requestOptions.baseUrl + this.parsePath(this.paths.resend, { id: webhookEvent.id })}`);
}
}
}

@@ -39,0 +72,0 @@ WebhookEventApi.paths = {

{
"name": "paypal-rest-api",
"version": "0.0.43",
"version": "0.0.44",
"description": "A typescript module for integrating with PayPal REST APIs.",

@@ -5,0 +5,0 @@ "license": "MIT",

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