@metamask-previews/profile-sync-controller 27.1.0-preview-378ea32e1 → 27.1.0-preview-1c2b324fd

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +0 -9
  2. package/dist/controllers/authentication/AuthenticationController.cjs +27 -32
  3. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  4. package/dist/controllers/authentication/AuthenticationController.d.cts +1 -1
  5. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
  6. package/dist/controllers/authentication/AuthenticationController.d.mts +1 -1
  7. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
  8. package/dist/controllers/authentication/AuthenticationController.mjs +27 -32
  9. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  10. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +1 -1
  11. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
  12. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts +1 -1
  13. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
  14. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +1 -1
  15. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
  16. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +1 -1
  17. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
  18. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +9 -6
  19. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  20. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +1 -1
  21. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  22. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +1 -1
  23. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  24. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +9 -6
  25. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  26. package/dist/sdk/authentication.cjs +2 -2
  27. package/dist/sdk/authentication.cjs.map +1 -1
  28. package/dist/sdk/authentication.d.cts +1 -1
  29. package/dist/sdk/authentication.d.cts.map +1 -1
  30. package/dist/sdk/authentication.d.mts +1 -1
  31. package/dist/sdk/authentication.d.mts.map +1 -1
  32. package/dist/sdk/authentication.mjs +2 -2
  33. package/dist/sdk/authentication.mjs.map +1 -1
  34. package/dist/sdk/mocks/auth.cjs +1 -1
  35. package/dist/sdk/mocks/auth.cjs.map +1 -1
  36. package/dist/sdk/mocks/auth.d.cts +1 -1
  37. package/dist/sdk/mocks/auth.d.cts.map +1 -1
  38. package/dist/sdk/mocks/auth.d.mts +1 -1
  39. package/dist/sdk/mocks/auth.d.mts.map +1 -1
  40. package/dist/sdk/mocks/auth.mjs +1 -1
  41. package/dist/sdk/mocks/auth.mjs.map +1 -1
  42. package/dist/sdk/utils/validate-login-response.cjs +3 -30
  43. package/dist/sdk/utils/validate-login-response.cjs.map +1 -1
  44. package/dist/sdk/utils/validate-login-response.d.cts +3 -7
  45. package/dist/sdk/utils/validate-login-response.d.cts.map +1 -1
  46. package/dist/sdk/utils/validate-login-response.d.mts +3 -7
  47. package/dist/sdk/utils/validate-login-response.d.mts.map +1 -1
  48. package/dist/sdk/utils/validate-login-response.mjs +3 -30
  49. package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
  50. package/package.json +1 -1
@@ -2,15 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateLoginResponse = void 0;
4
4
  /**
5
- * Validates that the input is a well-formed, non-expired LoginResponse.
6
- *
7
- * Checks structural shape (token + profile objects exist) and verifies
8
- * the JWT access token's `exp` claim is still in the future. This acts
9
- * as a hard guard against stale cached tokens regardless of client-side
10
- * TTL tracking (obtainedAt / expiresIn), which can be corrupted.
5
+ * Validates Shape is LoginResponse
6
+ * NOTE - validation is pretty loose, we can improve this by using external libs like Zod for improved/tighter validation
11
7
  *
12
8
  * @param input - unknown/untyped input
13
- * @returns boolean if input is a valid, non-expired LoginResponse
9
+ * @returns boolean if input is LoginResponse
14
10
  */
15
11
  function validateLoginResponse(input) {
16
12
  const assumedInput = input;
@@ -20,30 +16,7 @@ function validateLoginResponse(input) {
20
16
  if (!assumedInput?.token || !assumedInput?.profile) {
21
17
  return false;
22
18
  }
23
- if (isJwtExpired(assumedInput.token.accessToken)) {
24
- return false;
25
- }
26
19
  return true;
27
20
  }
28
21
  exports.validateLoginResponse = validateLoginResponse;
29
- /**
30
- * Checks whether a JWT has expired by decoding its `exp` claim.
31
- *
32
- * @param token - A JWT string.
33
- * @returns true if the token is expired or cannot be decoded; false if still valid.
34
- */
35
- function isJwtExpired(token) {
36
- try {
37
- const parts = token.split('.');
38
- if (parts.length !== 3) {
39
- return true;
40
- }
41
- const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');
42
- const { exp } = JSON.parse(atob(base64));
43
- return typeof exp !== 'number' || exp * 1000 <= Date.now();
44
- }
45
- catch {
46
- return true;
47
- }
48
- }
49
22
  //# sourceMappingURL=validate-login-response.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-login-response.cjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,SAAgB,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAhBD,sDAgBC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication';\n\n/**\n * Validates that the input is a well-formed, non-expired LoginResponse.\n *\n * Checks structural shape (token + profile objects exist) and verifies\n * the JWT access token's `exp` claim is still in the future. This acts\n * as a hard guard against stale cached tokens regardless of client-side\n * TTL tracking (obtainedAt / expiresIn), which can be corrupted.\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is a valid, non-expired LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n if (isJwtExpired(assumedInput.token.accessToken)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks whether a JWT has expired by decoding its `exp` claim.\n *\n * @param token - A JWT string.\n * @returns true if the token is expired or cannot be decoded; false if still valid.\n */\nfunction isJwtExpired(token: string): boolean {\n try {\n const parts = token.split('.');\n if (parts.length !== 3) {\n return true;\n }\n const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');\n const { exp } = JSON.parse(atob(base64));\n return typeof exp !== 'number' || exp * 1000 <= Date.now();\n } catch {\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"validate-login-response.cjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAZD,sDAYC","sourcesContent":["import type { LoginResponse } from '../authentication';\n\n/**\n * Validates Shape is LoginResponse\n * NOTE - validation is pretty loose, we can improve this by using external libs like Zod for improved/tighter validation\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n return true;\n}\n"]}
@@ -1,14 +1,10 @@
1
1
  import type { LoginResponse } from "../authentication.cjs";
2
2
  /**
3
- * Validates that the input is a well-formed, non-expired LoginResponse.
4
- *
5
- * Checks structural shape (token + profile objects exist) and verifies
6
- * the JWT access token's `exp` claim is still in the future. This acts
7
- * as a hard guard against stale cached tokens regardless of client-side
8
- * TTL tracking (obtainedAt / expiresIn), which can be corrupted.
3
+ * Validates Shape is LoginResponse
4
+ * NOTE - validation is pretty loose, we can improve this by using external libs like Zod for improved/tighter validation
9
5
  *
10
6
  * @param input - unknown/untyped input
11
- * @returns boolean if input is a valid, non-expired LoginResponse
7
+ * @returns boolean if input is LoginResponse
12
8
  */
13
9
  export declare function validateLoginResponse(input: unknown): input is LoginResponse;
14
10
  //# sourceMappingURL=validate-login-response.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-login-response.d.cts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA0B;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAgB5E"}
1
+ {"version":3,"file":"validate-login-response.d.cts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA0B;AAEvD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAY5E"}
@@ -1,14 +1,10 @@
1
1
  import type { LoginResponse } from "../authentication.mjs";
2
2
  /**
3
- * Validates that the input is a well-formed, non-expired LoginResponse.
4
- *
5
- * Checks structural shape (token + profile objects exist) and verifies
6
- * the JWT access token's `exp` claim is still in the future. This acts
7
- * as a hard guard against stale cached tokens regardless of client-side
8
- * TTL tracking (obtainedAt / expiresIn), which can be corrupted.
3
+ * Validates Shape is LoginResponse
4
+ * NOTE - validation is pretty loose, we can improve this by using external libs like Zod for improved/tighter validation
9
5
  *
10
6
  * @param input - unknown/untyped input
11
- * @returns boolean if input is a valid, non-expired LoginResponse
7
+ * @returns boolean if input is LoginResponse
12
8
  */
13
9
  export declare function validateLoginResponse(input: unknown): input is LoginResponse;
14
10
  //# sourceMappingURL=validate-login-response.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-login-response.d.mts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA0B;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAgB5E"}
1
+ {"version":3,"file":"validate-login-response.d.mts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA0B;AAEvD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAY5E"}
@@ -1,13 +1,9 @@
1
1
  /**
2
- * Validates that the input is a well-formed, non-expired LoginResponse.
3
- *
4
- * Checks structural shape (token + profile objects exist) and verifies
5
- * the JWT access token's `exp` claim is still in the future. This acts
6
- * as a hard guard against stale cached tokens regardless of client-side
7
- * TTL tracking (obtainedAt / expiresIn), which can be corrupted.
2
+ * Validates Shape is LoginResponse
3
+ * NOTE - validation is pretty loose, we can improve this by using external libs like Zod for improved/tighter validation
8
4
  *
9
5
  * @param input - unknown/untyped input
10
- * @returns boolean if input is a valid, non-expired LoginResponse
6
+ * @returns boolean if input is LoginResponse
11
7
  */
12
8
  export function validateLoginResponse(input) {
13
9
  const assumedInput = input;
@@ -17,29 +13,6 @@ export function validateLoginResponse(input) {
17
13
  if (!assumedInput?.token || !assumedInput?.profile) {
18
14
  return false;
19
15
  }
20
- if (isJwtExpired(assumedInput.token.accessToken)) {
21
- return false;
22
- }
23
16
  return true;
24
17
  }
25
- /**
26
- * Checks whether a JWT has expired by decoding its `exp` claim.
27
- *
28
- * @param token - A JWT string.
29
- * @returns true if the token is expired or cannot be decoded; false if still valid.
30
- */
31
- function isJwtExpired(token) {
32
- try {
33
- const parts = token.split('.');
34
- if (parts.length !== 3) {
35
- return true;
36
- }
37
- const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');
38
- const { exp } = JSON.parse(atob(base64));
39
- return typeof exp !== 'number' || exp * 1000 <= Date.now();
40
- }
41
- catch {
42
- return true;
43
- }
44
- }
45
18
  //# sourceMappingURL=validate-login-response.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-login-response.mjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication';\n\n/**\n * Validates that the input is a well-formed, non-expired LoginResponse.\n *\n * Checks structural shape (token + profile objects exist) and verifies\n * the JWT access token's `exp` claim is still in the future. This acts\n * as a hard guard against stale cached tokens regardless of client-side\n * TTL tracking (obtainedAt / expiresIn), which can be corrupted.\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is a valid, non-expired LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n if (isJwtExpired(assumedInput.token.accessToken)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks whether a JWT has expired by decoding its `exp` claim.\n *\n * @param token - A JWT string.\n * @returns true if the token is expired or cannot be decoded; false if still valid.\n */\nfunction isJwtExpired(token: string): boolean {\n try {\n const parts = token.split('.');\n if (parts.length !== 3) {\n return true;\n }\n const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');\n const { exp } = JSON.parse(atob(base64));\n return typeof exp !== 'number' || exp * 1000 <= Date.now();\n } catch {\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"validate-login-response.mjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication';\n\n/**\n * Validates Shape is LoginResponse\n * NOTE - validation is pretty loose, we can improve this by using external libs like Zod for improved/tighter validation\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n return true;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/profile-sync-controller",
3
- "version": "27.1.0-preview-378ea32e1",
3
+ "version": "27.1.0-preview-1c2b324fd",
4
4
  "description": "The profile sync helps developers synchronize data across multiple clients and devices in a privacy-preserving way. All data saved in the user storage database is encrypted client-side to preserve privacy. The user storage provides a modular design, giving developers the flexibility to construct and manage their storage spaces in a way that best suits their needs",
5
5
  "keywords": [
6
6
  "MetaMask",