1
0
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:
Justin Baur
2025-07-01 15:59:11 -04:00
committed by GitHub
parent 5eca3a5916
commit 172623e050
13 changed files with 111 additions and 1 deletions

1
.github/CODEOWNERS vendored
View File

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

View File

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

View File

@@ -0,0 +1,3 @@
import baseConfig from "../../eslint.config.mjs";
export default [...baseConfig];

View 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",
};

View 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"
}

View 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
}
}
}
}

View 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">;

View File

@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View 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"]
}

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

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

View File

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