@mindful-web/marko-web-identity-x 1.57.0 → 1.59.0

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.
@@ -0,0 +1,7 @@
1
+ const gql = require('graphql-tag');
2
+
3
+ module.exports = gql`
4
+ mutation SetThirdPartyBooleanFieldAnswers($input: UpdateAppUserCustomBooleanAnswersMutationInput!) {
5
+ updateAppUserCustomBooleanAnswers(input: $input) { id }
6
+ }
7
+ `;
@@ -0,0 +1,7 @@
1
+ const gql = require('graphql-tag');
2
+
3
+ module.exports = gql`
4
+ mutation SetThirdPartySelectFieldAnswers($input: UpdateAppUserCustomSelectAnswersMutationInput!) {
5
+ updateAppUserCustomSelectAnswers(input: $input) { id }
6
+ }
7
+ `;
@@ -0,0 +1,7 @@
1
+ const gql = require('graphql-tag');
2
+
3
+ module.exports = gql`
4
+ mutation SetUnverifiedThirdPartyData($input: SetAppUserUnverifiedDataMutationInput!) {
5
+ setAppUserUnverifiedData(input: $input) { id }
6
+ }
7
+ `;
@@ -0,0 +1,14 @@
1
+ const gql = require('graphql-tag');
2
+
3
+ module.exports = gql`
4
+ query localeRegions {
5
+ localeRegions {
6
+ id
7
+ code
8
+ name
9
+ country {
10
+ id
11
+ }
12
+ }
13
+ }
14
+ `;
@@ -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.57.0/components/access.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/access.marko",
56
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/comment-stream.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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"),
@@ -85,7 +85,7 @@ marko_template._ = marko_renderer(render, {
85
85
  }, marko_component);
86
86
 
87
87
  marko_template.meta = {
88
- id: "/@mindful-web/marko-web-identity-x$1.57.0/components/comment-stream.marko",
88
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/components/comment-stream.marko",
89
89
  component: "./comment-stream.marko",
90
90
  tags: [
91
91
  "@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.57.0/components/context.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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"),
@@ -49,7 +49,7 @@ marko_template._ = marko_renderer(render, {
49
49
  }, marko_component);
50
50
 
51
51
  marko_template.meta = {
52
- id: "/@mindful-web/marko-web-identity-x$1.57.0/components/context.marko",
52
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/components/context.marko",
53
53
  component: "./context.marko",
54
54
  tags: [
55
55
  "@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.57.0/components/form-access.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/components/form-access.marko",
6
6
  marko_component = require("./form-access.marko"),
7
7
  marko_renderer = require("marko/dist/runtime/components/renderer"),
8
8
  module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
@@ -146,7 +146,7 @@ marko_template._ = marko_renderer(render, {
146
146
  }, marko_component);
147
147
 
148
148
  marko_template.meta = {
149
- id: "/@mindful-web/marko-web-identity-x$1.57.0/components/form-access.marko",
149
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/components/form-access.marko",
150
150
  component: "./form-access.marko",
151
151
  tags: [
152
152
  "@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.57.0/components/form-authenticate.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/form-authenticate.marko",
71
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/form-change-email.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/form-change-email.marko",
62
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/form-login.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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"),
@@ -79,7 +79,7 @@ marko_template._ = marko_renderer(render, {
79
79
  }, marko_component);
80
80
 
81
81
  marko_template.meta = {
82
- id: "/@mindful-web/marko-web-identity-x$1.57.0/components/form-login.marko",
82
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/components/form-login.marko",
83
83
  component: "./form-login.marko",
84
84
  tags: [
85
85
  "@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.57.0/components/form-logout.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/form-logout.marko",
32
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/form-profile.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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"),
@@ -81,7 +81,7 @@ marko_template._ = marko_renderer(render, {
81
81
  }, marko_component);
82
82
 
83
83
  marko_template.meta = {
84
- id: "/@mindful-web/marko-web-identity-x$1.57.0/components/form-profile.marko",
84
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/components/form-profile.marko",
85
85
  component: "./form-profile.marko",
86
86
  tags: [
87
87
  "@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.57.0/components/form-register.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/form-register.marko",
28
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/identify.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/identify.marko",
53
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/non-auth-identify.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/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.57.0/components/non-auth-identify.marko",
48
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/components/non-auth-identify.marko",
49
49
  component: "./non-auth-identify.marko",
50
50
  tags: [
51
51
  "@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.57.0/components/subscribe.marko",
5
+ marko_componentType = "/@mindful-web/marko-web-identity-x$1.59.0/components/subscribe.marko",
6
6
  marko_component = require("./subscribe.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.57.0/components/subscribe.marko",
76
+ id: "/@mindful-web/marko-web-identity-x$1.59.0/components/subscribe.marko",
77
77
  component: "./subscribe.marko",
78
78
  tags: [
79
79
  "@mindful-web/marko-web/components/browser-component.marko",
package/index.js CHANGED
@@ -4,7 +4,7 @@ const middleware = require('./middleware');
4
4
  /**
5
5
  *
6
6
  * @param {object} app The express app instance
7
- * @param {IdentityXConfiguration} config The IdentityX config
7
+ * @param {import('./config')} config The IdentityX config
8
8
  */
9
9
  module.exports = (app, config, {
10
10
  templates = {},
@@ -38,3 +38,126 @@ module.exports = (app, config, {
38
38
  * @prop {boolean} [required] If the field should be required
39
39
  * @prop {number} [width] Column width (percentage specified as decimal)
40
40
  */
41
+ /**
42
+ * Built-in IdentityX field keys
43
+ * @typedef {(
44
+ * |"addressExtra"
45
+ * |"city"
46
+ * |"countryCode"
47
+ * |"displayName"
48
+ * |"email"
49
+ * |"familyName"
50
+ * |"givenName"
51
+ * |"mobileNumber"
52
+ * |"organization"
53
+ * |"organizationTitle"
54
+ * |"phoneNumber"
55
+ * |"postalCode"
56
+ * |"regionCode"
57
+ * |"street"
58
+ * )} IdXField
59
+ */
60
+
61
+ /**
62
+ * @typedef IdentityXContext
63
+ * @prop {IdentityXApp} application
64
+ * @prop {IdentityXAppUser|null} user
65
+ * @prop {Object[]} mergedTeams
66
+ * @prop {Object[]} mergedAccessLevels
67
+ * @prop {Boolean} hasTeams
68
+ * @prop {Boolean} hasUser
69
+ * @prop {Boolean} isEnabled
70
+ *
71
+ * @typedef IdentityXApp
72
+ * @prop {String} id
73
+ * @prop {String} name
74
+ * @prop {String} consentPolicy
75
+ * @prop {String} emailConsentRequest
76
+ * @prop {Object[]} regionalConsentPolicies
77
+ *
78
+ * @typedef IdentityXAppUser
79
+ * @prop {String} id
80
+ * @prop {String} email
81
+ * @prop {boolean} verified
82
+ * @prop {string} givenName
83
+ * @prop {string} familyName
84
+ * @prop {string} displayName
85
+ * @prop {string} organization
86
+ * @prop {string} organizationTitle
87
+ * @prop {string} countryCode
88
+ * @prop {string} regionCode
89
+ * @prop {string} postalCode
90
+ * @prop {string} city
91
+ * @prop {string} street
92
+ * @prop {string} addressExtra
93
+ * @prop {string} mobileNumber
94
+ * @prop {string} phoneNumber
95
+ * @prop {boolean} receiveEmail
96
+ * @prop {ExternalId[]} externalIds
97
+ * @prop {object} customAttributes
98
+ * @prop {CustomBooleanFieldAnswer[]} customBooleanFieldAnswers
99
+ * @prop {CustomSelectFieldAnswer[]} customSelectFieldAnswers
100
+ * @prop {CustomTextFieldAnswer[]} customTextFieldAnswers
101
+ *
102
+ * @typedef ExternalId
103
+ * @prop {string} id
104
+ * @prop {object} identifier
105
+ * @prop {string} identifier.value
106
+ * @prop {string?} identifier.type
107
+ * @prop {object} namespace
108
+ * @prop {string} namespace.provider
109
+ * @prop {string} namespace.tenant
110
+ * @prop {string} namespace.type
111
+ *
112
+ * @typedef CustomBooleanFieldAnswer
113
+ * @prop {string} id
114
+ * @todo
115
+ *
116
+ * @typedef CustomSelectFieldAnswer
117
+ * @prop {string} id
118
+ * @prop {boolean} hasAnswered
119
+ * @prop {CustomSelectFieldAnswerValue[]} answers
120
+ * @prop {CustomSelectField} field
121
+ *
122
+ * @typedef CustomSelectFieldAnswerValue
123
+ * @prop {string} id
124
+ * @prop {string} label
125
+ * @prop {string?} externalIdentifier
126
+ * @prop {string?} writeInValue
127
+ *
128
+ * @typedef CustomSelectField
129
+ * @prop {string} id
130
+ * @prop {string} label
131
+ * @prop {boolean} active
132
+ * @prop {boolean} multiple
133
+ * @prop {boolean} required
134
+ * @prop {ExternalId?} externalId
135
+ * @prop {CustomSelectFieldOption[]} options
136
+ *
137
+ * @typedef CustomSelectFieldOption
138
+ * @prop {string} id
139
+ * @prop {string} label
140
+ * @prop {boolean} canWriteIn
141
+ * @prop {boolean} canSelect
142
+ *
143
+ * @typedef CustomTextFieldAnswer
144
+ * @prop {string} id
145
+ * @todo
146
+ *
147
+ * @typedef IdxCustomField
148
+ * @prop {boolean} active
149
+ * @prop {ExternalId} externalId
150
+ * @prop {(|"BooleanField"|"SelectField"|"TextField")} __typename
151
+ * @prop {string} id
152
+ * @prop {mixed} value
153
+ * @prop {object} [whenTrue]
154
+ * @prop {mixed} whenTrue.value
155
+ */
156
+ /**
157
+ * @typedef Region
158
+ * @prop {string} id ISO 3166-2 code, e.g; US-AL or CA-AB
159
+ * @prop {string} code ISO 3166-2:XX subdivision code, e.g AL or AB
160
+ * @prop {string} name The full name of the country subdivision, e.g; Alabama or Alberta
161
+ * @prop {object} country
162
+ * @prop {string} country.id ISO 3166-1 alpha-2 code of the region/subdivision's country
163
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindful-web/marko-web-identity-x",
3
- "version": "1.57.0",
3
+ "version": "1.59.0",
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>",
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "9c22257ffa98b3558deb5f6b8cb5088a89fc78f1"
40
+ "gitHead": "fa6805fe999892992166818fcf98d5e5714ccbc3"
41
41
  }
package/service.js CHANGED
@@ -1,21 +1,25 @@
1
1
  const { get, getAsArray, getAsObject } = require('@mindful-web/object-path');
2
2
  const { getResponseCookies } = require('@mindful-web/utils');
3
+ const ADD_EXTERNAL_USER_ID = require('./api/mutations/add-external-user-id');
4
+ const APP_USER_BY_EXTERNAL_ID = require('./api/queries/load-user-by-external-id');
5
+ const APP_USER_BY_ID = require('./api/queries/load-user-by-id');
6
+ const callHooksFor = require('./utils/call-hooks-for');
7
+ const CHECK_CONTENT_ACCESS = require('./api/queries/check-content-access');
8
+ const CREATE_APP_USER = require('./api/mutations/create-app-user');
3
9
  const createClient = require('./utils/create-client');
4
- const getActiveContext = require('./api/queries/get-active-context');
5
- const checkContentAccess = require('./api/queries/check-content-access');
6
- const loadUser = require('./api/queries/load-user');
7
- const appUserByExternalIdQuery = require('./api/queries/load-user-by-external-id');
8
- const appUserByIdQuery = require('./api/queries/load-user-by-id');
9
- const addExternalUserId = require('./api/mutations/add-external-user-id');
10
- const setCustomAttributes = require('./api/mutations/set-custom-attributes');
11
- const impersonateAppUser = require('./api/mutations/impersonate-app-user');
12
- const sendChangeEmailLinkMutation = require('./api/mutations/send-change-email-link');
13
- const sendLoginLinkMutation = require('./api/mutations/send-login-link');
14
- const createAppUser = require('./api/mutations/create-app-user');
15
- const logoutAppUser = require('./api/mutations/logout-app-user');
16
- const deleteAppUserForCurrentApplicationMutation = require('./api/mutations/delete-app-user-for-current-application');
10
+ const DELETE_APP_USER = require('./api/mutations/delete-app-user-for-current-application');
11
+ const GET_ACTIVE_CONTEXT = require('./api/queries/get-active-context');
12
+ const GET_LOCALE_REGIONS = require('./api/queries/get-locale-regions');
13
+ const IMPERSONATE_APP_USER = require('./api/mutations/impersonate-app-user');
14
+ const LOAD_USER = require('./api/queries/load-user');
15
+ const LOG_OUT_APP_USER = require('./api/mutations/logout-app-user');
16
+ const SEND_CHANGE_EMAIL_LINK = require('./api/mutations/send-change-email-link');
17
+ const SEND_LOGIN_LINK = require('./api/mutations/send-login-link');
18
+ const SET_BOOLEAN_FIELD_ANSWERS = require('./api/mutations/set-boolean-field-answers');
19
+ const SET_CUSTOM_ATTRIBUTES = require('./api/mutations/set-custom-attributes');
20
+ const SET_SELECT_FIELD_ANSWERS = require('./api/mutations/set-select-field-answers');
21
+ const SET_UNVERIFIED_DATA = require('./api/mutations/set-unverified-data');
17
22
  const tokenCookie = require('./utils/token-cookie');
18
- const callHooksFor = require('./utils/call-hooks-for');
19
23
 
20
24
  const isEmpty = (v) => v == null || v === '';
21
25
  const isFn = (v) => typeof v === 'function';
@@ -154,7 +158,7 @@ class IdentityX {
154
158
  async loadActiveContext({ forceQuery = false, withFields = false } = {}) {
155
159
  // Only run the active context query once
156
160
  if (!this.activeContextQuery || forceQuery || withFields) {
157
- this.activeContextQuery = this.client.query({ query: getActiveContext({ withFields }) });
161
+ this.activeContextQuery = this.client.query({ query: GET_ACTIVE_CONTEXT({ withFields }) });
158
162
  }
159
163
  const { data = {} } = await this.activeContextQuery;
160
164
  const activeContext = data.activeAppContext || {};
@@ -172,7 +176,7 @@ class IdentityX {
172
176
  */
173
177
  async loadAppUserByEmail(email) {
174
178
  const { data } = await this.client.query({
175
- query: loadUser,
179
+ query: LOAD_USER,
176
180
  variables: { email },
177
181
  fetchPolicy: 'no-cache',
178
182
  context: { apiToken: this.getOrgUserApiToken() },
@@ -180,6 +184,22 @@ class IdentityX {
180
184
  return data.appUser;
181
185
  }
182
186
 
187
+ /**
188
+ * Returns available region data
189
+ *
190
+ * @returns {Promise<Region[]>}
191
+ */
192
+ async loadRegions() {
193
+ if (!this.regions) {
194
+ const { data } = await this.client.query({
195
+ context: { apiToken: this.getOrgUserApiToken() },
196
+ query: GET_LOCALE_REGIONS,
197
+ });
198
+ this.regions = data.localeRegions;
199
+ }
200
+ return this.regions;
201
+ }
202
+
183
203
  /**
184
204
  * Checks whether the current user can access the given content.
185
205
  *
@@ -188,7 +208,7 @@ class IdentityX {
188
208
  */
189
209
  async checkContentAccess(input) {
190
210
  const variables = { input };
191
- const { data = {} } = await this.client.query({ query: checkContentAccess, variables });
211
+ const { data = {} } = await this.client.query({ query: CHECK_CONTENT_ACCESS, variables });
192
212
  const access = data.checkContentAccess || {};
193
213
  access.requiresUserInput = false;
194
214
 
@@ -282,14 +302,15 @@ class IdentityX {
282
302
  * @param {Object} o
283
303
  * @param {String} o.identifier
284
304
  * @param {ExternalIdNamespace} o.namespace
305
+ * @param {String} [o.type]
285
306
  *
286
307
  * @returns {Promise<User|null>}
287
308
  */
288
- async findUserByExternalId({ identifier, namespace }) {
309
+ async findUserByExternalId({ identifier, namespace, type }) {
289
310
  const { data } = await this.client.query({
290
- query: appUserByExternalIdQuery,
311
+ query: APP_USER_BY_EXTERNAL_ID,
291
312
  variables: {
292
- identifier: { value: identifier },
313
+ identifier: { value: identifier, ...(type && { type }) },
293
314
  namespace,
294
315
  },
295
316
  context: { apiToken: this.getOrgUserApiToken() },
@@ -304,7 +325,7 @@ class IdentityX {
304
325
  */
305
326
  async findUserById(id) {
306
327
  const { data } = await this.client.query({
307
- query: appUserByIdQuery,
328
+ query: APP_USER_BY_ID,
308
329
  variables: { id },
309
330
  context: { apiToken: this.getOrgUserApiToken() },
310
331
  });
@@ -324,7 +345,7 @@ class IdentityX {
324
345
  const input = { userId, identifier, namespace };
325
346
  const variables = { input };
326
347
  const { data } = await this.client.mutate({
327
- mutation: addExternalUserId,
348
+ mutation: ADD_EXTERNAL_USER_ID,
328
349
  variables,
329
350
  context: { apiToken: this.getOrgUserApiToken() },
330
351
  });
@@ -350,7 +371,7 @@ class IdentityX {
350
371
  async impersonateAppUser({ userId }) {
351
372
  const variables = { input: { id: userId, verify: true } };
352
373
  const { data } = await this.client.mutate({
353
- mutation: impersonateAppUser,
374
+ mutation: IMPERSONATE_APP_USER,
354
375
  variables,
355
376
  context: { apiToken: this.getOrgUserApiToken() },
356
377
  });
@@ -364,7 +385,7 @@ class IdentityX {
364
385
  const input = { token };
365
386
  const variables = { input };
366
387
  const user = getAsObject({
367
- ...(token && await this.client.mutate({ mutation: logoutAppUser, variables })),
388
+ ...(token && await this.client.mutate({ mutation: LOG_OUT_APP_USER, variables })),
368
389
  }, 'data.logoutAppUserWithData');
369
390
  tokenCookie.removeFrom(this.res);
370
391
  await callHooksFor(this, 'onLogout', {
@@ -382,7 +403,7 @@ class IdentityX {
382
403
  const [valid, msg] = await this.validateEmail(email);
383
404
  if (!valid) throw new Error(msg || 'The supplied email address cannot be used.');
384
405
  const { data } = await this.client.mutate({
385
- mutation: createAppUser,
406
+ mutation: CREATE_APP_USER,
386
407
  variables: { email },
387
408
  context: { apiToken: this.getOrgUserApiToken() },
388
409
  });
@@ -394,20 +415,75 @@ class IdentityX {
394
415
  */
395
416
  async setAppUserCustomAttributes({ userId, attributes = {}, dispatch = true } = {}) {
396
417
  const { data: { updateOwnAppUserCustomAttributes: user } } = await this.client.mutate({
397
- mutation: setCustomAttributes,
418
+ mutation: SET_CUSTOM_ATTRIBUTES,
398
419
  variables: { input: { id: userId, attributes } },
399
420
  });
400
421
  if (dispatch) await callHooksFor(this, 'onUserProfileUpdate', { req: this.req, user });
401
422
  return user;
402
423
  }
403
424
 
425
+ /**
426
+ * Uses the `setUnverifiedAppUserData` mutation to push data to an app user. If the user is
427
+ * verified, this mutation does nothing. At minimum, the email address must be supplied.
428
+ *
429
+ * @param {object} input
430
+ * @param {string} input.email
431
+ */
432
+ async setUnverifiedAppUserData(input) {
433
+ if (!input.email) throw new Error('No "email" was specified for this operation.');
434
+ await this.client.mutate({
435
+ context: { apiToken: this.getOrgUserApiToken() },
436
+ mutation: SET_UNVERIFIED_DATA,
437
+ variables: { input },
438
+ });
439
+ return true;
440
+ }
441
+
442
+ /**
443
+ * Sets custom boolean answers if the user is not yet verified. If the user is verified, this does
444
+ * nothing.
445
+ *
446
+ * @param {string} email The IdentityX AppUser email
447
+ * @param {CustomBooleanFieldAnswer[]} answers
448
+ */
449
+ async setUnverifiedBooleanFieldAnswers(email, answers) {
450
+ if (answers || !answers.length) return false;
451
+ const appUser = this.loadAppUserByEmail(email);
452
+ if (!appUser || appUser.verified) return false;
453
+ await this.client.mutate({
454
+ context: { apiToken: this.getOrgUserApiToken() },
455
+ mutation: SET_BOOLEAN_FIELD_ANSWERS,
456
+ variables: { input: { id: appUser.id, answers } },
457
+ });
458
+ return true;
459
+ }
460
+
461
+ /**
462
+ * Sets custom select answers if the user is not yet verified. If the user is verified, this does
463
+ * nothing.
464
+ *
465
+ * @param {string} email The IdentityX AppUser email
466
+ * @param {CustomSelectFieldAnswer[]} answers
467
+ */
468
+ async setUnverifiedSelectFieldAnswers(email, answers) {
469
+ if (answers || !answers.length) return false;
470
+ const appUser = this.loadAppUserByEmail(email);
471
+ if (!appUser || appUser.verified) return false;
472
+ await this.client.mutate({
473
+ context: { apiToken: this.getOrgUserApiToken() },
474
+ mutation: SET_SELECT_FIELD_ANSWERS,
475
+ variables: { input: { id: appUser.id, answers } },
476
+ });
477
+ return true;
478
+ }
479
+
404
480
  /**
405
481
  * Sends a change email link to an existing user
406
482
  */
407
483
  async sendChangeEmailLink({ email }) {
408
484
  const authUrl = `${this.req.protocol}://${this.req.get('host')}${this.config.getEndpointFor('changeEmail')}`;
409
485
  await this.client.mutate({
410
- mutation: sendChangeEmailLinkMutation,
486
+ mutation: SEND_CHANGE_EMAIL_LINK,
411
487
  variables: { input: { email, authUrl, appContextId: this.config.get('appContextId') } },
412
488
  });
413
489
  await callHooksFor(this, 'onChangeEmailLinkSent', { email });
@@ -441,7 +517,7 @@ class IdentityX {
441
517
  additionalEventData,
442
518
  }) {
443
519
  await this.client.mutate({
444
- mutation: sendLoginLinkMutation,
520
+ mutation: SEND_LOGIN_LINK,
445
521
  variables: {
446
522
  input: {
447
523
  additionalContext: additionalEventData || {},
@@ -471,7 +547,7 @@ class IdentityX {
471
547
  userId,
472
548
  }) {
473
549
  const { data } = await this.client.mutate({
474
- mutation: deleteAppUserForCurrentApplicationMutation,
550
+ mutation: DELETE_APP_USER,
475
551
  variables: {
476
552
  input: {
477
553
  ...(email && { email }),
@@ -1,25 +1,5 @@
1
1
  /**
2
- * @typedef IdentityXContext
3
- * @prop {IdentityXApp} application
4
- * @prop {IdentityXAppUser|null} user
5
- * @prop {Object[]} mergedTeams
6
- * @prop {Object[]} mergedAccessLevels
7
- * @prop {Boolean} hasTeams
8
- * @prop {Boolean} hasUser
9
- * @prop {Boolean} isEnabled
10
- *
11
- * @typedef IdentityXApp
12
- * @prop {String} id
13
- * @prop {String} name
14
- * @prop {String} consentPolicy
15
- * @prop {String} emailConsentRequest
16
- * @prop {Object[]} regionalConsentPolicies
17
- *
18
- * @typedef IdentityXAppUser
19
- * @prop {String} id
20
- * @prop {String} email
21
- *
22
- * @param {IdentityXContext} context
2
+ * @param {import("..").IdentityXContext} context
23
3
  * @param {String|null} identity
24
4
  */
25
5
  module.exports = (context = {}, identity = null) => {