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

node-ninjacat

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ninjacat - npm Package Compare versions

Comparing version 0.1.17 to 0.1.18

120

global.d.ts

@@ -0,5 +1,24 @@

declare module 'JSONStream';
declare namespace Ninjacat {
interface Advertiser {
interface CustomField {
id: number;
name: string;
}
interface CustomFieldValue {
id: number;
custom_field_id: number;
name: string;
advertiserIds: number[];
}
type AgencyID = number;
type ReportID = number;
type TemplateID = number;
type AdvertiserID = number;
interface Advertiser {
id: AdvertiserID;
name: string;
phone?: string;

@@ -28,65 +47,62 @@ company: string;

custom_field?: string;
account_custom_field_values: Array<CustomFieldValues>;
account_custom_field_values: Array<CustomFieldValue>;
}
interface ReportPending {
status: 0;
id: ReportID;
}
type Response = { error: string } | { [key: string]: any };
interface ReportRunning {
status: 1;
id: ReportID;
}
namespace Report {
interface GReport {
[key: string]: number;
}
interface Report<T> {
success: boolean;
id: ReportID;
title: string;
dataRows: {
rows: Array<T>;
totals: Array<T>;
dataSampled: boolean;
type Generic = GReport & {
dimensions: object;
};
errors: {
[key: string]: {
type: string;
msg: string;
devMsg: string;
userMsg: string;
error: string;
info: Array<any>;
widgetArchiveId: number;
widgetId: number;
exceptionMessages: Array<any>;
interface Report<T> {
success: boolean;
id: ReportID;
title: string;
dataRows: {
rows: Array<T>;
totals: Array<T>;
dataSampled: boolean;
};
};
}
errors: {
[key: string]: {
type: string;
msg: string;
devMsg: string;
userMsg: string;
error: string;
info: Array<any>;
widgetArchiveId: number;
widgetId: number;
exceptionMessages: Array<any>;
};
};
}
interface GReport {
[key: string]: number;
}
interface Pending {
status: 0;
id: ReportID;
}
type GenericReport = GReport & { dimensions: object };
interface Running {
status: 1;
id: ReportID;
}
interface ReportReady {
status: 2;
id: ReportID;
data: Array<Report<GenericReport>>;
}
interface Ready {
status: 2;
id: ReportID;
data: Array<Report<Generic>>;
}
interface ErrorResponse {
error_message: string;
}
interface Error {
error_message: string;
}
type ReportResponse = ReportPending | ReportRunning | ReportReady;
interface CustomFieldValues {
[key: string]: number;
type Response = Pending | Running | Ready | Error;
}
type AgencyID = number;
type ReportID = number;
type TemplateID = number;
type AdvertiserID = number;
}
/// <reference path="../global.d.ts" />
import Request from 'request';
import Request, { CoreOptions } from 'request';
interface NinjacatClientOpts {

@@ -25,3 +25,3 @@ client_id: string;

}>;
get: (request_id: RequestID) => Promise<Ninjacat.ReportResponse>;
get: (request_id: RequestID) => Promise<Ninjacat.Report.Response>;
};

@@ -32,4 +32,7 @@ request: Request.RequestAPI<Request.Request, Request.CoreOptions, Request.RequiredUriUrl>;

auth(): Promise<any>;
post(endpoint: string, options?: CoreOptions): Ninjacat.Response;
get(endpoint: string, options?: CoreOptions): Promise<Ninjacat.Response>;
del(endpoint: string, options?: CoreOptions): Promise<Ninjacat.Response>;
advertisers(): Promise<Array<Ninjacat.Advertiser>>;
}
export {};

@@ -7,6 +7,7 @@ "use strict";

/// <reference path="../global.d.ts" />
const debug_1 = __importDefault(require("debug"));
const request_1 = __importDefault(require("request"));
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
// @ts-ignore
const JSONStream_1 = __importDefault(require("JSONStream"));
const debug = debug_1.default('ninjacat');
function isError(response) {

@@ -29,4 +30,4 @@ return (response && response.error_message != undefined);

Accept: 'application/json',
'x-api-key': this.agency_identifier,
},
'x-api-key': this.agency_identifier
}
});

@@ -38,3 +39,3 @@ this.report = {

agency_id: this.agency_id,
request_id,
request_id
};

@@ -46,4 +47,4 @@ const token = jsonwebtoken_1.default.sign(payload, this.report_secret);

Accept: 'application/json',
Authorization: `Bearer ${token}`,
},
Authorization: `Bearer ${token}`
}
};

@@ -77,3 +78,3 @@ return new Promise((resolve, reject) => {

template_id,
advertiser_id,
advertiser_id
].join('/');

@@ -83,3 +84,3 @@ const payload = {

template_id,
advertiser_id,
advertiser_id
};

@@ -91,4 +92,4 @@ const token = jsonwebtoken_1.default.sign(payload, this.report_secret);

Accept: 'application/json',
Authorization: `Bearer ${token}`,
},
Authorization: `Bearer ${token}`
}
};

@@ -119,3 +120,3 @@ if (opts) {

});
},
}
};

@@ -131,4 +132,4 @@ }

'Content-Type': 'application/x-www-form-urlencoded',
Authorization: `Basic ${basic}`,
},
Authorization: `Basic ${basic}`
}
}, (err, _res, body) => {

@@ -142,4 +143,4 @@ if (err) {

Authorization: `Bearer ${body.access_token}`,
'Content-Type': 'application/json',
},
'Content-Type': 'application/json'
}
});

@@ -152,2 +153,61 @@ resolve();

}
post(endpoint, options = {}) {
debug(`POST => ${endpoint}`);
let response;
return new Promise((resolve, reject) => {
this.request
.post(endpoint, options)
.on('error', reject)
.pipe(JSONStream_1.default.parse())
.once('data', (res) => {
if (res.error) {
reject(new Error(res.error));
}
else {
response = res;
}
})
.on('end', () => resolve(response));
});
}
get(endpoint, options = {}) {
debug(`GET => ${endpoint}`);
let response;
return new Promise((resolve, reject) => {
this.request
.get(endpoint, options)
.on('error', reject)
.pipe(JSONStream_1.default.parse())
.once('data', (res) => {
if (res.error) {
reject(new Error(res.error));
}
else {
response = res;
}
})
.on('end', () => resolve(response));
});
}
del(endpoint, options = {}) {
debug(`DEL => ${endpoint}`);
let response;
return new Promise((resolve, reject) => {
this.request
.del(endpoint, options)
.on('error', reject)
.pipe(JSONStream_1.default.parse())
.once('data', (res) => {
if (res.error) {
reject(new Error(res.error));
}
else {
response = res;
}
})
.on('end', () => {
resolve(response);
});
});
}
async advertisers() {

@@ -154,0 +214,0 @@ await this.auth();

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

Object.defineProperty(exports, "__esModule", { value: true });
const Client_1 = __importDefault(require("./Client"));
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
const env = process.env;

@@ -15,9 +15,29 @@ const client_id = env.client_id;

async function main() {
const client = new Client_1.default({
client_id,
client_secret,
agency_id,
agency_identifier,
report_secret,
});
const request_id = 120623;
const payload = {
agency_id: agency_id,
request_id
};
const token = jsonwebtoken_1.default.sign(payload, report_secret);
console.log(token);
// const config: any = {
// json: true,
// headers: {
// Accept: 'application/json',
// Authorization: `Bearer ${token}`
// }
// };
// const path = ['open_api/report', agency_id, request_id].join('/');
// Request.get(
// `https://app.ninjacat.io/${path}`,
// config,
// function processReportGet(err, res, body: Ninjacat.Report.Response) {
// if (err) {
// throw err;
// }
// const { statusCode } = res;
// console.log(statusCode);
// console.log(JSON.stringify(body, null, 2));
// }
// );
// const advertisers = await client.advertisers();

@@ -30,8 +50,8 @@ // advertisers;

// });
const res = await client.report.get(118105);
if (res.status === 2) {
console.log(res.data[0].dataRows.rows);
}
// const res = await client.report.get(118105);
// if (res.status === 2) {
// console.log(res.data[0].dataRows.rows);
// }
}
main();
//# sourceMappingURL=test.js.map
{
"name": "node-ninjacat",
"description": "Reporting & Management API Client for https://www.ninjacat.io/",
"version": "0.1.17",
"version": "0.1.18",
"main": "./lib/Client.js",

@@ -10,2 +10,3 @@ "types": "./lib/Client.d.ts",

"JSONStream": "^1.3.5",
"debug": "^4.1.1",
"jsonwebtoken": "^8.5.1",

@@ -15,2 +16,3 @@ "request": "^2.88.2"

"devDependencies": {
"@types/debug": "^4.1.5",
"@types/jsonwebtoken": "^8.3.9",

@@ -22,4 +24,4 @@ "@types/request": "^2.48.4",

"scripts": {
"prepare": "tsc"
"prepack": "tsc"
}
}

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