@adobe/alloy 2.14.0-alpha.0 → 2.14.0-alpha.10
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/libEs5/components/Context/injectPlaceContext.js +6 -3
- package/libEs5/components/DataCollector/index.js +28 -9
- package/libEs5/components/DataCollector/validateUserEventOptions.js +6 -1
- package/libEs5/components/Identity/appendIdentityToUrl/appendIdentityToUrlOptionsValidator.js +4 -1
- package/libEs5/components/Identity/createComponent.js +2 -2
- package/libEs5/components/Identity/getIdentity/createGetIdentity.js +11 -3
- package/libEs5/components/Identity/getIdentity/getIdentityOptionsValidator.js +8 -11
- package/libEs5/components/Identity/index.js +8 -4
- package/libEs5/components/Personalization/constants/surface.js +23 -0
- package/libEs5/components/Personalization/createComponent.js +8 -2
- package/libEs5/components/Personalization/createGetPageLocation.js +23 -0
- package/libEs5/components/Personalization/createPersonalizationDetails.js +44 -10
- package/libEs5/components/Personalization/groupDecisions.js +3 -3
- package/libEs5/components/Personalization/index.js +6 -0
- package/libEs5/components/Personalization/utils/isPageWideScope.js +24 -0
- package/libEs5/components/Personalization/utils/surfaceUtils.js +128 -0
- package/libEs5/components/Privacy/createComponent.js +4 -2
- package/libEs5/components/Privacy/index.js +2 -1
- package/libEs5/components/Privacy/injectSendSetConsentRequest.js +6 -2
- package/libEs5/components/Privacy/validateSetConsentOptions.js +2 -1
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/config/createCoreConfigs.js +2 -1
- package/libEs5/core/createEventManager.js +12 -3
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs5/core/index.js +6 -1
- package/libEs5/utils/filterObject.js +57 -0
- package/libEs5/utils/index.js +24 -0
- package/libEs5/utils/isNil.js +1 -1
- package/libEs5/utils/prepareConfigOverridesForEdge.js +61 -0
- package/libEs5/utils/request/createGetAssuranceValidationTokenParams.js +54 -0
- package/libEs5/utils/request/createRequestPayload.js +6 -0
- package/libEs5/utils/request/index.js +9 -1
- package/libEs5/utils/validateConfigOverride.js +20 -0
- package/libEs6/components/Context/injectPlaceContext.js +6 -3
- package/libEs6/components/DataCollector/index.js +27 -9
- package/libEs6/components/DataCollector/validateUserEventOptions.js +7 -2
- package/libEs6/components/Identity/appendIdentityToUrl/appendIdentityToUrlOptionsValidator.js +3 -1
- package/libEs6/components/Identity/createComponent.js +2 -2
- package/libEs6/components/Identity/getIdentity/createGetIdentity.js +10 -3
- package/libEs6/components/Identity/getIdentity/getIdentityOptionsValidator.js +6 -10
- package/libEs6/components/Identity/index.js +8 -4
- package/libEs6/components/Personalization/constants/surface.js +15 -0
- package/libEs6/components/Personalization/createComponent.js +6 -1
- package/libEs6/components/Personalization/createGetPageLocation.js +16 -0
- package/libEs6/components/Personalization/createPersonalizationDetails.js +40 -8
- package/libEs6/components/Personalization/groupDecisions.js +2 -2
- package/libEs6/components/Personalization/index.js +5 -0
- package/libEs6/components/Personalization/utils/isPageWideScope.js +14 -0
- package/libEs6/components/Personalization/utils/surfaceUtils.js +93 -0
- package/libEs6/components/Privacy/createComponent.js +4 -2
- package/libEs6/components/Privacy/index.js +2 -1
- package/libEs6/components/Privacy/injectSendSetConsentRequest.js +6 -2
- package/libEs6/components/Privacy/validateSetConsentOptions.js +3 -2
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/config/createCoreConfigs.js +3 -2
- package/libEs6/core/createEventManager.js +12 -3
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
- package/libEs6/core/index.js +7 -2
- package/libEs6/utils/filterObject.js +59 -0
- package/libEs6/utils/index.js +3 -0
- package/libEs6/utils/isNil.js +1 -1
- package/libEs6/utils/prepareConfigOverridesForEdge.js +57 -0
- package/libEs6/utils/request/createGetAssuranceValidationTokenParams.js +47 -0
- package/libEs6/utils/request/createRequestPayload.js +3 -1
- package/libEs6/utils/request/index.js +2 -1
- package/libEs6/utils/validateConfigOverride.js +13 -0
- package/package.json +5 -4
|
@@ -40,7 +40,8 @@ const createIdentity = ({
|
|
|
40
40
|
}) => {
|
|
41
41
|
const {
|
|
42
42
|
orgId,
|
|
43
|
-
thirdPartyCookiesEnabled
|
|
43
|
+
thirdPartyCookiesEnabled,
|
|
44
|
+
edgeConfigOverrides: globalConfigOverrides
|
|
44
45
|
} = config;
|
|
45
46
|
const getEcidFromVisitor = injectGetEcidFromVisitor({
|
|
46
47
|
logger,
|
|
@@ -64,7 +65,8 @@ const createIdentity = ({
|
|
|
64
65
|
const getIdentity = createGetIdentity({
|
|
65
66
|
sendEdgeNetworkRequest,
|
|
66
67
|
createIdentityRequestPayload,
|
|
67
|
-
createIdentityRequest
|
|
68
|
+
createIdentityRequest,
|
|
69
|
+
globalConfigOverrides
|
|
68
70
|
});
|
|
69
71
|
const setDomainForInitialIdentityPayload = injectSetDomainForInitialIdentityPayload({
|
|
70
72
|
thirdPartyCookiesEnabled,
|
|
@@ -100,7 +102,8 @@ const createIdentity = ({
|
|
|
100
102
|
});
|
|
101
103
|
const appendIdentityToUrl = injectAppendIdentityToUrl({
|
|
102
104
|
dateProvider: () => new Date(),
|
|
103
|
-
orgId
|
|
105
|
+
orgId,
|
|
106
|
+
globalConfigOverrides
|
|
104
107
|
});
|
|
105
108
|
return createComponent({
|
|
106
109
|
addEcidQueryToPayload,
|
|
@@ -112,7 +115,8 @@ const createIdentity = ({
|
|
|
112
115
|
getIdentity,
|
|
113
116
|
consent,
|
|
114
117
|
appendIdentityToUrl,
|
|
115
|
-
logger
|
|
118
|
+
logger,
|
|
119
|
+
config
|
|
116
120
|
});
|
|
117
121
|
};
|
|
118
122
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export const WEB = "web";
|
|
13
|
+
export const WEBAPP = "webapp";
|
|
14
|
+
export const SURFACE_TYPE_DELIMITER = "://";
|
|
15
|
+
export const FRAGMENT_DELIMITER = "#";
|
|
@@ -14,6 +14,7 @@ import createPersonalizationDetails from "./createPersonalizationDetails";
|
|
|
14
14
|
import { AUTHORING_ENABLED } from "./constants/loggerMessage";
|
|
15
15
|
import validateApplyPropositionsOptions from "./validateApplyPropositionsOptions";
|
|
16
16
|
export default (({
|
|
17
|
+
getPageLocation,
|
|
17
18
|
logger,
|
|
18
19
|
fetchDataHandler,
|
|
19
20
|
viewChangeHandler,
|
|
@@ -38,6 +39,7 @@ export default (({
|
|
|
38
39
|
event,
|
|
39
40
|
renderDecisions,
|
|
40
41
|
decisionScopes = [],
|
|
42
|
+
personalization = {},
|
|
41
43
|
onResponse = noop,
|
|
42
44
|
onRequestFailure = noop
|
|
43
45
|
}) {
|
|
@@ -57,10 +59,13 @@ export default (({
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
const personalizationDetails = createPersonalizationDetails({
|
|
62
|
+
getPageLocation,
|
|
60
63
|
renderDecisions,
|
|
61
64
|
decisionScopes,
|
|
65
|
+
personalization,
|
|
62
66
|
event,
|
|
63
|
-
viewCache
|
|
67
|
+
viewCache,
|
|
68
|
+
logger
|
|
64
69
|
});
|
|
65
70
|
|
|
66
71
|
if (personalizationDetails.shouldFetchData()) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export default (({
|
|
13
|
+
window
|
|
14
|
+
}) => () => {
|
|
15
|
+
return window.location;
|
|
16
|
+
});
|
|
@@ -9,15 +9,35 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
9
9
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import { includes } from "../../utils";
|
|
12
|
+
import { includes, isNonEmptyString, isNonEmptyArray } from "../../utils";
|
|
13
|
+
import { buildPageSurface, normalizeSurfaces } from "./utils/surfaceUtils";
|
|
13
14
|
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
|
|
14
15
|
import { DEFAULT_CONTENT_ITEM, DOM_ACTION, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM } from "./constants/schema";
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
const addPageWideScope = scopes => {
|
|
18
|
+
if (!includes(scopes, PAGE_WIDE_SCOPE)) {
|
|
19
|
+
scopes.push(PAGE_WIDE_SCOPE);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const addPageSurface = (surfaces, getPageLocation) => {
|
|
24
|
+
const pageSurface = buildPageSurface(getPageLocation);
|
|
25
|
+
|
|
26
|
+
if (!includes(surfaces, pageSurface)) {
|
|
27
|
+
surfaces.push(pageSurface);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const dedupe = array => array.filter((item, pos) => array.indexOf(item) === pos);
|
|
32
|
+
|
|
16
33
|
export default (({
|
|
34
|
+
getPageLocation,
|
|
17
35
|
renderDecisions,
|
|
18
36
|
decisionScopes,
|
|
37
|
+
personalization,
|
|
19
38
|
event,
|
|
20
|
-
viewCache
|
|
39
|
+
viewCache,
|
|
40
|
+
logger
|
|
21
41
|
}) => {
|
|
22
42
|
const viewName = event.getViewName();
|
|
23
43
|
return {
|
|
@@ -30,7 +50,11 @@ export default (({
|
|
|
30
50
|
},
|
|
31
51
|
|
|
32
52
|
hasScopes() {
|
|
33
|
-
return decisionScopes.length > 0;
|
|
53
|
+
return decisionScopes.length > 0 || isNonEmptyArray(personalization.decisionScopes);
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
hasSurfaces() {
|
|
57
|
+
return isNonEmptyArray(personalization.surfaces);
|
|
34
58
|
},
|
|
35
59
|
|
|
36
60
|
hasViewName() {
|
|
@@ -40,8 +64,15 @@ export default (({
|
|
|
40
64
|
createQueryDetails() {
|
|
41
65
|
const scopes = [...decisionScopes];
|
|
42
66
|
|
|
43
|
-
if (
|
|
44
|
-
scopes.push(
|
|
67
|
+
if (isNonEmptyArray(personalization.decisionScopes)) {
|
|
68
|
+
scopes.push(...personalization.decisionScopes);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const eventSurfaces = normalizeSurfaces(personalization.surfaces, getPageLocation, logger);
|
|
72
|
+
|
|
73
|
+
if (!this.isCacheInitialized()) {
|
|
74
|
+
addPageWideScope(scopes);
|
|
75
|
+
addPageSurface(eventSurfaces, getPageLocation);
|
|
45
76
|
}
|
|
46
77
|
|
|
47
78
|
const schemas = [DEFAULT_CONTENT_ITEM, HTML_CONTENT_ITEM, JSON_CONTENT_ITEM, REDIRECT_ITEM];
|
|
@@ -52,7 +83,8 @@ export default (({
|
|
|
52
83
|
|
|
53
84
|
return {
|
|
54
85
|
schemas,
|
|
55
|
-
decisionScopes: scopes
|
|
86
|
+
decisionScopes: dedupe(scopes),
|
|
87
|
+
surfaces: dedupe(eventSurfaces)
|
|
56
88
|
};
|
|
57
89
|
},
|
|
58
90
|
|
|
@@ -61,7 +93,7 @@ export default (({
|
|
|
61
93
|
},
|
|
62
94
|
|
|
63
95
|
shouldFetchData() {
|
|
64
|
-
return this.hasScopes() || !this.isCacheInitialized();
|
|
96
|
+
return this.hasScopes() || this.hasSurfaces() || !this.isCacheInitialized();
|
|
65
97
|
},
|
|
66
98
|
|
|
67
99
|
shouldUseCachedData() {
|
|
@@ -10,9 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
import { isNonEmptyArray, includes } from "../../utils";
|
|
13
|
+
import isPageWideScope from "./utils/isPageWideScope";
|
|
13
14
|
import { DOM_ACTION, REDIRECT_ITEM, DEFAULT_CONTENT_ITEM, MEASUREMENT_SCHEMA } from "./constants/schema";
|
|
14
15
|
import { VIEW_SCOPE_TYPE } from "./constants/scopeType";
|
|
15
|
-
import PAGE_WIDE_SCOPE from "../../constants/pageWideScope";
|
|
16
16
|
|
|
17
17
|
const splitItems = (items, schemas) => {
|
|
18
18
|
const matched = [];
|
|
@@ -90,7 +90,7 @@ const extractDecisionsByScope = decisions => {
|
|
|
90
90
|
|
|
91
91
|
if (isNonEmptyArray(decisions)) {
|
|
92
92
|
decisions.forEach(decision => {
|
|
93
|
-
if (decision.scope
|
|
93
|
+
if (isPageWideScope(decision.scope)) {
|
|
94
94
|
pageWideScopeDecisions.push(decision);
|
|
95
95
|
} else if (isViewScope(decision.scopeDetails)) {
|
|
96
96
|
appendScopeDecision(viewScopeDecisions, decision);
|
|
@@ -29,6 +29,7 @@ import createRedirectHandler from "./createRedirectHandler";
|
|
|
29
29
|
import createAutorenderingHandler from "./createAutoRenderingHandler";
|
|
30
30
|
import createNonRenderingHandler from "./createNonRenderingHandler";
|
|
31
31
|
import createApplyPropositions from "./createApplyPropositions";
|
|
32
|
+
import createGetPageLocation from "./createGetPageLocation";
|
|
32
33
|
import createSetTargetMigration from "./createSetTargetMigration";
|
|
33
34
|
|
|
34
35
|
const createPersonalization = ({
|
|
@@ -49,6 +50,9 @@ const createPersonalization = ({
|
|
|
49
50
|
getClickSelectors,
|
|
50
51
|
storeClickMetrics
|
|
51
52
|
} = createClickStorage();
|
|
53
|
+
const getPageLocation = createGetPageLocation({
|
|
54
|
+
window
|
|
55
|
+
});
|
|
52
56
|
const viewCache = createViewCacheManager();
|
|
53
57
|
const modules = initDomActionsModules(storeClickMetrics);
|
|
54
58
|
const executeDecisions = createExecuteDecisions({
|
|
@@ -103,6 +107,7 @@ const createPersonalization = ({
|
|
|
103
107
|
targetMigrationEnabled
|
|
104
108
|
});
|
|
105
109
|
return createComponent({
|
|
110
|
+
getPageLocation,
|
|
106
111
|
logger,
|
|
107
112
|
fetchDataHandler,
|
|
108
113
|
viewChangeHandler,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { isPageWideSurface } from "./surfaceUtils";
|
|
13
|
+
import PAGE_WIDE_SCOPE from "../../../constants/pageWideScope";
|
|
14
|
+
export default (scope => scope === PAGE_WIDE_SCOPE || isPageWideSurface(scope));
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { WEB, WEBAPP, SURFACE_TYPE_DELIMITER, FRAGMENT_DELIMITER } from "../constants/surface";
|
|
13
|
+
import { startsWith, isNil, isNonEmptyString, includes } from "../../../utils";
|
|
14
|
+
const SURFACE_REGEX = /^(\w+):\/\/([^/#]+)(\/[^#]*)?(#.*)?$/;
|
|
15
|
+
const AUTHORITY_REGEX = /^(?:.*@)?(?:[a-z\d\u00a1-\uffff.-]+|\[[a-f\d:]+])(?::\d+)?$/;
|
|
16
|
+
const PATH_REGEX = /^\/(?:[/\w\u00a1-\uffff-.~]|%[a-fA-F\d]{2})*$/;
|
|
17
|
+
const FRAGMENT_REGEX = /^#(?:[/\w\u00a1-\uffff-.~]|%[a-fA-F\d]{2})+$/;
|
|
18
|
+
|
|
19
|
+
const normalizePath = (path = "/") => {
|
|
20
|
+
let end = path.length;
|
|
21
|
+
|
|
22
|
+
while (end > 0 && "/".indexOf(path.charAt(end - 1)) !== -1) {
|
|
23
|
+
end -= 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return path.substring(0, end) || "/";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getSurfaceType = surfaceTypeMatch => isNonEmptyString(surfaceTypeMatch) ? surfaceTypeMatch.toLowerCase() : "";
|
|
30
|
+
|
|
31
|
+
const getAuthority = authorityMatch => isNonEmptyString(authorityMatch) ? authorityMatch.toLowerCase() : "";
|
|
32
|
+
|
|
33
|
+
const getPath = pathMatch => isNonEmptyString(pathMatch) ? normalizePath(pathMatch) : "/";
|
|
34
|
+
|
|
35
|
+
const parseSurface = surfaceString => {
|
|
36
|
+
const matched = surfaceString.match(SURFACE_REGEX);
|
|
37
|
+
return matched ? {
|
|
38
|
+
surfaceType: getSurfaceType(matched[1]),
|
|
39
|
+
authority: getAuthority(matched[2]),
|
|
40
|
+
path: getPath(matched[3]),
|
|
41
|
+
fragment: matched[4]
|
|
42
|
+
} : null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const stringifySurface = surface => `${surface.surfaceType}${SURFACE_TYPE_DELIMITER}${surface.authority}${surface.path || ""}${surface.fragment || ""}`;
|
|
46
|
+
|
|
47
|
+
export const buildPageSurface = getPageLocation => {
|
|
48
|
+
const location = getPageLocation();
|
|
49
|
+
const host = location.host.toLowerCase();
|
|
50
|
+
const path = location.pathname;
|
|
51
|
+
return WEB + SURFACE_TYPE_DELIMITER + host + normalizePath(path);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const expandFragmentSurface = (surface, getPageLocation) => startsWith(surface, FRAGMENT_DELIMITER) ? buildPageSurface(getPageLocation) + surface : surface;
|
|
55
|
+
|
|
56
|
+
const validateSurface = (surface, getPageLocation, logger) => {
|
|
57
|
+
const invalidateSurface = validationError => {
|
|
58
|
+
logger.warn(validationError);
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (!isNonEmptyString(surface)) {
|
|
63
|
+
return invalidateSurface(`Invalid surface: ${surface}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const expanded = expandFragmentSurface(surface, getPageLocation);
|
|
67
|
+
const parsed = parseSurface(expanded);
|
|
68
|
+
|
|
69
|
+
if (parsed === null) {
|
|
70
|
+
return invalidateSurface(`Invalid surface: ${surface}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!includes([WEB, WEBAPP], parsed.surfaceType)) {
|
|
74
|
+
return invalidateSurface(`Unsupported surface type ${parsed.surfaceType} in surface: ${surface}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!parsed.authority || !AUTHORITY_REGEX.test(parsed.authority)) {
|
|
78
|
+
return invalidateSurface(`Invalid authority ${parsed.authority} in surface: ${surface}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (parsed.path && !PATH_REGEX.test(parsed.path)) {
|
|
82
|
+
return invalidateSurface(`Invalid path ${parsed.path} in surface: ${surface}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (parsed.fragment && !FRAGMENT_REGEX.test(parsed.fragment)) {
|
|
86
|
+
return invalidateSurface(`Invalid fragment ${parsed.fragment} in surface: ${surface}`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return parsed;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const isPageWideSurface = scope => !!scope && scope.indexOf(WEB + SURFACE_TYPE_DELIMITER) === 0 && scope.indexOf(FRAGMENT_DELIMITER) === -1;
|
|
93
|
+
export const normalizeSurfaces = (surfaces = [], getPageLocation, logger) => surfaces.map(surface => validateSurface(surface, getPageLocation, logger)).filter(surface => !isNil(surface)).map(stringifySurface);
|
|
@@ -57,7 +57,8 @@ export default (({
|
|
|
57
57
|
optionsValidator: validateSetConsentOptions,
|
|
58
58
|
run: ({
|
|
59
59
|
consent: consentOptions,
|
|
60
|
-
identityMap
|
|
60
|
+
identityMap,
|
|
61
|
+
edgeConfigOverrides
|
|
61
62
|
}) => {
|
|
62
63
|
consent.suspend();
|
|
63
64
|
const consentHashes = consentHashStore.lookup(consentOptions);
|
|
@@ -65,7 +66,8 @@ export default (({
|
|
|
65
66
|
if (consentHashes.isNew()) {
|
|
66
67
|
return sendSetConsentRequest({
|
|
67
68
|
consentOptions,
|
|
68
|
-
identityMap
|
|
69
|
+
identityMap,
|
|
70
|
+
edgeConfigOverrides
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
73
|
|
|
@@ -38,7 +38,8 @@ const createPrivacy = ({
|
|
|
38
38
|
const sendSetConsentRequest = injectSendSetConsentRequest({
|
|
39
39
|
createConsentRequestPayload,
|
|
40
40
|
createConsentRequest,
|
|
41
|
-
sendEdgeNetworkRequest
|
|
41
|
+
sendEdgeNetworkRequest,
|
|
42
|
+
edgeConfigOverrides: config.edgeConfigOverrides
|
|
42
43
|
});
|
|
43
44
|
const storage = createNamespacedStorage(`${sanitizeOrgIdForCookieName(orgId)}.consentHashes.`);
|
|
44
45
|
const consentHashStore = createConsentHashStore({
|
|
@@ -13,13 +13,17 @@ import { isObject } from "../../utils";
|
|
|
13
13
|
export default (({
|
|
14
14
|
createConsentRequestPayload,
|
|
15
15
|
createConsentRequest,
|
|
16
|
-
sendEdgeNetworkRequest
|
|
16
|
+
sendEdgeNetworkRequest,
|
|
17
|
+
edgeConfigOverrides: globalConfigOverrides
|
|
17
18
|
}) => ({
|
|
18
19
|
consentOptions,
|
|
19
|
-
identityMap
|
|
20
|
+
identityMap,
|
|
21
|
+
edgeConfigOverrides: localConfigOverrides
|
|
20
22
|
}) => {
|
|
21
23
|
const payload = createConsentRequestPayload();
|
|
22
24
|
payload.setConsent(consentOptions);
|
|
25
|
+
payload.mergeConfigOverride(globalConfigOverrides);
|
|
26
|
+
payload.mergeConfigOverride(localConfigOverrides);
|
|
23
27
|
|
|
24
28
|
if (isObject(identityMap)) {
|
|
25
29
|
Object.keys(identityMap).forEach(key => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { objectOf, anything, arrayOf } from "../../utils/validation";
|
|
2
|
-
import { validateIdentityMap } from "../../utils";
|
|
2
|
+
import { validateIdentityMap, validateConfigOverride } from "../../utils";
|
|
3
3
|
export default objectOf({
|
|
4
4
|
consent: arrayOf(anything()).required().nonEmpty(),
|
|
5
|
-
identityMap: validateIdentityMap
|
|
5
|
+
identityMap: validateIdentityMap,
|
|
6
|
+
edgeConfigOverrides: validateConfigOverride
|
|
6
7
|
}).noUnknownFields().required();
|
|
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
import { boolean, string, callback, enumOf } from "../../utils/validation";
|
|
13
|
-
import { noop } from "../../utils";
|
|
13
|
+
import { noop, validateConfigOverride } from "../../utils";
|
|
14
14
|
import { EDGE as EDGE_DOMAIN } from "../../constants/domain";
|
|
15
15
|
import EDGE_BASE_PATH from "../../constants/edgeBasePath";
|
|
16
16
|
import { IN, OUT, PENDING } from "../../constants/consentStatus";
|
|
@@ -21,5 +21,6 @@ export default (() => ({
|
|
|
21
21
|
edgeDomain: string().domain().default(EDGE_DOMAIN),
|
|
22
22
|
edgeBasePath: string().nonEmpty().default(EDGE_BASE_PATH),
|
|
23
23
|
orgId: string().unique().required(),
|
|
24
|
-
onBeforeEventSend: callback().default(noop)
|
|
24
|
+
onBeforeEventSend: callback().default(noop),
|
|
25
|
+
edgeConfigOverrides: validateConfigOverride
|
|
25
26
|
}));
|
|
@@ -24,7 +24,8 @@ export default (({
|
|
|
24
24
|
applyResponse
|
|
25
25
|
}) => {
|
|
26
26
|
const {
|
|
27
|
-
onBeforeEventSend
|
|
27
|
+
onBeforeEventSend,
|
|
28
|
+
edgeConfigOverrides: globalConfigOverrides
|
|
28
29
|
} = config;
|
|
29
30
|
return {
|
|
30
31
|
createEvent,
|
|
@@ -37,7 +38,9 @@ export default (({
|
|
|
37
38
|
* the request payload.
|
|
38
39
|
* @param {Object} [options]
|
|
39
40
|
* @param {boolean} [options.renderDecisions=false]
|
|
40
|
-
* @param {Array} [options.decisionScopes]
|
|
41
|
+
* @param {Array} [options.decisionScopes] Note: this option will soon
|
|
42
|
+
* be deprecated, please use *personalization.decisionScopes* instead
|
|
43
|
+
* @param {Object} [options.personalization]
|
|
41
44
|
* @param {Object} [options.serverState]
|
|
42
45
|
* This will be passed to components
|
|
43
46
|
* so they can take appropriate action.
|
|
@@ -46,16 +49,21 @@ export default (({
|
|
|
46
49
|
sendEvent(event, options = {}) {
|
|
47
50
|
const {
|
|
48
51
|
renderDecisions = false,
|
|
49
|
-
decisionScopes
|
|
52
|
+
decisionScopes,
|
|
53
|
+
edgeConfigOverrides: localConfigOverrides,
|
|
54
|
+
personalization
|
|
50
55
|
} = options;
|
|
51
56
|
const payload = createDataCollectionRequestPayload();
|
|
52
57
|
const request = createDataCollectionRequest(payload);
|
|
53
58
|
const onResponseCallbackAggregator = createCallbackAggregator();
|
|
54
59
|
const onRequestFailureCallbackAggregator = createCallbackAggregator();
|
|
60
|
+
payload.mergeConfigOverride(globalConfigOverrides);
|
|
61
|
+
payload.mergeConfigOverride(localConfigOverrides);
|
|
55
62
|
return lifecycle.onBeforeEvent({
|
|
56
63
|
event,
|
|
57
64
|
renderDecisions,
|
|
58
65
|
decisionScopes,
|
|
66
|
+
personalization,
|
|
59
67
|
onResponse: onResponseCallbackAggregator.add,
|
|
60
68
|
onRequestFailure: onRequestFailureCallbackAggregator.add
|
|
61
69
|
}).then(() => {
|
|
@@ -111,6 +119,7 @@ export default (({
|
|
|
111
119
|
event,
|
|
112
120
|
renderDecisions,
|
|
113
121
|
decisionScopes: [PAGE_WIDE_SCOPE],
|
|
122
|
+
personalization: {},
|
|
114
123
|
onResponse: onResponseCallbackAggregator.add,
|
|
115
124
|
onRequestFailure: noop
|
|
116
125
|
}).then(() => {
|
|
@@ -21,7 +21,8 @@ export default (({
|
|
|
21
21
|
sendNetworkRequest,
|
|
22
22
|
createResponse,
|
|
23
23
|
processWarningsAndErrors,
|
|
24
|
-
getLocationHint
|
|
24
|
+
getLocationHint,
|
|
25
|
+
getAssuranceValidationTokenParams
|
|
25
26
|
}) => {
|
|
26
27
|
const {
|
|
27
28
|
edgeDomain,
|
|
@@ -52,7 +53,7 @@ export default (({
|
|
|
52
53
|
const endpointDomain = request.getUseIdThirdPartyDomain() ? ID_THIRD_PARTY_DOMAIN : edgeDomain;
|
|
53
54
|
const locationHint = getLocationHint();
|
|
54
55
|
const edgeBasePathWithLocationHint = locationHint ? `${edgeBasePath}/${locationHint}` : edgeBasePath;
|
|
55
|
-
const url = `https://${endpointDomain}/${edgeBasePathWithLocationHint}/${apiVersion}/${request.getAction()}?configId=${edgeConfigId}&requestId=${request.getId()}`;
|
|
56
|
+
const url = `https://${endpointDomain}/${edgeBasePathWithLocationHint}/${apiVersion}/${request.getAction()}?configId=${edgeConfigId}&requestId=${request.getId()}${getAssuranceValidationTokenParams()}`;
|
|
56
57
|
cookieTransfer.cookiesToPayload(request.getPayload(), endpointDomain);
|
|
57
58
|
return sendNetworkRequest({
|
|
58
59
|
requestId: request.getId(),
|
package/libEs6/core/index.js
CHANGED
|
@@ -35,7 +35,7 @@ import createLogger from "./createLogger";
|
|
|
35
35
|
import createEventManager from "./createEventManager";
|
|
36
36
|
import createCookieTransfer from "./createCookieTransfer";
|
|
37
37
|
import injectShouldTransferCookie from "./injectShouldTransferCookie";
|
|
38
|
-
import { createDataCollectionRequest, createDataCollectionRequestPayload } from "../utils/request";
|
|
38
|
+
import { createDataCollectionRequest, createDataCollectionRequestPayload, createGetAssuranceValidationTokenParams } from "../utils/request";
|
|
39
39
|
import injectSendEdgeNetworkRequest from "./edgeNetwork/injectSendEdgeNetworkRequest";
|
|
40
40
|
import injectProcessWarningsAndErrors from "./edgeNetwork/injectProcessWarningsAndErrors";
|
|
41
41
|
import injectGetLocationHint from "./edgeNetwork/injectGetLocationHint";
|
|
@@ -61,6 +61,10 @@ const sendFetchRequest = isFunction(fetch) ? injectSendFetchRequest({
|
|
|
61
61
|
XMLHttpRequest
|
|
62
62
|
});
|
|
63
63
|
const fireReferrerHideableImage = injectFireReferrerHideableImage();
|
|
64
|
+
const getAssuranceValidationTokenParams = createGetAssuranceValidationTokenParams({
|
|
65
|
+
window,
|
|
66
|
+
createNamespacedStorage
|
|
67
|
+
});
|
|
64
68
|
export const createExecuteCommand = ({
|
|
65
69
|
instanceName,
|
|
66
70
|
logController: {
|
|
@@ -140,7 +144,8 @@ export const createExecuteCommand = ({
|
|
|
140
144
|
sendNetworkRequest,
|
|
141
145
|
createResponse,
|
|
142
146
|
processWarningsAndErrors,
|
|
143
|
-
getLocationHint
|
|
147
|
+
getLocationHint,
|
|
148
|
+
getAssuranceValidationTokenParams
|
|
144
149
|
});
|
|
145
150
|
const applyResponse = injectApplyResponse({
|
|
146
151
|
lifecycle,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import isEmptyObject from "./isEmptyObject";
|
|
13
|
+
import isNil from "./isNil";
|
|
14
|
+
import isObject from "./isObject";
|
|
15
|
+
/**
|
|
16
|
+
* Given an object and a function that takes a value and returns a predicate, filter out
|
|
17
|
+
* all non-object deeply nested values that do not pass the predicate.
|
|
18
|
+
*
|
|
19
|
+
* Example: filterObject({ a: 2, b: { c: 6 } }, (val) => val > 5) returns { b { c: 6 } }
|
|
20
|
+
*
|
|
21
|
+
* @param {*} obj
|
|
22
|
+
* @param {* => boolean} predicate a function that takes a value and return a boolean,
|
|
23
|
+
* representing if it should be included in the result object or not.
|
|
24
|
+
* @returns A copy of the original object with the values that fail the predicate, filtered out.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const filterObject = (obj, predicate) => {
|
|
28
|
+
if (isNil(obj) || !isObject(obj)) {
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return Object.keys(obj).reduce((result, key) => {
|
|
33
|
+
const value = obj[key];
|
|
34
|
+
|
|
35
|
+
if (isObject(value)) {
|
|
36
|
+
// value is object, go deeper
|
|
37
|
+
const filteredValue = filterObject(value, predicate);
|
|
38
|
+
|
|
39
|
+
if (isEmptyObject(filteredValue)) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return { ...result,
|
|
44
|
+
[key]: filteredValue
|
|
45
|
+
};
|
|
46
|
+
} // value is not an object, test predicate
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if (predicate(value)) {
|
|
50
|
+
return { ...result,
|
|
51
|
+
[key]: value
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}, {});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default filterObject;
|
package/libEs6/utils/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { default as endsWith } from "./endsWith";
|
|
|
26
26
|
export { default as find } from "./find";
|
|
27
27
|
export { default as fireImage } from "./fireImage";
|
|
28
28
|
export { default as injectFireReferrerHideableImage } from "./injectFireReferrerHideableImage";
|
|
29
|
+
export { default as filterObject } from "./filterObject";
|
|
29
30
|
export { default as flatMap } from "./flatMap";
|
|
30
31
|
export { default as getApexDomain } from "./getApexDomain";
|
|
31
32
|
export { default as getLastArrayItems } from "./getLastArrayItems";
|
|
@@ -49,6 +50,7 @@ export { default as isString } from "./isString";
|
|
|
49
50
|
export { default as memoize } from "./memoize";
|
|
50
51
|
export { default as noop } from "./noop";
|
|
51
52
|
export { default as padStart } from "./padStart";
|
|
53
|
+
export { default as prepareConfigOverridesForEdge } from "./prepareConfigOverridesForEdge";
|
|
52
54
|
export { default as queryString } from "./querystring";
|
|
53
55
|
export { default as sanitizeOrgIdForCookieName } from "./sanitizeOrgIdForCookieName";
|
|
54
56
|
export { default as stackError } from "./stackError";
|
|
@@ -61,4 +63,5 @@ export { default as toISOStringLocal } from "./toISOStringLocal";
|
|
|
61
63
|
export { default as uuid } from "./uuid";
|
|
62
64
|
export { default as updateErrorMessage } from "./updateErrorMessage";
|
|
63
65
|
export { default as validateIdentityMap } from "./validateIdentityMap";
|
|
66
|
+
export { default as validateConfigOverride } from "./validateConfigOverride";
|
|
64
67
|
export { default as values } from "./values";
|
package/libEs6/utils/isNil.js
CHANGED