Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/imsamtar/hasurafire

Collection of svelte components for firebase authentication and hasura
https://github.com/imsamtar/hasurafire

authentication firebase firebase-auth hasura svelte

Last synced: about 3 hours ago
JSON representation

Collection of svelte components for firebase authentication and hasura

Awesome Lists containing this project

README

        

# hasurafire

### Collection of svelte components for firebase authentication and hasura

## Setup

```bash
npm i -D hasurafire
```

### Might need to edit _rollup.config.js_ (only if using rollup template)

```javascript
resolve({
mainFields: ['module', 'browser', 'main']
}),
```

## API
---

### Root Component

```html

import { Root } from "hasurafire";
const config = {
firebaseConfig,
endpoint, // hasura graphql endpoint
schema: 'v1', // %s in queries, mutations and subscriptions will be replaced by this value
queries: {
getMessages: `
query get_messages {
%s_messages {
content
sender_id
chat_id
}
}
`
}, // graphql queries, mutations and subscriptions
};










```
---

### User Component

```html

import { User } from "hasurafire";























```
---

### SaveUser Component

```html

import { User, SaveUser } from "hasurafire";

{#if fresh_signin}



























{/if}

```
---

### Query Component

```html

import { Query } from "hasurafire";
const variables = {};




























```
---

### Mutate Component

```html

import { Mutate } from "hasurafire";
const variables = {};




























```
---

### Subscribe Component

```html

import { Subscribe } from "hasurafire";
const variables = {};






















```
---

### query:

- Type: function
- Parameters:
- query
- variables (optional)
- options (optional) e.g. { role, headers, noauth, adminsecret }
- Returns
- graphql query response
---

### mutate:

- Type: function
- Parameters:
- mutatation
- variables (optional)
- options (optional) e.g. { role, headers, noauth, adminsecret }
- Returns
- graphql mutatation response
---

### subscribe:

- Type: function
- Parameters:
- query
- variables (optional)
- options (optional) e.g. { role, headers, noauth, adminsecret }
- Returns
- object
- observable
- qraphql subscription observable
- client
- client.close() function to disconnect this websocket connection
---

### firebase

- svelte store for firebase object
---

### user

- firebase current user
---

### loginStatus

- -1 if signed out
- 0 if not sure (pending)
- 1 if signed in
---

### accessToken

- JWT access token of currently signed-in user
---

### global

- fallback values for query, mutation and subscription variables
---

### signInWithGoogle

- call this function to signin with popup with google
---

### signInWithGithub

- call this function to signin with popup with github
---

### signInWithFacebook

- call this function to signin with popup with facebook
---

### signInWithTwitter

- call this function to signin with popup with twitter
---

### signInWithOAuth

- call this function to signin with popup with 0Auth
---

### signInWithGoogleRedirect

- call this function to signin with redirect with google
---

### signInWithGithubRedirect

- call this function to signin with redirect with github
---

### signInWithFacebookRedirect

- call this function to signin with redirect with facebook
---

### signInWithTwitterRedirect

- call this function to signin with redirect with twitter
---

### signInWithOAuthRedirect

- call this function to signin with redirect with 0Auth
---

### signIn

- call this function to signin with email and password
- accepts email and password
---

### verifyEmail

- call this function to send verification email to user
---

### updateProfile

- call this function to update user's profile
- accepts an object
```javascript
{
displayName: "", // optional
photoURL: "" // optional
}
```
---

### updateEmail

- call this function to update user's email
- accepts email
---

### updatePassword

- call this function to update user's password
- accepts password
---

### resetPassword

- call this function to send password reset email to user
---

### signOut

- call this function to signout
---

### deleteAccount

- call this function to delete user's account
---