MCPcopy Create free account
hub / github.com/bitwarden/clients / run

Method run

apps/cli/src/tools/import.command.ts:36–65  ·  view source on GitHub ↗
(format: ImportType, filepath: string, options: OptionValues)

Source from the content-addressed store, hash-verified

34 ) {}
35
36 async run(format: ImportType, filepath: string, options: OptionValues): Promise<Response> {
37 const organizationId = options.organizationid;
38 if (organizationId != null) {
39 const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
40 if (!userId) {
41 return Response.badRequest("No user found.");
42 }
43 const organization = await firstValueFrom(
44 this.organizationService.organizations$(userId).pipe(getOrganizationById(organizationId)),
45 );
46
47 if (organization == null) {
48 return Response.badRequest(
49 `You do not belong to an organization with the ID of ${organizationId}. Check the organization ID and sync your vault.`,
50 );
51 }
52
53 if (!organization.canAccessImport) {
54 return Response.badRequest(
55 "You are not authorized to import into the provided organization.",
56 );
57 }
58 }
59
60 if (options.formats || false) {
61 return await this.list();
62 } else {
63 return await this.import(format, filepath, organizationId, options);
64 }
65 }
66
67 private async import(
68 format: ImportType,

Callers 1

importCommandMethod · 0.95

Calls 6

listMethod · 0.95
importMethod · 0.95
getOrganizationByIdFunction · 0.90
getUserIdFunction · 0.85
badRequestMethod · 0.80
organizations$Method · 0.45

Tested by

no test coverage detected