π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move
Manav Rathi43ae1de2b537
diff --git a/web/packages/accounts/services/srp.ts b/web/packages/accounts/services/srp.tsindex a6131028c6..f93ece600b 100644--- a/web/packages/accounts/services/srp.ts+++ b/web/packages/accounts/services/srp.ts@@ -280,40 +280,6 @@ 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@@ -349,6 +315,40 @@ export const generateSRPSetupAttributes = async (return result;};+/**+ * 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");+};+interface SetupSRPRequest {srpUserID: string;srpSalt: string;