|
1 | | -# Userfront Core JS library |
| 1 | +# ⚠️ This Repo is Deprecated |
2 | 2 |
|
3 | | -The Userfront Core JavaScript library is intended for use in frontend applications. |
4 | | - |
5 | | -The Core library can be used for the following: |
6 | | - |
7 | | -- **Tokens**: read the user's access token to send to your backend |
8 | | -- **User info**: information about the currently logged in user |
9 | | -- **Authentication**: signup, login, logout, and password reset tasks; these are useful for building custom forms and auth flows. |
10 | | - |
11 | | -## Docs |
12 | | - |
13 | | -Full docs can be found in the Userfront guide: |
14 | | - |
15 | | -https://userfront.com/docs/js.html |
16 | | - |
17 | | -## Setup |
18 | | - |
19 | | -Install by npm (or yarn): |
20 | | - |
21 | | -```sh |
22 | | -npm install @userfront/core --save |
23 | | -``` |
24 | | - |
25 | | -Import and initialize the library: |
26 | | - |
27 | | -```js |
28 | | -import Userfront from "@userfront/core"; |
29 | | - |
30 | | -Userfront.init("demo1234"); |
31 | | -``` |
32 | | - |
33 | | -## Examples |
34 | | - |
35 | | -```js |
36 | | -// Import and initialize Userfront core JS |
37 | | -import Userfront from "@userfront/core"; |
38 | | -Userfront.init("demo1234"); |
39 | | - |
40 | | -// Send a login link |
41 | | -Userfront. sendLoginLink( "[email protected]"); |
42 | | - |
43 | | -// Read the access token |
44 | | -Userfront.tokens.accessToken; |
45 | | - |
46 | | -// => "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJtb2RlIjoidGVzdCIsImlzQ29uZmlybWVkIjp0cnVlLCJ1c2VySWQiOjEsInVzZXJVdWlkIjoiZDAwNTlmN2UtYzU0OS00NmYzLWEzYTMtOGEwNDY0MDkzZmMyIiwidGVuYW50SWQiOiJwOW55OGJkaiIsInNlc3Npb25JZCI6IjRlZjBlMjdjLTI1NDAtNDIzOS05YTJiLWRkZjgyZjE3YmExYiIsImF1dGhvcml6YXRpb24iOnsicDlueThiZGoiOnsidGVuYW50SWQiOiJwOW55OGJkaiIsIm5hbWUiOiJVc2VyZnJvbnQiLCJyb2xlcyI6WyJhZG1pbiJdLCJwZXJtaXNzaW9ucyI6W119fSwiaWF0IjoxNjE3MTQ4MDY3LCJleHAiOjE2MTk3NDAwNjd9.gYz4wxPHLY6PNp8KPEyIjLZ8QzG3-NFJGPitginuLaU" |
47 | | - |
48 | | -// Log the user out |
49 | | -Userfront.logout(); |
50 | | - |
51 | | -// Access the user's information |
52 | | -Userfront.user; |
53 | | - |
54 | | -/** => |
55 | | - * { |
56 | | - * email: "jane@example.com", |
57 | | - * phoneNumber: "+15558675309", |
58 | | - * name: "Jane Example", |
59 | | - * image: "https://res.cloudinary.com/component/image/upload/avatars/avatar-plain-9.png", |
60 | | - * data: {}, |
61 | | - * username: "jane-example", |
62 | | - * isEmailConfirmed: true, |
63 | | - * isPhoneNumberConfirmed: false, |
64 | | - * confirmedEmailAt: "2020-01-01T00:00:00.000Z", |
65 | | - * confirmedPhoneNumberAt: "2020-01-01T00:00:00.000Z", |
66 | | - * isMfaRequired: false, |
67 | | - * createdAt: "2020-01-01T00:00:00.000Z", |
68 | | - * updatedAt: "2020-01-01T00:00:00.000Z", |
69 | | - * mode: "test", |
70 | | - * tenantId: "demo1234", |
71 | | - * userId: 1, |
72 | | - * userUuid: "d6f0f045-f6ea-4262-8724-dfc0b77e7dc9", |
73 | | - * } |
74 | | - */ |
75 | | -``` |
76 | | - |
77 | | -## Development |
78 | | - |
79 | | -### Building |
80 | | - |
81 | | -- `npm build`: build all library files |
82 | | - |
83 | | -The build commands are split into two parts. `build` and `build:beta` both run these commands, which do not need to be run separately: |
84 | | - |
85 | | -- `npm build:standard`: build the standard library files: |
86 | | - - ESM module `build/userfront-core.module.js` |
87 | | - - CJS module `build/userfront-core.js` |
88 | | - - UMD module `build/userfront-core.umd.js` |
89 | | - - Module with bundled dependencies, for import from CDN: `build/userfront-core.modern.mjs` |
| 3 | +The Userfront JavaScript SDK is now located at [userfront/userfront/packages/core](https://github.com/userfront/userfront/tree/main/packages/core). |
0 commit comments