@metamask/profile-sync-controller 0.1.1 → 0.1.2

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 (33) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/{chunk-ELHJSRS2.js → chunk-5C53GKTU.js} +12 -4
  3. package/dist/chunk-5C53GKTU.js.map +1 -0
  4. package/dist/{chunk-KBCXN3YW.mjs → chunk-7SW3CC66.mjs} +12 -4
  5. package/dist/chunk-7SW3CC66.mjs.map +1 -0
  6. package/dist/{chunk-RX5R6BUI.js → chunk-FRVMGTOY.js} +8 -8
  7. package/dist/{chunk-YUXN5GSW.js → chunk-GWBBZZVV.js} +13 -7
  8. package/dist/chunk-GWBBZZVV.js.map +1 -0
  9. package/dist/{chunk-AARMY5TW.mjs → chunk-KKB3U6KO.mjs} +3 -3
  10. package/dist/{chunk-32HAX3MW.mjs → chunk-QU3RCIV3.mjs} +10 -4
  11. package/dist/chunk-QU3RCIV3.mjs.map +1 -0
  12. package/dist/controllers/authentication/AuthenticationController.js +3 -3
  13. package/dist/controllers/authentication/AuthenticationController.mjs +2 -2
  14. package/dist/controllers/authentication/index.js +4 -4
  15. package/dist/controllers/authentication/index.mjs +3 -3
  16. package/dist/controllers/authentication/services.js +2 -2
  17. package/dist/controllers/authentication/services.mjs +1 -1
  18. package/dist/controllers/index.js +4 -4
  19. package/dist/controllers/index.mjs +3 -3
  20. package/dist/index.js +4 -4
  21. package/dist/index.mjs +3 -3
  22. package/dist/tsconfig.build.tsbuildinfo +1 -1
  23. package/dist/types/controllers/authentication/AuthenticationController.d.ts +1 -1
  24. package/dist/types/controllers/authentication/AuthenticationController.d.ts.map +1 -1
  25. package/dist/types/controllers/authentication/services.d.ts +2 -1
  26. package/dist/types/controllers/authentication/services.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/chunk-32HAX3MW.mjs.map +0 -1
  29. package/dist/chunk-ELHJSRS2.js.map +0 -1
  30. package/dist/chunk-KBCXN3YW.mjs.map +0 -1
  31. package/dist/chunk-YUXN5GSW.js.map +0 -1
  32. /package/dist/{chunk-RX5R6BUI.js.map → chunk-FRVMGTOY.js.map} +0 -0
  33. /package/dist/{chunk-AARMY5TW.mjs.map → chunk-KKB3U6KO.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.2]
11
+
12
+ ### Added
13
+
14
+ - added platform field when logging in to receive correct OIDC access token ([#4480](https://github.com/MetaMask/core/pull/4480))
15
+ - added metametrics validation in constructor ([#4480](https://github.com/MetaMask/core/pull/4480))
16
+
17
+ ### Changed
18
+
19
+ - updated the `getMetaMetricsId` interface to support async calls to metametrics ID ([#4477](https://github.com/MetaMask/core/pull/4477))
20
+
10
21
  ## [0.1.1]
11
22
 
12
23
  ### Added
@@ -23,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
34
 
24
35
  - Initial release
25
36
 
26
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.1.1...HEAD
37
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.1.2...HEAD
38
+ [0.1.2]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.1.1...@metamask/profile-sync-controller@0.1.2
27
39
  [0.1.1]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.1.0...@metamask/profile-sync-controller@0.1.1
28
40
  [0.1.0]: https://github.com/MetaMask/core/releases/tag/@metamask/profile-sync-controller@0.1.0
@@ -10,7 +10,15 @@ var AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;
10
10
  var AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;
11
11
  var OIDC_ENDPOINT = ENV_URLS.oidcApiUrl || "";
12
12
  var OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;
13
- var OIDC_CLIENT_ID = _chunkSMKTWM6Ijs.getOidcClientId.call(void 0, "prd" /* PRD */, "extension" /* EXTENSION */);
13
+ var OIDC_CLIENT_ID = (platform) => {
14
+ if (platform === "extension") {
15
+ return _chunkSMKTWM6Ijs.getOidcClientId.call(void 0, "prd" /* PRD */, "extension" /* EXTENSION */);
16
+ }
17
+ if (platform === "mobile") {
18
+ return _chunkSMKTWM6Ijs.getOidcClientId.call(void 0, "prd" /* PRD */, "mobile" /* MOBILE */);
19
+ }
20
+ throw new Error(`Unsupported platform - ${platform}`);
21
+ };
14
22
  var OIDC_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
15
23
  async function getNonce(publicKey) {
16
24
  const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);
@@ -55,13 +63,13 @@ async function login(rawMessage, signature, clientMetaMetrics) {
55
63
  return null;
56
64
  }
57
65
  }
58
- async function getAccessToken(jwtToken) {
66
+ async function getAccessToken(jwtToken, platform) {
59
67
  const headers = new Headers({
60
68
  "Content-Type": "application/x-www-form-urlencoded"
61
69
  });
62
70
  const urlEncodedBody = new URLSearchParams();
63
71
  urlEncodedBody.append("grant_type", OIDC_GRANT_TYPE);
64
- urlEncodedBody.append("client_id", OIDC_CLIENT_ID);
72
+ urlEncodedBody.append("client_id", OIDC_CLIENT_ID(platform));
65
73
  urlEncodedBody.append("assertion", jwtToken);
66
74
  try {
67
75
  const response = await fetch(OIDC_TOKENS_ENDPOINT, {
@@ -95,4 +103,4 @@ function createLoginRawMessage(nonce, publicKey) {
95
103
 
96
104
 
97
105
  exports.AUTH_NONCE_ENDPOINT = AUTH_NONCE_ENDPOINT; exports.AUTH_LOGIN_ENDPOINT = AUTH_LOGIN_ENDPOINT; exports.OIDC_TOKENS_ENDPOINT = OIDC_TOKENS_ENDPOINT; exports.getNonce = getNonce; exports.login = login; exports.getAccessToken = getAccessToken; exports.createLoginRawMessage = createLoginRawMessage;
98
- //# sourceMappingURL=chunk-ELHJSRS2.js.map
106
+ //# sourceMappingURL=chunk-5C53GKTU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/controllers/authentication/services.ts"],"names":[],"mappings":";;;;;;AAEA,IAAM,WAAW,0BAAkB;AAEnC,IAAM,gBAAwB,SAAS;AAChC,IAAM,sBAAsB,GAAG,aAAa;AAC5C,IAAM,sBAAsB,GAAG,aAAa;AAEnD,IAAM,gBAAwB,SAAS,cAAc;AAC9C,IAAM,uBAAuB,GAAG,aAAa;AACpD,IAAM,iBAAiB,CAAC,aAAqC;AAC3D,MAAI,aAAa,aAAa;AAC5B,WAAO,4DAA2C;AAAA,EACpD;AACA,MAAI,aAAa,UAAU;AACzB,WAAO,sDAAwC;AAAA,EACjD;AAEA,QAAM,IAAI,MAAM,0BAA0B,QAAkB,EAAE;AAChE;AACA,IAAM,kBAAkB;AAYxB,eAAsB,SAAS,WAA2C;AACxE,QAAM,WAAW,IAAI,IAAI,mBAAmB;AAC5C,WAAS,aAAa,IAAI,cAAc,SAAS;AAEjD,MAAI;AACF,UAAM,gBAAgB,MAAM,MAAM,SAAS,SAAS,CAAC;AACrD,QAAI,CAAC,cAAc,IAAI;AACrB,aAAO;AAAA,IACT;AAEA,UAAM,YAA2B,MAAM,cAAc,KAAK;AAC1D,WAAO,WAAW,SAAS;AAAA,EAC7B,SAAS,GAAG;AACV,YAAQ,MAAM,2DAA2D,CAAC;AAC1E,WAAO;AAAA,EACT;AACF;AAqCA,eAAsB,MACpB,YACA,WACA,mBAC+B;AAC/B,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,qBAAqB;AAAA,MAChD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB;AAAA;AAAA,QAEA,aAAa;AAAA,QACb,aAAa;AAAA;AAAA,UAEX,gBAAgB,kBAAkB;AAAA,UAClC,OAAO,kBAAkB;AAAA,QAC3B;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,aAAO;AAAA,IACT;AAEA,UAAM,gBAA+B,MAAM,SAAS,KAAK;AACzD,WAAO,iBAAiB;AAAA,EAC1B,SAAS,GAAG;AACV,YAAQ,MAAM,uDAAuD,CAAC;AACtE,WAAO;AAAA,EACT;AACF;AAoBA,eAAsB,eACpB,UACA,UACwB;AACxB,QAAM,UAAU,IAAI,QAAQ;AAAA,IAC1B,gBAAgB;AAAA,EAClB,CAAC;AAED,QAAM,iBAAiB,IAAI,gBAAgB;AAC3C,iBAAe,OAAO,cAAc,eAAe;AACnD,iBAAe,OAAO,aAAa,eAAe,QAAQ,CAAC;AAC3D,iBAAe,OAAO,aAAa,QAAQ;AAE3C,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,sBAAsB;AAAA,MACjD,QAAQ;AAAA,MACR;AAAA,MACA,MAAM,eAAe,SAAS;AAAA,IAChC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,aAAO;AAAA,IACT;AAEA,UAAM,sBAA0C,MAAM,SAAS,KAAK;AACpE,WAAO,qBAAqB,gBAAgB;AAAA,EAC9C,SAAS,GAAG;AACV,YAAQ;AAAA,MACN;AAAA,MACA;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AASO,SAAS,sBACd,OACA,WACgC;AAChC,SAAO,YAAY,KAAK,IAAI,SAAS;AACvC","sourcesContent":["import { Env, Platform, getEnvUrls, getOidcClientId } from '../../sdk';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nconst AUTH_ENDPOINT: string = ENV_URLS.authApiUrl;\nexport const AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;\nexport const AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;\n\nconst OIDC_ENDPOINT: string = ENV_URLS.oidcApiUrl || '';\nexport const OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;\nconst OIDC_CLIENT_ID = (platform: 'mobile' | 'extension') => {\n if (platform === 'extension') {\n return getOidcClientId(Env.PRD, Platform.EXTENSION);\n }\n if (platform === 'mobile') {\n return getOidcClientId(Env.PRD, Platform.MOBILE);\n }\n\n throw new Error(`Unsupported platform - ${platform as string}`);\n};\nconst OIDC_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:jwt-bearer';\n\nexport type NonceResponse = {\n nonce: string;\n};\n\n/**\n * Auth Service - Get Nonce. Used for the initial JWTBearer flow\n *\n * @param publicKey - public key to associate a nonce with\n * @returns the nonce or null if failed\n */\nexport async function getNonce(publicKey: string): Promise<string | null> {\n const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);\n nonceUrl.searchParams.set('identifier', publicKey);\n\n try {\n const nonceResponse = await fetch(nonceUrl.toString());\n if (!nonceResponse.ok) {\n return null;\n }\n\n const nonceJson: NonceResponse = await nonceResponse.json();\n return nonceJson?.nonce ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to get nonce', e);\n return null;\n }\n}\n\n/**\n * The Login API Server Response Shape\n */\nexport type LoginResponse = {\n token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: string;\n /**\n * Contains anonymous information about the logged in profile.\n *\n * @property identifier_id - a deterministic unique identifier on the method used to sign in\n * @property profile_id - a unique id for a given profile\n * @property metametrics_id - an anonymous server id\n */\n profile: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n profile_id: string;\n };\n};\n\ntype ClientMetaMetrics = {\n metametricsId: string;\n agent: 'extension' | 'mobile';\n};\n\n/**\n * Auth Service - Login. Will perform login with a given signature and will return a single use JWT Token.\n *\n * @param rawMessage - the original message before signing\n * @param signature - the signed message\n * @param clientMetaMetrics - optional client metametrics id (to associate on backend)\n * @returns The Login Response\n */\nexport async function login(\n rawMessage: string,\n signature: string,\n clientMetaMetrics: ClientMetaMetrics,\n): Promise<LoginResponse | null> {\n try {\n const response = await fetch(AUTH_LOGIN_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n signature,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: rawMessage,\n metametrics: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n metametrics_id: clientMetaMetrics.metametricsId,\n agent: clientMetaMetrics.agent,\n },\n }),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const loginResponse: LoginResponse = await response.json();\n return loginResponse ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to login', e);\n return null;\n }\n}\n\n/**\n * The Auth API Token Response Shape\n */\nexport type OAuthTokenResponse = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n access_token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: number;\n};\n\n/**\n * OIDC Service - Access Token. Trades the Auth Token for an access token (to be used for other authenticated endpoints)\n * NOTE - the access token is short lived, which means it is best practice to validate session before calling authenticated endpoints\n *\n * @param jwtToken - the JWT Auth Token, received from `/login`\n * @param platform - the OIDC platform to retrieve access token\n * @returns JWT Access token to store and use on authorized endpoints.\n */\nexport async function getAccessToken(\n jwtToken: string,\n platform: ClientMetaMetrics['agent'],\n): Promise<string | null> {\n const headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded',\n });\n\n const urlEncodedBody = new URLSearchParams();\n urlEncodedBody.append('grant_type', OIDC_GRANT_TYPE);\n urlEncodedBody.append('client_id', OIDC_CLIENT_ID(platform));\n urlEncodedBody.append('assertion', jwtToken);\n\n try {\n const response = await fetch(OIDC_TOKENS_ENDPOINT, {\n method: 'POST',\n headers,\n body: urlEncodedBody.toString(),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const accessTokenResponse: OAuthTokenResponse = await response.json();\n return accessTokenResponse?.access_token ?? null;\n } catch (e) {\n console.error(\n 'authentication-controller/services: unable to get access token',\n e,\n );\n return null;\n }\n}\n\n/**\n * Utility to create the raw login message for the JWT bearer flow (via SRP)\n *\n * @param nonce - nonce received from `/nonce` endpoint\n * @param publicKey - public key used to retrieve nonce and for message signing\n * @returns Raw Message which will be used for signing & logging in.\n */\nexport function createLoginRawMessage(\n nonce: string,\n publicKey: string,\n): `metamask:${string}:${string}` {\n return `metamask:${nonce}:${publicKey}` as const;\n}\n"]}
@@ -10,7 +10,15 @@ var AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;
10
10
  var AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;
11
11
  var OIDC_ENDPOINT = ENV_URLS.oidcApiUrl || "";
12
12
  var OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;
13
- var OIDC_CLIENT_ID = getOidcClientId("prd" /* PRD */, "extension" /* EXTENSION */);
13
+ var OIDC_CLIENT_ID = (platform) => {
14
+ if (platform === "extension") {
15
+ return getOidcClientId("prd" /* PRD */, "extension" /* EXTENSION */);
16
+ }
17
+ if (platform === "mobile") {
18
+ return getOidcClientId("prd" /* PRD */, "mobile" /* MOBILE */);
19
+ }
20
+ throw new Error(`Unsupported platform - ${platform}`);
21
+ };
14
22
  var OIDC_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
15
23
  async function getNonce(publicKey) {
16
24
  const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);
@@ -55,13 +63,13 @@ async function login(rawMessage, signature, clientMetaMetrics) {
55
63
  return null;
56
64
  }
57
65
  }
58
- async function getAccessToken(jwtToken) {
66
+ async function getAccessToken(jwtToken, platform) {
59
67
  const headers = new Headers({
60
68
  "Content-Type": "application/x-www-form-urlencoded"
61
69
  });
62
70
  const urlEncodedBody = new URLSearchParams();
63
71
  urlEncodedBody.append("grant_type", OIDC_GRANT_TYPE);
64
- urlEncodedBody.append("client_id", OIDC_CLIENT_ID);
72
+ urlEncodedBody.append("client_id", OIDC_CLIENT_ID(platform));
65
73
  urlEncodedBody.append("assertion", jwtToken);
66
74
  try {
67
75
  const response = await fetch(OIDC_TOKENS_ENDPOINT, {
@@ -95,4 +103,4 @@ export {
95
103
  getAccessToken,
96
104
  createLoginRawMessage
97
105
  };
98
- //# sourceMappingURL=chunk-KBCXN3YW.mjs.map
106
+ //# sourceMappingURL=chunk-7SW3CC66.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/controllers/authentication/services.ts"],"sourcesContent":["import { Env, Platform, getEnvUrls, getOidcClientId } from '../../sdk';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nconst AUTH_ENDPOINT: string = ENV_URLS.authApiUrl;\nexport const AUTH_NONCE_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/nonce`;\nexport const AUTH_LOGIN_ENDPOINT = `${AUTH_ENDPOINT}/api/v2/srp/login`;\n\nconst OIDC_ENDPOINT: string = ENV_URLS.oidcApiUrl || '';\nexport const OIDC_TOKENS_ENDPOINT = `${OIDC_ENDPOINT}/oauth2/token`;\nconst OIDC_CLIENT_ID = (platform: 'mobile' | 'extension') => {\n if (platform === 'extension') {\n return getOidcClientId(Env.PRD, Platform.EXTENSION);\n }\n if (platform === 'mobile') {\n return getOidcClientId(Env.PRD, Platform.MOBILE);\n }\n\n throw new Error(`Unsupported platform - ${platform as string}`);\n};\nconst OIDC_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:jwt-bearer';\n\nexport type NonceResponse = {\n nonce: string;\n};\n\n/**\n * Auth Service - Get Nonce. Used for the initial JWTBearer flow\n *\n * @param publicKey - public key to associate a nonce with\n * @returns the nonce or null if failed\n */\nexport async function getNonce(publicKey: string): Promise<string | null> {\n const nonceUrl = new URL(AUTH_NONCE_ENDPOINT);\n nonceUrl.searchParams.set('identifier', publicKey);\n\n try {\n const nonceResponse = await fetch(nonceUrl.toString());\n if (!nonceResponse.ok) {\n return null;\n }\n\n const nonceJson: NonceResponse = await nonceResponse.json();\n return nonceJson?.nonce ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to get nonce', e);\n return null;\n }\n}\n\n/**\n * The Login API Server Response Shape\n */\nexport type LoginResponse = {\n token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: string;\n /**\n * Contains anonymous information about the logged in profile.\n *\n * @property identifier_id - a deterministic unique identifier on the method used to sign in\n * @property profile_id - a unique id for a given profile\n * @property metametrics_id - an anonymous server id\n */\n profile: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n profile_id: string;\n };\n};\n\ntype ClientMetaMetrics = {\n metametricsId: string;\n agent: 'extension' | 'mobile';\n};\n\n/**\n * Auth Service - Login. Will perform login with a given signature and will return a single use JWT Token.\n *\n * @param rawMessage - the original message before signing\n * @param signature - the signed message\n * @param clientMetaMetrics - optional client metametrics id (to associate on backend)\n * @returns The Login Response\n */\nexport async function login(\n rawMessage: string,\n signature: string,\n clientMetaMetrics: ClientMetaMetrics,\n): Promise<LoginResponse | null> {\n try {\n const response = await fetch(AUTH_LOGIN_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n signature,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: rawMessage,\n metametrics: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n metametrics_id: clientMetaMetrics.metametricsId,\n agent: clientMetaMetrics.agent,\n },\n }),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const loginResponse: LoginResponse = await response.json();\n return loginResponse ?? null;\n } catch (e) {\n console.error('authentication-controller/services: unable to login', e);\n return null;\n }\n}\n\n/**\n * The Auth API Token Response Shape\n */\nexport type OAuthTokenResponse = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n access_token: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n expires_in: number;\n};\n\n/**\n * OIDC Service - Access Token. Trades the Auth Token for an access token (to be used for other authenticated endpoints)\n * NOTE - the access token is short lived, which means it is best practice to validate session before calling authenticated endpoints\n *\n * @param jwtToken - the JWT Auth Token, received from `/login`\n * @param platform - the OIDC platform to retrieve access token\n * @returns JWT Access token to store and use on authorized endpoints.\n */\nexport async function getAccessToken(\n jwtToken: string,\n platform: ClientMetaMetrics['agent'],\n): Promise<string | null> {\n const headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded',\n });\n\n const urlEncodedBody = new URLSearchParams();\n urlEncodedBody.append('grant_type', OIDC_GRANT_TYPE);\n urlEncodedBody.append('client_id', OIDC_CLIENT_ID(platform));\n urlEncodedBody.append('assertion', jwtToken);\n\n try {\n const response = await fetch(OIDC_TOKENS_ENDPOINT, {\n method: 'POST',\n headers,\n body: urlEncodedBody.toString(),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const accessTokenResponse: OAuthTokenResponse = await response.json();\n return accessTokenResponse?.access_token ?? null;\n } catch (e) {\n console.error(\n 'authentication-controller/services: unable to get access token',\n e,\n );\n return null;\n }\n}\n\n/**\n * Utility to create the raw login message for the JWT bearer flow (via SRP)\n *\n * @param nonce - nonce received from `/nonce` endpoint\n * @param publicKey - public key used to retrieve nonce and for message signing\n * @returns Raw Message which will be used for signing & logging in.\n */\nexport function createLoginRawMessage(\n nonce: string,\n publicKey: string,\n): `metamask:${string}:${string}` {\n return `metamask:${nonce}:${publicKey}` as const;\n}\n"],"mappings":";;;;;;AAEA,IAAM,WAAW,0BAAkB;AAEnC,IAAM,gBAAwB,SAAS;AAChC,IAAM,sBAAsB,GAAG,aAAa;AAC5C,IAAM,sBAAsB,GAAG,aAAa;AAEnD,IAAM,gBAAwB,SAAS,cAAc;AAC9C,IAAM,uBAAuB,GAAG,aAAa;AACpD,IAAM,iBAAiB,CAAC,aAAqC;AAC3D,MAAI,aAAa,aAAa;AAC5B,WAAO,4DAA2C;AAAA,EACpD;AACA,MAAI,aAAa,UAAU;AACzB,WAAO,sDAAwC;AAAA,EACjD;AAEA,QAAM,IAAI,MAAM,0BAA0B,QAAkB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sBAAsB;AAAA,MACjD,QAAQ;AAAA,MACR;AAAA,MACA,MAAM,eAAe,SAAS;AAAA,IAChC,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,aAAO;AAAA,IACT;AAEA,UAAM,sBAA0C,MAAM,SAAS,KAAK;AACpE,WAAO,qBAAqB,gBAAgB;AAAA,EAC9C,SAAS,GAAG;AACV,YAAQ;AAAA,MACN;AAAA,MACA;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AASO,SAAS,sBACd,OACA,WACgC;AAChC,SAAO,YAAY,KAAK,IAAI,SAAS;AACvC;","names":[]}
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkYUXN5GSWjs = require('./chunk-YUXN5GSW.js');
4
+ var _chunkGWBBZZVVjs = require('./chunk-GWBBZZVV.js');
5
5
 
6
6
 
7
7
 
8
8
 
9
- var _chunkELHJSRS2js = require('./chunk-ELHJSRS2.js');
9
+ var _chunk5C53GKTUjs = require('./chunk-5C53GKTU.js');
10
10
 
11
11
 
12
12
  var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
@@ -14,9 +14,9 @@ var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
14
14
  // src/controllers/authentication/index.ts
15
15
  var authentication_exports = {};
16
16
  _chunkIGY2S5BCjs.__export.call(void 0, authentication_exports, {
17
- Controller: () => _chunkYUXN5GSWjs.AuthenticationController,
17
+ Controller: () => _chunkGWBBZZVVjs.AuthenticationController,
18
18
  Mocks: () => fixtures_exports,
19
- defaultState: () => _chunkYUXN5GSWjs.defaultState
19
+ defaultState: () => _chunkGWBBZZVVjs.defaultState
20
20
  });
21
21
 
22
22
  // src/controllers/authentication/__fixtures__/index.ts
@@ -40,7 +40,7 @@ var MOCK_NONCE_RESPONSE = {
40
40
  };
41
41
  var getMockAuthNonceResponse = () => {
42
42
  return {
43
- url: _chunkELHJSRS2js.AUTH_NONCE_ENDPOINT,
43
+ url: _chunk5C53GKTUjs.AUTH_NONCE_ENDPOINT,
44
44
  requestMethod: "GET",
45
45
  response: MOCK_NONCE_RESPONSE
46
46
  };
@@ -59,7 +59,7 @@ var MOCK_LOGIN_RESPONSE = {
59
59
  };
60
60
  var getMockAuthLoginResponse = () => {
61
61
  return {
62
- url: _chunkELHJSRS2js.AUTH_LOGIN_ENDPOINT,
62
+ url: _chunk5C53GKTUjs.AUTH_LOGIN_ENDPOINT,
63
63
  requestMethod: "POST",
64
64
  response: MOCK_LOGIN_RESPONSE
65
65
  };
@@ -73,7 +73,7 @@ var MOCK_OATH_TOKEN_RESPONSE = {
73
73
  };
74
74
  var getMockAuthAccessTokenResponse = () => {
75
75
  return {
76
- url: _chunkELHJSRS2js.OIDC_TOKENS_ENDPOINT,
76
+ url: _chunk5C53GKTUjs.OIDC_TOKENS_ENDPOINT,
77
77
  requestMethod: "POST",
78
78
  response: MOCK_OATH_TOKEN_RESPONSE
79
79
  };
@@ -83,4 +83,4 @@ var getMockAuthAccessTokenResponse = () => {
83
83
 
84
84
 
85
85
  exports.fixtures_exports = fixtures_exports; exports.authentication_exports = authentication_exports;
86
- //# sourceMappingURL=chunk-RX5R6BUI.js.map
86
+ //# sourceMappingURL=chunk-FRVMGTOY.js.map
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkELHJSRS2js = require('./chunk-ELHJSRS2.js');
6
+ var _chunk5C53GKTUjs = require('./chunk-5C53GKTU.js');
7
7
 
8
8
 
9
9
 
@@ -67,6 +67,9 @@ var AuthenticationController = class extends _basecontroller.BaseController {
67
67
  */
68
68
  _chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _snapSignMessage);
69
69
  _chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _metametrics, void 0);
70
+ if (!metametrics) {
71
+ throw new Error("`metametrics` field is required");
72
+ }
70
73
  _chunkIGY2S5BCjs.__privateSet.call(void 0, this, _metametrics, metametrics);
71
74
  _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
72
75
  }
@@ -143,14 +146,14 @@ _performAuthenticationFlow = new WeakSet();
143
146
  performAuthenticationFlow_fn = async function() {
144
147
  try {
145
148
  const publicKey = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _snapGetPublicKey, snapGetPublicKey_fn).call(this);
146
- const nonce = await _chunkELHJSRS2js.getNonce.call(void 0, publicKey);
149
+ const nonce = await _chunk5C53GKTUjs.getNonce.call(void 0, publicKey);
147
150
  if (!nonce) {
148
151
  throw new Error(`Unable to get nonce`);
149
152
  }
150
- const rawMessage = _chunkELHJSRS2js.createLoginRawMessage.call(void 0, nonce, publicKey);
153
+ const rawMessage = _chunk5C53GKTUjs.createLoginRawMessage.call(void 0, nonce, publicKey);
151
154
  const signature = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _snapSignMessage, snapSignMessage_fn).call(this, rawMessage);
152
- const loginResponse = await _chunkELHJSRS2js.login.call(void 0, rawMessage, signature, {
153
- metametricsId: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _metametrics).getMetaMetricsId(),
155
+ const loginResponse = await _chunk5C53GKTUjs.login.call(void 0, rawMessage, signature, {
156
+ metametricsId: await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _metametrics).getMetaMetricsId(),
154
157
  agent: _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _metametrics).agent
155
158
  });
156
159
  if (!loginResponse?.token) {
@@ -160,7 +163,10 @@ performAuthenticationFlow_fn = async function() {
160
163
  identifierId: loginResponse.profile.identifier_id,
161
164
  profileId: loginResponse.profile.profile_id
162
165
  };
163
- const accessToken = await _chunkELHJSRS2js.getAccessToken.call(void 0, loginResponse.token);
166
+ const accessToken = await _chunk5C53GKTUjs.getAccessToken.call(void 0,
167
+ loginResponse.token,
168
+ _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _metametrics).agent
169
+ );
164
170
  if (!accessToken) {
165
171
  throw new Error(`Unable to get Access Token`);
166
172
  }
@@ -221,4 +227,4 @@ snapSignMessage_fn = function(message) {
221
227
 
222
228
 
223
229
  exports.defaultState = defaultState; exports.AuthenticationController = AuthenticationController;
224
- //# sourceMappingURL=chunk-YUXN5GSW.js.map
230
+ //# sourceMappingURL=chunk-GWBBZZVV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAIA,SAAS,sBAAsB;AAe/B,IAAM,gBAAgB,MAAO,KAAK;AAElC,IAAM,iBAAiB;AA8BhB,IAAM,eAA8C;AAAA,EACzD,YAAY;AACd;AACA,IAAM,WAAyD;AAAA,EAC7D,YAAY;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAAA,EACA,aAAa;AAAA,IACX,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACF;AA/DA;AA2GA,IAAqB,2BAArB,cAAsD,eAIpD;AAAA,EAGA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAQG;AACD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,OAAO,EAAE,GAAG,cAAc,GAAG,MAAM;AAAA,IACrC,CAAC;AAeH;AAAA;AAAA;AAAA;AAAA;AAyEA;AAQA,uBAAM;AAmEN;AAuBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA3NA;AAsBE,QAAI,CAAC,aAAa;AAChB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AAEA,uBAAK,cAAe;AAEpB,0BAAK,sDAAL;AAAA,EACF;AAAA,EAiCA,MAAa,gBAAiC;AAC5C,UAAM,EAAE,YAAY,IAAI,MAAM,sBAAK,0DAAL;AAC9B,WAAO;AAAA,EACT;AAAA,EAEO,iBAAuB;AAC5B,0BAAK,oCAAL;AAEA,SAAK,OAAO,CAAC,UAA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B,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,KAAK,MAAM,YAAY,SAAS;AACjD,MAAI,MAAM,QAAQ,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,oBAAI,KAAK;AAC7B,QAAM,SAAS,KAAK,IAAI,YAAY,QAAQ,IAAI,QAAQ;AAExD,SAAO,gBAAgB;AACzB;AAOA;AAAA,sBAAiB,WAAoB;AACnC,SAAO,KAAK,gBAAgB;AAAA,IAC1B;AAAA,IACA,2BAA2B;AAAA,EAC7B;AACF;AAQA;AAAA,qBAAgB,SAAC,SAAgD;AAC/D,SAAO,KAAK,gBAAgB;AAAA,IAC1B;AAAA,IACA,6BAA6B,OAAO;AAAA,EACtC;AACF","sourcesContent":["import type {\n RestrictedControllerMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport type { UserStorageControllerDisableProfileSyncing } from '../user-storage/UserStorageController';\nimport {\n createSnapPublicKeyRequest,\n createSnapSignMessageRequest,\n} from './auth-snap-requests';\nimport {\n createLoginRawMessage,\n getAccessToken,\n getNonce,\n login,\n} from './services';\n\nconst THIRTY_MIN_MS = 1000 * 60 * 30;\n\nconst controllerName = 'AuthenticationController';\n\n// State\ntype SessionProfile = {\n identifierId: string;\n profileId: string;\n};\n\ntype SessionData = {\n /** profile - anonymous profile data for the given logged in user */\n profile: SessionProfile;\n /** accessToken - used to make requests authorized endpoints */\n accessToken: string;\n /** expiresIn - string date to determine if new access token is required */\n expiresIn: string;\n};\n\ntype MetaMetricsAuth = {\n getMetaMetricsId: () => string | Promise<string>;\n agent: 'extension' | 'mobile';\n};\n\nexport type AuthenticationControllerState = {\n /**\n * Global isSignedIn state.\n * Can be used to determine if \"Profile Syncing\" is enabled.\n */\n isSignedIn: boolean;\n sessionData?: SessionData;\n};\nexport const defaultState: AuthenticationControllerState = {\n isSignedIn: false,\n};\nconst metadata: StateMetadata<AuthenticationControllerState> = {\n isSignedIn: {\n persist: true,\n anonymous: true,\n },\n sessionData: {\n persist: true,\n anonymous: false,\n },\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof AuthenticationController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: AuthenticationController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performSignIn'\n | 'performSignOut'\n | 'getBearerToken'\n | 'getSessionProfile'\n | 'isSignedIn'\n>;\nexport type Actions = ActionsObj[keyof ActionsObj];\nexport type AuthenticationControllerPerformSignIn = ActionsObj['performSignIn'];\nexport type AuthenticationControllerPerformSignOut =\n ActionsObj['performSignOut'];\nexport type AuthenticationControllerGetBearerToken =\n ActionsObj['getBearerToken'];\nexport type AuthenticationControllerGetSessionProfile =\n ActionsObj['getSessionProfile'];\nexport type AuthenticationControllerIsSignedIn = ActionsObj['isSignedIn'];\n\n// Allowed Actions\nexport type AllowedActions =\n | HandleSnapRequest\n | UserStorageControllerDisableProfileSyncing;\n\n// Messenger\nexport type AuthenticationControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n never,\n AllowedActions['type'],\n never\n>;\n\n/**\n * Controller that enables authentication for restricted endpoints.\n * Used for Global Profile Syncing and Notifications\n */\nexport default class AuthenticationController extends BaseController<\n typeof controllerName,\n AuthenticationControllerState,\n AuthenticationControllerMessenger\n> {\n #metametrics: MetaMetricsAuth;\n\n constructor({\n messenger,\n state,\n metametrics,\n }: {\n messenger: AuthenticationControllerMessenger;\n state?: AuthenticationControllerState;\n /**\n * Not using the Messaging System as we\n * do not want to tie this strictly to extension\n */\n metametrics: MetaMetricsAuth;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n if (!metametrics) {\n throw new Error('`metametrics` field is required');\n }\n\n this.#metametrics = metametrics;\n\n this.#registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getBearerToken',\n this.getBearerToken.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getSessionProfile',\n this.getSessionProfile.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:isSignedIn',\n this.isSignedIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignIn',\n this.performSignIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignOut',\n this.performSignOut.bind(this),\n );\n }\n\n public async performSignIn(): Promise<string> {\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n public performSignOut(): void {\n this.#assertLoggedIn();\n\n this.update((state) => {\n state.isSignedIn = false;\n state.sessionData = undefined;\n });\n }\n\n public async getBearerToken(): Promise<string> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.accessToken;\n }\n\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n /**\n * Will return a session profile.\n * Throws if a user is not logged in.\n *\n * @returns profile for the session.\n */\n public async getSessionProfile(): Promise<SessionProfile> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.profile;\n }\n\n const { profile } = await this.#performAuthenticationFlow();\n return profile;\n }\n\n public isSignedIn(): boolean {\n return this.state.isSignedIn;\n }\n\n #assertLoggedIn(): void {\n if (!this.state.isSignedIn) {\n throw new Error(\n `${controllerName}: Unable to call method, user is not authenticated`,\n );\n }\n }\n\n async #performAuthenticationFlow(): Promise<{\n profile: SessionProfile;\n accessToken: string;\n }> {\n try {\n // 1. Nonce\n const publicKey = await this.#snapGetPublicKey();\n const nonce = await getNonce(publicKey);\n if (!nonce) {\n throw new Error(`Unable to get nonce`);\n }\n\n // 2. Login\n const rawMessage = createLoginRawMessage(nonce, publicKey);\n const signature = await this.#snapSignMessage(rawMessage);\n const loginResponse = await login(rawMessage, signature, {\n metametricsId: await this.#metametrics.getMetaMetricsId(),\n agent: this.#metametrics.agent,\n });\n if (!loginResponse?.token) {\n throw new Error(`Unable to login`);\n }\n\n const profile: SessionProfile = {\n identifierId: loginResponse.profile.identifier_id,\n profileId: loginResponse.profile.profile_id,\n };\n\n // 3. Trade for Access Token\n const accessToken = await getAccessToken(\n loginResponse.token,\n this.#metametrics.agent,\n );\n if (!accessToken) {\n throw new Error(`Unable to get Access Token`);\n }\n\n // Update Internal State\n this.update((state) => {\n state.isSignedIn = true;\n const expiresIn = new Date();\n expiresIn.setTime(expiresIn.getTime() + THIRTY_MIN_MS);\n state.sessionData = {\n profile,\n accessToken,\n expiresIn: expiresIn.toString(),\n };\n });\n\n return {\n profile,\n accessToken,\n };\n } catch (e) {\n console.error('Failed to authenticate', e);\n // Disable Profile Syncing\n await this.messagingSystem.call(\n 'UserStorageController:disableProfileSyncing',\n );\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new Error(\n `${controllerName}: Failed to authenticate - ${errorMessage}`,\n );\n }\n }\n\n #hasValidSession(\n sessionData: SessionData | undefined,\n ): sessionData is SessionData {\n if (!sessionData) {\n return false;\n }\n\n const prevDate = Date.parse(sessionData.expiresIn);\n if (isNaN(prevDate)) {\n return false;\n }\n\n const currentDate = new Date();\n const diffMs = Math.abs(currentDate.getTime() - prevDate);\n\n return THIRTY_MIN_MS > diffMs;\n }\n\n /**\n * Returns the auth snap public key.\n *\n * @returns The snap public key.\n */\n #snapGetPublicKey(): Promise<string> {\n return this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapPublicKeyRequest(),\n ) as Promise<string>;\n }\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n return this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n ) as Promise<string>;\n }\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  AuthenticationController,
3
3
  defaultState
4
- } from "./chunk-32HAX3MW.mjs";
4
+ } from "./chunk-QU3RCIV3.mjs";
5
5
  import {
6
6
  AUTH_LOGIN_ENDPOINT,
7
7
  AUTH_NONCE_ENDPOINT,
8
8
  OIDC_TOKENS_ENDPOINT
9
- } from "./chunk-KBCXN3YW.mjs";
9
+ } from "./chunk-7SW3CC66.mjs";
10
10
  import {
11
11
  __export
12
12
  } from "./chunk-U5UIDVOO.mjs";
@@ -83,4 +83,4 @@ export {
83
83
  fixtures_exports,
84
84
  authentication_exports
85
85
  };
86
- //# sourceMappingURL=chunk-AARMY5TW.mjs.map
86
+ //# sourceMappingURL=chunk-KKB3U6KO.mjs.map
@@ -3,7 +3,7 @@ import {
3
3
  getAccessToken,
4
4
  getNonce,
5
5
  login
6
- } from "./chunk-KBCXN3YW.mjs";
6
+ } from "./chunk-7SW3CC66.mjs";
7
7
  import {
8
8
  createSnapPublicKeyRequest,
9
9
  createSnapSignMessageRequest
@@ -67,6 +67,9 @@ var AuthenticationController = class extends BaseController {
67
67
  */
68
68
  __privateAdd(this, _snapSignMessage);
69
69
  __privateAdd(this, _metametrics, void 0);
70
+ if (!metametrics) {
71
+ throw new Error("`metametrics` field is required");
72
+ }
70
73
  __privateSet(this, _metametrics, metametrics);
71
74
  __privateMethod(this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
72
75
  }
@@ -150,7 +153,7 @@ performAuthenticationFlow_fn = async function() {
150
153
  const rawMessage = createLoginRawMessage(nonce, publicKey);
151
154
  const signature = await __privateMethod(this, _snapSignMessage, snapSignMessage_fn).call(this, rawMessage);
152
155
  const loginResponse = await login(rawMessage, signature, {
153
- metametricsId: __privateGet(this, _metametrics).getMetaMetricsId(),
156
+ metametricsId: await __privateGet(this, _metametrics).getMetaMetricsId(),
154
157
  agent: __privateGet(this, _metametrics).agent
155
158
  });
156
159
  if (!loginResponse?.token) {
@@ -160,7 +163,10 @@ performAuthenticationFlow_fn = async function() {
160
163
  identifierId: loginResponse.profile.identifier_id,
161
164
  profileId: loginResponse.profile.profile_id
162
165
  };
163
- const accessToken = await getAccessToken(loginResponse.token);
166
+ const accessToken = await getAccessToken(
167
+ loginResponse.token,
168
+ __privateGet(this, _metametrics).agent
169
+ );
164
170
  if (!accessToken) {
165
171
  throw new Error(`Unable to get Access Token`);
166
172
  }
@@ -221,4 +227,4 @@ export {
221
227
  defaultState,
222
228
  AuthenticationController
223
229
  };
224
- //# sourceMappingURL=chunk-32HAX3MW.mjs.map
230
+ //# sourceMappingURL=chunk-QU3RCIV3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/controllers/authentication/AuthenticationController.ts"],"sourcesContent":["import type {\n RestrictedControllerMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport type { UserStorageControllerDisableProfileSyncing } from '../user-storage/UserStorageController';\nimport {\n createSnapPublicKeyRequest,\n createSnapSignMessageRequest,\n} from './auth-snap-requests';\nimport {\n createLoginRawMessage,\n getAccessToken,\n getNonce,\n login,\n} from './services';\n\nconst THIRTY_MIN_MS = 1000 * 60 * 30;\n\nconst controllerName = 'AuthenticationController';\n\n// State\ntype SessionProfile = {\n identifierId: string;\n profileId: string;\n};\n\ntype SessionData = {\n /** profile - anonymous profile data for the given logged in user */\n profile: SessionProfile;\n /** accessToken - used to make requests authorized endpoints */\n accessToken: string;\n /** expiresIn - string date to determine if new access token is required */\n expiresIn: string;\n};\n\ntype MetaMetricsAuth = {\n getMetaMetricsId: () => string | Promise<string>;\n agent: 'extension' | 'mobile';\n};\n\nexport type AuthenticationControllerState = {\n /**\n * Global isSignedIn state.\n * Can be used to determine if \"Profile Syncing\" is enabled.\n */\n isSignedIn: boolean;\n sessionData?: SessionData;\n};\nexport const defaultState: AuthenticationControllerState = {\n isSignedIn: false,\n};\nconst metadata: StateMetadata<AuthenticationControllerState> = {\n isSignedIn: {\n persist: true,\n anonymous: true,\n },\n sessionData: {\n persist: true,\n anonymous: false,\n },\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof AuthenticationController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: AuthenticationController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performSignIn'\n | 'performSignOut'\n | 'getBearerToken'\n | 'getSessionProfile'\n | 'isSignedIn'\n>;\nexport type Actions = ActionsObj[keyof ActionsObj];\nexport type AuthenticationControllerPerformSignIn = ActionsObj['performSignIn'];\nexport type AuthenticationControllerPerformSignOut =\n ActionsObj['performSignOut'];\nexport type AuthenticationControllerGetBearerToken =\n ActionsObj['getBearerToken'];\nexport type AuthenticationControllerGetSessionProfile =\n ActionsObj['getSessionProfile'];\nexport type AuthenticationControllerIsSignedIn = ActionsObj['isSignedIn'];\n\n// Allowed Actions\nexport type AllowedActions =\n | HandleSnapRequest\n | UserStorageControllerDisableProfileSyncing;\n\n// Messenger\nexport type AuthenticationControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n never,\n AllowedActions['type'],\n never\n>;\n\n/**\n * Controller that enables authentication for restricted endpoints.\n * Used for Global Profile Syncing and Notifications\n */\nexport default class AuthenticationController extends BaseController<\n typeof controllerName,\n AuthenticationControllerState,\n AuthenticationControllerMessenger\n> {\n #metametrics: MetaMetricsAuth;\n\n constructor({\n messenger,\n state,\n metametrics,\n }: {\n messenger: AuthenticationControllerMessenger;\n state?: AuthenticationControllerState;\n /**\n * Not using the Messaging System as we\n * do not want to tie this strictly to extension\n */\n metametrics: MetaMetricsAuth;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n if (!metametrics) {\n throw new Error('`metametrics` field is required');\n }\n\n this.#metametrics = metametrics;\n\n this.#registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getBearerToken',\n this.getBearerToken.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getSessionProfile',\n this.getSessionProfile.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:isSignedIn',\n this.isSignedIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignIn',\n this.performSignIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignOut',\n this.performSignOut.bind(this),\n );\n }\n\n public async performSignIn(): Promise<string> {\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n public performSignOut(): void {\n this.#assertLoggedIn();\n\n this.update((state) => {\n state.isSignedIn = false;\n state.sessionData = undefined;\n });\n }\n\n public async getBearerToken(): Promise<string> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.accessToken;\n }\n\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n /**\n * Will return a session profile.\n * Throws if a user is not logged in.\n *\n * @returns profile for the session.\n */\n public async getSessionProfile(): Promise<SessionProfile> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.profile;\n }\n\n const { profile } = await this.#performAuthenticationFlow();\n return profile;\n }\n\n public isSignedIn(): boolean {\n return this.state.isSignedIn;\n }\n\n #assertLoggedIn(): void {\n if (!this.state.isSignedIn) {\n throw new Error(\n `${controllerName}: Unable to call method, user is not authenticated`,\n );\n }\n }\n\n async #performAuthenticationFlow(): Promise<{\n profile: SessionProfile;\n accessToken: string;\n }> {\n try {\n // 1. Nonce\n const publicKey = await this.#snapGetPublicKey();\n const nonce = await getNonce(publicKey);\n if (!nonce) {\n throw new Error(`Unable to get nonce`);\n }\n\n // 2. Login\n const rawMessage = createLoginRawMessage(nonce, publicKey);\n const signature = await this.#snapSignMessage(rawMessage);\n const loginResponse = await login(rawMessage, signature, {\n metametricsId: await this.#metametrics.getMetaMetricsId(),\n agent: this.#metametrics.agent,\n });\n if (!loginResponse?.token) {\n throw new Error(`Unable to login`);\n }\n\n const profile: SessionProfile = {\n identifierId: loginResponse.profile.identifier_id,\n profileId: loginResponse.profile.profile_id,\n };\n\n // 3. Trade for Access Token\n const accessToken = await getAccessToken(\n loginResponse.token,\n this.#metametrics.agent,\n );\n if (!accessToken) {\n throw new Error(`Unable to get Access Token`);\n }\n\n // Update Internal State\n this.update((state) => {\n state.isSignedIn = true;\n const expiresIn = new Date();\n expiresIn.setTime(expiresIn.getTime() + THIRTY_MIN_MS);\n state.sessionData = {\n profile,\n accessToken,\n expiresIn: expiresIn.toString(),\n };\n });\n\n return {\n profile,\n accessToken,\n };\n } catch (e) {\n console.error('Failed to authenticate', e);\n // Disable Profile Syncing\n await this.messagingSystem.call(\n 'UserStorageController:disableProfileSyncing',\n );\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new Error(\n `${controllerName}: Failed to authenticate - ${errorMessage}`,\n );\n }\n }\n\n #hasValidSession(\n sessionData: SessionData | undefined,\n ): sessionData is SessionData {\n if (!sessionData) {\n return false;\n }\n\n const prevDate = Date.parse(sessionData.expiresIn);\n if (isNaN(prevDate)) {\n return false;\n }\n\n const currentDate = new Date();\n const diffMs = Math.abs(currentDate.getTime() - prevDate);\n\n return THIRTY_MIN_MS > diffMs;\n }\n\n /**\n * Returns the auth snap public key.\n *\n * @returns The snap public key.\n */\n #snapGetPublicKey(): Promise<string> {\n return this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapPublicKeyRequest(),\n ) as Promise<string>;\n }\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n return this.messagingSystem.call(\n 'Snap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IAAI,QAAQ;AAExD,SAAO,gBAAgB;AACzB;AAOA;AAAA,sBAAiB,WAAoB;AACnC,SAAO,KAAK,gBAAgB;AAAA,IAC1B;AAAA,IACA,2BAA2B;AAAA,EAC7B;AACF;AAQA;AAAA,qBAAgB,SAAC,SAAgD;AAC/D,SAAO,KAAK,gBAAgB;AAAA,IAC1B;AAAA,IACA,6BAA6B,OAAO;AAAA,EACtC;AACF;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkYUXN5GSWjs = require('../../chunk-YUXN5GSW.js');
5
- require('../../chunk-ELHJSRS2.js');
4
+ var _chunkGWBBZZVVjs = require('../../chunk-GWBBZZVV.js');
5
+ require('../../chunk-5C53GKTU.js');
6
6
  require('../../chunk-IPSBQ3MS.js');
7
7
  require('../../chunk-PTR4DAX6.js');
8
8
  require('../../chunk-NLHLVVOO.js');
@@ -20,5 +20,5 @@ require('../../chunk-IGY2S5BC.js');
20
20
 
21
21
 
22
22
 
23
- exports.default = _chunkYUXN5GSWjs.AuthenticationController; exports.defaultState = _chunkYUXN5GSWjs.defaultState;
23
+ exports.default = _chunkGWBBZZVVjs.AuthenticationController; exports.defaultState = _chunkGWBBZZVVjs.defaultState;
24
24
  //# sourceMappingURL=AuthenticationController.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AuthenticationController,
3
3
  defaultState
4
- } from "../../chunk-32HAX3MW.mjs";
5
- import "../../chunk-KBCXN3YW.mjs";
4
+ } from "../../chunk-QU3RCIV3.mjs";
5
+ import "../../chunk-7SW3CC66.mjs";
6
6
  import "../../chunk-6P6CUKKI.mjs";
7
7
  import "../../chunk-WJCKQLKK.mjs";
8
8
  import "../../chunk-FCT2LIGH.mjs";
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkRX5R6BUIjs = require('../../chunk-RX5R6BUI.js');
3
+ var _chunkFRVMGTOYjs = require('../../chunk-FRVMGTOY.js');
4
4
 
5
5
 
6
6
 
7
- var _chunkYUXN5GSWjs = require('../../chunk-YUXN5GSW.js');
8
- require('../../chunk-ELHJSRS2.js');
7
+ var _chunkGWBBZZVVjs = require('../../chunk-GWBBZZVV.js');
8
+ require('../../chunk-5C53GKTU.js');
9
9
  require('../../chunk-IPSBQ3MS.js');
10
10
  require('../../chunk-PTR4DAX6.js');
11
11
  require('../../chunk-NLHLVVOO.js');
@@ -24,5 +24,5 @@ require('../../chunk-IGY2S5BC.js');
24
24
 
25
25
 
26
26
 
27
- exports.Controller = _chunkYUXN5GSWjs.AuthenticationController; exports.Mocks = _chunkRX5R6BUIjs.fixtures_exports; exports.defaultState = _chunkYUXN5GSWjs.defaultState;
27
+ exports.Controller = _chunkGWBBZZVVjs.AuthenticationController; exports.Mocks = _chunkFRVMGTOYjs.fixtures_exports; exports.defaultState = _chunkGWBBZZVVjs.defaultState;
28
28
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  fixtures_exports
3
- } from "../../chunk-AARMY5TW.mjs";
3
+ } from "../../chunk-KKB3U6KO.mjs";
4
4
  import {
5
5
  AuthenticationController,
6
6
  defaultState
7
- } from "../../chunk-32HAX3MW.mjs";
8
- import "../../chunk-KBCXN3YW.mjs";
7
+ } from "../../chunk-QU3RCIV3.mjs";
8
+ import "../../chunk-7SW3CC66.mjs";
9
9
  import "../../chunk-6P6CUKKI.mjs";
10
10
  import "../../chunk-WJCKQLKK.mjs";
11
11
  import "../../chunk-FCT2LIGH.mjs";
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- var _chunkELHJSRS2js = require('../../chunk-ELHJSRS2.js');
9
+ var _chunk5C53GKTUjs = require('../../chunk-5C53GKTU.js');
10
10
  require('../../chunk-PTR4DAX6.js');
11
11
  require('../../chunk-NLHLVVOO.js');
12
12
  require('../../chunk-Q5WIUNX5.js');
@@ -28,5 +28,5 @@ require('../../chunk-IGY2S5BC.js');
28
28
 
29
29
 
30
30
 
31
- exports.AUTH_LOGIN_ENDPOINT = _chunkELHJSRS2js.AUTH_LOGIN_ENDPOINT; exports.AUTH_NONCE_ENDPOINT = _chunkELHJSRS2js.AUTH_NONCE_ENDPOINT; exports.OIDC_TOKENS_ENDPOINT = _chunkELHJSRS2js.OIDC_TOKENS_ENDPOINT; exports.createLoginRawMessage = _chunkELHJSRS2js.createLoginRawMessage; exports.getAccessToken = _chunkELHJSRS2js.getAccessToken; exports.getNonce = _chunkELHJSRS2js.getNonce; exports.login = _chunkELHJSRS2js.login;
31
+ exports.AUTH_LOGIN_ENDPOINT = _chunk5C53GKTUjs.AUTH_LOGIN_ENDPOINT; exports.AUTH_NONCE_ENDPOINT = _chunk5C53GKTUjs.AUTH_NONCE_ENDPOINT; exports.OIDC_TOKENS_ENDPOINT = _chunk5C53GKTUjs.OIDC_TOKENS_ENDPOINT; exports.createLoginRawMessage = _chunk5C53GKTUjs.createLoginRawMessage; exports.getAccessToken = _chunk5C53GKTUjs.getAccessToken; exports.getNonce = _chunk5C53GKTUjs.getNonce; exports.login = _chunk5C53GKTUjs.login;
32
32
  //# sourceMappingURL=services.js.map
@@ -6,7 +6,7 @@ import {
6
6
  getAccessToken,
7
7
  getNonce,
8
8
  login
9
- } from "../../chunk-KBCXN3YW.mjs";
9
+ } from "../../chunk-7SW3CC66.mjs";
10
10
  import "../../chunk-WJCKQLKK.mjs";
11
11
  import "../../chunk-FCT2LIGH.mjs";
12
12
  import "../../chunk-JLDFMYAH.mjs";
@@ -1,8 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkRX5R6BUIjs = require('../chunk-RX5R6BUI.js');
4
- require('../chunk-YUXN5GSW.js');
5
- require('../chunk-ELHJSRS2.js');
3
+ var _chunkFRVMGTOYjs = require('../chunk-FRVMGTOY.js');
4
+ require('../chunk-GWBBZZVV.js');
5
+ require('../chunk-5C53GKTU.js');
6
6
 
7
7
 
8
8
  var _chunkH4TDS65Rjs = require('../chunk-H4TDS65R.js');
@@ -30,5 +30,5 @@ require('../chunk-IGY2S5BC.js');
30
30
 
31
31
 
32
32
 
33
- exports.Authentication = _chunkRX5R6BUIjs.authentication_exports; exports.UserStorage = _chunkH4TDS65Rjs.user_storage_exports;
33
+ exports.Authentication = _chunkFRVMGTOYjs.authentication_exports; exports.UserStorage = _chunkH4TDS65Rjs.user_storage_exports;
34
34
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  authentication_exports
3
- } from "../chunk-AARMY5TW.mjs";
4
- import "../chunk-32HAX3MW.mjs";
5
- import "../chunk-KBCXN3YW.mjs";
3
+ } from "../chunk-KKB3U6KO.mjs";
4
+ import "../chunk-QU3RCIV3.mjs";
5
+ import "../chunk-7SW3CC66.mjs";
6
6
  import {
7
7
  user_storage_exports
8
8
  } from "../chunk-LSVRA3X2.mjs";
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkRX5R6BUIjs = require('./chunk-RX5R6BUI.js');
4
- require('./chunk-YUXN5GSW.js');
5
- require('./chunk-ELHJSRS2.js');
3
+ var _chunkFRVMGTOYjs = require('./chunk-FRVMGTOY.js');
4
+ require('./chunk-GWBBZZVV.js');
5
+ require('./chunk-5C53GKTU.js');
6
6
 
7
7
 
8
8
  var _chunkH4TDS65Rjs = require('./chunk-H4TDS65R.js');
@@ -33,5 +33,5 @@ require('./chunk-IGY2S5BC.js');
33
33
 
34
34
 
35
35
 
36
- exports.AuthenticationController = _chunkRX5R6BUIjs.authentication_exports; exports.SDK = _chunkPTR4DAX6js.sdk_exports; exports.UserStorageController = _chunkH4TDS65Rjs.user_storage_exports;
36
+ exports.AuthenticationController = _chunkFRVMGTOYjs.authentication_exports; exports.SDK = _chunkPTR4DAX6js.sdk_exports; exports.UserStorageController = _chunkH4TDS65Rjs.user_storage_exports;
37
37
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  authentication_exports
3
- } from "./chunk-AARMY5TW.mjs";
4
- import "./chunk-32HAX3MW.mjs";
5
- import "./chunk-KBCXN3YW.mjs";
3
+ } from "./chunk-KKB3U6KO.mjs";
4
+ import "./chunk-QU3RCIV3.mjs";
5
+ import "./chunk-7SW3CC66.mjs";
6
6
  import {
7
7
  user_storage_exports
8
8
  } from "./chunk-LSVRA3X2.mjs";