Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cerebral/firebase

Package Overview
Dependencies
Maintainers
3
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cerebral/firebase - npm Package Compare versions

Comparing version 0.0.0-beta.3 to 1.0.0

lib/operators/signInWithCustomToken.js

16

lib/helpers.js

@@ -14,2 +14,3 @@ 'use strict';

exports.noop = noop;
exports.snapshotToArray = snapshotToArray;

@@ -34,3 +35,3 @@ var _firebase = require('firebase');

return Object.keys(options).reduce(function (ref, key) {
if (key === 'payload') {
if (key === 'payload' || key === 'asArray') {
return ref;

@@ -171,2 +172,15 @@ }

function noop() {}
function snapshotToArray(snapshot) {
var result = [];
snapshot.forEach(function (childSnapshot) {
result.push({
key: childSnapshot.key,
value: childSnapshot.val()
});
});
return result;
}
//# sourceMappingURL=helpers.js.map

@@ -114,2 +114,6 @@ 'use strict';

var _signInWithCustomToken = require('./signInWithCustomToken');
var _signInWithCustomToken2 = _interopRequireDefault(_signInWithCustomToken);
var _deleteUser = require('./deleteUser');

@@ -147,2 +151,3 @@

signInWithGithub: _signInWithGithub2.default,
signInWithCustomToken: _signInWithCustomToken2.default,
off: _helpers.stopListening,

@@ -149,0 +154,0 @@ onChildAdded: (0, _createOnChildAdded2.default)(context.controller),

@@ -88,2 +88,11 @@ 'use strict';

var _signInWithCustomToken = require('./signInWithCustomToken');
Object.defineProperty(exports, 'signInWithCustomToken', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_signInWithCustomToken).default;
}
});
var _signInWithFacebook = require('./signInWithFacebook');

@@ -90,0 +99,0 @@

4

lib/operators/value.js

@@ -9,3 +9,3 @@ 'use strict';

function valueFactory(valuePath) {
function valueFactory(valuePath, options) {
function value(_ref) {

@@ -16,3 +16,3 @@ var firebase = _ref.firebase,

return (0, _helpers.createReturnPromise)(firebase.value(resolve.value(valuePath)), path);
return (0, _helpers.createReturnPromise)(firebase.value(resolve.value(valuePath), (0, _helpers.convertObjectWithTemplates)(options, resolve)), path);
}

@@ -19,0 +19,0 @@

@@ -32,3 +32,4 @@ 'use strict';

totalBytes: snapshot.totalBytes,
state: snapshot.state });
state: snapshot.state // 'paused', 'running'
});
}, function (error) {

@@ -35,0 +36,0 @@ reject(new _errors.FirebaseProviderError(error));

@@ -16,3 +16,13 @@ 'use strict';

return ref.once('value').then(function (snapshot) {
return { key: snapshot.key, value: snapshot.val() };
if (options.asArray && 'forEach' in snapshot) {
return {
key: snapshot.key,
value: (0, _helpers.snapshotToArray)(snapshot)
};
}
return {
key: snapshot.key,
value: snapshot.val()
};
}).catch(function (error) {

@@ -19,0 +29,0 @@ throw new _errors.FirebaseProviderError(error);

{
"name": "@cerebral/firebase",
"version": "0.0.0-beta.3",
"version": "1.0.0",
"description": "Firebase provider for Cerebral",

@@ -29,7 +29,7 @@ "main": "lib/index.js",

"peerDependencies": {
"cerebral": "^2.0.0-beta.3"
"cerebral": "^2.0.0"
},
"devDependencies": {
"cerebral": "^2.0.0-beta.3"
"cerebral": "^2.0.0"
}
}
}

@@ -6,8 +6,4 @@ # @cerebral/firebase

`npm install @cerebral/firebase --save`
`npm install @cerebral/firebase`
**YARN**
`yarn add @cerebral/firebase`
## description

@@ -271,3 +267,16 @@ The Firebase provider is a Cerebral friendly wrapper around the Firebase client. By default the Firebase client is heavily event based, even just getting some value, handling authentication etc. This is useful in some types of apps, but Cerebral has a very straight forward way of thinking about side effects. You will find that a lot of the API exposed by the Firebase client is simplified!

function someAction({ firebase }) {
return firebase.value('someKey.foo')
return firebase.value('someKey.foo', {
limitToFirst: 5, // Read Firebase docs
limitToLast: 5, // Read Firebase docs
startAt: 5, // Read Firebase docs
endAt: 5, // Read Firebase docs
equalTo: 5, // Read Firebase docs
orderByChild: 'count', // Read Firebase docs
orderByKey: true, // Read Firebase docs
orderByValue: true, // Read Firebase docs
// Set to true to get an array of {key: '', value: {}}
// Useful with ordering options
asArray: false,
})
}

@@ -279,5 +288,9 @@ ```

import {value} from '@cerebral/firebase/operators'
import {state} from 'cerebral/tags'
export default [
value('foo.bar'),
value('foo.bar', {
asArray: true,
orderByChild: state`currentOrderChild`
}),

@@ -294,3 +307,7 @@ // Alternatively with explicit paths

```javascript
// Normally
{key: 'keyYouLookedUpValueOn', value: 'the value'}
// With "asArray"
[{key: 'keyYouLookedUpValueOn', value: 'the value'}, {key: 'keyYouLookedUpValueOn', value: 'the value'}]
```

@@ -599,3 +616,3 @@

```js
function someAction({ firebase, path, state }) {
function someAction({ firebase, state }) {
const email = state.get('register.email')

@@ -672,2 +689,33 @@ const password = state.get('register.password')

## signInWithCustomToken
Sign in a custom token.
*action*
```js
function someAction({ firebase, state }) {
return firebase.signInWithCustomToken(state.get('token'))
}
```
*factory*
```javascript
import {props, state} from 'cerebral/tags'
import {signInWithCustomToken} from '@cerebral/firebase/operators'
export default [
signInWithCustomToken(props`token`),
// Alternatively with explicit paths
signInWithCustomToken(state`token`), {
success: [],
error: []
}
]
```
*output*
```javascript
{user: {}}
```
## linkWithFacebook{PROVIDER}

@@ -674,0 +722,0 @@ Link an anonymous account with Facebook, Google or Github.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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