firebase: Provides its own types

This commit is contained in:
Andy Hanson 2017-12-19 12:56:38 -08:00
parent aa0f58044c
commit 674190e0c1
9 changed files with 14 additions and 1755 deletions

View File

@ -240,6 +240,12 @@
"sourceRepoURL": "http://fineuploader.com/",
"asOfVersion": "5.14.0"
},
{
"libraryName": "Firebase API",
"typingsPackageName": "firebase",
"sourceRepoURL": "https://www.firebase.com/docs/javascript/firebase",
"asOfVersion": "3.2.1"
},
{
"libraryName": "flatpickr",
"typingsPackageName": "flatpickr",

View File

@ -112,7 +112,7 @@ interface AngularFireObject extends AngularFireSimpleObject {
* @param {object} scope
* @param {string} varName
* @returns a promise which resolves to an unbind method after data is set in scope
*/
*/
$bindTo(scope: ng.IScope, varName: string): ng.IPromise<any>;
/**
@ -125,7 +125,7 @@ interface AngularFireObject extends AngularFireSimpleObject {
* @param {Function} cb
* @param {Object} [context]
* @returns {Function} invoke to stop observing events
*/
*/
$watch(callback: Function, context?: any): Function;
/**

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"@types/firebase": "^2.4.1"
}
}

View File

@ -1,94 +0,0 @@
// Type definitions for Firebase Simple Login
// Project: https://www.firebase.com/docs/security/simple-login-overview.html
// Definitions by: Wilker Lucio <https://github.com/wilkerlucio>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface IFirebaseSimpleLoginError {
code: string;
message: string;
}
interface IFirebaseSimpleLoginOptions {
// general options
debug?: boolean
rememberMe?: boolean
// email
email?: string
password?: string
// facebook / github / google / twitter
preferRedirect?: boolean
// facebook / github / google
scope?: string
// facebook
access_token?: string
// twitter
oauth_token?: string
// persona
backgroundColor?: string
privacyPolicy?: string
siteLogo?: string
siteName?: string
termsOfService?: string
}
interface IFirebaseSimpleLoginUser {
// general data
firebaseAuthToken: string;
id: string;
provider: string;
uid: string;
// email / persona
md5_hash?: string;
// email
email?: string;
// facebook / github / google / twitter
accessToken?: string
displayName?: string
thirdPartyUserData?: Object
// github / twitter
username?: string
// twitter
accessTokenSecret?: string
}
declare class FirebaseSimpleLogin {
email: string;
id: string;
provider: string;
uid: string;
username: string;
constructor(firebase: Firebase, callback: (err: IFirebaseSimpleLoginError, user: IFirebaseSimpleLoginUser) => any);
login(loginType: string, options?: IFirebaseSimpleLoginOptions): void;
logout(): void;
createUser(email: string,
password: string,
callback?: (err: IFirebaseSimpleLoginError, user: IFirebaseSimpleLoginUser) => any): void;
changePassword(email: string,
oldPassword: string,
newPassword: string,
callback?: (err: IFirebaseSimpleLoginError, success: boolean) => any): void;
sendPasswordResetEmail(email: string,
callback?: (err: IFirebaseSimpleLoginError, success: boolean) => any): void;
removeUser(email: string,
password: string,
callback?: (err: IFirebaseSimpleLoginError, success: boolean) => any): void;
}

View File

@ -1,418 +0,0 @@
// Type definitions for Firebase API 2.4.1
// Project: https://www.firebase.com/docs/javascript/firebase
// Definitions by: Vincent Botone <https://github.com/vbortone>, Shin1 Kashimura <https://github.com/in-async/>, Sebastien Dubois <https://github.com/dsebastien>, Szymon Stasik <https://github.com/ciekawy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface FirebaseAuthResult {
auth: any;
expires: number;
}
interface FirebaseDataSnapshot {
/**
* Returns true if this DataSnapshot contains any data.
* It is slightly more efficient than using snapshot.val() !== null.
*/
exists(): boolean;
/**
* Gets the JavaScript object representation of the DataSnapshot.
*/
val(): any;
/**
* Gets a DataSnapshot for the location at the specified relative path.
*/
child(childPath: string): FirebaseDataSnapshot;
/**
* Enumerates through the DataSnapshots children (in the default order).
*/
forEach(childAction: (childSnapshot: FirebaseDataSnapshot) => void): boolean;
forEach(childAction: (childSnapshot: FirebaseDataSnapshot) => boolean): boolean;
/**
* Returns true if the specified child exists.
*/
hasChild(childPath: string): boolean;
/**
* Returns true if the DataSnapshot has any children.
*/
hasChildren(): boolean;
/**
* Gets the key name of the location that generated this DataSnapshot.
*/
key(): string;
/**
* @deprecated Use key() instead.
* Gets the key name of the location that generated this DataSnapshot.
*/
name(): string;
/**
* Gets the number of children for this DataSnapshot.
*/
numChildren(): number;
/**
* Gets the Firebase reference for the location that generated this DataSnapshot.
*/
ref(): Firebase;
/**
* Gets the priority of the data in this DataSnapshot.
* @returns {string, number, null} The priority, or null if no priority was set.
*/
getPriority(): any; // string or number
/**
* Exports the entire contents of the DataSnapshot as a JavaScript object.
*/
exportVal(): Object;
}
interface FirebaseOnDisconnect {
/**
* Ensures the data at this location is set to the specified value when the client is disconnected
* (due to closing the browser, navigating to a new page, or network issues).
*/
set(value: any, onComplete: (error: any) => void): void;
set(value: any): Promise<void>;
/**
* Ensures the data at this location is set to the specified value and priority when the client is disconnected
* (due to closing the browser, navigating to a new page, or network issues).
*/
setWithPriority(value: any, priority: string|number, onComplete: (error: any) => void): void;
setWithPriority(value: any, priority: string|number): Promise<void>;
/**
* Writes the enumerated children at this Firebase location when the client is disconnected
* (due to closing the browser, navigating to a new page, or network issues).
*/
update(value: Object, onComplete: (error: any) => void): void;
update(value: Object): Promise<void>;
/**
* Ensures the data at this location is deleted when the client is disconnected
* (due to closing the browser, navigating to a new page, or network issues).
*/
remove(onComplete: (error: any) => void): void;
remove(): Promise<void>;
/**
* Cancels all previously queued onDisconnect() set or update events for this location and all children.
*/
cancel(onComplete: (error: any) => void): void;
cancel(): Promise<void>;
}
interface FirebaseQuery {
/**
* Listens for data changes at a particular location.
*/
on(eventType: string, callback: (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: (error: any) => void, context?: Object): (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void;
/**
* Detaches a callback previously attached with on().
*/
off(eventType?: string, callback?: (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void, context?: Object): void;
/**
* Listens for exactly one event of the specified event type, and then stops listening.
*/
once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, context?: Object): void;
once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, failureCallback?: (error: any) => void, context?: Object): void;
once(eventType: string): Promise<FirebaseDataSnapshot>
/**
* Generates a new Query object ordered by the specified child key.
*/
orderByChild(key: string): FirebaseQuery;
/**
* Generates a new Query object ordered by key name.
*/
orderByKey(): FirebaseQuery;
/**
* Generates a new Query object ordered by child values.
*/
orderByValue(): FirebaseQuery;
/**
* Generates a new Query object ordered by priority.
*/
orderByPriority(): FirebaseQuery;
/**
* @deprecated Use limitToFirst() and limitToLast() instead.
* Generates a new Query object limited to the specified number of children.
*/
limit(limit: number): FirebaseQuery;
/**
* Creates a Query with the specified starting point.
* The generated Query includes children which match the specified starting point.
*/
startAt(value: string, key?: string): FirebaseQuery;
startAt(value: number, key?: string): FirebaseQuery;
/**
* Creates a Query with the specified ending point.
* The generated Query includes children which match the specified ending point.
*/
endAt(value: string, key?: string): FirebaseQuery;
endAt(value: number, key?: string): FirebaseQuery;
/**
* Creates a Query which includes children which match the specified value.
*/
equalTo(value: string|number|boolean, key?: string): FirebaseQuery;
/**
* Generates a new Query object limited to the first certain number of children.
*/
limitToFirst(limit: number): FirebaseQuery;
/**
* Generates a new Query object limited to the last certain number of children.
*/
limitToLast(limit: number): FirebaseQuery;
/**
* Gets a Firebase reference to the Query's location.
*/
ref(): Firebase;
}
interface Firebase extends FirebaseQuery {
/**
* @deprecated Use authWithCustomToken() instead.
* Authenticates a Firebase client using the provided authentication token or Firebase Secret.
*/
auth(authToken: string, onComplete: (error: any, result: FirebaseAuthResult) => void, onCancel?:(error: any) => void): void;
auth(authToken: string): Promise<FirebaseAuthResult>;
/**
* Authenticates a Firebase client using an authentication token or Firebase Secret.
*/
authWithCustomToken(autoToken: string, onComplete: (error: any, authData: FirebaseAuthData) => void, options?:Object): void;
authWithCustomToken(autoToken: string, options?:Object): Promise<FirebaseAuthData>;
/**
* Authenticates a Firebase client using a new, temporary guest account.
*/
authAnonymously(onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void;
authAnonymously(options?: Object): Promise<FirebaseAuthData>;
/**
* Authenticates a Firebase client using an email / password combination.
*/
authWithPassword(credentials: FirebaseCredentials, onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void;
authWithPassword(credentials: FirebaseCredentials, options?: Object): Promise<FirebaseAuthData>;
/**
* Authenticates a Firebase client using a popup-based OAuth flow.
*/
authWithOAuthPopup(provider: string, onComplete:(error: any, authData: FirebaseAuthData) => void, options?: Object): void;
authWithOAuthPopup(provider: string, options?: Object): Promise<FirebaseAuthData>;
/**
* Authenticates a Firebase client using a redirect-based OAuth flow.
*/
authWithOAuthRedirect(provider: string, onComplete: (error: any) => void, options?: Object): void;
authWithOAuthRedirect(provider: string, options?: Object): Promise<void>;
/**
* Authenticates a Firebase client using OAuth access tokens or credentials.
*/
authWithOAuthToken(provider: string, credentials: string|Object, onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void;
authWithOAuthToken(provider: string, credentials: string|Object, options?: Object): Promise<FirebaseAuthData>;
/**
* Synchronously access the current authentication state of the client.
*/
getAuth(): FirebaseAuthData;
/**
* Listen for changes to the client's authentication state.
*/
onAuth(onComplete: (authData: FirebaseAuthData) => void, context?: Object): void;
/**
* Detaches a callback previously attached with onAuth().
*/
offAuth(onComplete: (authData: FirebaseAuthData) => void, context?: Object): void;
/**
* Unauthenticates a Firebase client.
*/
unauth(): void;
/**
* Gets a Firebase reference for the location at the specified relative path.
*/
child(childPath: string): Firebase;
/**
* Gets a Firebase reference to the parent location.
*/
parent(): Firebase;
/**
* Gets a Firebase reference to the root of the Firebase.
*/
root(): Firebase;
/**
* Returns the last token in a Firebase location.
*/
key(): string;
/**
* @deprecated Use key() instead.
* Returns the last token in a Firebase location.
*/
name(): string;
/**
* Gets the absolute URL corresponding to this Firebase reference's location.
*/
toString(): string;
/**
* Writes data to this Firebase location.
*/
set(value: any, onComplete: (error: any) => void): void;
set(value: any): Promise<void>;
/**
* Writes the enumerated children to this Firebase location.
*/
update(value: Object, onComplete: (error: any) => void): void;
update(value: Object): Promise<void>;
/**
* Removes the data at this Firebase location.
*/
remove(onComplete: (error: any) => void): void;
remove(): Promise<void>;
/**
* Generates a new child location using a unique name and returns a Firebase reference to it.
* @returns {Firebase} A Firebase reference for the generated location.
*/
push(value?: any, onComplete?: (error: any) => void): FirebaseWithPromise<void>;
/**
* Writes data to this Firebase location. Like set() but also specifies the priority for that data.
*/
setWithPriority(value: any, priority: string|number, onComplete: (error: any) => void): void;
setWithPriority(value: any, priority: string|number): Promise<void>;
/**
* Sets a priority for the data at this Firebase location.
*/
setPriority(priority: string|number, onComplete: (error: any) => void): void;
setPriority(priority: string|number): Promise<void>;
/**
* Atomically modifies the data at this location.
*/
transaction(updateFunction: (currentData: any)=> any, onComplete?: (error: any, committed: boolean, snapshot: FirebaseDataSnapshot) => void, applyLocally?: boolean): void;
/**
* Creates a new user account using an email / password combination.
*/
createUser(credentials: FirebaseCredentials, onComplete: (error: any, userData: any) => void): void;
/**
* Updates the email associated with an email / password user account.
*/
changeEmail(credentials: FirebaseChangeEmailCredentials, onComplete: (error: any) => void): void;
/**
* Change the password of an existing user using an email / password combination.
*/
changePassword(credentials: FirebaseChangePasswordCredentials, onComplete: (error: any) => void): void;
/**
* Removes an existing user account using an email / password combination.
*/
removeUser(credentials: FirebaseCredentials, onComplete: (error: any) => void): void;
/**
* Sends a password-reset email to the owner of the account, containing a token that may be used to authenticate and change the user password.
*/
resetPassword(credentials: FirebaseResetPasswordCredentials, onComplete: (error: any) => void): void;
onDisconnect(): FirebaseOnDisconnect;
}
interface FirebaseWithPromise<T> extends Firebase, Promise<T> {}
interface FirebaseStatic {
/**
* Constructs a new Firebase reference from a full Firebase URL.
*/
new (firebaseURL: string): Firebase;
/**
* Manually disconnects the Firebase client from the server and disables automatic reconnection.
*/
goOffline(): void;
/**
* Manually reestablishes a connection to the Firebase server and enables automatic reconnection.
*/
goOnline(): void;
ServerValue: {
/**
* A placeholder value for auto-populating the current timestamp
* (time since the Unix epoch, in milliseconds) by the Firebase servers.
*/
TIMESTAMP: any;
};
}
declare var Firebase: FirebaseStatic;
declare module 'firebase' {
export = Firebase;
}
// Reference: https://www.firebase.com/docs/web/api/firebase/getauth.html
interface FirebaseAuthData {
uid: string;
provider: string;
token: string;
expires: number;
auth: Object;
google?: FirebaseAuthDataGoogle;
twitter?: FirebaseAuthDataTwitter;
github?: FirebaseAuthDataGithub;
facebook?: FirebaseAuthDataFacebook;
password?: FirebaseAuthDataPassword;
anonymous?: any;
}
interface FirebaseAuthDataPassword{
email: string;
isTemporaryPassword: boolean;
profileImageURL: string;
}
interface FirebaseAuthDataTwitter{
id: string;
accessToken: string;
accessTokenSecret: string;
displayName: string;
username: string;
profileImageURL: string;
cachedUserProfile: any;
}
interface FirebaseAuthDataGithub{
id: string;
accessToken: string;
displayName: string;
email?: string;
username: string;
profileImageURL: string;
cachedUserProfile: any;
}
interface FirebaseAuthDataFacebook{
id: string;
accessToken: string;
displayName: string;
email?: string;
profileImageURL: string;
cachedUserProfile: any;
}
interface FirebaseAuthDataGoogle {
accessToken: string;
cachedUserProfile: FirebaseAuthDataGoogleCachedUserProfile;
displayName: string;
email?: string;
id: string;
profileImageURL: string;
}
interface FirebaseAuthDataGoogleCachedUserProfile {
"family name"?: string;
gender?: string;
"given name"?: string;
id?: string;
link?: string;
locale?: string;
name?: string;
picture?: string;
}
interface FirebaseCredentials {
email: string;
password: string;
}
interface FirebaseChangePasswordCredentials {
email: string;
oldPassword: string;
newPassword: string;
}
interface FirebaseChangeEmailCredentials {
oldEmail: string;
newEmail: string;
password: string;
}
interface FirebaseResetPasswordCredentials {
email: string;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,86 +0,0 @@
var chatRef: Firebase = new Firebase('https://<YOUR-FIREBASE>.firebaseio.com');
var auth: FirebaseSimpleLogin = new FirebaseSimpleLogin(chatRef, function(error, user) {
if (error) {
// an error occurred while attempting login
switch(error.code) {
case 'INVALID_EMAIL':
case 'INVALID_PASSWORD':
default:
}
} else if (user) {
// user authenticated with Firebase
console.log('User ID: ' + user.id + ', Provider: ' + user.provider);
} else {
// user is logged out
}
});
var email = 'my@email.com';
var password = 'secret';
var oldPassword = 'secret';
var newPassword = 'secret';
auth.login('password', {
email: '<email@domain.com>',
password: '<password>',
rememberMe: true
});
auth.login('facebook', {
rememberMe: true,
scope: 'email,user_likes'
});
auth.login('github', {
rememberMe: true,
scope: 'user,gist'
});
auth.login('google', {
rememberMe: true,
scope: 'https://www.googleapis.com/auth/plus.login'
});
auth.login('persona', {
rememberMe: true
});
auth.login('twitter', {
rememberMe: true
});
auth.login('anonymous');
auth.createUser(email, password, function(error, user) {
if (!error) {
console.log('User Id: ' + user.id + ', Email: ' + user.email);
}
});
auth.createUser(email, password);
auth.changePassword(email, oldPassword, newPassword, function(error, success) {
if (!error) {
console.log('Password changed successfully');
}
});
auth.changePassword(email, oldPassword, newPassword);
auth.sendPasswordResetEmail(email, function(error, success) {
if (!error) {
console.log('Password reset email sent successfully');
}
});
auth.sendPasswordResetEmail(email);
auth.removeUser(email, password, function(error, success) {
if (!error) {
console.log('User deleted successfully');
}
});
auth.removeUser(email, password);

View File

@ -1,26 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"firebase-simplelogin.d.ts",
"test/index.ts",
"test/simplelogin.ts"
]
}

View File

@ -1,79 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
}