pusher-platform-node
Advanced tools
Comparing version 0.4.2 to 0.4.3
{ | ||
"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
48013
851
107
3
+ Addedbody-parser@^1.17.2
+ Addedbody-parser@1.20.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedunpipe@1.0.0(transitive)
- Removedms@2.1.3(transitive)