https://github.com/cosmic-fi/oriauth
Ori-Auth is a simple TypeScript npm package designed to handle Firebase authentication. It offers a set of easy-to-use functions for creating users, retrieving user data, logging in, resetting passwords, and logging out.
https://github.com/cosmic-fi/oriauth
authentication firebase firebase-auth firebase-authentication firebase-user password-reset user-authentication user-management
Last synced: 2 months ago
JSON representation
Ori-Auth is a simple TypeScript npm package designed to handle Firebase authentication. It offers a set of easy-to-use functions for creating users, retrieving user data, logging in, resetting passwords, and logging out.
- Host: GitHub
- URL: https://github.com/cosmic-fi/oriauth
- Owner: cosmic-fi
- License: other
- Created: 2023-10-20T00:31:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-20T17:44:48.000Z (over 2 years ago)
- Last Synced: 2025-05-30T00:14:14.948Z (about 1 year ago)
- Topics: authentication, firebase, firebase-auth, firebase-authentication, firebase-user, password-reset, user-authentication, user-management
- Language: JavaScript
- Homepage:
- Size: 34.8 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README

##
Ori-Auth is a simple Javascrtipt npm package designed to handle Firebase authentication. It offers a set of easy-to-use functions for creating users, retrieving user data, logging in, resetting passwords, and logging out.
## Installation
You can install Ori-Auth via npm or yarn:
```bash
npm install ori-auth
```
or
```bash
yarn add ori-auth.
```
## Usage
To use this package, import it in your project:
```javascript
const OriAuth = require('ori-auth');
const auth = new OriAuth();
```
**Configuration**
To use this package, you need to configure it with your Firebase project details.
Pass your Firebase project configuration object to the config method:
```javascript
const config = {
apiKey: 'your-api-key',
authDomain: 'your-auth-domain',
projectId: 'your-project-id',
storageBucket: 'your-storage-bucket',
messagingSenderId: 'your-messaging-sender-id',
appId: 'your-app-id',
};
auth.config(firebaseConfig);
```
## API Methods
`createUser(email: string, password: string, username: string): Promise`
- Creates a new user with an email, password, and username. Returns the UID of the created user.
`getUser(email: string, password: string): Promise`
- Logs in a user with an email and password, then retrieves the user's data from Firestore. Returns an object with the user's username and UID.
`login(email: string, password: string): Promise`
- Logs in an existing user with an email and password.
`resetPassword(email: string): Promise`
- Sends a password reset email to the given email address.
`logout(): Promise`
- Logs the user out.
## Example
```javascript
const OriAuth = require('ori-auth');
const auth = new OriAuth();
const config = {
apiKey: 'your-api-key',
authDomain: 'your-auth-domain',
projectId: 'your-project-id',
storageBucket: 'your-storage-bucket',
messagingSenderId: 'your-messaging-sender-id',
appId: 'your-app-id',
};
auth.config(config);
async function run() {
try {
const uid = await auth.createUser('user@example.com', 'password123', 'myusername');
console.log('Created user with UID:', uid);
const userData = await auth.getUser('user@example.com', 'password123');
console.log('User data:', userData);
await auth.login('user@example.com', 'password123');
console.log('Logged in');
await auth.resetPassword('user@example.com');
console.log('Password reset email sent');
await auth.logout();
console.log('Logged out');
} catch (error) {
console.error('Error:', error.message);
}
}
run();
```
## License
This project is licensed under the MIT License. For more details, please see the [LICENSE][license-link] file.
[license-link]: https://github.com/cosmic-fi/OriAuth/blob/main/LICENSE.md