Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Git leaks #70

Merged
merged 6 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
git leaks, improve readme
  • Loading branch information
asafshen committed Apr 6, 2023
commit 5590468a68fa1bdf6300675477302c37a0bb2ad7
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ on: push
env:
NODE_VERSION: 18.2
jobs:
gitleaks:
name: 🔒 Run Git leaks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
- name: Install dependencies
run: npm ci --ignore-scripts
asafshen marked this conversation as resolved.
Show resolved Hide resolved
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
- name: Gitleaks
run: npm run leaks
shell: bash
pr:
name: 👷 Build / Lint / Test
runs-on: ubuntu-latest
Expand All @@ -22,6 +41,7 @@ jobs:
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}

- name: Build
run: pnpm run build
env:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"postbuild:ci_": "pnpm -r $(npm run print-affected:ci | tail -n 1 | sed 's/, / --filter /g;s/^/--filter /') exec pwd | sed 's/$/\\//' | xargs -I {} rsync -av --progress {} /Users/nirgurarie/dev/monorepo-playground/dist/packages/ --exclude node_modules",
"build": "nx affected --target build",
"build:ci": "pnpm affected:ci --target build --parallel 1",
"leaks": "bash ./tools/scripts/gitleaks/gitleaks.sh",
"lint": "nx affected --target lint --fix=true",
"lint:ci": "pnpm affected:ci --target lint",
"test": "nx affected --target test",
Expand Down
27 changes: 24 additions & 3 deletions packages/web-js-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import descopeSdk, { getSessionToken } from '@descope/web-js-sdk';

const myProjectId = 'xxx';
// Passing persistTokens as true will make `sdk.getSessionToken()` available, see bellow
const sdk = descopeSdk({ projectId: myProjectId, persistTokens: true });
const sdk = descopeSdk({
projectId: myProjectId,
persistTokens: true,
asafshen marked this conversation as resolved.
Show resolved Hide resolved
autoRefresh: true,
});

sdk.onSessionTokenChange((newSession, oldSession) => {
// handle session token change...
Expand All @@ -26,11 +30,28 @@ sdk.onSessionTokenChange((newSession, oldSession) => {
sdk.onUserChange((newUser, oldUser) => {
// handle user change...
});

// It is common to call the refresh function after sdk initialization, for a case that the browser has the refresh token on storage/cookie
asafshen marked this conversation as resolved.
Show resolved Hide resolved
// Note that if autoRefresh is true, and refresh is successful -
asafshen marked this conversation as resolved.
Show resolved Hide resolved
// The sdk will automatically continue to refresh the token
sdk.refresh();

// Alternatively - use the sdk's available authentication methods to authenticate the user
const userIdentifier = 'identifier';
sdk.otp.signIn.email(userIdentifier);
let res = await sdk.otp.signIn.email(userIdentifier);
if (!res.ok) {
throw Error('Failed to sign in');
}

// Get the code from email and
const codeFromEmail = '1234';
res = await sdk.otp.verify.email(userIdentifier, codeFromEmail);
if (!res.ok) {
throw Error('Failed to sign in');
}

// Get session token
// can be used to pass token to server on header
// Can be used to pass token to server on header
const sessionToken = sdk.getSessionToken();
```

Expand Down