mirror of
https://github.com/bitwarden/browser
synced 2024-12-22 07:57:01 +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:
parent
50b3e40a05
commit
f43272f243
@ -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
1
.github/CODEOWNERS
vendored
@ -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
vendored
1
.github/whitelist-capital-letters.txt
vendored
@ -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
|
||||
|
@ -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/*"]
|
||||
|
@ -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/*"]
|
||||
|
@ -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": {
|
||||
|
@ -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"]
|
||||
|
@ -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
3
libs/auth/README.md
Normal 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
16
libs/auth/jest.config.js
Normal 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
20
libs/auth/package.json
Normal 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
0
libs/auth/src/index.ts
Normal file
28
libs/auth/test.setup.ts
Normal file
28
libs/auth/test.setup.ts
Normal 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
5
libs/auth/tsconfig.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "../shared/tsconfig.libs",
|
||||
"include": ["src", "spec"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
4
libs/auth/tsconfig.spec.json
Normal file
4
libs/auth/tsconfig.spec.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"files": ["./test.setup.ts"]
|
||||
}
|
@ -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
9
package-lock.json
generated
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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": [
|
||||
{
|
||||
|
@ -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…
Reference in New Issue
Block a user