@mindful-web/marko-web-omeda-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.
- package/.eslintignore +1 -0
- package/LICENSE +21 -0
- package/README.md +86 -0
- package/add-integration-hooks.js +119 -0
- package/api/queries/customer-by-encrypted-id.js +10 -0
- package/browser/.eslintrc.js +1 -0
- package/browser/index.js +43 -0
- package/browser/rapid-identify.vue +34 -0
- package/components/identify.marko +16 -0
- package/components/identify.marko.js +60 -0
- package/components/marko.json +6 -0
- package/external-id/find-encrypted-customer-id.js +10 -0
- package/external-id/get-encrypted-customer-id.js +7 -0
- package/external-id/get-omeda-namespaces.js +16 -0
- package/external-id/is-demographic-id.js +8 -0
- package/external-id/is-deployment-type-id.js +8 -0
- package/external-id/is-encrypted-customer-id.js +10 -0
- package/external-id/is-omeda-namespace.js +18 -0
- package/external-id/is-product-id.js +8 -0
- package/index.js +261 -0
- package/integration-hooks/index.js +9 -0
- package/integration-hooks/on-authentication-success.js +59 -0
- package/integration-hooks/on-login-link-sent.js +106 -0
- package/integration-hooks/on-user-profile-update.js +54 -0
- package/marko.json +6 -0
- package/middleware/README.md +12 -0
- package/middleware/rapid-identify.js +56 -0
- package/middleware/resync-customer-data.js +69 -0
- package/middleware/set-identity-cookie.js +77 -0
- package/middleware/set-olytics-cookie.js +25 -0
- package/middleware/set-promo-source.js +20 -0
- package/middleware/strip-olytics-param.js +23 -0
- package/omeda-data/get-answered-question-map.js +19 -0
- package/omeda-data/get-omeda-customer-record.js +46 -0
- package/omeda-data/get-omeda-linked-fields.js +66 -0
- package/omeda-data/index.js +19 -0
- package/omeda-data/set-omeda-data.js +35 -0
- package/omeda-data/set-omeda-demographics.js +137 -0
- package/omeda-data/set-omeda-deployment-types.js +51 -0
- package/omeda-data/set-omeda-products.js +50 -0
- package/omeda-data/update-identity-x.js +68 -0
- package/package.json +33 -0
- package/rapid-identify.js +194 -0
- package/routes/rapid-identify.js +70 -0
- package/utils/append-data.js +24 -0
- package/utils/build-behavior.js +32 -0
- package/utils/extract-promo-code.js +8 -0
- package/utils/get-cookie-id.js +11 -0
- package/utils/resync-cookie.js +25 -0
- package/validation/props.js +20 -0
- package/validation/schemas/append-behavior.js +7 -0
- package/validation/schemas/append-demographic.js +8 -0
- package/validation/schemas/append-promo-code.js +5 -0
- package/validation/schemas/behavior.js +7 -0
- package/validation/schemas/hook-behavior.js +12 -0
- package/validation/schemas/hook-demographic.js +16 -0
- package/validation/schemas/hook-promo-code.js +12 -0
- package/validation/schemas/index.js +19 -0
- package/validation/schemas/should-await.js +7 -0
package/.eslintignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.marko.js
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Parameter1 LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Mindful Web Marko Omeda+IdentityX Integrations
|
|
2
|
+
Omeda+IdentityX components for Mindful Web/Marko websites.
|
|
3
|
+
|
|
4
|
+
Based on the identity provider(s) in use, install and configure ***only one*** of these packages. *The other packages can be installed separately if needed, but this package should be the only one configured.*
|
|
5
|
+
|
|
6
|
+
1. [omeda-identity-x](../marko-web-omeda-identity-x): For sites with both Omeda and IdentityX.
|
|
7
|
+
2. [omeda](../marko-web-omeda): For sites with Omeda, but **without** IdentityX.
|
|
8
|
+
3. [identity-x](../marko-web-identity-x): For sites with IdentityX, but **without** Omeda.
|
|
9
|
+
|
|
10
|
+
Additional information can be found in the [Omeda](https://training.omeda.com/knowledge-base/api-overview/) and [IdentityX](https://docs.parameter1.com/identity-x) API documentation.
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
All configuration data must be passed to the middleware when loaded (See [Middleware Setup](#1-middleware-setup) below.)
|
|
14
|
+
|
|
15
|
+
| Property | Required? | Description | Default value |
|
|
16
|
+
| - | - | - | - |
|
|
17
|
+
| `brandKey` | **Yes** | The Omeda Brand key (such as `orgcd`).
|
|
18
|
+
| `clientKey` | No | The Omeda client key (such as `client_orgc`.) *Required if sending deployment optIns via the underlying omeda package!* [marko-web-omeda docs](../marko-web-omeda)
|
|
19
|
+
| `appId` | **Yes** | The Omeda application API read token
|
|
20
|
+
| `inputId` | **Yes** | The Omeda application API write token
|
|
21
|
+
| `rapidIdentProductId` | **Yes** | The Omeda identifier for a Website product (ProductType=7).
|
|
22
|
+
| `idxConfig` | **Yes** | An instance of the IdentityX configuration class (see [marko-web-identity-x#1](../marko-web-identity-x/config.js)) | _n/a_
|
|
23
|
+
| `idxRouteTemplates` | **Yes** | An object containing the Marko templates to use for each IdentityX endpoint. (see [marko-web-identity-x#2](../marko-web-identity-x/index.js))
|
|
24
|
+
| `omedaPromoCodeCookieName` | No | The name of the cookie to look for a persisted/original promo code. | `omeda_promo_code` |
|
|
25
|
+
| `omedaPromoCodeDefault` | No | The default promo code to send with all Omeda requests. Falls back to input ID default configured by Omeda. |
|
|
26
|
+
| `idxOmedaRapidIdentifyProp` | No | The property (in the express app context) where the O+IdX rapid identification service is located. | `$idxOmedaRapidIdentify` |
|
|
27
|
+
| `omedaGraphQLClientProp` | No | The property (in the express app context) where the Omeda GraphQL client is located. | `$omedaGraphQLClient` |
|
|
28
|
+
| `omedaRapidIdentifyProp` | No | The property (in the express app context) where the Omeda rapid identification service is located. | `$omedaRapidIdentify` |
|
|
29
|
+
| `appendBehaviorToHook` | No | An array of objects defining behaviors to append to rapid identification calls.
|
|
30
|
+
| `appendBehaviorToHook[].hook` | | The name of the hook, such as `onLoginLinkSent`
|
|
31
|
+
| `appendBehaviorToHook[].behaviorId` || The Omeda Behavior ID to append to the rapid identification call.
|
|
32
|
+
| `appendDemographicToHook` | No | An array of objects defining demographics to append to rapid identification calls.
|
|
33
|
+
| `appendDemographicToHook[].hook` | | The name of the hook, such as `onLoginLinkSent`
|
|
34
|
+
| `appendDemographicToHook[].demographicId` || The Omeda Demographic ID to append.
|
|
35
|
+
| `appendDemographicToHook[].valueIds` || An array of Omeda Demographic Value IDs (`Int`s) to append
|
|
36
|
+
| `appendDemographicToHook[].writeInValue` || A string to include as an OEC/Other value
|
|
37
|
+
| `appendPromoCodeToHook` | No | An array of objects defining demographics to append to rapid identification calls.
|
|
38
|
+
| `appendPromoCodeToHook[].hook` | | The name of the hook, such as `onLoginLinkSent`
|
|
39
|
+
| `appendPromoCodeToHook[].promoCode` || The Omeda Promo Code (`String`) to append.
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
This package:
|
|
43
|
+
1. Configures the underlying [omeda](../marko-web-omeda) and [identity-x](../marko-web-identity-x) packages
|
|
44
|
+
2. Hooks into the IdentityX library to push Omeda data to IdX and push IdX data to Omeda when profile updates happen
|
|
45
|
+
3. Makes the rapid identification endpoint (`/__idx/omeda-rapid-ident`) available on a mindful-web website
|
|
46
|
+
4. (Optional) Provides a Vue component to call the rapid identification endpoint
|
|
47
|
+
|
|
48
|
+
### 1. Middleware Setup
|
|
49
|
+
To make the local omeda mountpoint available, load the middleware exported by this package. For most applications, this will be done in the `startServer` function passed to the marko-web package.
|
|
50
|
+
|
|
51
|
+
See config section above and the Omeda and IdentityX package documentation for available configurations.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const handler = require('@mindful-web/marko-web-omeda-identity-x');
|
|
55
|
+
const omedaConfig = require('./config/omeda');
|
|
56
|
+
const idXConfig = require('./config/identity-x');
|
|
57
|
+
const idxRouteTemplates = require('./templates/user');
|
|
58
|
+
|
|
59
|
+
startServer({
|
|
60
|
+
onStart: async (app) => {
|
|
61
|
+
handler(app, {
|
|
62
|
+
...omedaConfig,
|
|
63
|
+
idxConfig,
|
|
64
|
+
idxRouteTemplates,
|
|
65
|
+
})
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
It can also be loaded as a standard Express route middleware.
|
|
71
|
+
```js
|
|
72
|
+
module.exports = (app) => {
|
|
73
|
+
handler(app, { ...omedaConfig, idxConfig, idxRouteTemplates });
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Rapid Identification
|
|
78
|
+
|
|
79
|
+
To use the Rapid Identification hook, load the Vue component in your Browser config. When enabled, the Omeda Rapid Identification API will be called automatically when the `oly_enc_id` URL query parameter is present.
|
|
80
|
+
```js
|
|
81
|
+
import OmedaIdentityX from '@mindful-web/marko-web-omeda-identity-x/browser';
|
|
82
|
+
|
|
83
|
+
export default (Browser) => {
|
|
84
|
+
OmedaIdentityX(Browser);
|
|
85
|
+
};
|
|
86
|
+
```
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const Joi = require('@parameter1/joi');
|
|
2
|
+
const { validate } = require('@parameter1/joi/utils');
|
|
3
|
+
const { get } = require('@mindful-web/object-path');
|
|
4
|
+
const appendDataFactory = require('./utils/append-data');
|
|
5
|
+
const behaviorFactory = require('./utils/build-behavior');
|
|
6
|
+
const schemas = require('./validation/schemas');
|
|
7
|
+
const props = require('./validation/props');
|
|
8
|
+
const {
|
|
9
|
+
onAuthenticationSuccess,
|
|
10
|
+
onLoginLinkSent,
|
|
11
|
+
onUserProfileUpdate,
|
|
12
|
+
} = require('./integration-hooks');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {object} params
|
|
17
|
+
* @param {IdentityXConfiguration} params.idxConfig
|
|
18
|
+
*/
|
|
19
|
+
module.exports = (params = {}) => {
|
|
20
|
+
const {
|
|
21
|
+
appendBehaviorToHook,
|
|
22
|
+
appendDemographicToHook,
|
|
23
|
+
appendPromoCodeToHook,
|
|
24
|
+
behaviors,
|
|
25
|
+
behaviorAttributes,
|
|
26
|
+
idxConfig,
|
|
27
|
+
brandKey,
|
|
28
|
+
omedaGraphQLClientProp,
|
|
29
|
+
idxOmedaRapidIdentifyProp,
|
|
30
|
+
omedaPromoCodeCookieName,
|
|
31
|
+
omedaPromoCodeDefault,
|
|
32
|
+
shouldAwait,
|
|
33
|
+
onLoginLinkSentFormatter,
|
|
34
|
+
onAuthenticationSuccessFormatter,
|
|
35
|
+
onUserProfileUpdateFormatter,
|
|
36
|
+
} = validate(Joi.object({
|
|
37
|
+
appendBehaviorToHook: Joi.array().items(schemas.hookBehavior).default([]),
|
|
38
|
+
appendDemographicToHook: Joi.array().items(schemas.hookDemographic).default([]),
|
|
39
|
+
appendPromoCodeToHook: Joi.array().items(schemas.hookPromoCode).default([]),
|
|
40
|
+
behaviors: Joi.object().required(),
|
|
41
|
+
behaviorAttributes: Joi.object().required(),
|
|
42
|
+
brandKey: props.brandKey.required(),
|
|
43
|
+
idxConfig: props.idxConfig.required(),
|
|
44
|
+
idxOmedaRapidIdentifyProp: Joi.string().required(),
|
|
45
|
+
omedaGraphQLClientProp: Joi.string().required(),
|
|
46
|
+
omedaPromoCodeCookieName: Joi.string().required(),
|
|
47
|
+
omedaPromoCodeDefault: Joi.string(),
|
|
48
|
+
shouldAwait: schemas.shouldAwait,
|
|
49
|
+
onLoginLinkSentFormatter: Joi.function().required(),
|
|
50
|
+
onAuthenticationSuccessFormatter: Joi.function().required(),
|
|
51
|
+
onUserProfileUpdateFormatter: Joi.function().required(),
|
|
52
|
+
}), params);
|
|
53
|
+
|
|
54
|
+
const buildBehaviorFor = behaviorFactory({ behaviors, behaviorAttributes });
|
|
55
|
+
const appendDataFor = appendDataFactory({
|
|
56
|
+
behaviors: appendBehaviorToHook,
|
|
57
|
+
demographics: appendDemographicToHook,
|
|
58
|
+
promoCodes: appendPromoCodeToHook,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
idxConfig.addHook({
|
|
62
|
+
name: 'onLoginLinkSent',
|
|
63
|
+
shouldAwait: shouldAwait.onLoginLinkSent,
|
|
64
|
+
fn: async (args) => onLoginLinkSent({
|
|
65
|
+
...args,
|
|
66
|
+
brandKey,
|
|
67
|
+
idxOmedaRapidIdentify: get(args, `req.${idxOmedaRapidIdentifyProp}`),
|
|
68
|
+
omedaGraphQLClient: get(args, `req.${omedaGraphQLClientProp}`),
|
|
69
|
+
omedaPromoCodeCookieName,
|
|
70
|
+
omedaPromoCodeDefault,
|
|
71
|
+
formatter: onLoginLinkSentFormatter,
|
|
72
|
+
...appendDataFor('onLoginLinkSent'),
|
|
73
|
+
behavior: buildBehaviorFor('onLoginLinkSent', {
|
|
74
|
+
actionSource: get(args, 'actionSource'),
|
|
75
|
+
newsletterSignupType: get(args, 'newsletterSignupType'),
|
|
76
|
+
contentGateType: get(args, 'contentGateType'),
|
|
77
|
+
}),
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
idxConfig.addHook({
|
|
82
|
+
name: 'onAuthenticationSuccess',
|
|
83
|
+
shouldAwait: shouldAwait.onAuthenticationSuccess,
|
|
84
|
+
fn: async (args) => onAuthenticationSuccess({
|
|
85
|
+
...args,
|
|
86
|
+
brandKey,
|
|
87
|
+
idxOmedaRapidIdentify: get(args, `req.${idxOmedaRapidIdentifyProp}`),
|
|
88
|
+
omedaPromoCodeCookieName,
|
|
89
|
+
omedaPromoCodeDefault,
|
|
90
|
+
formatter: onAuthenticationSuccessFormatter,
|
|
91
|
+
...appendDataFor('onAuthenticationSuccess'),
|
|
92
|
+
behavior: buildBehaviorFor('onAuthenticationSuccess', {
|
|
93
|
+
actionSource: get(args, 'actionSource'),
|
|
94
|
+
newsletterSignupType: get(args, 'newsletterSignupType'),
|
|
95
|
+
contentGateType: get(args, 'contentGateType'),
|
|
96
|
+
}),
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
idxConfig.addHook({
|
|
101
|
+
name: 'onUserProfileUpdate',
|
|
102
|
+
shouldAwait: shouldAwait.onUserProfileUpdate,
|
|
103
|
+
fn: async (args) => onUserProfileUpdate({
|
|
104
|
+
...args,
|
|
105
|
+
idxOmedaRapidIdentify: get(args, `req.${idxOmedaRapidIdentifyProp}`),
|
|
106
|
+
omedaPromoCodeCookieName,
|
|
107
|
+
omedaPromoCodeDefault,
|
|
108
|
+
formatter: onUserProfileUpdateFormatter,
|
|
109
|
+
...appendDataFor('onUserProfileUpdate'),
|
|
110
|
+
behavior: buildBehaviorFor('onUserProfileUpdate', {
|
|
111
|
+
actionSource: get(args, 'actionSource'),
|
|
112
|
+
newsletterSignupType: get(args, 'newsletterSignupType'),
|
|
113
|
+
contentGateType: get(args, 'contentGateType'),
|
|
114
|
+
}),
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return idxConfig;
|
|
119
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../../eslintrc.browser');
|
package/browser/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import IdentityX from '@mindful-web/marko-web-identity-x/browser';
|
|
2
|
+
|
|
3
|
+
const RapidIdentify = () => import(/* webpackChunkName: "omeda-identity-x-rapid-identify" */ './rapid-identify.vue');
|
|
4
|
+
|
|
5
|
+
export default (Browser, idxArgs = {}) => {
|
|
6
|
+
IdentityX(Browser, idxArgs);
|
|
7
|
+
|
|
8
|
+
const { EventBus } = Browser;
|
|
9
|
+
EventBus.$on('identity-x-authenticated', (args = {}) => {
|
|
10
|
+
const { user = {} } = args;
|
|
11
|
+
const externalIds = user.externalIds || [];
|
|
12
|
+
const eid = externalIds.find((external) => {
|
|
13
|
+
if (!external || !external.namespace || !external.identifier) return false;
|
|
14
|
+
const { namespace, identifier } = external;
|
|
15
|
+
return namespace.provider === 'omeda'
|
|
16
|
+
&& namespace.tenant
|
|
17
|
+
&& namespace.type === 'customer'
|
|
18
|
+
&& identifier.type === 'encrypted'
|
|
19
|
+
&& identifier.value;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const encryptedId = eid ? eid.identifier.value : null;
|
|
23
|
+
const brandKey = eid ? eid.namespace.tenant : null;
|
|
24
|
+
EventBus.$emit('omeda-identity-x-authenticated', {
|
|
25
|
+
...args,
|
|
26
|
+
user,
|
|
27
|
+
eid,
|
|
28
|
+
brandKey,
|
|
29
|
+
encryptedId,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Browser.register('OmedaIdentityXRapidIdentify', RapidIdentify, {
|
|
34
|
+
on: {
|
|
35
|
+
'encrypted-id-found': (...args) => {
|
|
36
|
+
EventBus.$emit('omeda-identity-x-rapid-identify-encrypted-id-found', ...args);
|
|
37
|
+
},
|
|
38
|
+
response: (...args) => {
|
|
39
|
+
EventBus.$emit('omeda-identity-x-rapid-identify-response', ...args);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="omeda-rapid-identity-x" style="display: none;" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
const { error } = console;
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
props: {
|
|
10
|
+
endpoint: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: '/__idx/omeda-rapid-ident',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
created() {
|
|
17
|
+
this.rapidIdentify();
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
methods: {
|
|
21
|
+
async rapidIdentify() {
|
|
22
|
+
try {
|
|
23
|
+
const res = await fetch(this.endpoint, { method: 'GET' });
|
|
24
|
+
const json = await res.json();
|
|
25
|
+
const { encryptedId } = json;
|
|
26
|
+
if (encryptedId) this.$emit('encrypted-id-found', encryptedId);
|
|
27
|
+
this.$emit('response', json);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
error('IdentityX to Omeda identification failed.', e);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import getCookieId from "@mindful-web/marko-web-omeda-identity-x/utils/get-cookie-id";
|
|
2
|
+
import { getResponseCookies } from "@mindful-web/utils";
|
|
3
|
+
|
|
4
|
+
$ const { req, res } = out.global;
|
|
5
|
+
$ const { identityX } = req;
|
|
6
|
+
$ const cookies = { ...req.cookies, ...getResponseCookies(res) };
|
|
7
|
+
$ const olyEncId = cookies.oly_enc_id ? getCookieId(cookies.oly_enc_id, 'enc') : undefined;
|
|
8
|
+
$ const olyAnonId = cookies.oly_anon_id ? getCookieId(cookies.oly_anon_id, 'anon') : undefined;
|
|
9
|
+
|
|
10
|
+
<if(Boolean(identityX))>
|
|
11
|
+
<marko-web-resolve|{ resolved: user }| promise=identityX.getIdentityData()>
|
|
12
|
+
<if(user || olyEncId || olyAnonId)>
|
|
13
|
+
<marko-web-identity-x-identify provider-data={ oly_enc_id: olyEncId, oly_anon_id: olyAnonId } />
|
|
14
|
+
</if>
|
|
15
|
+
</marko-web-resolve>
|
|
16
|
+
</if>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Compiled using marko@4.20.2 - DO NOT EDIT
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-omeda-identity-x$1.0.0/components/identify.marko",
|
|
6
|
+
marko_component = require("./identify.marko"),
|
|
7
|
+
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
+
module_getCookieId = require("@mindful-web/marko-web-omeda-identity-x/utils/get-cookie-id"),
|
|
9
|
+
getCookieId = module_getCookieId.default || module_getCookieId,
|
|
10
|
+
module_utils_module = require("@mindful-web/utils"),
|
|
11
|
+
utils_module = module_utils_module.default || module_utils_module,
|
|
12
|
+
getResponseCookies = module_utils_module.getResponseCookies,
|
|
13
|
+
marko_web_identity_x_identify_template = require("@mindful-web/marko-web-identity-x/components/identify.marko"),
|
|
14
|
+
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
15
|
+
marko_web_identity_x_identify_tag = marko_loadTag(marko_web_identity_x_identify_template),
|
|
16
|
+
marko_web_resolve_template = require("@mindful-web/marko-core/components/resolve.marko"),
|
|
17
|
+
marko_web_resolve_tag = marko_loadTag(marko_web_resolve_template);
|
|
18
|
+
|
|
19
|
+
function render(input, out, __component, component, state) {
|
|
20
|
+
var data = input;
|
|
21
|
+
|
|
22
|
+
const { req, res } = out.global;
|
|
23
|
+
|
|
24
|
+
const { identityX } = req;
|
|
25
|
+
|
|
26
|
+
const cookies = { ...req.cookies, ...getResponseCookies(res) };
|
|
27
|
+
|
|
28
|
+
const olyEncId = cookies.oly_enc_id ? getCookieId(cookies.oly_enc_id, 'enc') : undefined;
|
|
29
|
+
|
|
30
|
+
const olyAnonId = cookies.oly_anon_id ? getCookieId(cookies.oly_anon_id, 'anon') : undefined;
|
|
31
|
+
|
|
32
|
+
if (Boolean(identityX)) {
|
|
33
|
+
marko_web_resolve_tag({
|
|
34
|
+
promise: identityX.getIdentityData(),
|
|
35
|
+
renderBody: function(out, { resolved: user }) {
|
|
36
|
+
if ((user || olyEncId) || olyAnonId) {
|
|
37
|
+
marko_web_identity_x_identify_tag({
|
|
38
|
+
providerData: {
|
|
39
|
+
oly_enc_id: olyEncId,
|
|
40
|
+
oly_anon_id: olyAnonId
|
|
41
|
+
}
|
|
42
|
+
}, out, __component, "1");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, out, __component, "0");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
marko_template._ = marko_renderer(render, {
|
|
50
|
+
e_: marko_componentType
|
|
51
|
+
}, marko_component);
|
|
52
|
+
|
|
53
|
+
marko_template.meta = {
|
|
54
|
+
id: "/@mindful-web/marko-web-omeda-identity-x$1.0.0/components/identify.marko",
|
|
55
|
+
component: "./identify.marko",
|
|
56
|
+
tags: [
|
|
57
|
+
"@mindful-web/marko-web-identity-x/components/identify.marko",
|
|
58
|
+
"@mindful-web/marko-core/components/resolve.marko"
|
|
59
|
+
]
|
|
60
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { asArray } = require('@mindful-web/utils');
|
|
2
|
+
const getEncryptedId = require('./get-encrypted-customer-id');
|
|
3
|
+
|
|
4
|
+
module.exports = ({ externalIds, brandKey } = {}) => {
|
|
5
|
+
const eid = asArray(externalIds).find((externalId) => getEncryptedId({
|
|
6
|
+
externalId,
|
|
7
|
+
brandKey,
|
|
8
|
+
}));
|
|
9
|
+
return eid ? eid.identifier.value : null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const olyticsCookie = require('@mindful-web/marko-web-omeda/olytics/customer-cookie');
|
|
2
|
+
const isEncryptedId = require('./is-encrypted-customer-id');
|
|
3
|
+
|
|
4
|
+
module.exports = ({ externalId, brandKey } = {}) => {
|
|
5
|
+
if (!isEncryptedId({ externalId, brandKey })) return null;
|
|
6
|
+
return olyticsCookie.clean(externalId.identifier.value);
|
|
7
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { asArray } = require('@mindful-web/utils');
|
|
2
|
+
const isOmedaNamespace = require('./is-omeda-namespace');
|
|
3
|
+
|
|
4
|
+
module.exports = ({
|
|
5
|
+
externalIds = [],
|
|
6
|
+
brandKey,
|
|
7
|
+
type,
|
|
8
|
+
idType,
|
|
9
|
+
valueMatcher,
|
|
10
|
+
} = {}) => asArray(externalIds.filter((externalId) => isOmedaNamespace({
|
|
11
|
+
externalId,
|
|
12
|
+
brandKey,
|
|
13
|
+
type,
|
|
14
|
+
idType,
|
|
15
|
+
valueMatcher,
|
|
16
|
+
})));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const olyticsCookie = require('@mindful-web/marko-web-omeda/olytics/customer-cookie');
|
|
2
|
+
const isOmedaNamespace = require('./is-omeda-namespace');
|
|
3
|
+
|
|
4
|
+
module.exports = ({ externalId, brandKey } = {}) => isOmedaNamespace({
|
|
5
|
+
externalId,
|
|
6
|
+
brandKey,
|
|
7
|
+
type: 'customer',
|
|
8
|
+
idType: 'encrypted',
|
|
9
|
+
valueMatcher: (id) => olyticsCookie.clean(id),
|
|
10
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { isFunction: isFn } = require('@mindful-web/utils');
|
|
2
|
+
|
|
3
|
+
module.exports = ({
|
|
4
|
+
externalId,
|
|
5
|
+
brandKey,
|
|
6
|
+
type,
|
|
7
|
+
idType,
|
|
8
|
+
valueMatcher,
|
|
9
|
+
} = {}) => {
|
|
10
|
+
if (!externalId) return false;
|
|
11
|
+
const { namespace, identifier } = externalId;
|
|
12
|
+
return namespace.provider === 'omeda'
|
|
13
|
+
&& namespace.tenant === brandKey.toLowerCase()
|
|
14
|
+
&& (type ? namespace.type === type : true)
|
|
15
|
+
&& identifier.value
|
|
16
|
+
&& (idType ? identifier.type === idType : true)
|
|
17
|
+
&& (isFn(valueMatcher) ? valueMatcher(identifier.value) : true);
|
|
18
|
+
};
|