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
6
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 3.7.0 to 3.8.0

dist/node/constants.js

77

dist/node/admin.js

@@ -28,4 +28,8 @@ 'use strict';

var _constants = require('./constants');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

@@ -37,6 +41,3 @@

var v3 = 3;
/** @private **/
var StitchAdminClientFactory = exports.StitchAdminClientFactory = function () {

@@ -92,3 +93,3 @@ function StitchAdminClientFactory() {

useRefreshToken: true,
apiVersion: v3
apiVersion: _constants.v3
}).then(function () {

@@ -120,3 +121,3 @@ return _this2.auth.clear();

value: function getAuthProviders() {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', this).call(this, '/auth/providers', 'GET', { noAuth: true, apiVersion: v3 }).then(function (response) {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', this).call(this, '/auth/providers', 'GET', { noAuth: true, apiVersion: _constants.v3 }).then(function (response) {
return response.json();

@@ -138,3 +139,3 @@ });

useRefreshToken: true,
apiVersion: v3
apiVersion: _constants.v3
}).then(function (response) {

@@ -775,2 +776,27 @@ return response.json();

};
},
realm: function realm() {
var realmUrl = appUrl + '/realm';
return {
config: function config() {
var realmConfigUrl = realmUrl + '/config';
return {
get: function get() {
return api._get(realmConfigUrl);
},
update: function update(data) {
return api._put(realmConfigUrl, { body: JSON.stringify(data) });
}
};
},
clientSchemas: function clientSchemas() {
var realmClientSchemasUrl = realmUrl + '/client_schemas';
return {
get: function get(language, filter) {
return api._get(realmClientSchemasUrl + '/' + language, filter);
}
};
}
};
}

@@ -782,2 +808,16 @@ };

}, {
key: 'privateAdminTriggers',
value: function privateAdminTriggers(groupId, appId) {
var privateApi = this._v1[_constants.API_TYPE_PRIVATE];
var baseUrl = '/admin/groups/' + groupId + '/apps/' + appId + '/triggers';
return {
list: function list() {
return privateApi._get(baseUrl);
},
get: function get(triggerId) {
return privateApi._get(baseUrl + '/' + triggerId);
}
};
}
}, {
key: 'type',

@@ -788,8 +828,29 @@ get: function get() {

}, {
key: '_v3',
key: '_v1',
get: function get() {
var _this3 = this;
var privateV1do = function privateV1do(url, method, options) {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', _this3).call(_this3, url, method, Object.assign({}, { apiVersion: _constants.v1, apiType: _constants.API_TYPE_PRIVATE }, options)).then(function (response) {
var contentHeader = response.headers.get('content-type') || '';
if (contentHeader.split(',').indexOf('application/json') >= 0) {
return response.json();
}
return response;
});
};
return _defineProperty({}, _constants.API_TYPE_PRIVATE, {
_get: function _get(url, queryParams, headers, options) {
return privateV1do(url, 'GET', Object.assign({}, { queryParams: queryParams, headers: headers }, options));
}
});
}
}, {
key: '_v3',
get: function get() {
var _this4 = this;
var v3do = function v3do(url, method, options) {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', _this3).call(_this3, url, method, Object.assign({}, { apiVersion: v3 }, options)).then(function (response) {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', _this4).call(_this4, url, method, Object.assign({}, { apiVersion: _constants.v3 }, options)).then(function (response) {
var contentHeader = response.headers.get('content-type') || '';

@@ -796,0 +857,0 @@ if (contentHeader.split(',').indexOf('application/json') >= 0) {

34

dist/node/client.js

@@ -38,2 +38,4 @@ 'use strict';

var _constants = require('./constants');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -47,10 +49,2 @@

var v1 = 1;
var v2 = 2;
var v3 = 3;
var API_TYPE_PUBLIC = 'public';
var API_TYPE_PRIVATE = 'private';
var API_TYPE_CLIENT = 'client';
var API_TYPE_APP = 'app';
var fetcher = exports.fetcher = function fetcher() {

@@ -113,3 +107,3 @@ return typeof fetch === 'undefined' ? require('node-fetch') : fetch;

stitchClient.rootURLsByAPIVersion = (_stitchClient$rootURL = {}, _defineProperty(_stitchClient$rootURL, v1, (_v = {}, _defineProperty(_v, API_TYPE_PUBLIC, baseUrl + '/api/public/v1.0'), _defineProperty(_v, API_TYPE_CLIENT, baseUrl + '/api/client/v1.0'), _defineProperty(_v, API_TYPE_PRIVATE, baseUrl + '/api/private/v1.0'), _defineProperty(_v, API_TYPE_APP, clientAppID ? baseUrl + '/api/client/v1.0/app/' + clientAppID : baseUrl + '/api/public/v1.0'), _v)), _defineProperty(_stitchClient$rootURL, v2, (_v2 = {}, _defineProperty(_v2, API_TYPE_PUBLIC, baseUrl + '/api/public/v2.0'), _defineProperty(_v2, API_TYPE_CLIENT, baseUrl + '/api/client/v2.0'), _defineProperty(_v2, API_TYPE_PRIVATE, baseUrl + '/api/private/v2.0'), _defineProperty(_v2, API_TYPE_APP, clientAppID ? baseUrl + '/api/client/v2.0/app/' + clientAppID : baseUrl + '/api/public/v2.0'), _v2)), _defineProperty(_stitchClient$rootURL, v3, (_v3 = {}, _defineProperty(_v3, API_TYPE_PUBLIC, baseUrl + '/api/public/v3.0'), _defineProperty(_v3, API_TYPE_CLIENT, baseUrl + '/api/client/v3.0'), _defineProperty(_v3, API_TYPE_APP, clientAppID ? baseUrl + '/api/client/v3.0/app/' + clientAppID : baseUrl + '/api/admin/v3.0'), _v3)), _stitchClient$rootURL);
stitchClient.rootURLsByAPIVersion = (_stitchClient$rootURL = {}, _defineProperty(_stitchClient$rootURL, _constants.v1, (_v = {}, _defineProperty(_v, _constants.API_TYPE_PUBLIC, baseUrl + '/api/public/v1.0'), _defineProperty(_v, _constants.API_TYPE_CLIENT, baseUrl + '/api/client/v1.0'), _defineProperty(_v, _constants.API_TYPE_PRIVATE, baseUrl + '/api/private/v1.0'), _defineProperty(_v, _constants.API_TYPE_APP, clientAppID ? baseUrl + '/api/client/v1.0/app/' + clientAppID : baseUrl + '/api/public/v1.0'), _v)), _defineProperty(_stitchClient$rootURL, _constants.v2, (_v2 = {}, _defineProperty(_v2, _constants.API_TYPE_PUBLIC, baseUrl + '/api/public/v2.0'), _defineProperty(_v2, _constants.API_TYPE_CLIENT, baseUrl + '/api/client/v2.0'), _defineProperty(_v2, _constants.API_TYPE_PRIVATE, baseUrl + '/api/private/v2.0'), _defineProperty(_v2, _constants.API_TYPE_APP, clientAppID ? baseUrl + '/api/client/v2.0/app/' + clientAppID : baseUrl + '/api/public/v2.0'), _v2)), _defineProperty(_stitchClient$rootURL, _constants.v3, (_v3 = {}, _defineProperty(_v3, _constants.API_TYPE_PUBLIC, baseUrl + '/api/public/v3.0'), _defineProperty(_v3, _constants.API_TYPE_CLIENT, baseUrl + '/api/client/v3.0'), _defineProperty(_v3, _constants.API_TYPE_APP, clientAppID ? baseUrl + '/api/client/v3.0/app/' + clientAppID : baseUrl + '/api/admin/v3.0'), _v3)), _stitchClient$rootURL);

@@ -282,3 +276,3 @@ var authOptions = {

useRefreshToken: true,
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT]
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT]
}).then(function () {

@@ -311,3 +305,3 @@ return _this3.auth.clear();

return this._do('/auth/profile', 'GET', {
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT]
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT]
}).then(function (response) {

@@ -433,3 +427,3 @@ return response.json();

useRefreshToken: true,
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT]
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT]
}).then(function (response) {

@@ -450,3 +444,3 @@ return response.json();

return this._do('/auth/api_keys', 'GET', {
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT],
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT],
useRefreshToken: true

@@ -469,3 +463,3 @@ }).then(function (response) {

return this._do('/auth/api_keys', 'POST', {
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT],
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT],
useRefreshToken: true,

@@ -489,3 +483,3 @@ body: JSON.stringify({ name: userApiKeyName })

return this._do('/auth/api_keys/' + keyID, 'GET', {
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT],
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT],
useRefreshToken: true

@@ -508,3 +502,3 @@ }).then(function (response) {

return this._do('/auth/api_keys/' + keyID, 'DELETE', {
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT],
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT],
useRefreshToken: true

@@ -525,3 +519,3 @@ });

return this._do('/auth/api_keys/' + keyID + '/enable', 'PUT', {
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT],
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT],
useRefreshToken: true

@@ -542,3 +536,3 @@ });

return this._do('/auth/api_keys/' + keyID + '/disable', 'PUT', {
rootURL: this.rootURLsByAPIVersion[v2][API_TYPE_CLIENT],
rootURL: this.rootURLsByAPIVersion[_constants.v2][_constants.API_TYPE_CLIENT],
useRefreshToken: true

@@ -621,4 +615,4 @@ });

useRefreshToken: false,
apiVersion: v2,
apiType: API_TYPE_APP,
apiVersion: _constants.v2,
apiType: _constants.API_TYPE_APP,
rootURL: undefined

@@ -625,0 +619,0 @@ }, options);

@@ -17,4 +17,4 @@ 'use strict';

var version = 'unknown';
if (typeof "3.7.0" !== 'undefined') {
version = "3.7.0";
if (typeof "3.8.0" !== 'undefined') {
version = "3.8.0";
}

@@ -21,0 +21,0 @@ var SDK_VERSION = exports.SDK_VERSION = version;

{
"name": "mongodb-stitch",
"version": "3.7.0",
"version": "3.8.0",
"description": "",

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

@@ -8,5 +8,4 @@ /* global window, fetch */

import { StitchError } from './errors';
import { v1, v3, API_TYPE_PRIVATE } from './constants';
const v3 = 3;
/** @private **/

@@ -37,2 +36,20 @@ export class StitchAdminClientFactory {

get _v1() {
const privateV1do = (url, method, options) =>
super._do(url, method, Object.assign({}, { apiVersion: v1, apiType: API_TYPE_PRIVATE }, options)).then(response => {
const contentHeader = response.headers.get('content-type') || '';
if (contentHeader.split(',').indexOf('application/json') >= 0) {
return response.json();
}
return response;
});
return {
[API_TYPE_PRIVATE]: {
_get: (url, queryParams, headers, options) =>
privateV1do(url, 'GET', Object.assign({}, { queryParams, headers }, options))
}
};
}
get _v3() {

@@ -452,2 +469,21 @@ const v3do = (url, method, options) =>

};
},
realm: () => {
const realmUrl = `${appUrl}/realm`;
return {
config: () => {
const realmConfigUrl = `${realmUrl}/config`;
return {
get: () => api._get(realmConfigUrl),
update: (data) => api._put(realmConfigUrl, { body: JSON.stringify(data) })
};
},
clientSchemas: () => {
const realmClientSchemasUrl = `${realmUrl}/client_schemas`;
return {
get: (language, filter) => api._get(`${realmClientSchemasUrl}/${language}`, filter)
};
}
};
}

@@ -458,2 +494,11 @@ };

}
privateAdminTriggers(groupId, appId) {
const privateApi = this._v1[API_TYPE_PRIVATE];
const baseUrl = `/admin/groups/${groupId}/apps/${appId}/triggers`;
return {
list: () => privateApi._get(baseUrl),
get: triggerId => privateApi._get(`${baseUrl}/${triggerId}`)
};
}
}

@@ -11,11 +11,4 @@ /* global window, fetch */

import {StitchError, ErrInvalidSession, ErrUnauthorized} from './errors';
import { v1, v2, v3, API_TYPE_PUBLIC, API_TYPE_PRIVATE, API_TYPE_CLIENT, API_TYPE_APP } from './constants';
const v1 = 1;
const v2 = 2;
const v3 = 3;
const API_TYPE_PUBLIC = 'public';
const API_TYPE_PRIVATE = 'private';
const API_TYPE_CLIENT = 'client';
const API_TYPE_APP = 'app';
export const fetcher = () => (typeof fetch === 'undefined' ? require('node-fetch') : fetch);

@@ -22,0 +15,0 @@

const StitchMongoFixture = require('../fixtures/stitch_mongo_fixture');
import { buildClientTestHarness, extractTestFixtureDataPoints } from '../testutil';
import { buildClientTestHarness, extractTestFixtureDataPoints, createSampleMongodbService, addRuleToMongodbService } from '../testutil';
const jwtDecode = require('jwt-decode');
function createSampleMongodbService(services) {
return services.create({
type: 'mongodb',
name: 'mdb',
config: {
uri: 'mongodb://localhost:26000'
}
});
}
describe('Custom User Data', () => {

@@ -119,13 +109,3 @@ let test = new StitchMongoFixture();

mongodbService = await createSampleMongodbService(services);
const monogSvcObj = services.service(mongodbService._id);
let testRuleConfig = {
read: {'%%true': true},
write: {'%%true': true},
valid: {'%%true': true},
fields: {_id: {}, a: {}, b: {}, c: {} }
};
const db = test.mongo.db(dbName);
await monogSvcObj.rules().create(
Object.assign({}, testRuleConfig, { name: 'testRule', namespace: `${dbName}.${collName}` })
);
await addRuleToMongodbService(services, mongodbService, { database: dbName, collection: collName });

@@ -142,2 +122,3 @@ // Create a user

// Insert some data into the collection
const db = test.mongo.db(dbName);
doc = { 'vegeta': userId, 'goku': 'clown' };

@@ -144,0 +125,0 @@ let insertResponse = await db.collection(collName).insertOne(doc);

@@ -17,2 +17,23 @@ const StitchMongoFixture = require('../fixtures/stitch_mongo_fixture');

th = await buildAdminTestHarness(true, apiKey, groupId, serverUrl);
const service = await th.app().services().create({
name: 'test',
type: 'mongodb',
config: {
uri: 'mongodb://localhost:26000'
}
});
await th.app().services().service(service._id).rules().create({
database: 'db',
collection: 'coll',
schema: {
properties: {
firstName: {
type: 'string'
}
}
}
});
graphql = th.app().graphql();

@@ -24,4 +45,12 @@ });

it('exposes a .post() which executes a graphql request', async() => {
const response = await graphql.post({ query: '{ __schema { types { name } } }' });
expect(response).toEqual({ data: {} });
const response = await graphql.post({ query: '{ __schema { queryType { name } } }' });
expect(response).toEqual({
data: {
__schema: {
queryType: {
name: 'Query'
}
}
}
});
});

@@ -28,0 +57,0 @@

const DEFAULT_URI = 'mongodb://localhost:26000/test';
const DEFAULT_SERVER_URL = 'http://localhost:9090';
const AUTH_DB = 'auth';
const DEFAULT_USER_ROLES = ['groupOwner', 'GROUP_OWNER'];
module.exports = { DEFAULT_URI, DEFAULT_SERVER_URL };
module.exports = { DEFAULT_URI, DEFAULT_SERVER_URL, AUTH_DB, DEFAULT_USER_ROLES };
import { StitchAdminClientFactory } from '../../src/admin';
const mongodb = require('mongodb');
const MongoClient = mongodb.MongoClient;
const { DEFAULT_URI, DEFAULT_SERVER_URL } = require('../constants');
const { DEFAULT_URI, DEFAULT_SERVER_URL, DEFAULT_USER_ROLES } = require('../constants');
const crypto = require('crypto');

@@ -24,3 +24,3 @@

export default class StitchFixture {
export default class StitchMongoFixture {
constructor(options) {

@@ -30,2 +30,5 @@ options = options || {};

options.baseUrl = options.baseUrl || DEFAULT_SERVER_URL;
const userRoles = options.userRoles || [];
options.userRoles = [...userRoles, ...DEFAULT_USER_ROLES];
this.options = options;

@@ -86,3 +89,3 @@ this.testNamespaces = [];

identities: [{ id: apiKeyId.toHexString(), providerType: 'api-key', providerId: rootProviderId }],
roles: [{ roleName: 'groupOwner', groupId }, { roleName: 'GROUP_OWNER', groupId }],
roles: this.options.userRoles.map(roleName => ({ roleName, groupId })),
domain_id_hash: 3795608245,

@@ -89,0 +92,0 @@ location: 'US-VA'

@@ -42,2 +42,18 @@ import { StitchAdminClientFactory } from '../src/admin';

export const createSampleMongodbService = async(services) => {
const mongodbService = await services.create({
type: 'mongodb',
name: 'mdb',
config: {
uri: 'mongodb://localhost:26000'
}
});
return mongodbService;
};
export const addRuleToMongodbService = async(services, mongodbService, { database, collection, config }) => {
const mongoSvcObj = services.service(mongodbService._id);
await mongoSvcObj.rules().create(Object.assign({}, config, { database, collection }));
};
class TestHarness {

@@ -120,2 +136,6 @@ static async initialize(apiKey, groupId, serverUrl = constants.DEFAULT_SERVER_URL) {

privateAdminTriggers() {
return this.adminClient.privateAdminTriggers(this.groupId, this.testApp._id);
}
async appRemove() {

@@ -122,0 +142,0 @@ await this.app().remove();

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