@calimero-network/mero-react 10.0.0 → 10.0.1

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.
package/dist/index.d.cts CHANGED
@@ -1010,11 +1010,13 @@ declare function useJoinInvitation(): {
1010
1010
  * Cloud tab and `ConnectButtonAccount` share one copy of it: the device keys,
1011
1011
  * the redirect to the wallet, and the completion when the tab comes back.
1012
1012
  *
1013
- * - `goToWallet` generates (or reuses) this tab's device keys, remembers a state
1014
- * parameter, and leaves for the wallet.
1015
- * - On the way back, the callback is read ONCE during render, the state is
1016
- * checked against the one sent, the certificate is completed and saved, the
1017
- * account's relays are looked up, and `connectWithAccount` connects.
1013
+ * - `goToWallet` generates (or reuses) this tab's device keys and leaves for the
1014
+ * wallet. mero-js's `deviceEnrolmentUrl` remembers the request under a fresh
1015
+ * state.
1016
+ * - On the way back, the callback is read ONCE during render, the certificate
1017
+ * is completed and saved (`completeDeviceEnrolment` refuses an answer to a
1018
+ * request this browser did not start, and spends its state), the account's
1019
+ * relays are looked up, and `connectWithAccount` connects.
1018
1020
  * - `note` is what the person should be told about that — an error, or a
1019
1021
  * connection with nowhere to write yet.
1020
1022
  * - `returning` is true when this page load carries an enrolment callback,
package/dist/index.d.ts CHANGED
@@ -1010,11 +1010,13 @@ declare function useJoinInvitation(): {
1010
1010
  * Cloud tab and `ConnectButtonAccount` share one copy of it: the device keys,
1011
1011
  * the redirect to the wallet, and the completion when the tab comes back.
1012
1012
  *
1013
- * - `goToWallet` generates (or reuses) this tab's device keys, remembers a state
1014
- * parameter, and leaves for the wallet.
1015
- * - On the way back, the callback is read ONCE during render, the state is
1016
- * checked against the one sent, the certificate is completed and saved, the
1017
- * account's relays are looked up, and `connectWithAccount` connects.
1013
+ * - `goToWallet` generates (or reuses) this tab's device keys and leaves for the
1014
+ * wallet. mero-js's `deviceEnrolmentUrl` remembers the request under a fresh
1015
+ * state.
1016
+ * - On the way back, the callback is read ONCE during render, the certificate
1017
+ * is completed and saved (`completeDeviceEnrolment` refuses an answer to a
1018
+ * request this browser did not start, and spends its state), the account's
1019
+ * relays are looked up, and `connectWithAccount` connects.
1018
1020
  * - `note` is what the person should be told about that — an error, or a
1019
1021
  * connection with nowhere to write yet.
1020
1022
  * - `returning` is true when this page load carries an enrolment callback,
package/dist/index.js CHANGED
@@ -855,7 +855,6 @@ function AccountSignInPanel({
855
855
  );
856
856
  }
857
857
  var DEVICE_KEY = "calimero.device";
858
- var STATE_KEY = "calimero.enrol.state";
859
858
  var HOSTED_WALLET = "https://wallet.cloud.calimero.network/account-enroll";
860
859
  var hex = (b) => [...new Uint8Array(b)].map((x) => x.toString(16).padStart(2, "0")).join("");
861
860
  function executorOf(relay) {
@@ -961,28 +960,10 @@ function useAccountEnrolment({
961
960
  (async () => {
962
961
  try {
963
962
  const keys = await deviceKeys();
964
- const sent = (() => {
965
- try {
966
- return sessionStorage.getItem(STATE_KEY);
967
- } catch {
968
- return null;
969
- }
970
- })();
971
- try {
972
- sessionStorage.removeItem(STATE_KEY);
973
- } catch {
974
- }
975
- if (!sent) {
976
- setNote(
977
- 'This enrolment could not be verified as one this tab started, so it was not accepted. Start again from "Enrol with your account".'
978
- );
979
- return;
980
- }
981
963
  const enrolled = await completeDeviceEnrolment({
982
964
  ...back,
983
965
  devicePublicKey: keys.signPk,
984
- kemPublicKey: keys.kemPk,
985
- expectState: sent
966
+ kemPublicKey: keys.kemPk
986
967
  });
987
968
  saveDelegatedCredential({
988
969
  account: enrolled.account,
@@ -1021,18 +1002,12 @@ function useAccountEnrolment({
1021
1002
  setNote(e instanceof Error ? e.message : String(e));
1022
1003
  return;
1023
1004
  }
1024
- const state = hex(crypto.getRandomValues(new Uint8Array(16)));
1025
- try {
1026
- sessionStorage.setItem(STATE_KEY, state);
1027
- } catch {
1028
- }
1029
1005
  window.location.assign(
1030
1006
  deviceEnrolmentUrl({
1031
1007
  walletUrl,
1032
1008
  devicePublicKey: keys.signPk,
1033
1009
  kemPublicKey: keys.kemPk,
1034
- returnTo: window.location.origin + window.location.pathname,
1035
- state
1010
+ returnTo: window.location.origin + window.location.pathname
1036
1011
  })
1037
1012
  );
1038
1013
  }, [walletUrl]);