mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-25 12:15:18 +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"
|
"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"],
|
"files": ["libs/common/src/**/*.ts"],
|
||||||
"rules": {
|
"rules": {
|
||||||
@ -147,15 +159,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": ["libs/angular/src/**/*.ts"],
|
"files": ["libs/exporter/src/**/*.ts"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/angular/*", "src/**/*"] }]
|
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/exporter/*", "src/**/*"] }]
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"files": ["libs/node/src/**/*.ts"],
|
|
||||||
"rules": {
|
|
||||||
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/node/*", "src/**/*"] }]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -165,9 +171,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": ["libs/exporter/src/**/*.ts"],
|
"files": ["libs/node/src/**/*.ts"],
|
||||||
"rules": {
|
"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/cli/src/auth @bitwarden/team-auth-dev
|
||||||
apps/desktop/src/auth @bitwarden/team-auth-dev
|
apps/desktop/src/auth @bitwarden/team-auth-dev
|
||||||
apps/web/src/app/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
|
# web connectors used for auth
|
||||||
apps/web/src/connectors @bitwarden/team-auth-dev
|
apps/web/src/connectors @bitwarden/team-auth-dev
|
||||||
bitwarden_license/bit-web/src/app/auth @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/vaultTimeoutSettings.service.ts
|
||||||
./libs/common/src/services/vaultTimeout/vaultTimeout.service.ts
|
./libs/common/src/services/vaultTimeout/vaultTimeout.service.ts
|
||||||
./libs/common/src/services/anonymousHub.service.ts
|
./libs/common/src/services/anonymousHub.service.ts
|
||||||
|
./libs/auth/README.md
|
||||||
./README.md
|
./README.md
|
||||||
./LICENSE_BITWARDEN.txt
|
./LICENSE_BITWARDEN.txt
|
||||||
./CONTRIBUTING.md
|
./CONTRIBUTING.md
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||||
|
"@bitwarden/auth": ["../../libs/auth/src"],
|
||||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||||
"@bitwarden/components": ["../../libs/components/src"],
|
"@bitwarden/components": ["../../libs/components/src"],
|
||||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||||
|
"@bitwarden/auth": ["../../libs/auth/src"],
|
||||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||||
"@bitwarden/components": ["../../libs/components/src"],
|
"@bitwarden/components": ["../../libs/components/src"],
|
||||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
"module": "ES2020",
|
"module": "ES2020",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/web-vault/*": ["src/*"],
|
|
||||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
|
||||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||||
|
"@bitwarden/auth": ["../../libs/auth/src"],
|
||||||
|
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||||
"@bitwarden/components": ["../../libs/components/src"],
|
"@bitwarden/components": ["../../libs/components/src"],
|
||||||
|
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
|
||||||
"@bitwarden/importer": ["../../libs/importer/src"],
|
"@bitwarden/importer": ["../../libs/importer/src"],
|
||||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
"@bitwarden/web-vault/*": ["src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"angularCompilerOptions": {
|
"angularCompilerOptions": {
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
"extends": "../../apps/web/tsconfig",
|
"extends": "../../apps/web/tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/web-vault/*": ["../../apps/web/src/*"],
|
|
||||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
|
||||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||||
|
"@bitwarden/auth": ["../../libs/auth/src"],
|
||||||
|
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||||
"@bitwarden/components": ["../../libs/components/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"]
|
"include": ["src/**/*.stories.ts"]
|
||||||
|
@ -21,10 +21,11 @@ module.exports = {
|
|||||||
"<rootDir>/bitwarden_license/bit-web/jest.config.js",
|
"<rootDir>/bitwarden_license/bit-web/jest.config.js",
|
||||||
|
|
||||||
"<rootDir>/libs/angular/jest.config.js",
|
"<rootDir>/libs/angular/jest.config.js",
|
||||||
|
"<rootDir>/libs/auth/jest.config.js",
|
||||||
"<rootDir>/libs/common/jest.config.js",
|
"<rootDir>/libs/common/jest.config.js",
|
||||||
"<rootDir>/libs/components/jest.config.js",
|
"<rootDir>/libs/components/jest.config.js",
|
||||||
"<rootDir>/libs/importer/jest.config.js",
|
|
||||||
"<rootDir>/libs/exporter/jest.config.js",
|
"<rootDir>/libs/exporter/jest.config.js",
|
||||||
|
"<rootDir>/libs/importer/jest.config.js",
|
||||||
"<rootDir>/libs/node/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",
|
"extends": "./tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/common/*": ["../common/src/*"],
|
|
||||||
"@bitwarden/angular/*": ["../angular/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/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",
|
"version": "0.0.0",
|
||||||
"license": "GPL-3.0"
|
"license": "GPL-3.0"
|
||||||
},
|
},
|
||||||
|
"libs/auth": {
|
||||||
|
"name": "@bitwarden/auth",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"license": "GPL-3.0"
|
||||||
|
},
|
||||||
"libs/common": {
|
"libs/common": {
|
||||||
"name": "@bitwarden/common",
|
"name": "@bitwarden/common",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
@ -4392,6 +4397,10 @@
|
|||||||
"resolved": "libs/angular",
|
"resolved": "libs/angular",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@bitwarden/auth": {
|
||||||
|
"resolved": "libs/auth",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
"node_modules/@bitwarden/browser": {
|
"node_modules/@bitwarden/browser": {
|
||||||
"resolved": "apps/browser",
|
"resolved": "apps/browser",
|
||||||
"link": true
|
"link": true
|
||||||
|
@ -3,6 +3,7 @@ const config = require("./libs/components/tailwind.config.base");
|
|||||||
|
|
||||||
config.content = [
|
config.content = [
|
||||||
"./libs/components/src/**/*.{html,ts,mdx}",
|
"./libs/components/src/**/*.{html,ts,mdx}",
|
||||||
|
"./libs/auth/src/**/*.{html,ts,mdx}",
|
||||||
"./apps/web/src/**/*.{html,ts,mdx}",
|
"./apps/web/src/**/*.{html,ts,mdx}",
|
||||||
"./bitwarden_license/bit-web/src/**/*.{html,ts,mdx}",
|
"./bitwarden_license/bit-web/src/**/*.{html,ts,mdx}",
|
||||||
"./.storybook/preview.js",
|
"./.storybook/preview.js",
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/common/*": ["./libs/common/src/*"],
|
|
||||||
"@bitwarden/angular/*": ["./libs/angular/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/components": ["./libs/components/src"],
|
||||||
"@bitwarden/exporter/*": ["./libs/exporter/src/*"]
|
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
|
||||||
|
"@bitwarden/node/*": ["./libs/node/src/*"]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
@ -15,12 +15,13 @@
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"@bitwarden/common/*": ["./libs/common/src/*"],
|
|
||||||
"@bitwarden/angular/*": ["./libs/angular/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/components": ["./libs/components/src"],
|
||||||
"@bitwarden/importer": ["./libs/importer/src"],
|
|
||||||
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
|
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
|
||||||
|
"@bitwarden/importer": ["./libs/importer/src"],
|
||||||
|
"@bitwarden/node/*": ["./libs/node/src/*"],
|
||||||
"@bitwarden/web-vault/*": ["./apps/web/src/*"]
|
"@bitwarden/web-vault/*": ["./apps/web/src/*"]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
Loading…
Reference in New Issue
Block a user