1 import type { HydratedAccessState } from '@proton/pass/store/reducers';
6 OrganizationGetResponse,
9 } from '@proton/pass/types';
10 import type { OrganizationSettings } from '@proton/pass/types/data/organization';
11 import type { MaxAgeMemoizedFn } from '@proton/pass/utils/fp/memo';
12 import type { AuthenticationStore } from '@proton/shared/lib/authentication/createAuthenticationStore';
13 import type { Address, User } from '@proton/shared/lib/interfaces';
15 export type PassBridgeInitOptions = {
17 authStore: AuthenticationStore;
21 export interface PassBridge {
23 * Initialize pass bridge crypto
24 * @param options arguments needed to initialize pass bridge crypto
25 * @returns a promise returning a boolean indicating if the bridge was successfully initialized
27 init: (options: PassBridgeInitOptions) => Promise<boolean>;
30 * Get the user plan which includes aliases limit
32 getUserAccess: MaxAgeMemoizedFn<() => Promise<HydratedAccessState>>;
36 * Resolves the default - oldest, active and owned - vault.
37 * If it does not exist, it returns undefined
39 * @param options.maxAge the time it should be cached in SECONDS
41 getDefault: MaxAgeMemoizedFn<() => Promise<Share<ShareType.Vault> | undefined>>;
43 * Create default vault
45 createDefaultVault: () => Promise<Share<ShareType.Vault>>;
48 /** Creates an alias item. Call `PassBridge.alias.getAliasOptions` in order
49 * to retrieve the available alias options */
50 create: (options: PassBridgeAliasCreate) => Promise<PassBridgeAliasItem>;
51 /** Retrieves the alias options for a given `shareId`. The alias options
52 * will be valid for a limited period of time (10 minutes) */
53 getAliasOptions: (shareId: string) => Promise<AliasOptions>;
54 /** Retrieves and decrypts all alias items for a given shareId and retrieves
55 * the alias details for the underlying items. */
56 getAllByShareId: MaxAgeMemoizedFn<(shareId: string) => Promise<PassBridgeAliasItem[]>>;
60 /** Get organization settings for Pass */
61 get: () => Promise<OrganizationGetResponse>;
62 /** Update an organization setting for Pass */
63 set: <K extends keyof OrganizationSettings>(
65 value: OrganizationSettings[K]
66 ) => Promise<OrganizationGetResponse>;
71 export type PassBridgeAliasItem = {
72 item: ItemRevision<'alias'>;
75 export type PassBridgeAliasCreate = {
76 /** vault shareId to create the alias in */
78 /** Name of the underlying item */
80 /** Optional note of the underlying item */
82 /** Alias creation options */
84 /** The full alias email : `prefix` + `unsigned suffix`.
85 * Validate it before submitting using the `validateEmailAddress`
86 * helper from `@proton/shared/lib/helpers/email`. */
88 /** The mailbox to forward emails to. Retrieved from `PassBridge.alias.getAliasOptions` */
89 mailbox: AliasMailbox;
90 /** Prefix for the alias. Should not include trailing `.` - it is
91 * already included in the suffix parameter */
93 /** A signed suffix retrieved from `PassBridge.alias.getAliasOptions` */