mirror of
https://github.com/bitwarden/clients.git
synced 2025-12-11 05:44:04 -06:00
Resolve breaking changes in the SDK (#15472)
This commit is contained in:
parent
a6ae7d23f7
commit
71bef25a96
@ -1,9 +1,11 @@
|
|||||||
import { ClientSettings, LogLevel, BitwardenClient } from "@bitwarden/sdk-internal";
|
import { BitwardenClient } from "@bitwarden/sdk-internal";
|
||||||
|
|
||||||
import { SdkClientFactory } from "../src/platform/abstractions/sdk/sdk-client-factory";
|
import { SdkClientFactory } from "../src/platform/abstractions/sdk/sdk-client-factory";
|
||||||
|
|
||||||
export class DefaultSdkClientFactory implements SdkClientFactory {
|
export class DefaultSdkClientFactory implements SdkClientFactory {
|
||||||
createSdkClient(settings?: ClientSettings, log_level?: LogLevel): Promise<BitwardenClient> {
|
createSdkClient(
|
||||||
|
...args: ConstructorParameters<typeof BitwardenClient>
|
||||||
|
): Promise<BitwardenClient> {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import {
|
|||||||
BitwardenClient,
|
BitwardenClient,
|
||||||
ClientSettings,
|
ClientSettings,
|
||||||
DeviceType as SdkDeviceType,
|
DeviceType as SdkDeviceType,
|
||||||
|
TokenProvider,
|
||||||
} from "@bitwarden/sdk-internal";
|
} from "@bitwarden/sdk-internal";
|
||||||
|
|
||||||
import { EncryptedOrganizationKeyData } from "../../../admin-console/models/data/encrypted-organization-key.data";
|
import { EncryptedOrganizationKeyData } from "../../../admin-console/models/data/encrypted-organization-key.data";
|
||||||
@ -41,6 +42,17 @@ import { EncryptedString } from "../../models/domain/enc-string";
|
|||||||
// blocking the creation of an internal client for that user.
|
// blocking the creation of an internal client for that user.
|
||||||
const UnsetClient = Symbol("UnsetClient");
|
const UnsetClient = Symbol("UnsetClient");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A token provider that exposes the access token to the SDK.
|
||||||
|
*/
|
||||||
|
class JsTokenProvider implements TokenProvider {
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
async get_access_token(): Promise<string | undefined> {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class DefaultSdkService implements SdkService {
|
export class DefaultSdkService implements SdkService {
|
||||||
private sdkClientOverrides = new BehaviorSubject<{
|
private sdkClientOverrides = new BehaviorSubject<{
|
||||||
[userId: UserId]: Rc<BitwardenClient> | typeof UnsetClient;
|
[userId: UserId]: Rc<BitwardenClient> | typeof UnsetClient;
|
||||||
@ -51,7 +63,7 @@ export class DefaultSdkService implements SdkService {
|
|||||||
concatMap(async (env) => {
|
concatMap(async (env) => {
|
||||||
await SdkLoadService.Ready;
|
await SdkLoadService.Ready;
|
||||||
const settings = this.toSettings(env);
|
const settings = this.toSettings(env);
|
||||||
return await this.sdkClientFactory.createSdkClient(settings);
|
return await this.sdkClientFactory.createSdkClient(new JsTokenProvider(), settings);
|
||||||
}),
|
}),
|
||||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
shareReplay({ refCount: true, bufferSize: 1 }),
|
||||||
);
|
);
|
||||||
@ -151,7 +163,10 @@ export class DefaultSdkService implements SdkService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const settings = this.toSettings(env);
|
const settings = this.toSettings(env);
|
||||||
const client = await this.sdkClientFactory.createSdkClient(settings);
|
const client = await this.sdkClientFactory.createSdkClient(
|
||||||
|
new JsTokenProvider(),
|
||||||
|
settings,
|
||||||
|
);
|
||||||
|
|
||||||
await this.initializeClient(
|
await this.initializeClient(
|
||||||
userId,
|
userId,
|
||||||
|
|||||||
@ -67,6 +67,7 @@ describe("AttachmentView", () => {
|
|||||||
sizeName: "sizeName",
|
sizeName: "sizeName",
|
||||||
fileName: "fileName",
|
fileName: "fileName",
|
||||||
key: "encKeyB64",
|
key: "encKeyB64",
|
||||||
|
decryptedKey: null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -59,6 +59,7 @@ export class AttachmentView implements View {
|
|||||||
sizeName: this.sizeName,
|
sizeName: this.sizeName,
|
||||||
fileName: this.fileName,
|
fileName: this.fileName,
|
||||||
key: this.encryptedKey?.toJSON(),
|
key: this.encryptedKey?.toJSON(),
|
||||||
|
decryptedKey: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import {
|
|||||||
CipherType as SdkCipherType,
|
CipherType as SdkCipherType,
|
||||||
CipherView as SdkCipherView,
|
CipherView as SdkCipherView,
|
||||||
CipherListView,
|
CipherListView,
|
||||||
Attachment as SdkAttachment,
|
AttachmentView as SdkAttachmentView,
|
||||||
} from "@bitwarden/sdk-internal";
|
} from "@bitwarden/sdk-internal";
|
||||||
|
|
||||||
import { mockEnc } from "../../../spec";
|
import { mockEnc } from "../../../spec";
|
||||||
@ -311,7 +311,9 @@ describe("DefaultCipherEncryptionService", () => {
|
|||||||
const expectedDecryptedContent = new Uint8Array([5, 6, 7, 8]);
|
const expectedDecryptedContent = new Uint8Array([5, 6, 7, 8]);
|
||||||
|
|
||||||
jest.spyOn(cipher, "toSdkCipher").mockReturnValue({ id: "id" } as SdkCipher);
|
jest.spyOn(cipher, "toSdkCipher").mockReturnValue({ id: "id" } as SdkCipher);
|
||||||
jest.spyOn(attachment, "toSdkAttachmentView").mockReturnValue({ id: "a1" } as SdkAttachment);
|
jest
|
||||||
|
.spyOn(attachment, "toSdkAttachmentView")
|
||||||
|
.mockReturnValue({ id: "a1" } as SdkAttachmentView);
|
||||||
mockSdkClient.vault().attachments().decrypt_buffer.mockReturnValue(expectedDecryptedContent);
|
mockSdkClient.vault().attachments().decrypt_buffer.mockReturnValue(expectedDecryptedContent);
|
||||||
|
|
||||||
const result = await cipherEncryptionService.decryptAttachmentContent(
|
const result = await cipherEncryptionService.decryptAttachmentContent(
|
||||||
|
|||||||
@ -31,7 +31,7 @@ const sdkPassphrase: GeneratorMetadata<PassphraseGenerationOptions> = {
|
|||||||
create(
|
create(
|
||||||
dependencies: GeneratorDependencyProvider,
|
dependencies: GeneratorDependencyProvider,
|
||||||
): CredentialGenerator<PassphraseGenerationOptions> {
|
): CredentialGenerator<PassphraseGenerationOptions> {
|
||||||
return new SdkPasswordRandomizer(new BitwardenClient(), Date.now); // @TODO hook up a real SDK client
|
return new SdkPasswordRandomizer(new BitwardenClient(null), Date.now); // @TODO hook up a real SDK client
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
profiles: {
|
profiles: {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ const sdkPassword: GeneratorMetadata<PasswordGeneratorSettings> = deepFreeze({
|
|||||||
create(
|
create(
|
||||||
dependencies: GeneratorDependencyProvider,
|
dependencies: GeneratorDependencyProvider,
|
||||||
): CredentialGenerator<PasswordGeneratorSettings> {
|
): CredentialGenerator<PasswordGeneratorSettings> {
|
||||||
return new SdkPasswordRandomizer(new BitwardenClient(), Date.now); // @TODO hook up a real SDK client
|
return new SdkPasswordRandomizer(new BitwardenClient(null), Date.now); // @TODO hook up a real SDK client
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
profiles: {
|
profiles: {
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@ -24,7 +24,7 @@
|
|||||||
"@angular/platform-browser": "19.2.14",
|
"@angular/platform-browser": "19.2.14",
|
||||||
"@angular/platform-browser-dynamic": "19.2.14",
|
"@angular/platform-browser-dynamic": "19.2.14",
|
||||||
"@angular/router": "19.2.14",
|
"@angular/router": "19.2.14",
|
||||||
"@bitwarden/sdk-internal": "0.2.0-main.213",
|
"@bitwarden/sdk-internal": "0.2.0-main.225",
|
||||||
"@electron/fuses": "1.8.0",
|
"@electron/fuses": "1.8.0",
|
||||||
"@emotion/css": "11.13.5",
|
"@emotion/css": "11.13.5",
|
||||||
"@koa/multer": "3.1.0",
|
"@koa/multer": "3.1.0",
|
||||||
@ -4610,9 +4610,9 @@
|
|||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@bitwarden/sdk-internal": {
|
"node_modules/@bitwarden/sdk-internal": {
|
||||||
"version": "0.2.0-main.213",
|
"version": "0.2.0-main.225",
|
||||||
"resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.213.tgz",
|
"resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.225.tgz",
|
||||||
"integrity": "sha512-/AUpdQQ++tLsH9dJDFQcIDihCpsI+ikdZuYwbztSXPp7piCnLk71f7r10yMPGQ8OEOF49mMEbLCG+dJKpBqeRg==",
|
"integrity": "sha512-bhSFNX584GPJ9wMBYff1d18/Hfj+o+D4E1l3uDLZNXRI9s7w919AQWqJ0xUy1vh8gpkLJovkf64HQGqs0OiQQA==",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"type-fest": "^4.41.0"
|
"type-fest": "^4.41.0"
|
||||||
|
|||||||
@ -160,7 +160,7 @@
|
|||||||
"@angular/platform-browser": "19.2.14",
|
"@angular/platform-browser": "19.2.14",
|
||||||
"@angular/platform-browser-dynamic": "19.2.14",
|
"@angular/platform-browser-dynamic": "19.2.14",
|
||||||
"@angular/router": "19.2.14",
|
"@angular/router": "19.2.14",
|
||||||
"@bitwarden/sdk-internal": "0.2.0-main.213",
|
"@bitwarden/sdk-internal": "0.2.0-main.225",
|
||||||
"@electron/fuses": "1.8.0",
|
"@electron/fuses": "1.8.0",
|
||||||
"@emotion/css": "11.13.5",
|
"@emotion/css": "11.13.5",
|
||||||
"@koa/multer": "3.1.0",
|
"@koa/multer": "3.1.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user