π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Stash and unstash
Manav Rathi7373a07a7131
diff --git a/web/packages/accounts/services/srp.ts b/web/packages/accounts/services/srp.tsindex b9286d437b..a6131028c6 100644--- a/web/packages/accounts/services/srp.ts+++ b/web/packages/accounts/services/srp.ts@@ -280,6 +280,40 @@ const SRPSetupAttributes = z.object({export type SRPSetupAttributes = z.infer<typeof SRPSetupAttributes>;+/**+ * Save {@link SRPSetupAttributes} in local storage for later use via+ * {@link unstashAndUseSRPSetupAttributes}.+ *+ * See: [Note: SRP setup attributes]+ */+export const stashSRPSetupAttributes = (+ srpSetupAttributes: SRPSetupAttributes,+) =>+ localStorage.setItem(+ "srpSetupAttributes",+ JSON.stringify(srpSetupAttributes),+ );++/**+ * Retrieve the {@link SRPSetupAttributes}, if any, that were stashed by a+ * previous call to {@link stashSRPSetupAttributes}.+ *+ * - If they are found, then invoke the provided callback ({@link cb}) with the+ * value. If the promise returned by the callback fulfills, then remove the+ * stashed value from local storage.+ *+ * - If they are not found, then the callback is not invoked.+ */+export const unstashAndUseSRPSetupAttributes = async (+ cb: (srpSetupAttributes: SRPSetupAttributes) => Promise<void>,+) => {+ const jsonString = localStorage.getItem("srpSetupAttributes");+ if (!jsonString) return;+ const srpSetupAttributes = SRPSetupAttributes.parse(JSON.parse(jsonString));+ await cb(srpSetupAttributes);+ localStorage.removeItem("srpSetupAttributes");+};+/**** @param loginSubKey The user's SRP password (autogenerated, derived