@bitwarden/sdk-internal 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- */
5
3
  export enum LogLevel {
6
4
  Trace = 0,
7
5
  Debug = 1,
@@ -9,6 +7,50 @@ export enum LogLevel {
9
7
  Warn = 3,
10
8
  Error = 4,
11
9
  }
10
+ export interface InitUserCryptoRequest {
11
+ /**
12
+ * The user\'s KDF parameters, as received from the prelogin request
13
+ */
14
+ kdfParams: Kdf;
15
+ /**
16
+ * The user\'s email address
17
+ */
18
+ email: string;
19
+ /**
20
+ * The user\'s encrypted private key
21
+ */
22
+ privateKey: string;
23
+ /**
24
+ * The initialization method to use
25
+ */
26
+ method: InitUserCryptoMethod;
27
+ }
28
+
29
+ export type InitUserCryptoMethod =
30
+ | { password: { password: string; user_key: string } }
31
+ | { decryptedKey: { decrypted_user_key: string } }
32
+ | { pin: { pin: string; pin_protected_user_key: EncString } }
33
+ | { authRequest: { request_private_key: string; method: AuthRequestMethod } }
34
+ | {
35
+ deviceKey: {
36
+ device_key: string;
37
+ protected_device_private_key: EncString;
38
+ device_protected_user_key: AsymmetricEncString;
39
+ };
40
+ }
41
+ | { keyConnector: { master_key: string; user_key: string } };
42
+
43
+ export type AuthRequestMethod =
44
+ | { userKey: { protected_user_key: AsymmetricEncString } }
45
+ | { masterKey: { protected_master_key: AsymmetricEncString; auth_request_key: EncString } };
46
+
47
+ export interface InitOrgCryptoRequest {
48
+ /**
49
+ * The encryption keys for all the organizations the user is a part of
50
+ */
51
+ organizationKeys: Map<Uuid, AsymmetricEncString>;
52
+ }
53
+
12
54
  export type DeviceType =
13
55
  | "Android"
14
56
  | "iOS"
@@ -73,8 +115,50 @@ export interface ClientSettings {
73
115
  deviceType?: DeviceType;
74
116
  }
75
117
 
118
+ export type AsymmetricEncString = string;
119
+
120
+ export type EncString = string;
121
+
122
+ /**
123
+ * Key Derivation Function for Bitwarden Account
124
+ *
125
+ * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
126
+ * Enum represents all the possible KDFs.
127
+ */
128
+ export type Kdf =
129
+ | { pBKDF2: { iterations: NonZeroU32 } }
130
+ | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
131
+
132
+ export interface Folder {
133
+ id: Uuid | undefined;
134
+ name: EncString;
135
+ revisionDate: DateTime<Utc>;
136
+ }
137
+
138
+ export interface FolderView {
139
+ id: Uuid | undefined;
140
+ name: string;
141
+ revisionDate: DateTime<Utc>;
142
+ }
143
+
144
+ export type Uuid = string;
145
+
146
+ /**
147
+ * RFC3339 compliant date-time string.
148
+ * @typeParam T - Not used in JavaScript.
149
+ */
150
+ export type DateTime<T = unknown> = string;
151
+
152
+ /**
153
+ * UTC date-time string. Not used in JavaScript.
154
+ */
155
+ export type Utc = unknown;
156
+
76
157
  /**
158
+ * An integer that is known not to equal zero.
77
159
  */
160
+ export type NonZeroU32 = number;
161
+
78
162
  export class BitwardenClient {
79
163
  free(): void;
80
164
  /**
@@ -94,4 +178,45 @@ export class BitwardenClient {
94
178
  * @returns {Promise<string>}
95
179
  */
96
180
  http_get(url: string): Promise<string>;
181
+ /**
182
+ * @returns {ClientCrypto}
183
+ */
184
+ crypto(): ClientCrypto;
185
+ /**
186
+ * @returns {ClientVault}
187
+ */
188
+ vault(): ClientVault;
189
+ }
190
+ export class ClientCrypto {
191
+ free(): void;
192
+ /**
193
+ * Initialization method for the user crypto. Needs to be called before any other crypto
194
+ * operations.
195
+ * @param {InitUserCryptoRequest} req
196
+ * @returns {Promise<void>}
197
+ */
198
+ initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
199
+ /**
200
+ * Initialization method for the organization crypto. Needs to be called after
201
+ * `initialize_user_crypto` but before any other crypto operations.
202
+ * @param {InitOrgCryptoRequest} req
203
+ * @returns {Promise<void>}
204
+ */
205
+ initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
206
+ }
207
+ export class ClientFolders {
208
+ free(): void;
209
+ /**
210
+ * Decrypt folder
211
+ * @param {Folder} folder
212
+ * @returns {FolderView}
213
+ */
214
+ decrypt(folder: Folder): FolderView;
215
+ }
216
+ export class ClientVault {
217
+ free(): void;
218
+ /**
219
+ * @returns {ClientFolders}
220
+ */
221
+ folders(): ClientFolders;
97
222
  }
@@ -1,4 +1,4 @@
1
1
  import * as wasm from "./bitwarden_wasm_internal_bg.wasm";
2
+ export * from "./bitwarden_wasm_internal_bg.js";
2
3
  import { __wbg_set_wasm } from "./bitwarden_wasm_internal_bg.js";
3
4
  __wbg_set_wasm(wasm);
4
- export * from "./bitwarden_wasm_internal_bg.js";