1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01:00

[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>
This commit is contained in:
Will Martin 2023-08-08 09:37:25 -04:00 committed by GitHub
parent 50b3e40a05
commit f43272f243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 128 additions and 26 deletions

View File

@ -134,6 +134,18 @@
"tailwindcss/no-contradicting-classname": "error"
}
},
{
"files": ["libs/angular/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/angular/*", "src/**/*"] }]
}
},
{
"files": ["libs/auth/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/auth/*", "src/**/*"] }]
}
},
{
"files": ["libs/common/src/**/*.ts"],
"rules": {
@ -147,15 +159,9 @@
}
},
{
"files": ["libs/angular/src/**/*.ts"],
"files": ["libs/exporter/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/angular/*", "src/**/*"] }]
}
},
{
"files": ["libs/node/src/**/*.ts"],
"rules": {
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/node/*", "src/**/*"] }]
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/exporter/*", "src/**/*"] }]
}
},
{
@ -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 vendored
View File

@ -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

View File

@ -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

View File

@ -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/*"]

View File

@ -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/*"]

View File

@ -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": {

View File

@ -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"]

View File

@ -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 Normal file
View File

@ -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 Normal file
View File

@ -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 Normal file
View File

@ -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 Normal file
View File

28
libs/auth/test.setup.ts Normal file
View File

@ -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 Normal file
View File

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

View File

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

View File

@ -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
View File

@ -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 @@
"resolved": "libs/angular",
"link": true
},
"node_modules/@bitwarden/auth": {
"resolved": "libs/auth",
"link": true
},
"node_modules/@bitwarden/browser": {
"resolved": "apps/browser",
"link": true

View File

@ -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",

View File

@ -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": [
{

View File

@ -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": [