@bitwarden/sdk-internal 0.2.0-main.134 → 0.2.0-main.136

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.
@@ -29,6 +29,52 @@ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
29
29
  * - `Err(UnsupportedKeyType)` if the key type is not supported
30
30
  */
31
31
  export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
32
+ export enum CardLinkedIdType {
33
+ CardholderName = 300,
34
+ ExpMonth = 301,
35
+ ExpYear = 302,
36
+ Code = 303,
37
+ Brand = 304,
38
+ Number = 305,
39
+ }
40
+ export enum CipherRepromptType {
41
+ None = 0,
42
+ Password = 1,
43
+ }
44
+ export enum CipherType {
45
+ Login = 1,
46
+ SecureNote = 2,
47
+ Card = 3,
48
+ Identity = 4,
49
+ SshKey = 5,
50
+ }
51
+ export enum FieldType {
52
+ Text = 0,
53
+ Hidden = 1,
54
+ Boolean = 2,
55
+ Linked = 3,
56
+ }
57
+ export enum IdentityLinkedIdType {
58
+ Title = 400,
59
+ MiddleName = 401,
60
+ Address1 = 402,
61
+ Address2 = 403,
62
+ Address3 = 404,
63
+ City = 405,
64
+ State = 406,
65
+ PostalCode = 407,
66
+ Country = 408,
67
+ Company = 409,
68
+ Email = 410,
69
+ Phone = 411,
70
+ Ssn = 412,
71
+ Username = 413,
72
+ PassportNumber = 414,
73
+ LicenseNumber = 415,
74
+ FirstName = 416,
75
+ LastName = 417,
76
+ FullName = 418,
77
+ }
32
78
  export enum LogLevel {
33
79
  Trace = 0,
34
80
  Debug = 1,
@@ -36,6 +82,21 @@ export enum LogLevel {
36
82
  Warn = 3,
37
83
  Error = 4,
38
84
  }
85
+ export enum LoginLinkedIdType {
86
+ Username = 100,
87
+ Password = 101,
88
+ }
89
+ export enum SecureNoteType {
90
+ Generic = 0,
91
+ }
92
+ export enum UriMatchType {
93
+ Domain = 0,
94
+ Host = 1,
95
+ StartsWith = 2,
96
+ Exact = 3,
97
+ RegularExpression = 4,
98
+ Never = 5,
99
+ }
39
100
  export interface InitUserCryptoRequest {
40
101
  /**
41
102
  * The user\'s KDF parameters, as received from the prelogin request
@@ -234,17 +295,6 @@ export type Endpoint =
234
295
  | "DesktopRenderer"
235
296
  | "DesktopMain";
236
297
 
237
- export interface OutgoingMessage {
238
- data: number[];
239
- destination: Endpoint;
240
- }
241
-
242
- export interface IncomingMessage {
243
- data: number[];
244
- destination: Endpoint;
245
- source: Endpoint;
246
- }
247
-
248
298
  export interface CommunicationBackend {
249
299
  send(message: OutgoingMessage): Promise<void>;
250
300
  receive(): Promise<IncomingMessage>;
@@ -279,6 +329,226 @@ export interface KeyGenerationError extends Error {
279
329
 
280
330
  export function isKeyGenerationError(error: any): error is KeyGenerationError;
281
331
 
332
+ export interface Cipher {
333
+ id: Uuid | undefined;
334
+ organizationId: Uuid | undefined;
335
+ folderId: Uuid | undefined;
336
+ collectionIds: Uuid[];
337
+ /**
338
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
339
+ * Cipher.
340
+ */
341
+ key: EncString | undefined;
342
+ name: EncString;
343
+ notes: EncString | undefined;
344
+ type: CipherType;
345
+ login: Login | undefined;
346
+ identity: Identity | undefined;
347
+ card: Card | undefined;
348
+ secureNote: SecureNote | undefined;
349
+ sshKey: SshKey | undefined;
350
+ favorite: boolean;
351
+ reprompt: CipherRepromptType;
352
+ organizationUseTotp: boolean;
353
+ edit: boolean;
354
+ permissions: CipherPermissions | undefined;
355
+ viewPassword: boolean;
356
+ localData: LocalData | undefined;
357
+ attachments: Attachment[] | undefined;
358
+ fields: Field[] | undefined;
359
+ passwordHistory: PasswordHistory[] | undefined;
360
+ creationDate: DateTime<Utc>;
361
+ deletedDate: DateTime<Utc> | undefined;
362
+ revisionDate: DateTime<Utc>;
363
+ }
364
+
365
+ export interface CipherView {
366
+ id: Uuid | undefined;
367
+ organizationId: Uuid | undefined;
368
+ folderId: Uuid | undefined;
369
+ collectionIds: Uuid[];
370
+ /**
371
+ * Temporary, required to support re-encrypting existing items.
372
+ */
373
+ key: EncString | undefined;
374
+ name: string;
375
+ notes: string | undefined;
376
+ type: CipherType;
377
+ login: LoginView | undefined;
378
+ identity: IdentityView | undefined;
379
+ card: CardView | undefined;
380
+ secureNote: SecureNoteView | undefined;
381
+ sshKey: SshKeyView | undefined;
382
+ favorite: boolean;
383
+ reprompt: CipherRepromptType;
384
+ organizationUseTotp: boolean;
385
+ edit: boolean;
386
+ permissions: CipherPermissions | undefined;
387
+ viewPassword: boolean;
388
+ localData: LocalDataView | undefined;
389
+ attachments: AttachmentView[] | undefined;
390
+ fields: FieldView[] | undefined;
391
+ passwordHistory: PasswordHistoryView[] | undefined;
392
+ creationDate: DateTime<Utc>;
393
+ deletedDate: DateTime<Utc> | undefined;
394
+ revisionDate: DateTime<Utc>;
395
+ }
396
+
397
+ export type CipherListViewType =
398
+ | { login: LoginListView }
399
+ | "secureNote"
400
+ | "card"
401
+ | "identity"
402
+ | "sshKey";
403
+
404
+ export interface CipherListView {
405
+ id: Uuid | undefined;
406
+ organizationId: Uuid | undefined;
407
+ folderId: Uuid | undefined;
408
+ collectionIds: Uuid[];
409
+ /**
410
+ * Temporary, required to support calculating TOTP from CipherListView.
411
+ */
412
+ key: EncString | undefined;
413
+ name: string;
414
+ subtitle: string;
415
+ type: CipherListViewType;
416
+ favorite: boolean;
417
+ reprompt: CipherRepromptType;
418
+ organizationUseTotp: boolean;
419
+ edit: boolean;
420
+ permissions: CipherPermissions | undefined;
421
+ viewPassword: boolean;
422
+ /**
423
+ * The number of attachments
424
+ */
425
+ attachments: number;
426
+ creationDate: DateTime<Utc>;
427
+ deletedDate: DateTime<Utc> | undefined;
428
+ revisionDate: DateTime<Utc>;
429
+ }
430
+
431
+ export interface Field {
432
+ name: EncString | undefined;
433
+ value: EncString | undefined;
434
+ type: FieldType;
435
+ linkedId: LinkedIdType | undefined;
436
+ }
437
+
438
+ export interface FieldView {
439
+ name: string | undefined;
440
+ value: string | undefined;
441
+ type: FieldType;
442
+ linkedId: LinkedIdType | undefined;
443
+ }
444
+
445
+ export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
446
+
447
+ export interface LoginUri {
448
+ uri: EncString | undefined;
449
+ match: UriMatchType | undefined;
450
+ uriChecksum: EncString | undefined;
451
+ }
452
+
453
+ export interface LoginUriView {
454
+ uri: string | undefined;
455
+ match: UriMatchType | undefined;
456
+ uriChecksum: string | undefined;
457
+ }
458
+
459
+ export interface Fido2Credential {
460
+ credentialId: EncString;
461
+ keyType: EncString;
462
+ keyAlgorithm: EncString;
463
+ keyCurve: EncString;
464
+ keyValue: EncString;
465
+ rpId: EncString;
466
+ userHandle: EncString | undefined;
467
+ userName: EncString | undefined;
468
+ counter: EncString;
469
+ rpName: EncString | undefined;
470
+ userDisplayName: EncString | undefined;
471
+ discoverable: EncString;
472
+ creationDate: DateTime<Utc>;
473
+ }
474
+
475
+ export interface Fido2CredentialListView {
476
+ credentialId: string;
477
+ rpId: string;
478
+ userHandle: string | undefined;
479
+ userName: string | undefined;
480
+ userDisplayName: string | undefined;
481
+ }
482
+
483
+ export interface Fido2CredentialView {
484
+ credentialId: string;
485
+ keyType: string;
486
+ keyAlgorithm: string;
487
+ keyCurve: string;
488
+ keyValue: EncString;
489
+ rpId: string;
490
+ userHandle: string | undefined;
491
+ userName: string | undefined;
492
+ counter: string;
493
+ rpName: string | undefined;
494
+ userDisplayName: string | undefined;
495
+ discoverable: string;
496
+ creationDate: DateTime<Utc>;
497
+ }
498
+
499
+ export interface Fido2CredentialNewView {
500
+ credentialId: string;
501
+ keyType: string;
502
+ keyAlgorithm: string;
503
+ keyCurve: string;
504
+ rpId: string;
505
+ userHandle: string | undefined;
506
+ userName: string | undefined;
507
+ counter: string;
508
+ rpName: string | undefined;
509
+ userDisplayName: string | undefined;
510
+ creationDate: DateTime<Utc>;
511
+ }
512
+
513
+ export interface Login {
514
+ username: EncString | undefined;
515
+ password: EncString | undefined;
516
+ passwordRevisionDate: DateTime<Utc> | undefined;
517
+ uris: LoginUri[] | undefined;
518
+ totp: EncString | undefined;
519
+ autofillOnPageLoad: boolean | undefined;
520
+ fido2Credentials: Fido2Credential[] | undefined;
521
+ }
522
+
523
+ export interface LoginView {
524
+ username: string | undefined;
525
+ password: string | undefined;
526
+ passwordRevisionDate: DateTime<Utc> | undefined;
527
+ uris: LoginUriView[] | undefined;
528
+ totp: string | undefined;
529
+ autofillOnPageLoad: boolean | undefined;
530
+ fido2Credentials: Fido2Credential[] | undefined;
531
+ }
532
+
533
+ export interface LoginListView {
534
+ fido2Credentials: Fido2CredentialListView[] | undefined;
535
+ hasFido2: boolean;
536
+ username: string | undefined;
537
+ /**
538
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
539
+ */
540
+ totp: EncString | undefined;
541
+ uris: LoginUriView[] | undefined;
542
+ }
543
+
544
+ export interface SecureNote {
545
+ type: SecureNoteType;
546
+ }
547
+
548
+ export interface SecureNoteView {
549
+ type: SecureNoteType;
550
+ }
551
+
282
552
  export interface Folder {
283
553
  id: Uuid | undefined;
284
554
  name: EncString;
@@ -337,6 +607,16 @@ export interface TotpError extends Error {
337
607
 
338
608
  export function isTotpError(error: any): error is TotpError;
339
609
 
610
+ export interface PasswordHistoryView {
611
+ password: string;
612
+ lastUsedDate: DateTime<Utc>;
613
+ }
614
+
615
+ export interface PasswordHistory {
616
+ password: EncString;
617
+ lastUsedDate: DateTime<Utc>;
618
+ }
619
+
340
620
  export interface SshKeyView {
341
621
  /**
342
622
  * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
@@ -352,6 +632,117 @@ export interface SshKeyView {
352
632
  fingerprint: string;
353
633
  }
354
634
 
635
+ export interface SshKey {
636
+ /**
637
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
638
+ */
639
+ privateKey: EncString;
640
+ /**
641
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
642
+ */
643
+ publicKey: EncString;
644
+ /**
645
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
646
+ */
647
+ fingerprint: EncString;
648
+ }
649
+
650
+ export interface LocalDataView {
651
+ lastUsedDate: number | undefined;
652
+ lastLaunched: number | undefined;
653
+ }
654
+
655
+ export interface LocalData {
656
+ lastUsedDate: number | undefined;
657
+ lastLaunched: number | undefined;
658
+ }
659
+
660
+ export interface IdentityView {
661
+ title: string | undefined;
662
+ firstName: string | undefined;
663
+ middleName: string | undefined;
664
+ lastName: string | undefined;
665
+ address1: string | undefined;
666
+ address2: string | undefined;
667
+ address3: string | undefined;
668
+ city: string | undefined;
669
+ state: string | undefined;
670
+ postalCode: string | undefined;
671
+ country: string | undefined;
672
+ company: string | undefined;
673
+ email: string | undefined;
674
+ phone: string | undefined;
675
+ ssn: string | undefined;
676
+ username: string | undefined;
677
+ passportNumber: string | undefined;
678
+ licenseNumber: string | undefined;
679
+ }
680
+
681
+ export interface Identity {
682
+ title: EncString | undefined;
683
+ firstName: EncString | undefined;
684
+ middleName: EncString | undefined;
685
+ lastName: EncString | undefined;
686
+ address1: EncString | undefined;
687
+ address2: EncString | undefined;
688
+ address3: EncString | undefined;
689
+ city: EncString | undefined;
690
+ state: EncString | undefined;
691
+ postalCode: EncString | undefined;
692
+ country: EncString | undefined;
693
+ company: EncString | undefined;
694
+ email: EncString | undefined;
695
+ phone: EncString | undefined;
696
+ ssn: EncString | undefined;
697
+ username: EncString | undefined;
698
+ passportNumber: EncString | undefined;
699
+ licenseNumber: EncString | undefined;
700
+ }
701
+
702
+ export interface CipherPermissions {
703
+ delete: boolean;
704
+ restore: boolean;
705
+ }
706
+
707
+ export interface CardView {
708
+ cardholderName: string | undefined;
709
+ expMonth: string | undefined;
710
+ expYear: string | undefined;
711
+ code: string | undefined;
712
+ brand: string | undefined;
713
+ number: string | undefined;
714
+ }
715
+
716
+ export interface Card {
717
+ cardholderName: EncString | undefined;
718
+ expMonth: EncString | undefined;
719
+ expYear: EncString | undefined;
720
+ code: EncString | undefined;
721
+ brand: EncString | undefined;
722
+ number: EncString | undefined;
723
+ }
724
+
725
+ export interface AttachmentView {
726
+ id: string | undefined;
727
+ url: string | undefined;
728
+ size: string | undefined;
729
+ sizeName: string | undefined;
730
+ fileName: string | undefined;
731
+ key: EncString | undefined;
732
+ }
733
+
734
+ export interface Attachment {
735
+ id: string | undefined;
736
+ url: string | undefined;
737
+ size: string | undefined;
738
+ /**
739
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
740
+ */
741
+ sizeName: string | undefined;
742
+ fileName: EncString | undefined;
743
+ key: EncString | undefined;
744
+ }
745
+
355
746
  export type Uuid = string;
356
747
 
357
748
  /**
@@ -392,6 +783,54 @@ export class BitwardenClient {
392
783
  crypto(): CryptoClient;
393
784
  vault(): VaultClient;
394
785
  }
786
+ export class ClientCiphers {
787
+ private constructor();
788
+ free(): void;
789
+ /**
790
+ * Encrypt cipher
791
+ *
792
+ * # Arguments
793
+ * - `cipher_view` - The decrypted cipher to encrypt
794
+ *
795
+ * # Returns
796
+ * - `Ok(Cipher)` containing the encrypted cipher
797
+ * - `Err(EncryptError)` if encryption fails
798
+ */
799
+ encrypt(cipher_view: CipherView): Cipher;
800
+ /**
801
+ * Decrypt cipher
802
+ *
803
+ * # Arguments
804
+ * - `cipher` - The encrypted cipher to decrypt
805
+ *
806
+ * # Returns
807
+ * - `Ok(CipherView)` containing the decrypted cipher
808
+ * - `Err(DecryptError)` if decryption fails
809
+ */
810
+ decrypt(cipher: Cipher): CipherView;
811
+ /**
812
+ * Decrypt list of ciphers
813
+ *
814
+ * # Arguments
815
+ * - `ciphers` - The list of encrypted ciphers to decrypt
816
+ *
817
+ * # Returns
818
+ * - `Ok(Vec<CipherListView>)` containing the decrypted ciphers
819
+ * - `Err(DecryptError)` if decryption fails
820
+ */
821
+ decrypt_list(ciphers: Cipher[]): CipherListView[];
822
+ /**
823
+ * Decrypt FIDO2 credentials
824
+ *
825
+ * # Arguments
826
+ * - `cipher_view` - Cipher to encrypt containing the FIDO2 credential
827
+ *
828
+ * # Returns
829
+ * - `Ok(Vec<Fido2CredentialView>)` containing the decrypted FIDO2 credentials
830
+ * - `Err(DecryptError)` if decryption fails
831
+ */
832
+ decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
833
+ }
395
834
  export class ClientFolders {
396
835
  private constructor();
397
836
  free(): void;
@@ -444,12 +883,42 @@ export class CryptoClient {
444
883
  */
445
884
  verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
446
885
  }
886
+ export class IncomingMessage {
887
+ free(): void;
888
+ constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
889
+ /**
890
+ * Try to parse the payload as JSON.
891
+ * @returns The parsed JSON value, or undefined if the payload is not valid JSON.
892
+ */
893
+ parse_payload_as_json(): any;
894
+ payload: Uint8Array;
895
+ destination: Endpoint;
896
+ source: Endpoint;
897
+ get topic(): string | undefined;
898
+ set topic(value: string | null | undefined);
899
+ }
447
900
  export class IpcClient {
448
901
  free(): void;
449
902
  constructor(communication_provider: CommunicationBackend);
450
903
  send(message: OutgoingMessage): Promise<void>;
451
904
  receive(): Promise<IncomingMessage>;
452
905
  }
906
+ export class OutgoingMessage {
907
+ free(): void;
908
+ constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
909
+ /**
910
+ * Create a new message and encode the payload as JSON.
911
+ */
912
+ static new_json_payload(
913
+ payload: any,
914
+ destination: Endpoint,
915
+ topic?: string | null,
916
+ ): OutgoingMessage;
917
+ payload: Uint8Array;
918
+ destination: Endpoint;
919
+ get topic(): string | undefined;
920
+ set topic(value: string | null | undefined);
921
+ }
453
922
  /**
454
923
  * This module represents a stopgap solution to provide access to primitive crypto functions for JS
455
924
  * clients. It is not intended to be used outside of the JS clients and this pattern should not be
@@ -468,18 +937,20 @@ export class PureCrypto {
468
937
  export class ReceiveError {
469
938
  private constructor();
470
939
  free(): void;
471
- crypto_error: any;
472
- communication_error: any;
940
+ timeout: boolean;
941
+ crypto: any;
942
+ communication: any;
473
943
  }
474
944
  export class SendError {
475
945
  private constructor();
476
946
  free(): void;
477
- crypto_error: any;
478
- communication_error: any;
947
+ crypto: any;
948
+ communication: any;
479
949
  }
480
950
  export class VaultClient {
481
951
  private constructor();
482
952
  free(): void;
953
+ ciphers(): ClientCiphers;
483
954
  folders(): ClientFolders;
484
955
  totp(): ClientTotp;
485
956
  }