Skip to content

Commit a1ed953

Browse files
authored
Basic authentication sdk (#1)
* added types added basic package json added otp sign in and sign up added ci workflow * fix workflow * updated packages fixed lint * intial authentication service added workflow leaks test and sizing added deployment * fixing sizing and build * remove from jest conf * fix leaks * fix sizing and ci workflow * fix git ignore * add ignore * fix sizing build * added lint cleaned code * lint * added error handling added lint and fixed formatting added types added tests and mocks * added tests and new JWT error * modified lint configs added more tests fixed format added coverage * fix formats * fix git leaks and format * format * fix git leaks removed sizing until main fixed and reformated example app added logger support added support for vanilla js * format * fix ci * fix gitleaks * matched es lint added logout and ouath to sdk and example refactor namings added tests * format * add publish configurations removed unused lines and moved functions fixed timeout too short by default * changed sign in and sign up to use external id * removed and formated files added project id enforcement added test * remove semicolon reformatted logger and shared types added OTP interface and comments * fix format * fixed required semicolon * add commonjs example fixed types out dir fixed default url * added enforce spaces removed unused dep renamed error renamed shared file to http * remove launch.json
1 parent d0b720e commit a1ed953

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+22287
-30
lines changed

.eslintrc.cjs

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const fs = require('fs');
2+
3+
module.exports = {
4+
root: true,
5+
extends: ['airbnb-base', 'prettier', 'plugin:jest/recommended', 'plugin:import/typescript', 'airbnb-typescript/base'],
6+
plugins: [
7+
"@typescript-eslint",
8+
"prettier",
9+
"import",
10+
"prefer-arrow",
11+
"jest-dom",
12+
"jest",
13+
"jest-formatting",
14+
"no-only-tests"],
15+
parser: '@typescript-eslint/parser',
16+
parserOptions: {
17+
project: './tsconfig.json',
18+
},
19+
env: {
20+
jest: true,
21+
node: true,
22+
},
23+
settings: {
24+
"import/parsers": {
25+
"@typescript-eslint/parser": [".ts", ".tsx", ".js"]
26+
},
27+
"import/resolver": {
28+
"typescript": {
29+
"alwaysTryTypes": true
30+
}
31+
}
32+
},
33+
rules: {
34+
"no-tabs": ["error", { "allowIndentationTabs": true }],
35+
"@typescript-eslint/indent": ["off"],
36+
"quotes": [
37+
"error",
38+
"single",
39+
{ "avoidEscape": true, "allowTemplateLiterals": true }
40+
],
41+
"@typescript-eslint/quotes": [
42+
"error",
43+
"single",
44+
{ "avoidEscape": true, "allowTemplateLiterals": true }
45+
],
46+
"semi": ["error", "never"],
47+
"space-before-blocks": 2,
48+
"space-before-function-paren": 2,
49+
"no-multi-spaces": 2,
50+
"@typescript-eslint/semi": "off",
51+
"no-unexpected-multiline": "error",
52+
"@typescript-eslint/comma-dangle": ["off"],
53+
"comma-dangle": ["off"],
54+
"no-console": 2,
55+
"class-methods-use-this": 0,
56+
"no-only-tests/no-only-tests": 2,
57+
"no-warning-comments": 2,
58+
"import/no-unresolved": 2,
59+
"import/named": 2,
60+
"import/no-relative-packages": 2,
61+
"import/no-cycle": 2,
62+
"import/newline-after-import": 2,
63+
"import/no-namespace": 2,
64+
"import/no-duplicates": 2,
65+
"import/first": 2,
66+
"import/exports-last": 2,
67+
"import/no-absolute-path": 2,
68+
"import/no-dynamic-require": 2,
69+
"import/no-self-import": 2,
70+
"import/no-useless-path-segments": 2,
71+
"import/no-extraneous-dependencies": [
72+
2,
73+
{
74+
"devDependencies": [
75+
"!./src/**/*"
76+
]
77+
}
78+
],
79+
'import/extensions': [
80+
'error',
81+
'ignorePackages',
82+
{
83+
js: 'never',
84+
jsx: 'never',
85+
ts: 'never',
86+
tsx: 'never',
87+
},
88+
],
89+
},
90+
ignorePatterns: ['.eslintrc.cjs', 'build/*', 'dist/*', 'coverage/*', '**/testutils/*'],
91+
};

.github/CODEOWNERS

Whitespace-only changes.

.github/actions/setup/action.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Setup
2+
description: Setup
3+
inputs:
4+
node_version:
5+
description: Node version to use
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Setup Node.js 🔠
11+
uses: actions/setup-node@v3
12+
with:
13+
node-version: ${{ inputs.node_version }}
14+
15+
- name: Cache node modules 💸
16+
uses: actions/cache@v3
17+
env:
18+
cache-name: cache-node-modules
19+
with:
20+
path: ~/.npm
21+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
22+
restore-keys: |
23+
${{ runner.os }}-build-${{ env.cache-name }}-
24+
${{ runner.os }}-build-
25+
${{ runner.os }}-
26+
- name: Install Dependencies 🪛
27+
shell: bash
28+
run: npm i

.github/pull_request_template.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Description
2+
3+
A few sentences describing the overall goals of the pull request's commits.
4+
5+
## Must
6+
7+
- [ ] Tests
8+
- [ ] Documentation (if applicable)

.github/workflows/ci.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on: push
4+
5+
env:
6+
NODE_VERSION: 16.14
7+
8+
jobs:
9+
build:
10+
name: 👷 Build & Deploy
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
- name: Setup
16+
uses: ./.github/actions/setup
17+
with:
18+
node_version: ${{ env.NODE_VERSION }}
19+
- name: Building
20+
run: npm run build
21+
- name: 🆙⬆️ Upload Artifacts
22+
uses: actions/upload-artifact@v3
23+
with:
24+
name: node-sdk-${{github.sha}}
25+
path: build/
26+
27+
eslint:
28+
name: 🪥 ESLint
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
- name: Setup
34+
uses: ./.github/actions/setup
35+
with:
36+
node_version: ${{ env.NODE_VERSION }}
37+
- run: npm run check-format
38+
- run: npm run lint
39+
40+
gitleaks:
41+
name: 🔒 Run Git leaks
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v3
46+
- name: Setup
47+
uses: ./.github/actions/setup
48+
with:
49+
node_version: ${{ env.NODE_VERSION }}
50+
- name: Gitleaks
51+
run: |
52+
npm run leaks
53+
shell: bash
54+
55+
unit-test:
56+
name: 👔 Run Unit Tests
57+
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
version: [14, 16, 18]
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v3
64+
- name: Setup
65+
uses: ./.github/actions/setup
66+
with:
67+
node-version: ${{ matrix.version }}
68+
- name: Testing
69+
run: npm test
70+
- name: Coverage check
71+
uses: devmasx/[email protected]
72+
with:
73+
type: lcov
74+
min_coverage: 95
75+
result_path: coverage/lcov.info
76+
token: ${{ github.token }}

.github/workflows/publish.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 📢 publish
2+
3+
on:
4+
create:
5+
tags:
6+
- 'release/**'
7+
8+
env:
9+
NODE_VERSION: 16.14
10+
11+
jobs:
12+
publish:
13+
name: 📢 Publish
14+
permissions:
15+
packages: write
16+
contents: read
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ env.NODE_VERSION }}
24+
registry-url: https://npm.pkg.github.com/
25+
26+
- name: Install dependencies
27+
run: npm i
28+
env:
29+
CI: true
30+
31+
- name: Publish to GitHub Package Registry
32+
run: npm publish
33+
env:
34+
CI: true
35+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sizing.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Sizing
2+
3+
on: [pull_request]
4+
5+
env:
6+
NODE_VERSION: 16.14
7+
8+
jobs:
9+
sizing:
10+
name: 🏋️ Sizing
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: DISABLED UNTIL MAIN
14+
if: ${{ false }}
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
- name: Setup
18+
uses: ./.github/actions/setup
19+
with:
20+
node_version: ${{ env.NODE_VERSION }}
21+
- uses: andresz1/size-limit-action@v1
22+
with:
23+
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
build_script: build

.gitignore

+7-29
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ lib-cov
2121
# Coverage directory used by tools like istanbul
2222
coverage
2323
*.lcov
24+
coverage/
2425

2526
# nyc test coverage
2627
.nyc_output
@@ -62,9 +63,6 @@ typings/
6263
# Optional REPL history
6364
.node_repl_history
6465

65-
# Output of 'npm pack'
66-
*.tgz
67-
6866
# Yarn Integrity file
6967
.yarn-integrity
7068

@@ -75,30 +73,10 @@ typings/
7573
# parcel-bundler cache (https://parceljs.org/)
7674
.cache
7775

78-
# Next.js build output
79-
.next
80-
81-
# Nuxt.js build / generate output
82-
.nuxt
83-
dist
84-
85-
# Gatsby files
86-
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
90-
91-
# vuepress build output
92-
.vuepress/dist
93-
94-
# Serverless directories
95-
.serverless/
96-
97-
# FuseBox cache
98-
.fusebox/
99-
100-
# DynamoDB Local files
101-
.dynamodb/
76+
# build and example files
77+
dist/
78+
*.crt
79+
*.key
10280

103-
# TernJS port file
104-
.tern-port
81+
# VS Code
82+
!.vscode/launch.json.default

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
npm run format
2+
npm run lint
3+
npm run leaks
4+
npm test

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@descope:registry=https://npm.pkg.github.com

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore generated output
2+
dist
3+
types
4+
coverage

.prettierrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"trailingComma": "all"
8+
}

.vscode/launch.json.default

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// run the command to modify and use in VS Code:
2+
// cp launch.json.default launch.json
3+
{
4+
"version": "0.2.0",
5+
"configurations": [
6+
{
7+
"name": "Debug Jest Tests",
8+
"type": "node",
9+
"request": "launch",
10+
"runtimeArgs": ["--inspect-brk", "${workspaceFolder}/node_modules/.bin/jest", "--runInBand"],
11+
"console": "integratedTerminal",
12+
"internalConsoleOptions": "neverOpen"
13+
},
14+
{
15+
"type": "pwa-node",
16+
"request": "launch",
17+
"name": "Run Example: Express",
18+
"env": {
19+
"DESCOPE_PROJECT_ID": "<insert here>"
20+
},
21+
"program": "${workspaceFolder}/example/example.js"
22+
}
23+
]
24+
}

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# descope-node-client-sdk
1+
![Node-SDK](https://github.com/descope/node-sdk/actions/workflows/ci.yml/badge.svg)
2+
3+
# descope Node SDK
4+
25
Node.js client library used to integrate with Descope

babel.config.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [["@babel/preset-env", { "modules": false }], "@babel/preset-typescript"],
3+
"targets": "node 14",
4+
"ignore": ["**/*.test.ts", "**/testutils/*"],
5+
"plugins": ["babel-plugin-add-import-extension"]
6+
}

0 commit comments

Comments
 (0)