mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-20247] Initialize user-core library (#15029)
* Initialize user-core library * Run `npm install` * Fix patched generator bug
This commit is contained in:
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -18,6 +18,7 @@ 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
|
||||
libs/user-core @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
|
||||
|
||||
@@ -2,7 +2,9 @@ import { Opaque } from "type-fest";
|
||||
|
||||
export type Guid = Opaque<string, "Guid">;
|
||||
|
||||
export type UserId = Opaque<string, "UserId">;
|
||||
// Convenience re-export of UserId from it's original location, any library that
|
||||
// wants to be lower level than common should instead import it from user-core.
|
||||
export { UserId } from "@bitwarden/user-core";
|
||||
export type OrganizationId = Opaque<string, "OrganizationId">;
|
||||
export type CollectionId = Opaque<string, "CollectionId">;
|
||||
export type ProviderId = Opaque<string, "ProviderId">;
|
||||
|
||||
6
libs/user-core/README.md
Normal file
6
libs/user-core/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# user-core
|
||||
|
||||
Owned by: auth
|
||||
|
||||
The very basic concept that constitutes a user, this needs to be very low level to facilitate
|
||||
Platform keeping their own code low level.
|
||||
3
libs/user-core/eslint.config.mjs
Normal file
3
libs/user-core/eslint.config.mjs
Normal file
@@ -0,0 +1,3 @@
|
||||
import baseConfig from "../../eslint.config.mjs";
|
||||
|
||||
export default [...baseConfig];
|
||||
10
libs/user-core/jest.config.js
Normal file
10
libs/user-core/jest.config.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
displayName: "user-core",
|
||||
preset: "../../jest.preset.js",
|
||||
testEnvironment: "node",
|
||||
transform: {
|
||||
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
||||
},
|
||||
moduleFileExtensions: ["ts", "js", "html"],
|
||||
coverageDirectory: "../../coverage/libs/user-core",
|
||||
};
|
||||
10
libs/user-core/package.json
Normal file
10
libs/user-core/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@bitwarden/user-core",
|
||||
"version": "0.0.0",
|
||||
"description": "The very basic concept that constitutes a user, this needs to be very low level to facilitate Platform keeping their own code low level.",
|
||||
"type": "commonjs",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "GPL-3.0",
|
||||
"author": "auth"
|
||||
}
|
||||
27
libs/user-core/project.json
Normal file
27
libs/user-core/project.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "user-core",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "libs/user-core/src",
|
||||
"projectType": "library",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/libs/user-core",
|
||||
"main": "libs/user-core/src/index.ts",
|
||||
"tsConfig": "libs/user-core/tsconfig.lib.json",
|
||||
"assets": ["libs/user-core/*.md"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "libs/user-core/jest.config.js",
|
||||
"passWithNoTests": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
libs/user-core/src/index.ts
Normal file
9
libs/user-core/src/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Opaque } from "type-fest";
|
||||
|
||||
/**
|
||||
* The main identifier for a user. It is a string that should be in valid guid format.
|
||||
*
|
||||
* You should avoid `as UserId`-ing strings as much as possible and instead retrieve the {@see UserId} from
|
||||
* a valid source instead.
|
||||
*/
|
||||
export type UserId = Opaque<string, "UserId">;
|
||||
13
libs/user-core/tsconfig.json
Normal file
13
libs/user-core/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
10
libs/user-core/tsconfig.lib.json
Normal file
10
libs/user-core/tsconfig.lib.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["jest.config.js", "src/**/*.spec.ts"]
|
||||
}
|
||||
10
libs/user-core/tsconfig.spec.json
Normal file
10
libs/user-core/tsconfig.spec.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node10",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
|
||||
}
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -427,6 +427,10 @@
|
||||
"version": "0.0.0",
|
||||
"license": "GPL-3.0"
|
||||
},
|
||||
"libs/user-core": {
|
||||
"version": "0.0.0",
|
||||
"license": "GPL-3.0"
|
||||
},
|
||||
"libs/vault": {
|
||||
"name": "@bitwarden/vault",
|
||||
"version": "0.0.0",
|
||||
@@ -4640,6 +4644,10 @@
|
||||
"resolved": "libs/ui/common",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/user-core": {
|
||||
"resolved": "libs/user-core",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/vault": {
|
||||
"resolved": "libs/vault",
|
||||
"link": true
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
"@bitwarden/storage-test-utils": ["libs/storage-test-utils/src/index.ts"],
|
||||
"@bitwarden/ui-common": ["./libs/ui/common/src"],
|
||||
"@bitwarden/ui-common/setup-jest": ["./libs/ui/common/src/setup-jest"],
|
||||
"@bitwarden/user-core": ["libs/user-core/src/index.ts"],
|
||||
"@bitwarden/vault": ["./libs/vault/src"],
|
||||
"@bitwarden/vault-export-core": ["./libs/tools/export/vault-export/vault-export-core/src"],
|
||||
"@bitwarden/vault-export-ui": ["./libs/tools/export/vault-export/vault-export-ui/src"],
|
||||
|
||||
Reference in New Issue
Block a user