@keyhive/keyhive 0.1.0-alpha.4 → 0.1.0-alpha.5

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.
@@ -46,37 +46,6 @@ class Access {
46
46
  if (Symbol.dispose) Access.prototype[Symbol.dispose] = Access.prototype.free;
47
47
  exports.Access = Access;
48
48
 
49
- /**
50
- * The result of adding a member: the membership delegation.
51
- */
52
- class AddMemberUpdate {
53
- static __wrap(ptr) {
54
- const obj = Object.create(AddMemberUpdate.prototype);
55
- obj.__wbg_ptr = ptr;
56
- AddMemberUpdateFinalization.register(obj, obj.__wbg_ptr, obj);
57
- return obj;
58
- }
59
- __destroy_into_raw() {
60
- const ptr = this.__wbg_ptr;
61
- this.__wbg_ptr = 0;
62
- AddMemberUpdateFinalization.unregister(this);
63
- return ptr;
64
- }
65
- free() {
66
- const ptr = this.__destroy_into_raw();
67
- wasm.__wbg_addmemberupdate_free(ptr, 0);
68
- }
69
- /**
70
- * @returns {SignedDelegation}
71
- */
72
- get delegation() {
73
- const ret = wasm.addmemberupdate_delegation(this.__wbg_ptr);
74
- return SignedDelegation.__wrap(ret);
75
- }
76
- }
77
- if (Symbol.dispose) AddMemberUpdate.prototype[Symbol.dispose] = AddMemberUpdate.prototype.free;
78
- exports.AddMemberUpdate = AddMemberUpdate;
79
-
80
49
  class Agent {
81
50
  static __wrap(ptr) {
82
51
  const obj = Object.create(Agent.prototype);
@@ -598,33 +567,31 @@ exports.ContactCard = ContactCard;
598
567
 
599
568
  /**
600
569
  * Plaintext plus the application secret key that decrypted it.
601
- *
602
- * The key lets the consumer recover the blob's external predecessor-secret
603
- * chain and chain further encryptions onto it, without re-entering CGKA.
604
570
  */
605
- class DecryptedWithKey {
571
+ class DecryptedKeyed {
606
572
  static __wrap(ptr) {
607
- const obj = Object.create(DecryptedWithKey.prototype);
573
+ const obj = Object.create(DecryptedKeyed.prototype);
608
574
  obj.__wbg_ptr = ptr;
609
- DecryptedWithKeyFinalization.register(obj, obj.__wbg_ptr, obj);
575
+ DecryptedKeyedFinalization.register(obj, obj.__wbg_ptr, obj);
610
576
  return obj;
611
577
  }
612
578
  __destroy_into_raw() {
613
579
  const ptr = this.__wbg_ptr;
614
580
  this.__wbg_ptr = 0;
615
- DecryptedWithKeyFinalization.unregister(this);
581
+ DecryptedKeyedFinalization.unregister(this);
616
582
  return ptr;
617
583
  }
618
584
  free() {
619
585
  const ptr = this.__destroy_into_raw();
620
- wasm.__wbg_decryptedwithkey_free(ptr, 0);
586
+ wasm.__wbg_decryptedkeyed_free(ptr, 0);
621
587
  }
622
588
  /**
623
589
  * The 32-byte application secret key used to decrypt this content.
590
+ * Treat as secret: do not log or persist unencrypted.
624
591
  * @returns {Uint8Array}
625
592
  */
626
593
  get applicationSecret() {
627
- const ret = wasm.decryptedwithkey_applicationSecret(this.__wbg_ptr);
594
+ const ret = wasm.decryptedkeyed_applicationSecret(this.__wbg_ptr);
628
595
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
629
596
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
630
597
  return v1;
@@ -633,14 +600,14 @@ class DecryptedWithKey {
633
600
  * @returns {Uint8Array}
634
601
  */
635
602
  get plaintext() {
636
- const ret = wasm.decryptedwithkey_plaintext(this.__wbg_ptr);
603
+ const ret = wasm.decryptedkeyed_plaintext(this.__wbg_ptr);
637
604
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
638
605
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
639
606
  return v1;
640
607
  }
641
608
  }
642
- if (Symbol.dispose) DecryptedWithKey.prototype[Symbol.dispose] = DecryptedWithKey.prototype.free;
643
- exports.DecryptedWithKey = DecryptedWithKey;
609
+ if (Symbol.dispose) DecryptedKeyed.prototype[Symbol.dispose] = DecryptedKeyed.prototype.free;
610
+ exports.DecryptedKeyed = DecryptedKeyed;
644
611
 
645
612
  class Delegation {
646
613
  static __wrap(ptr) {
@@ -927,8 +894,7 @@ class Encrypted {
927
894
  }
928
895
  /**
929
896
  * Decrypt this content with an explicit 32-byte application secret key,
930
- * bypassing CGKA. The consumer uses this to follow the external
931
- * predecessor-secret chain once it has recovered a blob's key.
897
+ * bypassing CGKA.
932
898
  * @param {Uint8Array} key
933
899
  * @returns {Uint8Array}
934
900
  */
@@ -1025,15 +991,50 @@ class EncryptedContentWithUpdate {
1025
991
  const ptr = this.__destroy_into_raw();
1026
992
  wasm.__wbg_encryptedcontentwithupdate_free(ptr, 0);
1027
993
  }
994
+ /**
995
+ * @returns {Encrypted}
996
+ */
997
+ encrypted_content() {
998
+ const ret = wasm.encryptedcontentwithupdate_encrypted_content(this.__wbg_ptr);
999
+ return Encrypted.__wrap(ret);
1000
+ }
1001
+ /**
1002
+ * @returns {SignedCgkaOperation | undefined}
1003
+ */
1004
+ update_op() {
1005
+ const ret = wasm.encryptedcontentwithupdate_update_op(this.__wbg_ptr);
1006
+ return ret === 0 ? undefined : SignedCgkaOperation.__wrap(ret);
1007
+ }
1008
+ }
1009
+ if (Symbol.dispose) EncryptedContentWithUpdate.prototype[Symbol.dispose] = EncryptedContentWithUpdate.prototype.free;
1010
+ exports.EncryptedContentWithUpdate = EncryptedContentWithUpdate;
1011
+
1012
+ /**
1013
+ * Encrypted content plus the application secret key it was encrypted under.
1014
+ */
1015
+ class EncryptedKeyed {
1016
+ static __wrap(ptr) {
1017
+ const obj = Object.create(EncryptedKeyed.prototype);
1018
+ obj.__wbg_ptr = ptr;
1019
+ EncryptedKeyedFinalization.register(obj, obj.__wbg_ptr, obj);
1020
+ return obj;
1021
+ }
1022
+ __destroy_into_raw() {
1023
+ const ptr = this.__wbg_ptr;
1024
+ this.__wbg_ptr = 0;
1025
+ EncryptedKeyedFinalization.unregister(this);
1026
+ return ptr;
1027
+ }
1028
+ free() {
1029
+ const ptr = this.__destroy_into_raw();
1030
+ wasm.__wbg_encryptedkeyed_free(ptr, 0);
1031
+ }
1028
1032
  /**
1029
1033
  * The 32-byte application secret key used to encrypt this content.
1030
- *
1031
- * Lets the consumer build the external predecessor-secret chain and chain
1032
- * further encryptions onto this blob.
1033
1034
  * @returns {Uint8Array}
1034
1035
  */
1035
1036
  get applicationSecret() {
1036
- const ret = wasm.encryptedcontentwithupdate_applicationSecret(this.__wbg_ptr);
1037
+ const ret = wasm.encryptedkeyed_applicationSecret(this.__wbg_ptr);
1037
1038
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1038
1039
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1039
1040
  return v1;
@@ -1042,19 +1043,19 @@ class EncryptedContentWithUpdate {
1042
1043
  * @returns {Encrypted}
1043
1044
  */
1044
1045
  encrypted_content() {
1045
- const ret = wasm.encryptedcontentwithupdate_encrypted_content(this.__wbg_ptr);
1046
+ const ret = wasm.encryptedkeyed_encrypted_content(this.__wbg_ptr);
1046
1047
  return Encrypted.__wrap(ret);
1047
1048
  }
1048
1049
  /**
1049
1050
  * @returns {SignedCgkaOperation | undefined}
1050
1051
  */
1051
1052
  update_op() {
1052
- const ret = wasm.encryptedcontentwithupdate_update_op(this.__wbg_ptr);
1053
+ const ret = wasm.encryptedkeyed_update_op(this.__wbg_ptr);
1053
1054
  return ret === 0 ? undefined : SignedCgkaOperation.__wrap(ret);
1054
1055
  }
1055
1056
  }
1056
- if (Symbol.dispose) EncryptedContentWithUpdate.prototype[Symbol.dispose] = EncryptedContentWithUpdate.prototype.free;
1057
- exports.EncryptedContentWithUpdate = EncryptedContentWithUpdate;
1057
+ if (Symbol.dispose) EncryptedKeyed.prototype[Symbol.dispose] = EncryptedKeyed.prototype.free;
1058
+ exports.EncryptedKeyed = EncryptedKeyed;
1058
1059
 
1059
1060
  class Event {
1060
1061
  static __wrap(ptr) {
@@ -1513,7 +1514,7 @@ class Keyhive {
1513
1514
  * @param {Membered} membered
1514
1515
  * @param {Access} access
1515
1516
  * @param {Document[]} other_relevant_docs
1516
- * @returns {Promise<AddMemberUpdate>}
1517
+ * @returns {Promise<SignedDelegation>}
1517
1518
  */
1518
1519
  addMember(to_add, membered, access, other_relevant_docs) {
1519
1520
  _assertClass(to_add, Agent);
@@ -1586,8 +1587,7 @@ class Keyhive {
1586
1587
  /**
1587
1588
  * Force a PCS key rotation and return the new leaf secret, serialized as a
1588
1589
  * one-entry `BTreeMap<ShareKey, ShareSecretKey>` (the exact format
1589
- * `importPrekeySecrets` accepts). A sibling instance of this identity can
1590
- * install it to derive the rotated key without re-importing the whole bundle.
1590
+ * `importPrekeySecrets` accepts).
1591
1591
  * @param {Document} doc
1592
1592
  * @returns {Promise<Uint8Array>}
1593
1593
  */
@@ -1597,8 +1597,6 @@ class Keyhive {
1597
1597
  return ret;
1598
1598
  }
1599
1599
  /**
1600
- * Generate a document. Whether it provides forward secrecy is determined by
1601
- * this peer's forward-secrecy policy (chosen at `Keyhive.init`).
1602
1600
  * @param {Peer[]} coparents
1603
1601
  * @param {ChangeId} initial_content_ref_head
1604
1602
  * @param {ChangeId[]} more_initial_content_refs
@@ -1723,7 +1721,6 @@ class Keyhive {
1723
1721
  return ret;
1724
1722
  }
1725
1723
  /**
1726
- * Initialize a peer.
1727
1724
  * @param {Signer} signer
1728
1725
  * @param {CiphertextStore} ciphertext_store
1729
1726
  * @param {Function} event_handler
@@ -1832,17 +1829,14 @@ class Keyhive {
1832
1829
  }
1833
1830
  /**
1834
1831
  * Decrypt content and also return the 32-byte application secret key used.
1835
- *
1836
- * The consumer follows the external predecessor-secret chain from this key
1837
- * with `Encrypted.decryptWithKey`, avoiding further CGKA dives.
1838
1832
  * @param {Document} doc
1839
1833
  * @param {Encrypted} encrypted
1840
- * @returns {Promise<DecryptedWithKey>}
1834
+ * @returns {Promise<DecryptedKeyed>}
1841
1835
  */
1842
- tryDecryptWithKey(doc, encrypted) {
1836
+ tryDecryptKeyed(doc, encrypted) {
1843
1837
  _assertClass(doc, Document);
1844
1838
  _assertClass(encrypted, Encrypted);
1845
- const ret = wasm.keyhive_tryDecryptWithKey(this.__wbg_ptr, doc.__wbg_ptr, encrypted.__wbg_ptr);
1839
+ const ret = wasm.keyhive_tryDecryptKeyed(this.__wbg_ptr, doc.__wbg_ptr, encrypted.__wbg_ptr);
1846
1840
  return ret;
1847
1841
  }
1848
1842
  /**
@@ -1879,6 +1873,25 @@ class Keyhive {
1879
1873
  const ret = wasm.keyhive_tryEncryptArchive(this.__wbg_ptr, doc.__wbg_ptr, content_ref.__wbg_ptr, ptr0, len0, ptr1, len1);
1880
1874
  return ret;
1881
1875
  }
1876
+ /**
1877
+ * Encrypt content and also return the application secret key it was
1878
+ * encrypted under.
1879
+ * @param {Document} doc
1880
+ * @param {ChangeId} content_ref
1881
+ * @param {ChangeId[]} js_pred_refs
1882
+ * @param {Uint8Array} content
1883
+ * @returns {Promise<EncryptedKeyed>}
1884
+ */
1885
+ tryEncryptKeyed(doc, content_ref, js_pred_refs, content) {
1886
+ _assertClass(doc, Document);
1887
+ _assertClass(content_ref, ChangeId);
1888
+ const ptr0 = passArrayJsValueToWasm0(js_pred_refs, wasm.__wbindgen_malloc);
1889
+ const len0 = WASM_VECTOR_LEN;
1890
+ const ptr1 = passArray8ToWasm0(content, wasm.__wbindgen_malloc);
1891
+ const len1 = WASM_VECTOR_LEN;
1892
+ const ret = wasm.keyhive_tryEncryptKeyed(this.__wbg_ptr, doc.__wbg_ptr, content_ref.__wbg_ptr, ptr0, len0, ptr1, len1);
1893
+ return ret;
1894
+ }
1882
1895
  /**
1883
1896
  * @param {Document} doc
1884
1897
  * @returns {Promise<Uint8Array | undefined>}
@@ -2708,13 +2721,7 @@ function symmetricDecrypt(key, blob) {
2708
2721
  exports.symmetricDecrypt = symmetricDecrypt;
2709
2722
 
2710
2723
  /**
2711
- * AEAD-encrypt `plaintext` under a 32-byte `key`.
2712
- *
2713
- * `associated_data` flavors the synthetic nonce (e.g. the document or content
2714
- * id) so identical plaintext under the same key in different contexts produces
2715
- * distinct ciphertext. Returns `nonce(24) || ciphertext` (the ciphertext
2716
- * includes the Poly1305 tag). The nonce is carried in the output, so
2717
- * [`symmetric_decrypt`] does not need the associated data.
2724
+ * Encrypt `plaintext` under a 32-byte `key`, returning `nonce(24) || ciphertext`.
2718
2725
  * @param {Uint8Array} key
2719
2726
  * @param {Uint8Array} plaintext
2720
2727
  * @param {Uint8Array} associated_data
@@ -2799,10 +2806,6 @@ function __wbg_get_imports() {
2799
2806
  const ret = arg0.add(arg1);
2800
2807
  return ret;
2801
2808
  },
2802
- __wbg_addmemberupdate_new: function(arg0) {
2803
- const ret = AddMemberUpdate.__wrap(arg0);
2804
- return ret;
2805
- },
2806
2809
  __wbg_agent_new: function(arg0) {
2807
2810
  const ret = Agent.__wrap(arg0);
2808
2811
  return ret;
@@ -2869,8 +2872,8 @@ function __wbg_get_imports() {
2869
2872
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2870
2873
  }
2871
2874
  },
2872
- __wbg_decryptedwithkey_new: function(arg0) {
2873
- const ret = DecryptedWithKey.__wrap(arg0);
2875
+ __wbg_decryptedkeyed_new: function(arg0) {
2876
+ const ret = DecryptedKeyed.__wrap(arg0);
2874
2877
  return ret;
2875
2878
  },
2876
2879
  __wbg_doccontentrefs_new: function(arg0) {
@@ -2885,6 +2888,10 @@ function __wbg_get_imports() {
2885
2888
  const ret = EncryptedContentWithUpdate.__wrap(arg0);
2886
2889
  return ret;
2887
2890
  },
2891
+ __wbg_encryptedkeyed_new: function(arg0) {
2892
+ const ret = EncryptedKeyed.__wrap(arg0);
2893
+ return ret;
2894
+ },
2888
2895
  __wbg_error_8b62d3db440cf4a8: function(arg0, arg1) {
2889
2896
  let deferred0_0;
2890
2897
  let deferred0_1;
@@ -3220,7 +3227,7 @@ function __wbg_get_imports() {
3220
3227
  }
3221
3228
  },
3222
3229
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
3223
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 712, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3230
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 716, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3224
3231
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h9887d5ab72723f8a);
3225
3232
  return ret;
3226
3233
  },
@@ -3320,9 +3327,6 @@ function wasm_bindgen__convert__closures_____invoke__h58982df154245cbc(arg0, arg
3320
3327
  const AccessFinalization = (typeof FinalizationRegistry === 'undefined')
3321
3328
  ? { register: () => {}, unregister: () => {} }
3322
3329
  : new FinalizationRegistry(ptr => wasm.__wbg_access_free(ptr, 1));
3323
- const AddMemberUpdateFinalization = (typeof FinalizationRegistry === 'undefined')
3324
- ? { register: () => {}, unregister: () => {} }
3325
- : new FinalizationRegistry(ptr => wasm.__wbg_addmemberupdate_free(ptr, 1));
3326
3330
  const AgentFinalization = (typeof FinalizationRegistry === 'undefined')
3327
3331
  ? { register: () => {}, unregister: () => {} }
3328
3332
  : new FinalizationRegistry(ptr => wasm.__wbg_agent_free(ptr, 1));
@@ -3353,9 +3357,9 @@ const CiphertextStoreFinalization = (typeof FinalizationRegistry === 'undefined'
3353
3357
  const ContactCardFinalization = (typeof FinalizationRegistry === 'undefined')
3354
3358
  ? { register: () => {}, unregister: () => {} }
3355
3359
  : new FinalizationRegistry(ptr => wasm.__wbg_contactcard_free(ptr, 1));
3356
- const DecryptedWithKeyFinalization = (typeof FinalizationRegistry === 'undefined')
3360
+ const DecryptedKeyedFinalization = (typeof FinalizationRegistry === 'undefined')
3357
3361
  ? { register: () => {}, unregister: () => {} }
3358
- : new FinalizationRegistry(ptr => wasm.__wbg_decryptedwithkey_free(ptr, 1));
3362
+ : new FinalizationRegistry(ptr => wasm.__wbg_decryptedkeyed_free(ptr, 1));
3359
3363
  const DelegationFinalization = (typeof FinalizationRegistry === 'undefined')
3360
3364
  ? { register: () => {}, unregister: () => {} }
3361
3365
  : new FinalizationRegistry(ptr => wasm.__wbg_delegation_free(ptr, 1));
@@ -3374,6 +3378,9 @@ const EncryptedFinalization = (typeof FinalizationRegistry === 'undefined')
3374
3378
  const EncryptedContentWithUpdateFinalization = (typeof FinalizationRegistry === 'undefined')
3375
3379
  ? { register: () => {}, unregister: () => {} }
3376
3380
  : new FinalizationRegistry(ptr => wasm.__wbg_encryptedcontentwithupdate_free(ptr, 1));
3381
+ const EncryptedKeyedFinalization = (typeof FinalizationRegistry === 'undefined')
3382
+ ? { register: () => {}, unregister: () => {} }
3383
+ : new FinalizationRegistry(ptr => wasm.__wbg_encryptedkeyed_free(ptr, 1));
3377
3384
  const EventFinalization = (typeof FinalizationRegistry === 'undefined')
3378
3385
  ? { register: () => {}, unregister: () => {} }
3379
3386
  : new FinalizationRegistry(ptr => wasm.__wbg_event_free(ptr, 1));
Binary file