-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pre-alpha: Add descope headers to node sdk, fix build, lint, fix exam…
…ples (#70) 1. Add descope headers to node sdk 2. Fix build 3. Fix lint 4. Fix format 5. Add husky to commit 6. Fix examples
- Loading branch information
Showing
29 changed files
with
2,703 additions
and
1,093 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
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
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name: 📢 publish | ||
|
||
on: | ||
create: | ||
push: | ||
tags: | ||
- 'release/**' | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
npm run format | ||
npm run lint | ||
npm run leaks | ||
npm test | ||
npm run format-lint |
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 |
---|---|---|
@@ -1 +1 @@ | ||
# @descope:registry=https://npm.pkg.github.com | ||
@descope:registry=https://registry.npmjs.org |
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
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
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 |
---|---|---|
|
@@ -11,52 +11,54 @@ flowchart LR | |
|
||
### Prerequisites | ||
|
||
Replace any instance of `<ProjectID>` in the code below with your company's Project ID, which can be found in the [Descope console](https://app.descope.com). | ||
Replace any instance of `<ProjectID>` in the code below with your company's Project ID, which can be found in the [Descope console](https://app.descope.com). | ||
|
||
* Run the following commands in your project | ||
- Run the following commands in your project | ||
|
||
These commands will add the Descope NodeJS SDK as a project dependency. | ||
These commands will add the Descope NodeJS SDK as a project dependency. | ||
|
||
```bash | ||
npm i --save @descope/node-sdk | ||
``` | ||
```bash | ||
npm i --save @descope/node-sdk | ||
``` | ||
|
||
* Import and initialize the ExpresSDK for NodeJS client in your source code | ||
- Import and initialize the ExpresSDK for NodeJS client in your source code | ||
|
||
```javascript | ||
import DescopeClient from '@descope/node-sdk'; | ||
const descopeClient = DescopeClient({ projectId: <ProjectID> }); | ||
``` | ||
or | ||
```javascript | ||
import DescopeClient from '@descope/node-sdk'; | ||
const descopeClient = DescopeClient({ projectId: <ProjectID> }); | ||
``` | ||
|
||
```javascript | ||
const sdk = require('@descope/node-sdk'); | ||
const descopeClient = sdk({ projectId: <ProjectID> }); | ||
``` | ||
or | ||
|
||
```javascript | ||
const sdk = require('@descope/node-sdk'); | ||
const descopeClient = sdk({ projectId: <ProjectID> }); | ||
``` | ||
|
||
### 1. Customer Sign-up | ||
|
||
In your sign-up route using magic link (for example, `myapp.com/signup`) generate a sign-up request and send the magic link via the selected delivery method. In the example below an email is sent to "[email protected]" containing the magic link and the link will automatically return back to the provided URL ("https://mydomain.com/verify"). In additon, optional user data (for exmaple, a custom username in the code sample below) can be gathered during the sign-up process. | ||
|
||
```javascript | ||
await descopeClient.magiclink.signUp.email("[email protected]", { name: "custom name" }) | ||
await descopeClient.magiclink.signUp.email('[email protected]', { name: 'custom name' }); | ||
``` | ||
|
||
### 2. Customer Sign-in | ||
In your sign-in route using magic link (for exmaple, `myapp.com/login`) generate a sign-in request send the magic link via the selected delivery method. In the example below an email is sent to "[email protected]" containing the magic link and the link will automatically return back to the provided URL ("https://mydomain.com/verify"). | ||
|
||
In your sign-in route using magic link (for exmaple, `myapp.com/login`) generate a sign-in request send the magic link via the selected delivery method. In the example below an email is sent to "[email protected]" containing the magic link and the link will automatically return back to the provided URL ("https://mydomain.com/verify"). | ||
|
||
```javascript | ||
await descopeClient.magiclink.signIn.email("[email protected]") | ||
await descopeClient.magiclink.signIn.email('[email protected]'); | ||
``` | ||
|
||
### 3. Customer Verification | ||
|
||
In your verify customer route for magic link (for example, `mydomain.com/verify`) verify the token from either a customer sign-up or sign-in. | ||
|
||
```javascript | ||
const out = await descopeClient.magiclink.verify(token) | ||
const out = await descopeClient.magiclink.verify(token); | ||
if (out.data.cookies) { | ||
res.set('Set-Cookie', out.data.cookies) | ||
res.set('Set-Cookie', out.data.cookies); | ||
} | ||
``` | ||
|
||
|
@@ -65,8 +67,8 @@ if (out.data.cookies) { | |
Session validation checks to see that the visitor to your website or application is who they say they are, by comparing the value in the validation variables against the session data that is already stored. | ||
|
||
```javascript | ||
const out = await descopeClient.validateSession(session_jwt, refresh_jwt) | ||
const out = await descopeClient.validateSession(session_jwt, refresh_jwt); | ||
if (out?.cookies) { | ||
res.set('Set-Cookie', out.cookies) | ||
res.set('Set-Cookie', out.cookies); | ||
} | ||
``` |
Oops, something went wrong.