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

@wireapp/api-client

Package Overview
Dependencies
Maintainers
6
Versions
1434
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wireapp/api-client - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

22

dist/commonjs/auth/AuthAPI.js

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

LOGOUT: 'logout',
REGISTER: '/register'
REGISTER: '/register',
};

@@ -30,3 +30,3 @@ },

method: 'post',
url: AuthAPI.URL.COOKIES + "/remove"
url: AuthAPI.URL.COOKIES + "/remove",
};

@@ -41,5 +41,7 @@ return this.client.sendRequest(config);

method: 'post',
url: AuthAPI.URL.LOGIN + "?persist=" + login.persist
url: AuthAPI.URL.LOGIN + "?persist=" + login.persist,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -52,5 +54,7 @@ });

method: 'post',
url: AuthAPI.URL.ACCESS + "/" + AuthAPI.URL.LOGOUT
url: AuthAPI.URL.ACCESS + "/" + AuthAPI.URL.LOGOUT,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -63,5 +67,7 @@ });

method: 'post',
url: "" + AuthAPI.URL.ACCESS
url: "" + AuthAPI.URL.ACCESS,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -68,0 +74,0 @@ });

@@ -25,13 +25,13 @@ "use strict";

_this.auth = {
api: undefined
api: undefined,
};
_this.client = {
http: undefined,
ws: undefined
ws: undefined,
};
_this.user = {
api: undefined
api: undefined,
};
_this.team = {
api: undefined
api: undefined,
};

@@ -47,3 +47,4 @@ _this.client.http = new HttpClient_1.default(urls.rest);

var _this = this;
return this.auth.api.postLogin(data)
return this.auth.api
.postLogin(data)
.then(function (accessToken) {

@@ -57,4 +58,3 @@ _this.client.http.accessToken = accessToken;

var _this = this;
return this.auth.api.postAccess()
.then(function (accessToken) {
return this.auth.api.postAccess().then(function (accessToken) {
_this.client.http.accessToken = accessToken;

@@ -67,4 +67,3 @@ _this.client.ws.accessToken = _this.client.http.accessToken;

var _this = this;
return this.client.ws.connect(clientId)
.then(function (socket) {
return this.client.ws.connect(clientId).then(function (socket) {
socket.on('message', function (data) {

@@ -80,4 +79,4 @@ var notification = JSON.parse(Buffer.from(data).toString('utf8'));

WireAPIClient.TOPIC = {
WEB_SOCKET_MESSAGE: 'WireAPIClient.TOPIC.WEB_SOCKET_MESSAGE'
WEB_SOCKET_MESSAGE: 'WireAPIClient.TOPIC.WEB_SOCKET_MESSAGE',
};
exports.default = WireAPIClient;

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

Object.assign(config.headers, {
'Content-Type': ContentType_1.default.APPLICATION_JSON
'Content-Type': ContentType_1.default.APPLICATION_JSON,
});
if (this.accessToken) {
config.headers.Authorization = this.accessToken.token_type + " " + this.accessToken.access_token;
config.headers.Authorization = this.accessToken.token_type + " " + this
.accessToken.access_token;
}

@@ -26,0 +27,0 @@ return this.sendRequest(config);

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

ContentType: ContentType_1.default,
StatusCode: StatusCode_1.default
StatusCode: StatusCode_1.default,
};

@@ -9,3 +9,4 @@ "use strict";

WebSocketClient.prototype.connect = function (clientId) {
var url = this.baseURL + "/await?access_token=" + this.accessToken.access_token;
var url = this.baseURL + "/await?access_token=" + this.accessToken
.access_token;
if (clientId) {

@@ -12,0 +13,0 @@ url += "&client=" + clientId;

@@ -24,5 +24,7 @@ "use strict";

method: 'post',
url: "" + TeamAPI.URL.TEAMS
url: "" + TeamAPI.URL.TEAMS,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.headers['location'];

@@ -38,5 +40,7 @@ });

method: 'put',
url: TeamAPI.URL.TEAMS + "/" + team.id
url: TeamAPI.URL.TEAMS + "/" + team.id,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -48,5 +52,7 @@ });

method: 'get',
url: "" + TeamAPI.URL.TEAMS
url: "" + TeamAPI.URL.TEAMS,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -58,5 +64,7 @@ });

method: 'get',
url: TeamAPI.URL.TEAMS + "/" + teamId
url: TeamAPI.URL.TEAMS + "/" + teamId,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -68,5 +76,7 @@ });

method: 'delete',
url: TeamAPI.URL.TEAMS + "/" + teamId
url: TeamAPI.URL.TEAMS + "/" + teamId,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -78,5 +88,7 @@ });

method: 'get',
url: TeamAPI.URL.TEAMS + "/" + teamId + "/" + TeamAPI.URL.MEMBERS
url: TeamAPI.URL.TEAMS + "/" + teamId + "/" + TeamAPI.URL.MEMBERS,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -88,5 +100,7 @@ });

method: 'delete',
url: TeamAPI.URL.TEAMS + "/" + teamId + "/" + TeamAPI.URL.MEMBERS + "/" + userId
url: TeamAPI.URL.TEAMS + "/" + teamId + "/" + TeamAPI.URL.MEMBERS + "/" + userId,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -101,10 +115,26 @@ });

method: 'post',
url: TeamAPI.URL.TEAMS + "/" + teamId + "/" + TeamAPI.URL.MEMBERS
url: TeamAPI.URL.TEAMS + "/" + teamId + "/" + TeamAPI.URL.MEMBERS,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;
});
};
TeamAPI.prototype.putMembers = function (teamId, member) {
var config = {
data: {
member: member,
},
method: 'put',
url: TeamAPI.URL.TEAMS + "/" + teamId + "/" + TeamAPI.URL.MEMBERS,
};
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;
});
};
return TeamAPI;
}());
exports.default = TeamAPI;

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

SELF: '/self',
USERS: '/users'
USERS: '/users',
};

@@ -23,5 +23,7 @@ },

method: 'get',
url: UserAPI.URL.SELF
url: UserAPI.URL.SELF,
};
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -33,3 +35,3 @@ });

method: 'get',
url: UserAPI.URL.USERS
url: UserAPI.URL.USERS,
};

@@ -42,3 +44,5 @@ if (parameters.handles) {

}
return this.client.sendJSONRequest(config).then(function (response) {
return this.client
.sendJSONRequest(config)
.then(function (response) {
return response.data;

@@ -45,0 +49,0 @@ });

@@ -14,7 +14,10 @@ {

"concurrently": "3.4.0",
"husky": "0.13.4",
"istanbul": "0.4.5",
"jasmine": "2.6.0",
"lint-staged": "3.6.0",
"optimist": "0.6.1",
"prettier": "1.4.2",
"rimraf": "2.6.1",
"sinon": "1.17.6 ",
"sinon": "1.17.6",
"sinon-har-server": "0.3.0",

@@ -27,2 +30,8 @@ "typescript": "2.3.2",

"license": "GPL-3.0",
"lint-staged": {
"*.ts": [
"yarn prettier",
"git add"
]
},
"main": "dist/commonjs/index.js",

@@ -38,11 +47,12 @@ "name": "@wireapp/api-client",

"dist": "yarn clean && tsc",
"lint": "echo \"No linting specified\" && exit 0",
"preversion": "yarn lint && yarn dist && yarn test",
"version": "yarn dist",
"postversion": "git push && git push --tags",
"precommit": "lint-staged",
"prettier": "prettier --single-quote --trailing-comma='all' --no-bracket-spacing --write 'src/**/*.ts'",
"preversion": "yarn dist && yarn test",
"start": "yarn clean && concurrently \"tsc -w\" \"yarn watch\"",
"test": "jasmine",
"version": "yarn dist",
"watch": "webpack-dev-server --config webpack.config.js --open"
},
"version": "0.0.15"
"version": "0.0.16"
}

@@ -6,4 +6,3 @@ import {AxiosPromise, AxiosRequestConfig, AxiosResponse} from 'axios';

export default class AuthAPI {
constructor(private client: HttpClient) {
}
constructor(private client: HttpClient) {}

@@ -18,3 +17,3 @@ static get URL() {

LOGOUT: 'logout',
REGISTER: '/register'
REGISTER: '/register',
};

@@ -30,3 +29,3 @@ }

method: 'post',
url: `${AuthAPI.URL.COOKIES}/remove`
url: `${AuthAPI.URL.COOKIES}/remove`,
};

@@ -43,8 +42,10 @@

method: 'post',
url: `${AuthAPI.URL.LOGIN}?persist=${login.persist}`
url: `${AuthAPI.URL.LOGIN}?persist=${login.persist}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -56,8 +57,10 @@

method: 'post',
url: `${AuthAPI.URL.ACCESS}/${AuthAPI.URL.LOGOUT}`
url: `${AuthAPI.URL.ACCESS}/${AuthAPI.URL.LOGOUT}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -69,9 +72,11 @@

method: 'post',
url: `${AuthAPI.URL.ACCESS}`
url: `${AuthAPI.URL.ACCESS}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}
}

@@ -11,24 +11,24 @@ import * as WebSocket from 'ws';

export default class WireAPIClient extends EventEmitter {
public auth: { api: AuthAPI } = {
api: undefined
public auth: {api: AuthAPI} = {
api: undefined,
};
public client: { http: HttpClient, ws: WebSocketClient } = {
public client: {http: HttpClient; ws: WebSocketClient} = {
http: undefined,
ws: undefined
ws: undefined,
};
public user: { api: UserAPI } = {
api: undefined
public user: {api: UserAPI} = {
api: undefined,
};
public team: { api: TeamAPI } = {
api: undefined
public team: {api: TeamAPI} = {
api: undefined,
};
public static TOPIC = {
WEB_SOCKET_MESSAGE: 'WireAPIClient.TOPIC.WEB_SOCKET_MESSAGE'
WEB_SOCKET_MESSAGE: 'WireAPIClient.TOPIC.WEB_SOCKET_MESSAGE',
};
constructor(public urls: { rest: string, ws?: string }) {
constructor(public urls: {rest: string; ws?: string}) {
super();

@@ -45,3 +45,4 @@

public login(data: LoginData): Promise<AccessTokenData> {
return this.auth.api.postLogin(data)
return this.auth.api
.postLogin(data)
.then((accessToken: AccessTokenData) => {

@@ -55,20 +56,18 @@ this.client.http.accessToken = accessToken;

public refreshAccessToken(): Promise<AccessTokenData> {
return this.auth.api.postAccess()
.then((accessToken: AccessTokenData) => {
this.client.http.accessToken = accessToken;
this.client.ws.accessToken = this.client.http.accessToken;
return accessToken;
});
return this.auth.api.postAccess().then((accessToken: AccessTokenData) => {
this.client.http.accessToken = accessToken;
this.client.ws.accessToken = this.client.http.accessToken;
return accessToken;
});
}
public listen(clientId: string): Promise<WebSocket> {
return this.client.ws.connect(clientId)
.then((socket: WebSocket) => {
socket.on('message', (data: ArrayBuffer) => {
const notification = JSON.parse(Buffer.from(data).toString('utf8'));
this.emit(WireAPIClient.TOPIC.WEB_SOCKET_MESSAGE, notification);
});
return socket;
return this.client.ws.connect(clientId).then((socket: WebSocket) => {
socket.on('message', (data: ArrayBuffer) => {
const notification = JSON.parse(Buffer.from(data).toString('utf8'));
this.emit(WireAPIClient.TOPIC.WEB_SOCKET_MESSAGE, notification);
});
return socket;
});
}
}

@@ -8,4 +8,3 @@ import axios, {AxiosPromise, AxiosRequestConfig} from 'axios';

constructor(public baseURL: string) {
}
constructor(public baseURL: string) {}

@@ -25,7 +24,8 @@ public createUrl(url: string) {

Object.assign(config.headers, {
'Content-Type': ContentType.APPLICATION_JSON
'Content-Type': ContentType.APPLICATION_JSON,
});
if (this.accessToken) {
config.headers.Authorization = `${this.accessToken.token_type} ${this.accessToken.access_token}`;
config.headers.Authorization = `${this.accessToken.token_type} ${this
.accessToken.access_token}`;
}

@@ -32,0 +32,0 @@

@@ -6,3 +6,3 @@ import ContentType from './ContentType';

ContentType: ContentType,
StatusCode: StatusCode
StatusCode: StatusCode,
};

@@ -6,7 +6,7 @@ import * as WebSocket from 'ws';

constructor(public baseURL: string) {
}
constructor(public baseURL: string) {}
public connect(clientId?: string): Promise<WebSocket> {
let url = `${this.baseURL}/await?access_token=${this.accessToken.access_token}`;
let url = `${this.baseURL}/await?access_token=${this.accessToken
.access_token}`;
if (clientId) {

@@ -19,3 +19,3 @@ url += `&client=${clientId}`;

return new Promise((resolve) => {
return new Promise(resolve => {
socket.on('open', function open() {

@@ -22,0 +22,0 @@ resolve(socket);

@@ -6,4 +6,3 @@ import {AxiosPromise, AxiosRequestConfig, AxiosResponse} from 'axios';

export default class TeamAPI {
constructor(private client: HttpClient) {
}
constructor(private client: HttpClient) {}

@@ -24,8 +23,10 @@ static get URL() {

method: 'post',
url: `${TeamAPI.URL.TEAMS}`
url: `${TeamAPI.URL.TEAMS}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.headers['location'];
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.headers['location'];
});
}

@@ -40,8 +41,10 @@

method: 'put',
url: `${TeamAPI.URL.TEAMS}/${team.id}`
url: `${TeamAPI.URL.TEAMS}/${team.id}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -52,8 +55,10 @@

method: 'get',
url: `${TeamAPI.URL.TEAMS}`
url: `${TeamAPI.URL.TEAMS}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -64,8 +69,10 @@

method: 'get',
url: `${TeamAPI.URL.TEAMS}/${teamId}`
url: `${TeamAPI.URL.TEAMS}/${teamId}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -76,8 +83,10 @@

method: 'delete',
url: `${TeamAPI.URL.TEAMS}/${teamId}`
url: `${TeamAPI.URL.TEAMS}/${teamId}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -88,8 +97,10 @@

method: 'get',
url: `${TeamAPI.URL.TEAMS}/${teamId}/${TeamAPI.URL.MEMBERS}`
url: `${TeamAPI.URL.TEAMS}/${teamId}/${TeamAPI.URL.MEMBERS}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -100,8 +111,10 @@

method: 'delete',
url: `${TeamAPI.URL.TEAMS}/${teamId}/${TeamAPI.URL.MEMBERS}/${userId}`
url: `${TeamAPI.URL.TEAMS}/${teamId}/${TeamAPI.URL.MEMBERS}/${userId}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}

@@ -115,9 +128,27 @@

method: 'post',
url: `${TeamAPI.URL.TEAMS}/${teamId}/${TeamAPI.URL.MEMBERS}`
url: `${TeamAPI.URL.TEAMS}/${teamId}/${TeamAPI.URL.MEMBERS}`,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}
public putMembers(teamId: string, member: MemberData): AxiosPromise {
const config: AxiosRequestConfig = {
data: {
member: member,
},
method: 'put',
url: `${TeamAPI.URL.TEAMS}/${teamId}/${TeamAPI.URL.MEMBERS}`,
};
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}
}

@@ -6,4 +6,3 @@ import {AxiosRequestConfig, AxiosResponse} from 'axios';

export default class UserAPI {
constructor(private client: HttpClient) {
}
constructor(private client: HttpClient) {}

@@ -15,3 +14,3 @@ static get URL() {

SELF: '/self',
USERS: '/users'
USERS: '/users',
};

@@ -23,14 +22,18 @@ }

method: 'get',
url: UserAPI.URL.SELF
url: UserAPI.URL.SELF,
};
return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}
public getUsers(parameters: { handles?: string[], ids?: string[] }): Promise<UserData[]> {
public getUsers(
parameters: {handles?: string[]; ids?: string[]}
): Promise<UserData[]> {
const config: AxiosRequestConfig = {
method: 'get',
url: UserAPI.URL.USERS
url: UserAPI.URL.USERS,
};

@@ -46,6 +49,8 @@

return this.client.sendJSONRequest(config).then((response: AxiosResponse) => {
return response.data;
});
return this.client
.sendJSONRequest(config)
.then((response: AxiosResponse) => {
return response.data;
});
}
}

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

interface UserAssetData {
}
interface UserAssetData {}
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