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

pusher-platform-node

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pusher-platform-node - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

3

package.json
{
"name": "pusher-platform-node",
"version": "0.4.2",
"version": "0.4.3",
"main": "./target/index.js",

@@ -8,2 +8,3 @@ "types": "./target/index.d.ts",

"extend": "^2.0.1",
"body-parser": "^1.17.2",
"jsonwebtoken": "^7.4.1"

@@ -10,0 +11,0 @@ },

@@ -39,3 +39,16 @@ # pusher-platform-nodejs

- `authenticatePayload` param is essentially object of type `AuthenticatePayload`. The object must have the following format: (Please note that if you using one of our client libraries they will handle this format for you)
```js
type AuthenticatePayload {
grant_type?: string;
refresh_token?: string;
};
```
```js
let authenticatePayload = {
grant_type: 'client_credentials'
};
let authOptions = {

@@ -47,11 +60,5 @@ userId: 'zan',

}
}
};
let authResponse = app.authenticate(req, {
userId: 'r00t',
serviceClaims: {
name: 'zan',
admin: true
}
});
let authResponse = app.authenticate(authenticatePayload, authOptions);
```

@@ -58,0 +65,0 @@

@@ -10,3 +10,3 @@ import extend = require("extend");

import BaseClient from "./base_client";
import {AuthenticateOptions, RequestOptions} from "./common";
import {AuthenticateOptions, RequestOptions, AuthenticatePayload} from "./common";

@@ -58,4 +58,4 @@ // 5 minutes should be enough for a single sudo request

authenticate(request: IncomingMessageWithBody, options: AuthenticateOptions): AuthenticationResponse {
return this.authenticator.authenticate(request, options);
authenticate(authenticatePayload: AuthenticatePayload, options: AuthenticateOptions): AuthenticationResponse {
return this.authenticator.authenticate(authenticatePayload, options);
}

@@ -62,0 +62,0 @@

import {IncomingMessage} from "http";
import * as jwt from "jsonwebtoken";
import {AuthenticateOptions, IncomingMessageWithBody} from "./common";
import {AuthenticateOptions, IncomingMessageWithBody, AuthenticatePayload} from "./common";
import {UnsupportedGrantTypeError, InvalidGrantTypeError} from "./errors";

@@ -37,5 +37,4 @@

authenticate(request: IncomingMessageWithBody, options: AuthenticateOptions): AuthenticationResponse {
let body = request.body; // FIXME - we should figure out better way then just rely on express.js body parser.
let grantType = body["grant_type"];
authenticate(authenticatePayload: AuthenticatePayload, options: AuthenticateOptions): AuthenticationResponse {
let grantType = authenticatePayload["grant_type"];

@@ -46,3 +45,3 @@ switch (grantType) {

case REFRESH_TOKEN_GRANT_TYPE:
let oldRefreshToken = body[REFRESH_TOKEN_GRANT_TYPE];
let oldRefreshToken = authenticatePayload[REFRESH_TOKEN_GRANT_TYPE];
return this.authenticateWithRefreshToken(oldRefreshToken, options);

@@ -49,0 +48,0 @@ default:

@@ -33,1 +33,6 @@ import {Readable} from "stream";

}
export interface AuthenticatePayload {
grant_type?: string;
refresh_token?: string;
}
/// <reference types="node" />
import { IncomingMessage } from "http";
import { IncomingMessageWithBody } from "./common";
import { TokenWithExpiry, AuthenticationResponse } from "./authenticator";
import BaseClient from "./base_client";
import { AuthenticateOptions, RequestOptions } from "./common";
import { AuthenticateOptions, RequestOptions, AuthenticatePayload } from "./common";
export interface Options {

@@ -21,3 +20,3 @@ cluster: string;

request(options: RequestOptions): Promise<IncomingMessage>;
authenticate(request: IncomingMessageWithBody, options: AuthenticateOptions): AuthenticationResponse;
authenticate(authenticatePayload: AuthenticatePayload, options: AuthenticateOptions): AuthenticationResponse;
generateAccessToken(options: AuthenticateOptions): TokenWithExpiry;

@@ -24,0 +23,0 @@ generateSuperuserJWT(): {

@@ -30,4 +30,4 @@ "use strict";

};
App.prototype.authenticate = function (request, options) {
return this.authenticator.authenticate(request, options);
App.prototype.authenticate = function (authenticatePayload, options) {
return this.authenticator.authenticate(authenticatePayload, options);
};

@@ -34,0 +34,0 @@ App.prototype.generateAccessToken = function (options) {

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

import { AuthenticateOptions, IncomingMessageWithBody } from "./common";
import { AuthenticateOptions, AuthenticatePayload } from "./common";
export declare const TOKEN_LEEWAY: number;

@@ -21,3 +21,3 @@ export interface TokenWithExpiry {

constructor(appId: string, appKeyId: string, appKeySecret: string);
authenticate(request: IncomingMessageWithBody, options: AuthenticateOptions): AuthenticationResponse;
authenticate(authenticatePayload: AuthenticatePayload, options: AuthenticateOptions): AuthenticationResponse;
private authenticateWithClientCredentials(options);

@@ -24,0 +24,0 @@ private authenticateWithRefreshToken(oldRefreshToken, options);

@@ -23,5 +23,4 @@ "use strict";

}
Authenticator.prototype.authenticate = function (request, options) {
var body = request.body; // FIXME - we should figure out better way then just rely on express.js body parser.
var grantType = body["grant_type"];
Authenticator.prototype.authenticate = function (authenticatePayload, options) {
var grantType = authenticatePayload["grant_type"];
switch (grantType) {

@@ -31,3 +30,3 @@ case CLIENT_CREDENTIALS_GRANT_TYPE:

case REFRESH_TOKEN_GRANT_TYPE:
var oldRefreshToken = body[REFRESH_TOKEN_GRANT_TYPE];
var oldRefreshToken = authenticatePayload[REFRESH_TOKEN_GRANT_TYPE];
return this.authenticateWithRefreshToken(oldRefreshToken, options);

@@ -34,0 +33,0 @@ default:

@@ -27,1 +27,5 @@ /// <reference types="node" />

}
export interface AuthenticatePayload {
grant_type?: string;
refresh_token?: string;
}

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