@mindful-web/marko-web-identity-x 1.18.4 → 1.19.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.
@@ -15,7 +15,7 @@
15
15
  <option disabled value="">
16
16
  {{ placeholder }}
17
17
  </option>
18
- <option v-for="country in countries" :key="country.id" :value="country.id">
18
+ <option v-for="country in countries" :key="country.code" :value="country.code">
19
19
  {{ country.name }} {{ country.flag }}
20
20
  </option>
21
21
  </select>
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/access.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/access.marko",
6
6
  marko_component = require("./access.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_objectPath_module = require("@mindful-web/object-path"),
@@ -53,7 +53,7 @@ marko_template._ = marko_renderer(render, {
53
53
  }, marko_component);
54
54
 
55
55
  marko_template.meta = {
56
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/access.marko",
56
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/access.marko",
57
57
  component: "./access.marko",
58
58
  tags: [
59
59
  "@mindful-web/marko-core/components/resolve.marko"
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/comment-stream.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/comment-stream.marko",
6
6
  marko_component = require("./comment-stream.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_objectPath_module = require("@mindful-web/object-path"),
@@ -68,7 +68,7 @@ marko_template._ = marko_renderer(render, {
68
68
  }, marko_component);
69
69
 
70
70
  marko_template.meta = {
71
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/comment-stream.marko",
71
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/comment-stream.marko",
72
72
  component: "./comment-stream.marko",
73
73
  tags: [
74
74
  "@mindful-web/marko-web/components/browser-component.marko",
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/context.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/context.marko",
6
6
  marko_component = require("./context.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
@@ -44,7 +44,7 @@ marko_template._ = marko_renderer(render, {
44
44
  }, marko_component);
45
45
 
46
46
  marko_template.meta = {
47
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/context.marko",
47
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/context.marko",
48
48
  component: "./context.marko",
49
49
  tags: [
50
50
  "@mindful-web/marko-core/components/resolve.marko"
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/form-access.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/form-access.marko",
6
6
  marko_renderer = require("marko/dist/runtime/components/renderer"),
7
7
  module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
8
8
  defaultValue = module_defaultValue.default || module_defaultValue,
@@ -107,7 +107,7 @@ marko_template._ = marko_renderer(render, {
107
107
  });
108
108
 
109
109
  marko_template.meta = {
110
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/form-access.marko",
110
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/form-access.marko",
111
111
  tags: [
112
112
  "@mindful-web/marko-web/components/browser-component.marko"
113
113
  ]
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/form-authenticate.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/form-authenticate.marko",
6
6
  marko_component = require("./form-authenticate.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_objectPath_module = require("@mindful-web/object-path"),
@@ -68,7 +68,7 @@ marko_template._ = marko_renderer(render, {
68
68
  }, marko_component);
69
69
 
70
70
  marko_template.meta = {
71
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/form-authenticate.marko",
71
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/form-authenticate.marko",
72
72
  component: "./form-authenticate.marko",
73
73
  tags: [
74
74
  "@mindful-web/marko-web/components/browser-component.marko",
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/form-change-email.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/form-change-email.marko",
6
6
  marko_component = require("./form-change-email.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_objectPath_module = require("@mindful-web/object-path"),
@@ -59,7 +59,7 @@ marko_template._ = marko_renderer(render, {
59
59
  }, marko_component);
60
60
 
61
61
  marko_template.meta = {
62
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/form-change-email.marko",
62
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/form-change-email.marko",
63
63
  component: "./form-change-email.marko",
64
64
  tags: [
65
65
  "@mindful-web/marko-web/components/browser-component.marko",
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/form-login.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/form-login.marko",
6
6
  marko_component = require("./form-login.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_objectPath_module = require("@mindful-web/object-path"),
@@ -64,7 +64,7 @@ marko_template._ = marko_renderer(render, {
64
64
  }, marko_component);
65
65
 
66
66
  marko_template.meta = {
67
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/form-login.marko",
67
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/form-login.marko",
68
68
  component: "./form-login.marko",
69
69
  tags: [
70
70
  "@mindful-web/marko-web/components/browser-component.marko",
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/form-logout.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/form-logout.marko",
6
6
  marko_renderer = require("marko/dist/runtime/components/renderer"),
7
7
  module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
8
8
  defaultValue = module_defaultValue.default || module_defaultValue,
@@ -29,7 +29,7 @@ marko_template._ = marko_renderer(render, {
29
29
  });
30
30
 
31
31
  marko_template.meta = {
32
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/form-logout.marko",
32
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/form-logout.marko",
33
33
  tags: [
34
34
  "@mindful-web/marko-web/components/browser-component.marko"
35
35
  ]
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/form-profile.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/form-profile.marko",
6
6
  marko_component = require("./form-profile.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_objectPath_module = require("@mindful-web/object-path"),
@@ -73,7 +73,7 @@ marko_template._ = marko_renderer(render, {
73
73
  }, marko_component);
74
74
 
75
75
  marko_template.meta = {
76
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/form-profile.marko",
76
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/form-profile.marko",
77
77
  component: "./form-profile.marko",
78
78
  tags: [
79
79
  "@mindful-web/marko-web/components/browser-component.marko",
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/form-register.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/form-register.marko",
6
6
  marko_renderer = require("marko/dist/runtime/components/renderer"),
7
7
  marko_assign = require("marko/dist/runtime/helpers/assign"),
8
8
  marko_web_identity_x_form_login_template = require("./form-login.marko"),
@@ -25,7 +25,7 @@ marko_template._ = marko_renderer(render, {
25
25
  });
26
26
 
27
27
  marko_template.meta = {
28
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/form-register.marko",
28
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/form-register.marko",
29
29
  tags: [
30
30
  "./form-login.marko"
31
31
  ]
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/identify.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/identify.marko",
6
6
  marko_component = require("./identify.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_objectPath_module = require("@mindful-web/object-path"),
@@ -50,7 +50,7 @@ marko_template._ = marko_renderer(render, {
50
50
  }, marko_component);
51
51
 
52
52
  marko_template.meta = {
53
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/identify.marko",
53
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/identify.marko",
54
54
  component: "./identify.marko",
55
55
  tags: [
56
56
  "@mindful-web/marko-web-gtm/components/push.marko",
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var marko_template = module.exports = require("marko/dist/html").t(__filename),
5
- marko_componentType = "/@mindful-web/marko-web-identity-x$1.18.4/components/non-auth-identify.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.19.2/components/non-auth-identify.marko",
6
6
  marko_component = require("./non-auth-identify.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
@@ -45,7 +45,7 @@ marko_template._ = marko_renderer(render, {
45
45
  }, marko_component);
46
46
 
47
47
  marko_template.meta = {
48
- id: "/@mindful-web/marko-web-identity-x$1.18.4/components/non-auth-identify.marko",
48
+ id: "/@mindful-web/marko-web-identity-x$1.19.2/components/non-auth-identify.marko",
49
49
  component: "./non-auth-identify.marko",
50
50
  tags: [
51
51
  "@mindful-web/marko-core/components/resolve.marko"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindful-web/marko-web-identity-x",
3
- "version": "1.18.4",
3
+ "version": "1.19.2",
4
4
  "description": "Marko Wrapper for IdentityX",
5
5
  "repository": "https://github.com/parameter1/mindful-web/tree/main/packages/marko-web-identity-x",
6
6
  "author": "Josh Worden <josh@parameter1.com>",
@@ -25,6 +25,7 @@
25
25
  "dayjs": "^1.11.7",
26
26
  "express": "^4.18.2",
27
27
  "graphql-tag": "^2.12.6",
28
+ "i18n-iso-countries": "^4.3.1",
28
29
  "jsonwebtoken": "^8.5.1",
29
30
  "node-fetch": "^2.6.9",
30
31
  "object-path": "^0.11.8"
@@ -36,5 +37,5 @@
36
37
  "publishConfig": {
37
38
  "access": "public"
38
39
  },
39
- "gitHead": "df2f4666a412e0e4587a6e02ea036259872fb42e"
40
+ "gitHead": "2fcda9841ac8b9827dd18ed3549157eadbae05cd"
40
41
  }
@@ -1,25 +1,48 @@
1
- const gql = require('graphql-tag');
1
+ const countries = require('i18n-iso-countries');
2
2
  const { asyncRoute } = require('@mindful-web/utils');
3
+ const getEmoji = require('../utils/get-country-emoji');
4
+ const sortByName = require('../utils/sort-by-name');
3
5
 
4
- const localeCountries = gql`
5
- query LocaleCountries($input: LocaleCountriesQueryInput) {
6
- localeCountries(input: $input) {
7
- id
8
- name
9
- flag
10
- }
11
- }
12
- `;
6
+ const { isArray } = Array;
13
7
 
14
8
  module.exports = asyncRoute(async (req, res) => {
15
- /** @type {import('../middleware').IdentityXRequest} */
16
- const { identityX, query } = req;
17
- const { lang = 'en' } = query;
18
- const prioritize = lang === 'pt' ? ['BR', 'US'] : null;
19
- const input = {
20
- lang,
21
- ...(prioritize && { prioritize }),
22
- };
23
- const { data } = await identityX.client.query({ query: localeCountries, variables: { input } });
24
- res.json(data.localeCountries);
9
+ const { query } = req;
10
+ const { lang = 'en', withFlag = true } = query;
11
+ const prioritize = [];
12
+ switch (lang) {
13
+ case 'pt':
14
+ prioritize.push('BR', 'US');
15
+ break;
16
+ default:
17
+ prioritize.push('US', 'CA', 'MX');
18
+ }
19
+
20
+ // Must clone this data, otherwise deleting keys will remain sticky.
21
+ const data = { ...countries.getNames(lang) };
22
+
23
+ const top = (isArray(prioritize) && prioritize.length ? prioritize : [])
24
+ .filter((code) => code)
25
+ .map((code) => code.toUpperCase())
26
+ .reduce((o, code) => {
27
+ const value = data[code];
28
+ if (value) {
29
+ delete data[code];
30
+ return { ...o, [code]: value };
31
+ }
32
+ return o;
33
+ }, {});
34
+
35
+ const sorted = Object.keys(data)
36
+ .map((code) => ({ code, name: data[code] }))
37
+ .sort(sortByName)
38
+ .reduce((o, { code, name }) => ({ ...o, [code]: name }), {});
39
+
40
+ const ordered = { ...top, ...sorted };
41
+ const localeCountries = Object.keys(ordered).map((code) => {
42
+ const obj = { code, name: ordered[code], alpha3: countries.getAlpha3Code(ordered[code], lang) };
43
+ if (!withFlag) return obj;
44
+ obj.flag = getEmoji(code);
45
+ return obj;
46
+ });
47
+ res.json({ ...localeCountries });
25
48
  });
@@ -0,0 +1,5 @@
1
+ module.exports = (code) => {
2
+ const OFFSET = 127397;
3
+ const chars = [...code].map((c) => c.charCodeAt() + OFFSET);
4
+ return String.fromCodePoint(...chars);
5
+ };
@@ -0,0 +1,8 @@
1
+ const normalize = (name) => name.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
2
+ module.exports = (a, b) => {
3
+ const nameA = normalize(a.name);
4
+ const nameB = normalize(b.name);
5
+ if (nameA > nameB) return 1;
6
+ if (nameA < nameB) return -1;
7
+ return 0;
8
+ };