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

mongodb-stitch

Package Overview
Dependencies
Maintainers
2
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-stitch - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

33

dist/node/auth/providers.js

@@ -14,20 +14,14 @@ 'use strict';

function localProvider(auth) {
function anonProvider(auth) {
return {
login: function login(username, password, opts) {
if (username === undefined || password === undefined) {
var _fetchArgs = common.makeFetchArgs('GET');
_fetchArgs.cors = true;
return fetch(auth.rootUrl + '/anon/user', _fetchArgs).then(common.checkStatus).then(function (response) {
return response.json();
}).then(function (json) {
return auth.set(json);
});
login: function login(opts) {
// reuse existing auth if present
if (auth.get().hasOwnProperty('accessToken')) {
return;
}
var fetchArgs = common.makeFetchArgs('POST', JSON.stringify({ username: username, password: password }));
var fetchArgs = common.makeFetchArgs('GET');
fetchArgs.cors = true;
return fetch(auth.rootUrl + '/local/userpass', fetchArgs).then(common.checkStatus).then(function (response) {
return fetch(auth.rootUrl + '/anon/user', fetchArgs).then(common.checkStatus).then(function (response) {
return response.json();

@@ -43,2 +37,13 @@ }).then(function (json) {

return {
login: function login(username, password, opts) {
var fetchArgs = common.makeFetchArgs('POST', JSON.stringify({ username: username, password: password }));
fetchArgs.cors = true;
return fetch(auth.rootUrl + '/local/userpass', fetchArgs).then(common.checkStatus).then(function (response) {
return response.json();
}).then(function (json) {
return auth.set(json);
});
},
emailConfirm: function emailConfirm(tokenId, token) {

@@ -189,3 +194,3 @@ var fetchArgs = common.makeFetchArgs('POST', JSON.stringify({ tokenId: tokenId, token: token }));

return {
local: localProvider(auth),
anon: anonProvider(auth),
apiKey: apiKeyProvider(auth),

@@ -192,0 +197,0 @@ google: googleProvider(auth),

@@ -70,7 +70,5 @@ 'use strict';

this.authUrl = baseUrl + '/api/public/v1.0/auth';
this.profileUrl = baseUrl + '/api/public/v1.0/auth/me';
if (clientAppID) {
this.appUrl = baseUrl + '/api/client/v1.0/app/' + clientAppID;
this.authUrl = this.appUrl + '/auth';
this.profileUrl = this.appUrl + '/auth/me';
}

@@ -116,3 +114,7 @@

return this.auth.provider('local').login(email, password, options);
if (email === undefined || password === undefined) {
return this.auth.provider('anon').login(options);
}
return this.auth.provider('userpass').login(email, password, options);
}

@@ -190,9 +192,3 @@

value: function userProfile() {
var fetchArgs = common.makeFetchArgs('GET');
var token = this.auth.getAccessToken() || this.auth.getRefreshToken();
if (!token) {
return Promise.reject('must be logged in first');
}
fetchArgs.headers.Authorization = 'Bearer ' + token;
return fetch('' + this.profileUrl, fetchArgs).then(function (response) {
return this._do('/auth/me', 'GET').then(function (response) {
return response.json();

@@ -316,3 +312,3 @@ });

if (!options.noAuth) {
if (this.user === null) {
if (!this.authedId()) {
return Promise.reject(new _errors.StitchError('Must auth first', _errors.ErrUnauthorized));

@@ -319,0 +315,0 @@ }

{
"name": "mongodb-stitch",
"version": "0.0.12",
"version": "0.0.13",
"description": "",

@@ -5,0 +5,0 @@ "author": "",

import * as common from '../common';
function localProvider(auth) {
function anonProvider(auth) {
return {
login: (username, password, opts) => {
if (username === undefined || password === undefined) {
let fetchArgs = common.makeFetchArgs('GET');
fetchArgs.cors = true;
return fetch(`${auth.rootUrl}/anon/user`, fetchArgs)
.then(common.checkStatus)
.then(response => response.json())
.then(json => auth.set(json));
login: (opts) => {
// reuse existing auth if present
if (auth.get().hasOwnProperty('accessToken')) {
return;
}
const fetchArgs = common.makeFetchArgs('POST', JSON.stringify({ username, password }));
let fetchArgs = common.makeFetchArgs('GET');
fetchArgs.cors = true;
return fetch(`${auth.rootUrl}/local/userpass`, fetchArgs)
return fetch(`${auth.rootUrl}/anon/user`, fetchArgs)
.then(common.checkStatus)

@@ -29,2 +24,12 @@ .then(response => response.json())

return {
login: (username, password, opts) => {
const fetchArgs = common.makeFetchArgs('POST', JSON.stringify({ username, password }));
fetchArgs.cors = true;
return fetch(`${auth.rootUrl}/local/userpass`, fetchArgs)
.then(common.checkStatus)
.then(response => response.json())
.then(json => auth.set(json));
},
emailConfirm: (tokenId, token) => {

@@ -166,3 +171,3 @@ const fetchArgs = common.makeFetchArgs('POST', JSON.stringify({ tokenId, token }));

return {
local: localProvider(auth),
anon: anonProvider(auth),
apiKey: apiKeyProvider(auth),

@@ -169,0 +174,0 @@ google: googleProvider(auth),

@@ -33,7 +33,5 @@ /* global window, fetch */

this.authUrl = `${baseUrl}/api/public/v1.0/auth`;
this.profileUrl = `${baseUrl}/api/public/v1.0/auth/me`;
if (clientAppID) {
this.appUrl = `${baseUrl}/api/client/v1.0/app/${clientAppID}`;
this.authUrl = `${this.appUrl}/auth`;
this.profileUrl = `${this.appUrl}/auth/me`;
}

@@ -71,3 +69,7 @@

login(email, password, options = {}) {
return this.auth.provider('local').login(email, password, options);
if (email === undefined || password === undefined) {
return this.auth.provider('anon').login(options);
}
return this.auth.provider('userpass').login(email, password, options);
}

@@ -125,9 +127,3 @@

userProfile() {
const fetchArgs = common.makeFetchArgs('GET');
const token = this.auth.getAccessToken() || this.auth.getRefreshToken();
if (!token) {
return Promise.reject('must be logged in first');
}
fetchArgs.headers.Authorization = `Bearer ${token}`;
return fetch(`${this.profileUrl}`, fetchArgs)
return this._do('/auth/me', 'GET')
.then(response => response.json());

@@ -227,3 +223,3 @@ }

if (!options.noAuth) {
if (this.user === null) {
if (!this.authedId()) {
return Promise.reject(new StitchError('Must auth first', ErrUnauthorized));

@@ -230,0 +226,0 @@ }

@@ -129,3 +129,3 @@ /* global expect, it, describe, global, afterEach, beforeEach, afterAll, beforeAll, require, Buffer, Promise */

const a = new Auth(null, '/auth');
return a.provider('local').login('user', 'password')
return a.provider('userpass').login('user', 'password')
.then(() => expect(a.authedId()).toEqual(hexStr));

@@ -137,3 +137,3 @@ });

const auth = new Auth(null, '/auth');
return auth.provider('local').login('user', 'password')
return auth.provider('userpass').login('user', 'password')
.then(() => {

@@ -140,0 +140,0 @@ expect(auth.authedId()).toEqual(hexStr);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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