@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.
@@ -45,36 +45,6 @@ export class Access {
45
45
  }
46
46
  if (Symbol.dispose) Access.prototype[Symbol.dispose] = Access.prototype.free;
47
47
 
48
- /**
49
- * The result of adding a member: the membership delegation.
50
- */
51
- export class AddMemberUpdate {
52
- static __wrap(ptr) {
53
- const obj = Object.create(AddMemberUpdate.prototype);
54
- obj.__wbg_ptr = ptr;
55
- AddMemberUpdateFinalization.register(obj, obj.__wbg_ptr, obj);
56
- return obj;
57
- }
58
- __destroy_into_raw() {
59
- const ptr = this.__wbg_ptr;
60
- this.__wbg_ptr = 0;
61
- AddMemberUpdateFinalization.unregister(this);
62
- return ptr;
63
- }
64
- free() {
65
- const ptr = this.__destroy_into_raw();
66
- wasm.__wbg_addmemberupdate_free(ptr, 0);
67
- }
68
- /**
69
- * @returns {SignedDelegation}
70
- */
71
- get delegation() {
72
- const ret = wasm.addmemberupdate_delegation(this.__wbg_ptr);
73
- return SignedDelegation.__wrap(ret);
74
- }
75
- }
76
- if (Symbol.dispose) AddMemberUpdate.prototype[Symbol.dispose] = AddMemberUpdate.prototype.free;
77
-
78
48
  export class Agent {
79
49
  static __wrap(ptr) {
80
50
  const obj = Object.create(Agent.prototype);
@@ -586,33 +556,31 @@ if (Symbol.dispose) ContactCard.prototype[Symbol.dispose] = ContactCard.prototyp
586
556
 
587
557
  /**
588
558
  * Plaintext plus the application secret key that decrypted it.
589
- *
590
- * The key lets the consumer recover the blob's external predecessor-secret
591
- * chain and chain further encryptions onto it, without re-entering CGKA.
592
559
  */
593
- export class DecryptedWithKey {
560
+ export class DecryptedKeyed {
594
561
  static __wrap(ptr) {
595
- const obj = Object.create(DecryptedWithKey.prototype);
562
+ const obj = Object.create(DecryptedKeyed.prototype);
596
563
  obj.__wbg_ptr = ptr;
597
- DecryptedWithKeyFinalization.register(obj, obj.__wbg_ptr, obj);
564
+ DecryptedKeyedFinalization.register(obj, obj.__wbg_ptr, obj);
598
565
  return obj;
599
566
  }
600
567
  __destroy_into_raw() {
601
568
  const ptr = this.__wbg_ptr;
602
569
  this.__wbg_ptr = 0;
603
- DecryptedWithKeyFinalization.unregister(this);
570
+ DecryptedKeyedFinalization.unregister(this);
604
571
  return ptr;
605
572
  }
606
573
  free() {
607
574
  const ptr = this.__destroy_into_raw();
608
- wasm.__wbg_decryptedwithkey_free(ptr, 0);
575
+ wasm.__wbg_decryptedkeyed_free(ptr, 0);
609
576
  }
610
577
  /**
611
578
  * The 32-byte application secret key used to decrypt this content.
579
+ * Treat as secret: do not log or persist unencrypted.
612
580
  * @returns {Uint8Array}
613
581
  */
614
582
  get applicationSecret() {
615
- const ret = wasm.decryptedwithkey_applicationSecret(this.__wbg_ptr);
583
+ const ret = wasm.decryptedkeyed_applicationSecret(this.__wbg_ptr);
616
584
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
617
585
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
618
586
  return v1;
@@ -621,13 +589,13 @@ export class DecryptedWithKey {
621
589
  * @returns {Uint8Array}
622
590
  */
623
591
  get plaintext() {
624
- const ret = wasm.decryptedwithkey_plaintext(this.__wbg_ptr);
592
+ const ret = wasm.decryptedkeyed_plaintext(this.__wbg_ptr);
625
593
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
626
594
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
627
595
  return v1;
628
596
  }
629
597
  }
630
- if (Symbol.dispose) DecryptedWithKey.prototype[Symbol.dispose] = DecryptedWithKey.prototype.free;
598
+ if (Symbol.dispose) DecryptedKeyed.prototype[Symbol.dispose] = DecryptedKeyed.prototype.free;
631
599
 
632
600
  export class Delegation {
633
601
  static __wrap(ptr) {
@@ -910,8 +878,7 @@ export class Encrypted {
910
878
  }
911
879
  /**
912
880
  * Decrypt this content with an explicit 32-byte application secret key,
913
- * bypassing CGKA. The consumer uses this to follow the external
914
- * predecessor-secret chain once it has recovered a blob's key.
881
+ * bypassing CGKA.
915
882
  * @param {Uint8Array} key
916
883
  * @returns {Uint8Array}
917
884
  */
@@ -1007,15 +974,49 @@ export class EncryptedContentWithUpdate {
1007
974
  const ptr = this.__destroy_into_raw();
1008
975
  wasm.__wbg_encryptedcontentwithupdate_free(ptr, 0);
1009
976
  }
977
+ /**
978
+ * @returns {Encrypted}
979
+ */
980
+ encrypted_content() {
981
+ const ret = wasm.encryptedcontentwithupdate_encrypted_content(this.__wbg_ptr);
982
+ return Encrypted.__wrap(ret);
983
+ }
984
+ /**
985
+ * @returns {SignedCgkaOperation | undefined}
986
+ */
987
+ update_op() {
988
+ const ret = wasm.encryptedcontentwithupdate_update_op(this.__wbg_ptr);
989
+ return ret === 0 ? undefined : SignedCgkaOperation.__wrap(ret);
990
+ }
991
+ }
992
+ if (Symbol.dispose) EncryptedContentWithUpdate.prototype[Symbol.dispose] = EncryptedContentWithUpdate.prototype.free;
993
+
994
+ /**
995
+ * Encrypted content plus the application secret key it was encrypted under.
996
+ */
997
+ export class EncryptedKeyed {
998
+ static __wrap(ptr) {
999
+ const obj = Object.create(EncryptedKeyed.prototype);
1000
+ obj.__wbg_ptr = ptr;
1001
+ EncryptedKeyedFinalization.register(obj, obj.__wbg_ptr, obj);
1002
+ return obj;
1003
+ }
1004
+ __destroy_into_raw() {
1005
+ const ptr = this.__wbg_ptr;
1006
+ this.__wbg_ptr = 0;
1007
+ EncryptedKeyedFinalization.unregister(this);
1008
+ return ptr;
1009
+ }
1010
+ free() {
1011
+ const ptr = this.__destroy_into_raw();
1012
+ wasm.__wbg_encryptedkeyed_free(ptr, 0);
1013
+ }
1010
1014
  /**
1011
1015
  * The 32-byte application secret key used to encrypt this content.
1012
- *
1013
- * Lets the consumer build the external predecessor-secret chain and chain
1014
- * further encryptions onto this blob.
1015
1016
  * @returns {Uint8Array}
1016
1017
  */
1017
1018
  get applicationSecret() {
1018
- const ret = wasm.encryptedcontentwithupdate_applicationSecret(this.__wbg_ptr);
1019
+ const ret = wasm.encryptedkeyed_applicationSecret(this.__wbg_ptr);
1019
1020
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1020
1021
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1021
1022
  return v1;
@@ -1024,18 +1025,18 @@ export class EncryptedContentWithUpdate {
1024
1025
  * @returns {Encrypted}
1025
1026
  */
1026
1027
  encrypted_content() {
1027
- const ret = wasm.encryptedcontentwithupdate_encrypted_content(this.__wbg_ptr);
1028
+ const ret = wasm.encryptedkeyed_encrypted_content(this.__wbg_ptr);
1028
1029
  return Encrypted.__wrap(ret);
1029
1030
  }
1030
1031
  /**
1031
1032
  * @returns {SignedCgkaOperation | undefined}
1032
1033
  */
1033
1034
  update_op() {
1034
- const ret = wasm.encryptedcontentwithupdate_update_op(this.__wbg_ptr);
1035
+ const ret = wasm.encryptedkeyed_update_op(this.__wbg_ptr);
1035
1036
  return ret === 0 ? undefined : SignedCgkaOperation.__wrap(ret);
1036
1037
  }
1037
1038
  }
1038
- if (Symbol.dispose) EncryptedContentWithUpdate.prototype[Symbol.dispose] = EncryptedContentWithUpdate.prototype.free;
1039
+ if (Symbol.dispose) EncryptedKeyed.prototype[Symbol.dispose] = EncryptedKeyed.prototype.free;
1039
1040
 
1040
1041
  export class Event {
1041
1042
  static __wrap(ptr) {
@@ -1485,7 +1486,7 @@ export class Keyhive {
1485
1486
  * @param {Membered} membered
1486
1487
  * @param {Access} access
1487
1488
  * @param {Document[]} other_relevant_docs
1488
- * @returns {Promise<AddMemberUpdate>}
1489
+ * @returns {Promise<SignedDelegation>}
1489
1490
  */
1490
1491
  addMember(to_add, membered, access, other_relevant_docs) {
1491
1492
  _assertClass(to_add, Agent);
@@ -1558,8 +1559,7 @@ export class Keyhive {
1558
1559
  /**
1559
1560
  * Force a PCS key rotation and return the new leaf secret, serialized as a
1560
1561
  * one-entry `BTreeMap<ShareKey, ShareSecretKey>` (the exact format
1561
- * `importPrekeySecrets` accepts). A sibling instance of this identity can
1562
- * install it to derive the rotated key without re-importing the whole bundle.
1562
+ * `importPrekeySecrets` accepts).
1563
1563
  * @param {Document} doc
1564
1564
  * @returns {Promise<Uint8Array>}
1565
1565
  */
@@ -1569,8 +1569,6 @@ export class Keyhive {
1569
1569
  return ret;
1570
1570
  }
1571
1571
  /**
1572
- * Generate a document. Whether it provides forward secrecy is determined by
1573
- * this peer's forward-secrecy policy (chosen at `Keyhive.init`).
1574
1572
  * @param {Peer[]} coparents
1575
1573
  * @param {ChangeId} initial_content_ref_head
1576
1574
  * @param {ChangeId[]} more_initial_content_refs
@@ -1695,7 +1693,6 @@ export class Keyhive {
1695
1693
  return ret;
1696
1694
  }
1697
1695
  /**
1698
- * Initialize a peer.
1699
1696
  * @param {Signer} signer
1700
1697
  * @param {CiphertextStore} ciphertext_store
1701
1698
  * @param {Function} event_handler
@@ -1804,17 +1801,14 @@ export class Keyhive {
1804
1801
  }
1805
1802
  /**
1806
1803
  * Decrypt content and also return the 32-byte application secret key used.
1807
- *
1808
- * The consumer follows the external predecessor-secret chain from this key
1809
- * with `Encrypted.decryptWithKey`, avoiding further CGKA dives.
1810
1804
  * @param {Document} doc
1811
1805
  * @param {Encrypted} encrypted
1812
- * @returns {Promise<DecryptedWithKey>}
1806
+ * @returns {Promise<DecryptedKeyed>}
1813
1807
  */
1814
- tryDecryptWithKey(doc, encrypted) {
1808
+ tryDecryptKeyed(doc, encrypted) {
1815
1809
  _assertClass(doc, Document);
1816
1810
  _assertClass(encrypted, Encrypted);
1817
- const ret = wasm.keyhive_tryDecryptWithKey(this.__wbg_ptr, doc.__wbg_ptr, encrypted.__wbg_ptr);
1811
+ const ret = wasm.keyhive_tryDecryptKeyed(this.__wbg_ptr, doc.__wbg_ptr, encrypted.__wbg_ptr);
1818
1812
  return ret;
1819
1813
  }
1820
1814
  /**
@@ -1851,6 +1845,25 @@ export class Keyhive {
1851
1845
  const ret = wasm.keyhive_tryEncryptArchive(this.__wbg_ptr, doc.__wbg_ptr, content_ref.__wbg_ptr, ptr0, len0, ptr1, len1);
1852
1846
  return ret;
1853
1847
  }
1848
+ /**
1849
+ * Encrypt content and also return the application secret key it was
1850
+ * encrypted under.
1851
+ * @param {Document} doc
1852
+ * @param {ChangeId} content_ref
1853
+ * @param {ChangeId[]} js_pred_refs
1854
+ * @param {Uint8Array} content
1855
+ * @returns {Promise<EncryptedKeyed>}
1856
+ */
1857
+ tryEncryptKeyed(doc, content_ref, js_pred_refs, content) {
1858
+ _assertClass(doc, Document);
1859
+ _assertClass(content_ref, ChangeId);
1860
+ const ptr0 = passArrayJsValueToWasm0(js_pred_refs, wasm.__wbindgen_malloc);
1861
+ const len0 = WASM_VECTOR_LEN;
1862
+ const ptr1 = passArray8ToWasm0(content, wasm.__wbindgen_malloc);
1863
+ const len1 = WASM_VECTOR_LEN;
1864
+ const ret = wasm.keyhive_tryEncryptKeyed(this.__wbg_ptr, doc.__wbg_ptr, content_ref.__wbg_ptr, ptr0, len0, ptr1, len1);
1865
+ return ret;
1866
+ }
1854
1867
  /**
1855
1868
  * @param {Document} doc
1856
1869
  * @returns {Promise<Uint8Array | undefined>}
@@ -2664,13 +2677,7 @@ export function symmetricDecrypt(key, blob) {
2664
2677
  }
2665
2678
 
2666
2679
  /**
2667
- * AEAD-encrypt `plaintext` under a 32-byte `key`.
2668
- *
2669
- * `associated_data` flavors the synthetic nonce (e.g. the document or content
2670
- * id) so identical plaintext under the same key in different contexts produces
2671
- * distinct ciphertext. Returns `nonce(24) || ciphertext` (the ciphertext
2672
- * includes the Poly1305 tag). The nonce is carried in the output, so
2673
- * [`symmetric_decrypt`] does not need the associated data.
2680
+ * Encrypt `plaintext` under a 32-byte `key`, returning `nonce(24) || ciphertext`.
2674
2681
  * @param {Uint8Array} key
2675
2682
  * @param {Uint8Array} plaintext
2676
2683
  * @param {Uint8Array} associated_data
@@ -2754,10 +2761,6 @@ function __wbg_get_imports() {
2754
2761
  const ret = arg0.add(arg1);
2755
2762
  return ret;
2756
2763
  },
2757
- __wbg_addmemberupdate_new: function(arg0) {
2758
- const ret = AddMemberUpdate.__wrap(arg0);
2759
- return ret;
2760
- },
2761
2764
  __wbg_agent_new: function(arg0) {
2762
2765
  const ret = Agent.__wrap(arg0);
2763
2766
  return ret;
@@ -2824,8 +2827,8 @@ function __wbg_get_imports() {
2824
2827
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2825
2828
  }
2826
2829
  },
2827
- __wbg_decryptedwithkey_new: function(arg0) {
2828
- const ret = DecryptedWithKey.__wrap(arg0);
2830
+ __wbg_decryptedkeyed_new: function(arg0) {
2831
+ const ret = DecryptedKeyed.__wrap(arg0);
2829
2832
  return ret;
2830
2833
  },
2831
2834
  __wbg_doccontentrefs_new: function(arg0) {
@@ -2840,6 +2843,10 @@ function __wbg_get_imports() {
2840
2843
  const ret = EncryptedContentWithUpdate.__wrap(arg0);
2841
2844
  return ret;
2842
2845
  },
2846
+ __wbg_encryptedkeyed_new: function(arg0) {
2847
+ const ret = EncryptedKeyed.__wrap(arg0);
2848
+ return ret;
2849
+ },
2843
2850
  __wbg_error_8b62d3db440cf4a8: function(arg0, arg1) {
2844
2851
  let deferred0_0;
2845
2852
  let deferred0_1;
@@ -3175,7 +3182,7 @@ function __wbg_get_imports() {
3175
3182
  }
3176
3183
  },
3177
3184
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
3178
- // 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`.
3185
+ // 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`.
3179
3186
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h9887d5ab72723f8a);
3180
3187
  return ret;
3181
3188
  },
@@ -3275,9 +3282,6 @@ function wasm_bindgen__convert__closures_____invoke__h58982df154245cbc(arg0, arg
3275
3282
  const AccessFinalization = (typeof FinalizationRegistry === 'undefined')
3276
3283
  ? { register: () => {}, unregister: () => {} }
3277
3284
  : new FinalizationRegistry(ptr => wasm.__wbg_access_free(ptr, 1));
3278
- const AddMemberUpdateFinalization = (typeof FinalizationRegistry === 'undefined')
3279
- ? { register: () => {}, unregister: () => {} }
3280
- : new FinalizationRegistry(ptr => wasm.__wbg_addmemberupdate_free(ptr, 1));
3281
3285
  const AgentFinalization = (typeof FinalizationRegistry === 'undefined')
3282
3286
  ? { register: () => {}, unregister: () => {} }
3283
3287
  : new FinalizationRegistry(ptr => wasm.__wbg_agent_free(ptr, 1));
@@ -3308,9 +3312,9 @@ const CiphertextStoreFinalization = (typeof FinalizationRegistry === 'undefined'
3308
3312
  const ContactCardFinalization = (typeof FinalizationRegistry === 'undefined')
3309
3313
  ? { register: () => {}, unregister: () => {} }
3310
3314
  : new FinalizationRegistry(ptr => wasm.__wbg_contactcard_free(ptr, 1));
3311
- const DecryptedWithKeyFinalization = (typeof FinalizationRegistry === 'undefined')
3315
+ const DecryptedKeyedFinalization = (typeof FinalizationRegistry === 'undefined')
3312
3316
  ? { register: () => {}, unregister: () => {} }
3313
- : new FinalizationRegistry(ptr => wasm.__wbg_decryptedwithkey_free(ptr, 1));
3317
+ : new FinalizationRegistry(ptr => wasm.__wbg_decryptedkeyed_free(ptr, 1));
3314
3318
  const DelegationFinalization = (typeof FinalizationRegistry === 'undefined')
3315
3319
  ? { register: () => {}, unregister: () => {} }
3316
3320
  : new FinalizationRegistry(ptr => wasm.__wbg_delegation_free(ptr, 1));
@@ -3329,6 +3333,9 @@ const EncryptedFinalization = (typeof FinalizationRegistry === 'undefined')
3329
3333
  const EncryptedContentWithUpdateFinalization = (typeof FinalizationRegistry === 'undefined')
3330
3334
  ? { register: () => {}, unregister: () => {} }
3331
3335
  : new FinalizationRegistry(ptr => wasm.__wbg_encryptedcontentwithupdate_free(ptr, 1));
3336
+ const EncryptedKeyedFinalization = (typeof FinalizationRegistry === 'undefined')
3337
+ ? { register: () => {}, unregister: () => {} }
3338
+ : new FinalizationRegistry(ptr => wasm.__wbg_encryptedkeyed_free(ptr, 1));
3332
3339
  const EventFinalization = (typeof FinalizationRegistry === 'undefined')
3333
3340
  ? { register: () => {}, unregister: () => {} }
3334
3341
  : new FinalizationRegistry(ptr => wasm.__wbg_event_free(ptr, 1));
Binary file