Browse Source

[PM-3172] create @bitwarden/auth lib (#5906)

* scaffold new lib

* update jest config

* update tsconfig

* add readme

* update tailwind config

* update package-lock

* update tsconfigs

* update jest displayName

* update tsconfig.libs.json

* fix alias glob

* update package lock

* add readme to whitelist-capital-letters

* update CODEOWNERS

* remove test utils

* update eslint rules

* alphabetize eslint and tsconfig

* sort jest config

---------

Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
pull/5996/head
Will Martin 2 years ago committed by GitHub
parent
commit
f43272f243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      .eslintrc.json
  2. 1
      .github/CODEOWNERS
  3. 1
      .github/whitelist-capital-letters.txt
  4. 1
      apps/browser/tsconfig.json
  5. 1
      apps/desktop/tsconfig.json
  6. 7
      apps/web/tsconfig.json
  7. 7
      bitwarden_license/bit-web/tsconfig.json
  8. 3
      jest.config.js
  9. 3
      libs/auth/README.md
  10. 16
      libs/auth/jest.config.js
  11. 20
      libs/auth/package.json
  12. 0
      libs/auth/src/index.ts
  13. 28
      libs/auth/test.setup.ts
  14. 5
      libs/auth/tsconfig.json
  15. 4
      libs/auth/tsconfig.spec.json
  16. 7
      libs/shared/tsconfig.libs.json
  17. 9
      package-lock.json
  18. 1
      tailwind.config.js
  19. 7
      tsconfig.eslint.json
  20. 7
      tsconfig.json

26
.eslintrc.json

@ -135,27 +135,33 @@ @@ -135,27 +135,33 @@
}
},
{
"files": ["libs/common/src/**/*.ts"],
"files": ["libs/angular/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/common/*", "src/**/*"] }]
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/angular/*", "src/**/*"] }]
}
},
{
"files": ["libs/components/src/**/*.ts"],
"files": ["libs/auth/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/components/*", "src/**/*"] }]
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/auth/*", "src/**/*"] }]
}
},
{
"files": ["libs/angular/src/**/*.ts"],
"files": ["libs/common/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/angular/*", "src/**/*"] }]
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/common/*", "src/**/*"] }]
}
},
{
"files": ["libs/node/src/**/*.ts"],
"files": ["libs/components/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/node/*", "src/**/*"] }]
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/components/*", "src/**/*"] }]
}
},
{
"files": ["libs/exporter/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/exporter/*", "src/**/*"] }]
}
},
{
@ -165,9 +171,9 @@ @@ -165,9 +171,9 @@
}
},
{
"files": ["libs/exporter/src/**/*.ts"],
"files": ["libs/node/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/exporter/*", "src/**/*"] }]
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/node/*", "src/**/*"] }]
}
}
]

1
.github/CODEOWNERS

@ -14,6 +14,7 @@ apps/browser/src/auth @bitwarden/team-auth-dev @@ -14,6 +14,7 @@ apps/browser/src/auth @bitwarden/team-auth-dev
apps/cli/src/auth @bitwarden/team-auth-dev
apps/desktop/src/auth @bitwarden/team-auth-dev
apps/web/src/app/auth @bitwarden/team-auth-dev
libs/auth @bitwarden/team-auth-dev
# web connectors used for auth
apps/web/src/connectors @bitwarden/team-auth-dev
bitwarden_license/bit-web/src/app/auth @bitwarden/team-auth-dev

1
.github/whitelist-capital-letters.txt

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
./libs/common/src/services/vaultTimeout/vaultTimeoutSettings.service.ts
./libs/common/src/services/vaultTimeout/vaultTimeout.service.ts
./libs/common/src/services/anonymousHub.service.ts
./libs/auth/README.md
./README.md
./LICENSE_BITWARDEN.txt
./CONTRIBUTING.md

1
apps/browser/tsconfig.json

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
"baseUrl": ".",
"paths": {
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
"@bitwarden/auth": ["../../libs/auth/src"],
"@bitwarden/common/*": ["../../libs/common/src/*"],
"@bitwarden/components": ["../../libs/components/src"],
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]

1
apps/desktop/tsconfig.json

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
"baseUrl": ".",
"paths": {
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
"@bitwarden/auth": ["../../libs/auth/src"],
"@bitwarden/common/*": ["../../libs/common/src/*"],
"@bitwarden/components": ["../../libs/components/src"],
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]

7
apps/web/tsconfig.json

@ -5,12 +5,13 @@ @@ -5,12 +5,13 @@
"module": "ES2020",
"resolveJsonModule": true,
"paths": {
"@bitwarden/web-vault/*": ["src/*"],
"@bitwarden/common/*": ["../../libs/common/src/*"],
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
"@bitwarden/auth": ["../../libs/auth/src"],
"@bitwarden/common/*": ["../../libs/common/src/*"],
"@bitwarden/components": ["../../libs/components/src"],
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
"@bitwarden/importer": ["../../libs/importer/src"],
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
"@bitwarden/web-vault/*": ["src/*"]
}
},
"angularCompilerOptions": {

7
bitwarden_license/bit-web/tsconfig.json

@ -2,11 +2,12 @@ @@ -2,11 +2,12 @@
"extends": "../../apps/web/tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/web-vault/*": ["../../apps/web/src/*"],
"@bitwarden/common/*": ["../../libs/common/src/*"],
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
"@bitwarden/auth": ["../../libs/auth/src"],
"@bitwarden/common/*": ["../../libs/common/src/*"],
"@bitwarden/components": ["../../libs/components/src"],
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
"@bitwarden/web-vault/*": ["../../apps/web/src/*"]
}
},
"include": ["src/**/*.stories.ts"]

3
jest.config.js

@ -21,10 +21,11 @@ module.exports = { @@ -21,10 +21,11 @@ module.exports = {
"<rootDir>/bitwarden_license/bit-web/jest.config.js",
"<rootDir>/libs/angular/jest.config.js",
"<rootDir>/libs/auth/jest.config.js",
"<rootDir>/libs/common/jest.config.js",
"<rootDir>/libs/components/jest.config.js",
"<rootDir>/libs/importer/jest.config.js",
"<rootDir>/libs/exporter/jest.config.js",
"<rootDir>/libs/importer/jest.config.js",
"<rootDir>/libs/node/jest.config.js",
],

3
libs/auth/README.md

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
# Auth
This lib represents the public API of the Auth team at Bitwarden. Modules are imported using `@bitwarden/auth`.

16
libs/auth/jest.config.js

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("../shared/tsconfig.libs");
const sharedConfig = require("../../libs/shared/jest.config.angular");
/** @type {import('jest').Config} */
module.exports = {
...sharedConfig,
displayName: "libs/auth tests",
preset: "jest-preset-angular",
setupFilesAfterEnv: ["<rootDir>/test.setup.ts"],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, {
prefix: "<rootDir>/",
}),
};

20
libs/auth/package.json

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
{
"name": "@bitwarden/auth",
"version": "0.0.0",
"description": "Common code used across Bitwarden JavaScript projects.",
"keywords": [
"bitwarden"
],
"author": "Bitwarden Inc.",
"homepage": "https://bitwarden.com",
"repository": {
"type": "git",
"url": "https://github.com/bitwarden/clients"
},
"license": "GPL-3.0",
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && tsc",
"build:watch": "npm run clean && tsc -watch"
}
}

0
libs/auth/src/index.ts

28
libs/auth/test.setup.ts

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
import { webcrypto } from "crypto";
import "jest-preset-angular/setup-jest";
Object.defineProperty(window, "CSS", { value: null });
Object.defineProperty(window, "getComputedStyle", {
value: () => {
return {
display: "none",
appearance: ["-webkit-appearance"],
};
},
});
Object.defineProperty(document, "doctype", {
value: "<!DOCTYPE html>",
});
Object.defineProperty(document.body.style, "transform", {
value: () => {
return {
enumerable: true,
configurable: true,
};
},
});
Object.defineProperty(window, "crypto", {
value: webcrypto,
});

5
libs/auth/tsconfig.json

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
{
"extends": "../shared/tsconfig.libs",
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}

4
libs/auth/tsconfig.spec.json

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"files": ["./test.setup.ts"]
}

7
libs/shared/tsconfig.libs.json

@ -2,11 +2,12 @@ @@ -2,11 +2,12 @@
"extends": "./tsconfig",
"compilerOptions": {
"paths": {
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/angular/*": ["../angular/src/*"],
"@bitwarden/node/*": ["../node/src/*"],
"@bitwarden/auth": ["../auth/src/*"],
"@bitwarden/common/*": ["../common/src/*"],
"@bitwarden/exporter/*": ["../exporter/src/*"],
"@bitwarden/importer": ["../importer/src"],
"@bitwarden/exporter/*": ["../exporter/src/*"]
"@bitwarden/node/*": ["../node/src/*"]
}
}
}

9
package-lock.json generated

@ -250,6 +250,11 @@ @@ -250,6 +250,11 @@
"version": "0.0.0",
"license": "GPL-3.0"
},
"libs/auth": {
"name": "@bitwarden/auth",
"version": "0.0.0",
"license": "GPL-3.0"
},
"libs/common": {
"name": "@bitwarden/common",
"version": "0.0.0",
@ -4392,6 +4397,10 @@ @@ -4392,6 +4397,10 @@
"resolved": "libs/angular",
"link": true
},
"node_modules/@bitwarden/auth": {
"resolved": "libs/auth",
"link": true
},
"node_modules/@bitwarden/browser": {
"resolved": "apps/browser",
"link": true

1
tailwind.config.js

@ -3,6 +3,7 @@ const config = require("./libs/components/tailwind.config.base"); @@ -3,6 +3,7 @@ const config = require("./libs/components/tailwind.config.base");
config.content = [
"./libs/components/src/**/*.{html,ts,mdx}",
"./libs/auth/src/**/*.{html,ts,mdx}",
"./apps/web/src/**/*.{html,ts,mdx}",
"./bitwarden_license/bit-web/src/**/*.{html,ts,mdx}",
"./.storybook/preview.js",

7
tsconfig.eslint.json

@ -15,11 +15,12 @@ @@ -15,11 +15,12 @@
"outDir": "dist",
"baseUrl": ".",
"paths": {
"@bitwarden/common/*": ["./libs/common/src/*"],
"@bitwarden/angular/*": ["./libs/angular/src/*"],
"@bitwarden/node/*": ["./libs/node/src/*"],
"@bitwarden/auth": ["./libs/auth/src"],
"@bitwarden/common/*": ["./libs/common/src/*"],
"@bitwarden/components": ["./libs/components/src"],
"@bitwarden/exporter/*": ["./libs/exporter/src/*"]
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
"@bitwarden/node/*": ["./libs/node/src/*"]
},
"plugins": [
{

7
tsconfig.json

@ -15,12 +15,13 @@ @@ -15,12 +15,13 @@
"baseUrl": ".",
"resolveJsonModule": true,
"paths": {
"@bitwarden/common/*": ["./libs/common/src/*"],
"@bitwarden/angular/*": ["./libs/angular/src/*"],
"@bitwarden/node/*": ["./libs/node/src/*"],
"@bitwarden/auth": ["./libs/auth/src"],
"@bitwarden/common/*": ["./libs/common/src/*"],
"@bitwarden/components": ["./libs/components/src"],
"@bitwarden/importer": ["./libs/importer/src"],
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
"@bitwarden/importer": ["./libs/importer/src"],
"@bitwarden/node/*": ["./libs/node/src/*"],
"@bitwarden/web-vault/*": ["./apps/web/src/*"]
},
"plugins": [

Loading…
Cancel
Save