@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.
@@ -0,0 +1,222 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export enum LogLevel {
4
+ Trace = 0,
5
+ Debug = 1,
6
+ Info = 2,
7
+ Warn = 3,
8
+ Error = 4,
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
+
54
+ export type DeviceType =
55
+ | "Android"
56
+ | "iOS"
57
+ | "ChromeExtension"
58
+ | "FirefoxExtension"
59
+ | "OperaExtension"
60
+ | "EdgeExtension"
61
+ | "WindowsDesktop"
62
+ | "MacOsDesktop"
63
+ | "LinuxDesktop"
64
+ | "ChromeBrowser"
65
+ | "FirefoxBrowser"
66
+ | "OperaBrowser"
67
+ | "EdgeBrowser"
68
+ | "IEBrowser"
69
+ | "UnknownBrowser"
70
+ | "AndroidAmazon"
71
+ | "UWP"
72
+ | "SafariBrowser"
73
+ | "VivaldiBrowser"
74
+ | "VivaldiExtension"
75
+ | "SafariExtension"
76
+ | "SDK"
77
+ | "Server"
78
+ | "WindowsCLI"
79
+ | "MacOsCLI"
80
+ | "LinuxCLI";
81
+
82
+ /**
83
+ * Basic client behavior settings. These settings specify the various targets and behavior of the
84
+ * Bitwarden Client. They are optional and uneditable once the client is initialized.
85
+ *
86
+ * Defaults to
87
+ *
88
+ * ```
89
+ * # use bitwarden_core::{ClientSettings, DeviceType};
90
+ * let settings = ClientSettings {
91
+ * identity_url: \"https://identity.bitwarden.com\".to_string(),
92
+ * api_url: \"https://api.bitwarden.com\".to_string(),
93
+ * user_agent: \"Bitwarden Rust-SDK\".to_string(),
94
+ * device_type: DeviceType::SDK,
95
+ * };
96
+ * let default = ClientSettings::default();
97
+ * ```
98
+ */
99
+ export interface ClientSettings {
100
+ /**
101
+ * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
102
+ */
103
+ identityUrl?: string;
104
+ /**
105
+ * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
106
+ */
107
+ apiUrl?: string;
108
+ /**
109
+ * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
110
+ */
111
+ userAgent?: string;
112
+ /**
113
+ * Device type to send to Bitwarden. Defaults to SDK
114
+ */
115
+ deviceType?: DeviceType;
116
+ }
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
+
157
+ /**
158
+ * An integer that is known not to equal zero.
159
+ */
160
+ export type NonZeroU32 = number;
161
+
162
+ export class BitwardenClient {
163
+ free(): void;
164
+ /**
165
+ * @param {ClientSettings | undefined} [settings]
166
+ * @param {LogLevel | undefined} [log_level]
167
+ */
168
+ constructor(settings?: ClientSettings, log_level?: LogLevel);
169
+ /**
170
+ * Test method, echoes back the input
171
+ * @param {string} msg
172
+ * @returns {string}
173
+ */
174
+ echo(msg: string): string;
175
+ /**
176
+ * Test method, calls http endpoint
177
+ * @param {string} url
178
+ * @returns {Promise<string>}
179
+ */
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;
222
+ }