-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d04c153
Showing
10 changed files
with
6,944 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: CI | ||
on: [push] | ||
jobs: | ||
build: | ||
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
node: ['14.x','16.x'] | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node ${{ matrix.node }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install deps and build (with cache) | ||
uses: bahmutov/npm-install@v1 | ||
|
||
|
||
- name: Build | ||
run: yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Publish | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm install | ||
- run: npm run build | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: size | ||
on: [pull_request] | ||
jobs: | ||
size: | ||
runs-on: ubuntu-latest | ||
env: | ||
CI_JOB_NUMBER: 1 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: andresz1/size-limit-action@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.log | ||
.DS_Store | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Nouhack | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<h1 style="text-align: center;">Fauth</h1> | ||
|
||
<p align="center"> | ||
<img src="https://drive.google.com/uc?id=1ElgsHenw7OrryqlOjrecebw6pmbexPCE"> | ||
</p> | ||
<h1 style="text-align: center;"><span style="color: green">Fake</span> Auth solution </h1> | ||
<h5 style="text-align: center;">The lightest fake authentication solution only JS . </h5> | ||
|
||
|
||
## Installation | ||
npm installation : | ||
|
||
```sh | ||
npm i @nouhsa/fauth | ||
``` | ||
|
||
CDN : | ||
|
||
```sh | ||
<script src= "https://unpkg.com/@nouhsa/[email protected]/script.js"> </script> | ||
``` | ||
## Functions list | ||
|
||
- sign_up ( username , email , password , image_profile ) | ||
- sign_in ( email , password ) | ||
- sign_out() | ||
- is_authenticated() | ||
- modify( new_user_data_object ) | ||
- delete_account() | ||
|
||
|
||
|
||
|
||
## Release History | ||
|
||
* 1.0.0 | ||
* The first stable release . | ||
|
||
|
||
## Meta | ||
|
||
Contact me :tw-1f4e9: – [@FiX_0_](https://twitter.com/FiX_0_) – [email protected] . | ||
Donate (paypal) : :tw-25b6: [email protected] . | ||
|
||
|
||
Distributed under the MIT license. | ||
|
||
## Contributing | ||
|
||
1. Fork it (<https://github.com/Nouhack/Fauth>) | ||
2. Create your feature branch (`git checkout -b feature/fooBar`) | ||
3. Commit your changes (`git commit -am 'Add some fooBar'`) | ||
4. Push to the branch (`git push origin feature/fooBar`) | ||
5. Create a new Pull Request | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "tsdx test", | ||
"lint": "tsdx lint", | ||
"prepare": "tsdx build", | ||
"size": "size-limit", | ||
"analyze": "size-limit --why" | ||
}, | ||
"peerDependencies": {}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "tsdx lint" | ||
} | ||
}, | ||
"prettier": { | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
}, | ||
"name": "@nouhsa/fauth", | ||
"author": "Nouhack", | ||
"module": "dist/mylib.esm.js", | ||
"size-limit": [ | ||
{ | ||
"path": "dist/mylib.cjs.production.min.js", | ||
"limit": "10 KB" | ||
}, | ||
{ | ||
"path": "dist/mylib.esm.js", | ||
"limit": "10 KB" | ||
} | ||
], | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "^8.1.0", | ||
"husky": "^8.0.2", | ||
"size-limit": "^8.1.0", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.4.1", | ||
"typescript": "^4.8.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
interface user_data { | ||
username: 'user'; | ||
email: string; | ||
password: string; | ||
image_profile: ''; | ||
} | ||
// sign up function ========================= | ||
export const sign_up = (user: user_data) => { | ||
var the_new_user = { | ||
username: user.username, | ||
email: user.email, | ||
password: user.password, | ||
logged_in: true, | ||
created_at: new Date(), | ||
image_profile: user.image_profile, | ||
}; | ||
window.localStorage.setItem('user', JSON.stringify(the_new_user)); | ||
}; | ||
// ========================================== | ||
// sign out function ======================== | ||
export const sign_out = () => { | ||
var authenticated_user = JSON.parse(window.localStorage.getItem('user')!); | ||
var kk = { | ||
...authenticated_user, | ||
logged_in: false, | ||
}; | ||
window.localStorage.setItem('user', JSON.stringify(kk)); | ||
}; | ||
// ========================================== | ||
// sign in function ========================= | ||
|
||
export const sign_in = (email: string, password: string) => { | ||
var signed_user = JSON.parse(window.localStorage.getItem('user')!); | ||
if (signed_user === null) { | ||
return { | ||
sign_in: false, | ||
message: 'you should log in first', | ||
}; | ||
} else { | ||
// here verify the credentials | ||
if (signed_user.email === email && | ||
signed_user.password === password | ||
) { | ||
var pp = { | ||
...signed_user, | ||
logged_in: true, | ||
}; | ||
window.localStorage.setItem('user', JSON.stringify(pp)); | ||
return { | ||
sign_in: true, | ||
message: 'congrats you logged in', | ||
}; | ||
} else { | ||
return { | ||
sign_in: false, | ||
message: 'credential error', | ||
} | ||
} | ||
} | ||
}; | ||
// ========================================== | ||
// is authenticated function ================ | ||
export const is_authenticated = () => { | ||
var authenticated_user = JSON.parse(window.localStorage.getItem('user')!); | ||
if (authenticated_user === null || !authenticated_user.logged_in) { | ||
return authenticated_user; | ||
} | ||
return authenticated_user; | ||
}; | ||
// ========================================== | ||
// delete account function ================== | ||
export const delete_account = () => { | ||
window.localStorage.removeItem('user'); | ||
}; | ||
// ========================================== | ||
// modify account function ================== | ||
// | ||
export const modify = (newData: user_data) => { | ||
var current_user = JSON.parse(window.localStorage.getItem('user')!); | ||
var modified_user = { | ||
username: newData.username ? newData.username : current_user.username, | ||
email: newData.email ? newData.email : current_user.email, | ||
password: newData.password ? newData.password : current_user.password, | ||
created_at: current_user.created_at, | ||
logged_in: true, | ||
image_profile: newData.image_profile ? newData.image_profile : current_user.image_profile | ||
}; | ||
window.localStorage.setItem('user', JSON.stringify(modified_user)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs | ||
"include": ["src", "types"], | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"lib": ["dom", "esnext"], | ||
"importHelpers": true, | ||
// output .d.ts declaration files for consumers | ||
"declaration": true, | ||
// output .js.map sourcemap files for consumers | ||
"sourceMap": true, | ||
// match output dir to input dir. e.g. dist/index instead of dist/src/index | ||
"rootDir": "./src", | ||
// stricter type-checking for stronger correctness. Recommended by TS | ||
"strict": true, | ||
// linter checks for common issues | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
// noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
// use Node's module resolution algorithm, instead of the legacy TS one | ||
"moduleResolution": "node", | ||
// transpile JSX to React.createElement | ||
"jsx": "react", | ||
// interop between ESM and CJS modules. Recommended by TS | ||
"esModuleInterop": true, | ||
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS | ||
"skipLibCheck": true, | ||
// error out if import and file system have a casing mismatch. Recommended by TS | ||
"forceConsistentCasingInFileNames": true, | ||
// `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc` | ||
"noEmit": true, | ||
} | ||
} |
Oops, something went wrong.