Skip to content

Commit

Permalink
Add linting and prettifying (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored Jun 11, 2024
1 parent f8f81c9 commit f6acb8b
Show file tree
Hide file tree
Showing 12 changed files with 1,579 additions and 553 deletions.
15 changes: 11 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,44 @@
Thank you for contributing! Please follow the steps below to help us process your PR quickly.
- 📝 Use a meaningful title for the pull request, e.g: "PAS-XXX | short pr description"
- 💭 Write a clear description and share screenshots (if applicable) to help describe your change.
- 🔍 Not all sections below will apply to you and are mostly for our internal team. It's okay to delete them if they are not applicable.
- 🔍 Not all sections below will apply to you and are mostly for our internal team. It's okay to delete them if they are not applicable.
-->

### Ticket

<!-- For Jira Tasks: (remove if external contributor) -->

- Closes [PAS-XXX](https://bitwarden.atlassian.net/browse/PAS-XXX)

<!-- For GitHub Issues: -->
<!-- - Closes #XXX -->


### Description

<!--
Introduction that should allow the reviewer to quickly be able to understand the reason for opening this PR.
-->

### Shape

<!--
Give a high-level overview of the technical design involved in the implemented changes.
If the changes don't have any architectural impact, you can remove this section.
-->

### Screenshots

<!--
Include any relevant UI screenshots showcasing the before & after of your changes.
If the changes don't have any UI impact, you can remove this section.
-->

### Checklist

I did the following to ensure that my changes were tested thoroughly:
- __

- \_\_

I did the following to ensure that my changes do not introduce security vulnerabilities:
- __

- \_\_
76 changes: 76 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: main

on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- published

jobs:
format:
runs-on: ubuntu-22.04

permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Install NodeJS
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Run format
run: npm run format:check

deploy:
if: ${{ github.event_name == 'release' }}
needs: format
runs-on: ubuntu-22.04

permissions:
actions: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Install NodeJS
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Run build
run: npm run build

- name: Upload artifacts
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: packages
path: |
dist
package.json
- name: Dispatch deployment
env:
GITHUB_TOKEN: ${{ secrets.DEPLOYMENT_GITHUB_TOKEN }}
run: >
gh workflow run passwordless-client-js
--repo bitwarden/passwordless-devops
--field repository=${{ github.repository }}
--field run-id=${{ github.run_id }}
--field name=packages
38 changes: 0 additions & 38 deletions .github/workflows/release.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"arrowParens": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"endOfLine": "auto",
"printWidth": 100,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"quoteProps": "consistent"
}
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
![passwordless by bitwarden](./Screenshot%202023-04-28%20at%2011.50.52%20AM%20(2).png)
![passwordless by bitwarden](<./Screenshot%202023-04-28%20at%2011.50.52%20AM%20(2).png>)

Welcome to Passwordless.dev by Bitwarden. Passwordless.dev is a software toolkit that helps developers bring FIDO2 WebAuthn passkeys to their end users. Provide passwordless authentication without the need to read W3C specification documentation, determine cryptography, or manage stored public keys. Passwordless with Bitwarden does this for you.

## Get started

Passwordless.dev consists of three key parts:

* An open-source client side library, used by your frontend to make requests to the end-user's browser WebAuthn API and requests to the passwordless.dev APIs.
* A public RESTful API used to complete FIDO2 WebAuthn cryptographic exchanges with the browser.
* a private RESTful API used to initiate key registrations, verify signins, and retrieve keys for end-users.
- An open-source client side library, used by your frontend to make requests to the end-user's browser WebAuthn API and requests to the passwordless.dev APIs.
- A public RESTful API used to complete FIDO2 WebAuthn cryptographic exchanges with the browser.
- a private RESTful API used to initiate key registrations, verify signins, and retrieve keys for end-users.

To start, download the Passwordless.js library:

Expand All @@ -30,22 +30,26 @@ Next, your front end must import the library to call the methods:

```js
import { Client } from '@passwordlessdev/passwordless-client';
const p = new Client({apiKey: ""});
const p = new Client({ apiKey: '' });
```

#### HTML

Install the Passwordless.dev JS client:

```html
<script src="https://cdn.passwordless.dev/dist/1.1.0/passwordless.iife.js" crossorigin="anonymous"></script>`
<script
src="https://cdn.passwordless.dev/dist/1.1.0/passwordless.iife.js"
crossorigin="anonymous"
></script>
`
```

Next, your front end must import the libary to call the methods:

```html
<script>
const p = new Passwordless.Client({apiKey: ""});
const p = new Passwordless.Client({ apiKey: '' });
</script>
```

Expand All @@ -54,12 +58,14 @@ Registering a token could look like:
```javascript
// Instantiate a passwordless client using your API public key.
const p = new Passwordless.Client({
apiKey: "myapplication:public:4364b1a49a404b38b843fe3697b803c8"
apiKey: 'myapplication:public:4364b1a49a404b38b843fe3697b803c8'
});

// Fetch the registration token from the backend.
const backendUrl = "https://localhost:8002";
const registerToken = await fetch(backendUrl + "/create-token?userId" + userId).then(r => r.json());
const backendUrl = 'https://localhost:8002';
const registerToken = await fetch(backendUrl + '/create-token?userId' + userId).then((r) =>
r.json()
);

// Register the token with the end-user's device.
const { token, error } = await p.register(registerToken);
Expand Down Expand Up @@ -90,7 +96,7 @@ To create an account for yourself or your organization, visit [this link](https:
## Next steps

1. Call the function `register` or (e.g. `signinWithDiscoverable()`).
2. Add two endpoints to your backend that integrate to your existing user system (*set cookie, sessions, and more*) and will communicate secrets with our API.
2. Add two endpoints to your backend that integrate to your existing user system (_set cookie, sessions, and more_) and will communicate secrets with our API.
3. Make a request between your clientside code and the verification endpoints on your backend to verify the registration or sign in.

We've written a more detailed guide, with more language examples and SDKs in the [Passwordless.dev](https://docs.passwordless.dev/guide/) documentation.
Expand All @@ -100,6 +106,7 @@ We've written a more detailed guide, with more language examples and SDKs in the
To talk to the passwordless team, send us an email at [email protected]

## References

- [Using the JavaScript client](https://docs.passwordless.dev/guide/frontend/javascript.html)

## Bitwarden
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';

export default [
js.configs.recommended,
eslintConfigPrettier,
{
ignores: ['node_modules/'],
rules: {
'no-unused-vars': 'warn'
}
}
];
Loading

0 comments on commit f6acb8b

Please sign in to comment.