@nodeart/firebase-connector
Advanced tools
Comparing version 2.1.23 to 2.1.24
16
index.ts
export {FirebaseConnectorModule} from './src/firebase-connector.module'; | ||
export {FirebaseConnector} from './src/firebase-connector'; | ||
export {FirebaseConnector} from './src/firebase-connector'; | ||
export {GoogleAuth} from "./src/authMethods/google"; | ||
export {GithubAuth} from "./src/authMethods/github"; | ||
export {FacebookAuth} from "./src/authMethods/facebook"; | ||
export {PasswordAuth} from "./src/authMethods/password"; | ||
export {TwitterAuth} from "./src/authMethods/twitter"; | ||
export {AnonymouslyAuth} from "./src/authMethods/anonymously"; | ||
export {VkAuth} from "./src/authMethods/vk"; | ||
export { | ||
VkAuthConfig, | ||
PopupConfig, | ||
VkConfig | ||
} from "./src/authMethods/vk"; |
@@ -37,3 +37,3 @@ { | ||
}, | ||
"version": "2.1.23" | ||
"version": "2.1.24" | ||
} |
# Firebase connector | ||
**GoogleAuth** | ||
`google.com` firebaseAuth method | ||
**GithubAuth** | ||
`github.com` firebaseAuth method | ||
**FacebookAuth** | ||
`facebook.com` firebaseAuth method | ||
**PasswordAuth** | ||
email & password firebaseAuth method | ||
**TwitterAuth** | ||
`twitter.com` firebaseAuth method | ||
**AnonymouslyAuth** | ||
anonymous firebaseAuth method | ||
**VkAuth** | ||
@@ -18,7 +42,7 @@ | ||
//vkAuthConfig.service.ts | ||
import {Injectable} from "@angular.core"; | ||
import {Injectable} from "@angular/core"; | ||
import {VkAuthConfig, VkConfig, PopupConfig} from "@nodeart/firebase-connector"; | ||
@Injectable() | ||
export class VkConfig implements VkAuthConfig { | ||
export class VkConfiguration implements VkAuthConfig { | ||
public vkConfig : VkConfig = { | ||
@@ -36,4 +60,4 @@ client_id: 'app_id', | ||
}; | ||
public cleanUp: true; | ||
public dbPath: 'vkAuth'; | ||
public cleanUp: boolean = true; | ||
public dbPath: string = 'vkAuth'; | ||
constructor() { } | ||
@@ -46,6 +70,6 @@ } | ||
import {NgModule} from "@angular/core"; | ||
import {VkConfig} from "./vkAuthConfig.service"; | ||
import {VkConfiguration} from "./vkAuthConfig.service"; | ||
@NgModule({ | ||
providers: [ | ||
{provide: 'VkAuthConfig', useClass: VkConfig} | ||
{provide: 'VkAuthConfig', useClass: VkConfiguration} | ||
] | ||
@@ -52,0 +76,0 @@ }) |
@@ -8,3 +8,84 @@ import { FirebaseAuthState } from 'angularfire2'; | ||
* Vk firebase auth service | ||
* `vk.com` is not among standard auth providers in firebase, so we provide our own solution for | ||
* this. To get acquainted with the flow, please, read [this](https://vk.com/dev/implicit_flow_user) article. | ||
* | ||
* In order to avoid creation of http server, vkAuthService works only with firebase and not with REST API. | ||
* So, we strongly recommend to set redirect url to be a current location, thus one can get a token on a client side. | ||
* | ||
* Internal work of a service one can found in source tab. | ||
* | ||
* **Usage:** | ||
* | ||
* `VkConfigService` declaration | ||
* ```typescript | ||
* //vkAuthConfig.service.ts | ||
* import {Injectable} from "@angular/core"; | ||
* import {VkAuthConfig, VkConfig, PopupConfig} from "@nodeart/firebase-connector"; | ||
* | ||
* \@Injectable() | ||
* export class VkConfiguration implements VkAuthConfig { | ||
* public vkConfig : VkConfig = { | ||
* client_id: 'app_id', | ||
* display: 'popup', | ||
* scope: ['friends'], | ||
* response_type: 'token', | ||
* v: 5.63 | ||
* }; | ||
* public popupConfig: PopupConfig = { | ||
* location: 'no', | ||
* height: 600, | ||
* width: 600 | ||
* }; | ||
* public cleanUp: boolean = true; | ||
* public dbPath: string = 'vkAuth'; | ||
* constructor() { } | ||
* } | ||
* ``` | ||
* | ||
* `VkConfigService` register | ||
* | ||
* ```typescript | ||
* //someModule.module.ts | ||
* import {NgModule} from "@angular/core"; | ||
* import {VkConfiguration} from "./vkAuthConfig.service"; | ||
* \@NgModule({ | ||
* providers: [ | ||
* {provide: 'VkAuthConfig', useClass: VkConfiguration} | ||
* ] | ||
* }) | ||
* export class SomeModule { } | ||
* ``` | ||
* | ||
* Server side or [firebase cloud functions](https://firebase.google.com/docs/functions/) code: | ||
* ```javascript | ||
* 'use strict'; | ||
* | ||
* const admin = require('firebase-admin'); | ||
* const authWithVk = admin.database().ref('auth/vk'); | ||
* | ||
* const listener = (ref, snapshot) => { | ||
* const key = snapshot.key, | ||
* val = snapshot.val(); | ||
* | ||
* if (!val.processed) { | ||
* admin.auth() | ||
* .createCustomToken(val['access_token']) | ||
* .then(token => { | ||
* const data = Object.assign(val, { | ||
* access_token: token, | ||
* expires_in: null, | ||
* processed: true | ||
* }); | ||
* ref.child(key).set(data); | ||
* return data | ||
* }) | ||
* .then(data => console.log(`custom token generated = ${JSON.stringify(data)}`)) | ||
* } | ||
* }; | ||
* | ||
* authWithVk.on('child_added', snapshot => listener(authWithVk, snapshot)); | ||
* ``` | ||
* | ||
*/ | ||
@Injectable() | ||
@@ -11,0 +92,0 @@ export class VkAuth implements AuthMethod { |
@@ -14,8 +14,2 @@ import {NgModule} from "@angular/core"; | ||
export { | ||
VkAuthConfig, | ||
PopupConfig, | ||
VkConfig | ||
} from "./authMethods/vk"; | ||
@NgModule({ | ||
@@ -22,0 +16,0 @@ providers: [ |
43180
1032
105