@mindful-web/marko-web-identity-x 1.0.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.
Files changed (138) hide show
  1. package/.eslintignore +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +200 -0
  4. package/api/fragment-types.json +1 -0
  5. package/api/fragments/active-user.js +108 -0
  6. package/api/mutations/add-external-user-id.js +24 -0
  7. package/api/mutations/create-app-user.js +11 -0
  8. package/api/mutations/delete-app-user-for-current-application.js +7 -0
  9. package/api/mutations/impersonate-app-user.js +12 -0
  10. package/api/mutations/logout-app-user.js +11 -0
  11. package/api/mutations/send-change-email-link.js +7 -0
  12. package/api/mutations/send-login-link.js +7 -0
  13. package/api/mutations/set-custom-attributes.js +15 -0
  14. package/api/queries/check-content-access.js +19 -0
  15. package/api/queries/get-active-context.js +45 -0
  16. package/api/queries/load-user-by-external-id.js +14 -0
  17. package/api/queries/load-user-by-id.js +11 -0
  18. package/api/queries/load-user.js +11 -0
  19. package/browser/.eslintrc.js +11 -0
  20. package/browser/access.vue +377 -0
  21. package/browser/authenticate.vue +278 -0
  22. package/browser/change-email-confirm.vue +120 -0
  23. package/browser/change-email-init.vue +179 -0
  24. package/browser/comments/create.vue +107 -0
  25. package/browser/comments/post.vue +151 -0
  26. package/browser/comments/stream.vue +319 -0
  27. package/browser/custom-column.vue +314 -0
  28. package/browser/dayjs.js +6 -0
  29. package/browser/download-related.vue +120 -0
  30. package/browser/download.vue +380 -0
  31. package/browser/errors/authentication.js +7 -0
  32. package/browser/errors/feature.js +7 -0
  33. package/browser/errors/form.js +7 -0
  34. package/browser/errors/logout.js +7 -0
  35. package/browser/form/address-block.vue +131 -0
  36. package/browser/form/common/checkbox-group.vue +140 -0
  37. package/browser/form/common/form-group.vue +24 -0
  38. package/browser/form/common/form-label.vue +17 -0
  39. package/browser/form/consent.vue +121 -0
  40. package/browser/form/fields/address-extra.vue +68 -0
  41. package/browser/form/fields/city.vue +68 -0
  42. package/browser/form/fields/comment-body.vue +63 -0
  43. package/browser/form/fields/country.vue +94 -0
  44. package/browser/form/fields/custom-boolean.vue +58 -0
  45. package/browser/form/fields/custom-select-group.vue +25 -0
  46. package/browser/form/fields/custom-select-multiple.vue +97 -0
  47. package/browser/form/fields/custom-select-write-in-inline.vue +39 -0
  48. package/browser/form/fields/custom-select-write-in.vue +66 -0
  49. package/browser/form/fields/custom-select.vue +191 -0
  50. package/browser/form/fields/custom-text.vue +62 -0
  51. package/browser/form/fields/display-name.vue +64 -0
  52. package/browser/form/fields/email.vue +62 -0
  53. package/browser/form/fields/family-name.vue +68 -0
  54. package/browser/form/fields/given-name.vue +68 -0
  55. package/browser/form/fields/organization-title.vue +68 -0
  56. package/browser/form/fields/organization.vue +68 -0
  57. package/browser/form/fields/phone-number.vue +68 -0
  58. package/browser/form/fields/postal-code.vue +68 -0
  59. package/browser/form/fields/receive-email.vue +58 -0
  60. package/browser/form/fields/region.vue +106 -0
  61. package/browser/form/fields/regional-policy.vue +59 -0
  62. package/browser/form/fields/street.vue +68 -0
  63. package/browser/graphql/create-client.js +65 -0
  64. package/browser/graphql/parse.js +1 -0
  65. package/browser/graphql/queries/download-related-content.js +38 -0
  66. package/browser/index.js +110 -0
  67. package/browser/login-fields.vue +214 -0
  68. package/browser/login.vue +331 -0
  69. package/browser/logout.vue +68 -0
  70. package/browser/mixins/global-auto-signup-event-emitter.js +18 -0
  71. package/browser/mixins/global-event-emitter.js +28 -0
  72. package/browser/profile.vue +688 -0
  73. package/browser/service.js +32 -0
  74. package/browser/utils/clean-path.js +1 -0
  75. package/browser/utils/cookies-enabled.js +10 -0
  76. package/browser/utils/get-as-array.js +6 -0
  77. package/browser/utils/get-referring-page.js +7 -0
  78. package/browser/utils/get.js +8 -0
  79. package/browser/utils/post.js +10 -0
  80. package/browser/utils/redirect.js +7 -0
  81. package/browser/utils/region-country-codes.js +1 -0
  82. package/components/access.marko +24 -0
  83. package/components/access.marko.js +61 -0
  84. package/components/comment-stream.marko +31 -0
  85. package/components/comment-stream.marko.js +71 -0
  86. package/components/context.marko +15 -0
  87. package/components/context.marko.js +52 -0
  88. package/components/form-access.marko +60 -0
  89. package/components/form-access.marko.js +111 -0
  90. package/components/form-authenticate.marko +32 -0
  91. package/components/form-authenticate.marko.js +73 -0
  92. package/components/form-change-email.marko +27 -0
  93. package/components/form-change-email.marko.js +68 -0
  94. package/components/form-login.marko +32 -0
  95. package/components/form-login.marko.js +72 -0
  96. package/components/form-logout.marko +7 -0
  97. package/components/form-logout.marko.js +36 -0
  98. package/components/form-profile.marko +38 -0
  99. package/components/form-profile.marko.js +78 -0
  100. package/components/form-register.marko +2 -0
  101. package/components/form-register.marko.js +32 -0
  102. package/components/identify.marko +17 -0
  103. package/components/identify.marko.js +59 -0
  104. package/components/marko.json +90 -0
  105. package/components/non-auth-identify.marko +15 -0
  106. package/components/non-auth-identify.marko.js +53 -0
  107. package/config.js +161 -0
  108. package/hooks.js +20 -0
  109. package/index.js +30 -0
  110. package/marko.json +6 -0
  111. package/middleware/content-access-state.js +31 -0
  112. package/middleware/content-download-state.js +27 -0
  113. package/middleware.js +32 -0
  114. package/package.json +40 -0
  115. package/routes/access.js +29 -0
  116. package/routes/authenticate.js +58 -0
  117. package/routes/change-email-confirm.js +60 -0
  118. package/routes/change-email-init.js +16 -0
  119. package/routes/comment-count.js +19 -0
  120. package/routes/comments.js +43 -0
  121. package/routes/countries.js +19 -0
  122. package/routes/create-comment.js +25 -0
  123. package/routes/download.js +29 -0
  124. package/routes/flag-comment.js +21 -0
  125. package/routes/index.js +40 -0
  126. package/routes/login-fields.js +35 -0
  127. package/routes/login.js +95 -0
  128. package/routes/logout.js +19 -0
  129. package/routes/profile.js +183 -0
  130. package/routes/regions.js +22 -0
  131. package/service.js +483 -0
  132. package/utils/call-hooks-for.js +28 -0
  133. package/utils/context-cookie.js +30 -0
  134. package/utils/create-client.js +48 -0
  135. package/utils/create-identity-builder.js +33 -0
  136. package/utils/get-as-array.js +6 -0
  137. package/utils/json-error-handler.js +41 -0
  138. package/utils/token-cookie.js +30 -0
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <div v-if="error">
3
+ <p>{{ error }}</p>
4
+ </div>
5
+ <div v-else>
6
+ <p>Logging out...</p>
7
+ </div>
8
+ </template>
9
+
10
+ <script>
11
+ import redirect from './utils/redirect';
12
+ import getReferringPage from './utils/get-referring-page';
13
+ import cookiesEnabled from './utils/cookies-enabled';
14
+ import post from './utils/post';
15
+ import LogoutError from './errors/logout';
16
+ import FeatureError from './errors/feature';
17
+ import EventEmitter from './mixins/global-event-emitter';
18
+
19
+ export default {
20
+ /**
21
+ *
22
+ */
23
+ mixins: [EventEmitter],
24
+
25
+ props: {
26
+ redirectTo: {
27
+ type: String,
28
+ default: null,
29
+ },
30
+ },
31
+ data: () => ({
32
+ error: null,
33
+ }),
34
+ mounted() {
35
+ if (cookiesEnabled()) {
36
+ this.emit('logout-mounted');
37
+ this.logout();
38
+ } else {
39
+ const error = new FeatureError('Your browser does not support cookies. Please enable cookies to use this feature.');
40
+ this.error = error.message;
41
+ this.emit('logout-errored', { message: error.message });
42
+ }
43
+ },
44
+ methods: {
45
+ /**
46
+ *
47
+ */
48
+ async logout() {
49
+ this.error = null;
50
+ try {
51
+ const res = await post('/logout');
52
+ const data = await res.json();
53
+ if (!res.ok) throw new LogoutError(data.message, res.status);
54
+ this.emit('logout-submitted', { data });
55
+ this.redirect();
56
+ } catch (e) {
57
+ this.error = `Unable to logout: ${e.message}`;
58
+ this.emit('logout-errored', { message: e.message });
59
+ }
60
+ },
61
+
62
+ redirect() {
63
+ const to = this.redirectTo ? this.redirectTo : getReferringPage();
64
+ redirect(to);
65
+ },
66
+ },
67
+ };
68
+ </script>
@@ -0,0 +1,18 @@
1
+ import getAsArray from '../../utils/get-as-array';
2
+
3
+ export default {
4
+ inject: ['EventBus'],
5
+ methods: {
6
+ emitAutoSignup(data) {
7
+ const { EventBus } = this;
8
+ // See if there are any autoSignups added to the additionalEventData
9
+ // Trigger related autoSignup events for each productId being applied.
10
+ const autoSignups = getAsArray(data, 'additionalEventData.autoSignups');
11
+ if (autoSignups && autoSignups.length) {
12
+ autoSignups.forEach((autoSignup) => {
13
+ EventBus.$emit('identity-x-auto-signup', autoSignup);
14
+ });
15
+ }
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,28 @@
1
+ export default {
2
+ inject: ['EventBus'],
3
+ props: {
4
+ additionalEventData: {
5
+ type: Object,
6
+ default: () => ({}),
7
+ },
8
+ },
9
+ methods: {
10
+ emit(name, data, entity) {
11
+ const source = this.loginSource || this.source;
12
+ const dataActionSource = data ? data.actionSource : undefined;
13
+ const actionSource = dataActionSource || window.IdentityX.getLoginSource() || source;
14
+ const payload = {
15
+ ...data,
16
+ ...this.additionalEventData,
17
+ additionalEventData: this.additionalEventData,
18
+ actionSource,
19
+ loginSource: actionSource,
20
+ source: actionSource,
21
+ entity,
22
+ };
23
+ const { EventBus } = this;
24
+ this.$emit(name, payload);
25
+ EventBus.$emit(`identity-x-${name}`, payload);
26
+ },
27
+ },
28
+ };