mirror of
https://github.com/bitwarden/clients.git
synced 2026-11-16 07:03:29 +00:00
[PAM-264] Move shared PAM code to bit-pam and bit-pam-components (#24417)
* [PAM-121] Move shared PAM code to bit-pam and bit-pam-components Creates two licensed libs owned by team-pam-dev and moves the shared PAM code into them from bit-web so other clients can consume it: - bitwarden_license/bit-pam (@bitwarden/bit-pam): framework-free abstractions, helpers, date formatting and SDK services, usable from the browser background. ESLint keeps Angular and the UI libraries out of it. - bitwarden_license/bit-pam-components (@bitwarden/bit-pam-components): the shared components, pipes, confirm dialogs and Angular-injected services. Each lib exposes a single barrel. Split out of #22430 to reduce its size; no behavioural changes. * [PAM-121] Run Chromatic on bit-pam-components changes * [PAM-121] Run prettier
This commit is contained in:
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@@ -253,8 +253,10 @@ apps/browser/src/background/nativeMessaging.background.ts @bitwarden/team-
|
||||
apps/desktop/src/services/biometric-message-handler.service.ts @bitwarden/team-key-management-dev
|
||||
|
||||
## PAM
|
||||
bitwarden_license/bit-web/src/app/pam @bitwarden/team-pam-dev
|
||||
apps/web/src/app/pam @bitwarden/team-pam-dev
|
||||
bitwarden_license/bit-pam @bitwarden/team-pam-dev
|
||||
bitwarden_license/bit-pam-components @bitwarden/team-pam-dev
|
||||
bitwarden_license/bit-web/src/app/pam @bitwarden/team-pam-dev
|
||||
libs/pam @bitwarden/team-pam-dev
|
||||
|
||||
## Automation driver ##
|
||||
|
||||
6
.github/workflows/build-browser.yml
vendored
6
.github/workflows/build-browser.yml
vendored
@@ -195,12 +195,16 @@ jobs:
|
||||
mkdir -p browser-source/apps/browser
|
||||
cp -r apps/browser/* browser-source/apps/browser
|
||||
|
||||
# Copy bitwarden_license/bit-browser and its bit-common dependency to the Browser source directory
|
||||
# Copy bitwarden_license/bit-browser and its bit-common, bit-pam and bit-pam-components dependencies to the Browser source directory
|
||||
if [[ ${{matrix.license_type.include_bitwarden_license_folder}} == "true" ]]; then
|
||||
mkdir -p browser-source/bitwarden_license/bit-browser
|
||||
cp -r bitwarden_license/bit-browser/* browser-source/bitwarden_license/bit-browser
|
||||
mkdir -p browser-source/bitwarden_license/bit-common
|
||||
cp -r bitwarden_license/bit-common/* browser-source/bitwarden_license/bit-common
|
||||
mkdir -p browser-source/bitwarden_license/bit-pam
|
||||
cp -r bitwarden_license/bit-pam/* browser-source/bitwarden_license/bit-pam
|
||||
mkdir -p browser-source/bitwarden_license/bit-pam-components
|
||||
cp -r bitwarden_license/bit-pam-components/* browser-source/bitwarden_license/bit-pam-components
|
||||
fi
|
||||
|
||||
# Copy libs to Browser source directory
|
||||
|
||||
4
.github/workflows/build-web.yml
vendored
4
.github/workflows/build-web.yml
vendored
@@ -13,6 +13,8 @@ on:
|
||||
paths:
|
||||
- 'apps/web/**'
|
||||
- 'bitwarden_license/bit-common/**'
|
||||
- 'bitwarden_license/bit-pam/**'
|
||||
- 'bitwarden_license/bit-pam-components/**'
|
||||
- 'bitwarden_license/bit-web/**'
|
||||
- 'libs/**'
|
||||
- '*'
|
||||
@@ -27,6 +29,8 @@ on:
|
||||
paths:
|
||||
- 'apps/web/**'
|
||||
- 'bitwarden_license/bit-common/**'
|
||||
- 'bitwarden_license/bit-pam/**'
|
||||
- 'bitwarden_license/bit-pam-components/**'
|
||||
- 'bitwarden_license/bit-web/**'
|
||||
- 'libs/**'
|
||||
- '*'
|
||||
|
||||
1
.github/workflows/chromatic.yml
vendored
1
.github/workflows/chromatic.yml
vendored
@@ -57,6 +57,7 @@ jobs:
|
||||
filters: |
|
||||
storyFiles:
|
||||
- "apps/!(cli)/**"
|
||||
- "bitwarden_license/bit-pam-components/**"
|
||||
- "bitwarden_license/bit-web/src/app/**"
|
||||
- "libs/!(eslint)/**"
|
||||
- "package.json"
|
||||
|
||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -83,7 +83,7 @@ jobs:
|
||||
artifact: jest-coverage-cli
|
||||
junit: junit-cli.xml
|
||||
- name: Libs
|
||||
paths: libs bitwarden_license/bit-common
|
||||
paths: libs bitwarden_license/bit-common bitwarden_license/bit-pam bitwarden_license/bit-pam-components
|
||||
artifact: jest-coverage-libs
|
||||
junit: junit-libs.xml
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ const config = require("../../libs/components/tailwind.config.base");
|
||||
const browserContent = [
|
||||
path.resolve(__dirname, "./src/**/*.{html,ts,mdx}"),
|
||||
path.resolve(__dirname, "../../bitwarden_license/bit-browser/src/**/*.{html,ts,mdx}"),
|
||||
path.resolve(__dirname, "../../bitwarden_license/bit-pam-components/src/**/*.{html,ts}"),
|
||||
];
|
||||
|
||||
config.content = [...config.content, ...browserContent];
|
||||
|
||||
@@ -7,6 +7,7 @@ const config = require("../../libs/components/tailwind.config.base");
|
||||
const webContent = [
|
||||
path.resolve(__dirname, "./src/**/*.{html,ts,mdx}"),
|
||||
path.resolve(__dirname, "../../bitwarden_license/bit-web/src/**/*.{html,ts,mdx}"),
|
||||
path.resolve(__dirname, "../../bitwarden_license/bit-pam-components/src/**/*.{html,ts}"),
|
||||
];
|
||||
|
||||
config.content = [...config.content, ...webContent];
|
||||
|
||||
24
bitwarden_license/bit-pam-components/jest.config.js
Normal file
24
bitwarden_license/bit-pam-components/jest.config.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const { pathsToModuleNameMapper } = require("ts-jest");
|
||||
const { compilerOptions } = require("../../tsconfig.base");
|
||||
const sharedConfig = require("../../libs/shared/jest.config.angular");
|
||||
|
||||
/** @type {import('jest').Config} */
|
||||
module.exports = {
|
||||
...sharedConfig,
|
||||
displayName: "bit-pam-components tests",
|
||||
testEnvironment: "jsdom",
|
||||
moduleNameMapper: pathsToModuleNameMapper(
|
||||
{
|
||||
"@bitwarden/common/spec": ["libs/common/spec"],
|
||||
"@bitwarden/common": ["libs/common/src/*"],
|
||||
"@bitwarden/admin-console/common": ["libs/admin-console/src/common"],
|
||||
...(compilerOptions?.paths ?? {}),
|
||||
},
|
||||
{
|
||||
prefix: "<rootDir>/../../",
|
||||
},
|
||||
),
|
||||
setupFilesAfterEnv: ["<rootDir>/test.setup.ts"],
|
||||
transformIgnorePatterns: ["node_modules/(?!(.*\\.mjs$|@angular|rxjs|@bitwarden))"],
|
||||
moduleFileExtensions: ["ts", "js", "html", "mjs"],
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, inject } from "@angular/core";
|
||||
import { FormBuilder, ReactiveFormsModule, Validators } from "@angular/forms";
|
||||
|
||||
import { AccessLeaseExtensionRequest, EXTENSION_DURATION_OPTIONS } from "@bitwarden/bit-pam";
|
||||
import {
|
||||
AsyncActionsModule,
|
||||
ButtonModule,
|
||||
@@ -12,8 +13,6 @@ import {
|
||||
} from "@bitwarden/components";
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
|
||||
import { AccessLeaseExtensionRequest, EXTENSION_DURATION_OPTIONS } from "../..";
|
||||
|
||||
/** Collects a lease extension. The reason is required because the server rejects an empty one. */
|
||||
@Component({
|
||||
selector: "pam-extend-lease-dialog",
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
||||
|
||||
import { AccessBadgeState } from "@bitwarden/bit-pam";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
|
||||
import { AccessBadgeState } from "./access-badge-state";
|
||||
import { AccessStateBadgeComponent } from "./access-state-badge.component";
|
||||
|
||||
describe("AccessStateBadgeComponent", () => {
|
||||
@@ -9,12 +9,10 @@ import {
|
||||
import { toObservable, toSignal } from "@angular/core/rxjs-interop";
|
||||
import { EMPTY, switchMap } from "rxjs";
|
||||
|
||||
import { formatRemaining, AccessBadgeState, ENDING_SOON_THRESHOLD_MS } from "@bitwarden/bit-pam";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { BadgeComponent, BadgeVariant } from "@bitwarden/components";
|
||||
|
||||
import { formatRemaining } from "../date/format-remaining";
|
||||
|
||||
import { AccessBadgeState, ENDING_SOON_THRESHOLD_MS } from "./access-badge-state";
|
||||
import { AccessBadgeTickerService } from "./access-badge-ticker.service";
|
||||
|
||||
type BadgeIcon =
|
||||
@@ -3,6 +3,23 @@ import { ComponentFixture, TestBed } from "@angular/core/testing";
|
||||
import { mock, MockProxy } from "jest-mock-extended";
|
||||
import { BehaviorSubject, NEVER, of, Subject } from "rxjs";
|
||||
|
||||
import {
|
||||
AccessLeaseSdkService,
|
||||
AccessRefreshService,
|
||||
AccessRequestSdkService,
|
||||
LeasingErrorService,
|
||||
REQUEST_ACCESS_SERVER_ERRORS,
|
||||
composeRequestWindow,
|
||||
toDateInputValue,
|
||||
formatDuration,
|
||||
DefaultAccessRefreshService,
|
||||
} from "@bitwarden/bit-pam";
|
||||
import type {
|
||||
AccessLeaseView,
|
||||
AccessPreCheckView,
|
||||
AccessRequestView,
|
||||
CipherAccessStateView,
|
||||
} from "@bitwarden/bit-pam";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
@@ -14,24 +31,7 @@ import { RevealedCipherService } from "@bitwarden/common/vault/abstractions/reve
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
|
||||
import {
|
||||
AccessLeaseSdkService,
|
||||
AccessRefreshService,
|
||||
AccessRequestSdkService,
|
||||
LeasingErrorService,
|
||||
REQUEST_ACCESS_SERVER_ERRORS,
|
||||
composeRequestWindow,
|
||||
toDateInputValue,
|
||||
} from "..";
|
||||
import type {
|
||||
AccessLeaseView,
|
||||
AccessPreCheckView,
|
||||
AccessRequestView,
|
||||
CipherAccessStateView,
|
||||
} from "../abstractions/access-lease";
|
||||
import { formatDuration } from "../date/format-duration";
|
||||
import { AccessRequestCancelService } from "../services/access-request-cancel.service";
|
||||
import { DefaultAccessRefreshService } from "../services/default-access-refresh.service";
|
||||
import { MyLeasesService } from "../services/my-leases.service";
|
||||
|
||||
import { CipherViewBannerComponent } from "./cipher-view-banner.component";
|
||||
@@ -31,30 +31,6 @@ import {
|
||||
switchMap,
|
||||
} from "rxjs";
|
||||
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { CipherId } from "@bitwarden/common/types/guid";
|
||||
import { RevealedCipherService } from "@bitwarden/common/vault/abstractions/revealed-cipher.service";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import {
|
||||
AsyncActionsModule,
|
||||
ButtonModule,
|
||||
CardComponent,
|
||||
DialogService,
|
||||
FormFieldModule,
|
||||
IconButtonModule,
|
||||
IconModule,
|
||||
IconTileComponent,
|
||||
ToastService,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
|
||||
import {
|
||||
type AccessApprovalMode,
|
||||
AccessLeaseSdkService,
|
||||
@@ -80,19 +56,45 @@ import {
|
||||
toDateInputValue,
|
||||
toTimeInputValue,
|
||||
windowEndAt,
|
||||
} from "..";
|
||||
ENDING_SOON_THRESHOLD_MS,
|
||||
formatCompoundDuration,
|
||||
formatDuration,
|
||||
formatRemaining,
|
||||
isGovernedCipher,
|
||||
isUnlicensedError,
|
||||
callerOrganizations$,
|
||||
unlicensedForPam,
|
||||
} from "@bitwarden/bit-pam";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { CipherId } from "@bitwarden/common/types/guid";
|
||||
import { RevealedCipherService } from "@bitwarden/common/vault/abstractions/revealed-cipher.service";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import {
|
||||
AsyncActionsModule,
|
||||
ButtonModule,
|
||||
CardComponent,
|
||||
DialogService,
|
||||
FormFieldModule,
|
||||
IconButtonModule,
|
||||
IconModule,
|
||||
IconTileComponent,
|
||||
ToastService,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
|
||||
import { ExtendLeaseDialogComponent } from "../access-requests/extend-lease-dialog/extend-lease-dialog.component";
|
||||
import { ENDING_SOON_THRESHOLD_MS } from "../access-state-badge/access-badge-state";
|
||||
import { AccessBadgeTickerService } from "../access-state-badge/access-badge-ticker.service";
|
||||
import { DurationLongPipe } from "../date/duration-long.pipe";
|
||||
import { DurationShortPipe } from "../date/duration-short.pipe";
|
||||
import { formatCompoundDuration, formatDuration } from "../date/format-duration";
|
||||
import { formatRemaining } from "../date/format-remaining";
|
||||
import { isGovernedCipher } from "../helpers/governed-cipher";
|
||||
import { isUnlicensedError } from "../helpers/pam-license-error";
|
||||
import { AccessRequestCancelService } from "../services/access-request-cancel.service";
|
||||
import { MyLeasesService } from "../services/my-leases.service";
|
||||
import { callerOrganizations$, unlicensedForPam } from "../services/pam-membership";
|
||||
|
||||
import {
|
||||
REQUEST_WINDOW_ERROR_KEY,
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
type RequestWindowFormValue,
|
||||
type RequestWindowProblem,
|
||||
requestWindowProblem,
|
||||
} from "../helpers/request-access-window";
|
||||
} from "@bitwarden/bit-pam";
|
||||
|
||||
export const REQUEST_WINDOW_ERROR_KEY = "requestWindow";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LOCALE_ID, Pipe, PipeTransform, inject } from "@angular/core";
|
||||
|
||||
import { formatDuration } from "./format-duration";
|
||||
import { formatDuration } from "@bitwarden/bit-pam";
|
||||
|
||||
/** Spelled-out, localized duration label, e.g. `15 minutes`, `4 hours`, `1 day`. */
|
||||
@Pipe({
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LOCALE_ID, Pipe, PipeTransform, inject } from "@angular/core";
|
||||
|
||||
import { formatDuration } from "./format-duration";
|
||||
import { formatDuration } from "@bitwarden/bit-pam";
|
||||
|
||||
/** Compact, localized duration label, e.g. `15m`, `4h`, `1d`. */
|
||||
@Pipe({
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LOCALE_ID, Pipe, PipeTransform, inject } from "@angular/core";
|
||||
|
||||
import { formatRelativeTime } from "..";
|
||||
import { formatRelativeTime } from "@bitwarden/bit-pam";
|
||||
|
||||
/** A localized relative phrase, e.g. "5 min. ago" or "in 2 hr.". */
|
||||
@Pipe({
|
||||
@@ -1,6 +1,6 @@
|
||||
import { inject, LOCALE_ID, Pipe, PipeTransform } from "@angular/core";
|
||||
|
||||
import { formatRemaining } from "..";
|
||||
import { formatRemaining } from "@bitwarden/bit-pam";
|
||||
|
||||
/** Pure, so pass a ticking `nowMs` for the countdown to move. */
|
||||
@Pipe({
|
||||
17
bitwarden_license/bit-pam-components/src/index.ts
Normal file
17
bitwarden_license/bit-pam-components/src/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export { accessRuleDeleteConfirmOptions } from "./helpers/access-rule-delete-confirm";
|
||||
export { accessRuleDeactivateConfirmOptions } from "./helpers/access-rule-deactivate-confirm";
|
||||
export { ExtendLeaseDialogComponent } from "./access-requests/extend-lease-dialog/extend-lease-dialog.component";
|
||||
export { AccessBadgeTickerService } from "./access-state-badge/access-badge-ticker.service";
|
||||
export { AccessStateBadgeComponent } from "./access-state-badge/access-state-badge.component";
|
||||
export { CipherViewBannerComponent } from "./cipher-view-banner/cipher-view-banner.component";
|
||||
export { DurationLongPipe } from "./date/duration-long.pipe";
|
||||
export { DurationShortPipe } from "./date/duration-short.pipe";
|
||||
export { RelativeTimePipe } from "./date/relative-time.pipe";
|
||||
export { RemainingTimePipe } from "./date/remaining-time.pipe";
|
||||
export {
|
||||
accessConnectorDeactivateConfirmOptions,
|
||||
accessConnectorDeleteConfirmOptions,
|
||||
} from "./helpers/access-connector-confirm";
|
||||
export { ItemDetailsStateBadgeComponent } from "./item-details-state-badge/item-details-state-badge.component";
|
||||
export { AccessRequestCancelService } from "./services/access-request-cancel.service";
|
||||
export { MyLeasesService } from "./services/my-leases.service";
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
||||
import { BehaviorSubject, of, Subject } from "rxjs";
|
||||
|
||||
import { AccessRefreshService, AccessRequestSdkService } from "@bitwarden/bit-pam";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -10,9 +11,6 @@ import { RevealedCipherService } from "@bitwarden/common/vault/abstractions/reve
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import type { CipherAccessStateView } from "@bitwarden/sdk-internal";
|
||||
|
||||
import { AccessRefreshService } from "../abstractions/access-refresh.service";
|
||||
import { AccessRequestSdkService } from "../abstractions/access-request-sdk.service";
|
||||
|
||||
import { ItemDetailsStateBadgeComponent } from "./item-details-state-badge.component";
|
||||
|
||||
describe("ItemDetailsStateBadgeComponent", () => {
|
||||
@@ -13,6 +13,15 @@ import {
|
||||
take,
|
||||
} from "rxjs";
|
||||
|
||||
import {
|
||||
AccessRefreshService,
|
||||
AccessRequestSdkService,
|
||||
AccessBadgeState,
|
||||
cipherAccessBadgeState,
|
||||
isGovernedCipher,
|
||||
liveActiveLease,
|
||||
} from "@bitwarden/bit-pam";
|
||||
import type { CipherAccessStateView } from "@bitwarden/bit-pam";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
@@ -22,14 +31,8 @@ import { CipherId } from "@bitwarden/common/types/guid";
|
||||
import { RevealedCipherService } from "@bitwarden/common/vault/abstractions/revealed-cipher.service";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
|
||||
import type { CipherAccessStateView } from "../abstractions/access-lease";
|
||||
import { AccessRefreshService } from "../abstractions/access-refresh.service";
|
||||
import { AccessRequestSdkService } from "../abstractions/access-request-sdk.service";
|
||||
import { AccessBadgeState, cipherAccessBadgeState } from "../access-state-badge/access-badge-state";
|
||||
import { AccessBadgeTickerService } from "../access-state-badge/access-badge-ticker.service";
|
||||
import { AccessStateBadgeComponent } from "../access-state-badge/access-state-badge.component";
|
||||
import { isGovernedCipher } from "../helpers/governed-cipher";
|
||||
import { liveActiveLease } from "../helpers/lease-liveness";
|
||||
|
||||
/**
|
||||
* Binds `ITEM_DETAILS_BADGE`, the access-state pill on the open item's name row. A live
|
||||
@@ -1,15 +1,13 @@
|
||||
import { mock, MockProxy } from "jest-mock-extended";
|
||||
import { NEVER } from "rxjs";
|
||||
|
||||
import { AccessRequestSdkService, DefaultAccessRefreshService } from "@bitwarden/bit-pam";
|
||||
import type { AccessRequestId, CipherAccessStateView } from "@bitwarden/bit-pam";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
|
||||
import type { AccessRequestId, CipherAccessStateView } from "../abstractions/access-lease";
|
||||
import { AccessRequestSdkService } from "../abstractions/access-request-sdk.service";
|
||||
|
||||
import { AccessRequestCancelService } from "./access-request-cancel.service";
|
||||
import { DefaultAccessRefreshService } from "./default-access-refresh.service";
|
||||
|
||||
const CIPHER_ID = "cipher-1";
|
||||
const REQUEST_ID = "request-1" as unknown as AccessRequestId;
|
||||
@@ -1,9 +1,8 @@
|
||||
import { AccessRefreshService, AccessRequestSdkService } from "@bitwarden/bit-pam";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
|
||||
import { AccessRefreshService, AccessRequestSdkService } from "..";
|
||||
|
||||
/**
|
||||
* Withdraws the caller's outstanding request for a gated cipher, for entry points that start from a
|
||||
* cipher rather than a request id.
|
||||
@@ -1,11 +1,10 @@
|
||||
import { mock, MockProxy } from "jest-mock-extended";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { AccessLeaseSdkService } from "@bitwarden/bit-pam";
|
||||
import type { AccessLeaseView } from "@bitwarden/bit-pam";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
|
||||
import type { AccessLeaseView } from "../abstractions/access-lease";
|
||||
import { AccessLeaseSdkService } from "../abstractions/access-lease-sdk.service";
|
||||
|
||||
import { MyLeasesService } from "./my-leases.service";
|
||||
|
||||
/** Only the three fields the gate reads; the SDK view is wide and entirely server-populated. */
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { catchError, defer, map, Observable, of, shareReplay } from "rxjs";
|
||||
|
||||
import { AccessLeaseSdkService } from "@bitwarden/bit-pam";
|
||||
import type { AccessLeaseView } from "@bitwarden/bit-pam";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { uuidAsString } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||
|
||||
import type { AccessLeaseView } from "../abstractions/access-lease";
|
||||
import { AccessLeaseSdkService } from "../abstractions/access-lease-sdk.service";
|
||||
|
||||
/** How long a cached read serves new consumers, checked lazily on access. */
|
||||
const CACHE_TTL_MS = 30_000;
|
||||
|
||||
1
bitwarden_license/bit-pam-components/test.setup.ts
Normal file
1
bitwarden_license/bit-pam-components/test.setup.ts
Normal file
@@ -0,0 +1 @@
|
||||
import "@bitwarden/ui-common/setup-jest";
|
||||
6
bitwarden_license/bit-pam-components/tsconfig.json
Normal file
6
bitwarden_license/bit-pam-components/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base",
|
||||
"files": ["../bit-common/src/platform/sdk/sdk-alias.d.ts"],
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
3
bitwarden_license/bit-pam-components/tsconfig.spec.json
Normal file
3
bitwarden_license/bit-pam-components/tsconfig.spec.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "./tsconfig.json"
|
||||
}
|
||||
16
bitwarden_license/bit-pam/jest.config.js
Normal file
16
bitwarden_license/bit-pam/jest.config.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { pathsToModuleNameMapper } = require("ts-jest");
|
||||
|
||||
const { compilerOptions } = require("../../tsconfig.base");
|
||||
|
||||
const sharedConfig = require("../../libs/shared/jest.config.ts");
|
||||
|
||||
/** @type {import('jest').Config} */
|
||||
module.exports = {
|
||||
...sharedConfig,
|
||||
displayName: "bit-pam tests",
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "jsdom",
|
||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths ?? {}, {
|
||||
prefix: "<rootDir>/../../",
|
||||
}),
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { AccessRuleError, AccessRuleErrorVariant } from "./access-rule";
|
||||
import {
|
||||
accessRuleErrorMessage,
|
||||
isAccessRuleNotFound,
|
||||
@@ -6,6 +5,7 @@ import {
|
||||
isIpAllowlist,
|
||||
isKnownAccessCondition,
|
||||
} from "./access-rule";
|
||||
import type { AccessRuleError, AccessRuleErrorVariant } from "./access-rule";
|
||||
|
||||
function accessRuleError(variant: AccessRuleErrorVariant, message = "boom"): AccessRuleError {
|
||||
const error = new Error(message) as unknown as AccessRuleError;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DurationUnit, pickDurationUnit } from "..";
|
||||
import { DurationUnit, pickDurationUnit } from "../helpers/lease-window.utils";
|
||||
|
||||
const formatters = new Map<string, Intl.NumberFormat>();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user