@adobe/alloy 2.29.0-beta.0 → 2.29.0-beta.13
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/ActivityCollector/utils/dom/findClickableElement.js +4 -0
- package/libEs5/components/Advertising/createComponent.js +1 -5
- package/libEs5/components/Advertising/handlers/clickThroughHandler.js +2 -1
- package/libEs5/components/Advertising/handlers/sendAdConversion.js +6 -8
- package/libEs5/components/Advertising/handlers/viewThroughHandler.js +4 -3
- package/libEs5/components/Consent/createConsentRequestPayload.js +14 -3
- package/libEs5/components/Consent/types.js +18 -0
- package/libEs5/components/Identity/createComponent.js +5 -4
- package/libEs5/components/Identity/index.js +4 -9
- package/libEs5/components/Personalization/dom-actions/action.js +7 -4
- package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +10 -10
- package/libEs5/components/PushNotifications/helpers/getPushSubscriptionDetails.js +112 -0
- package/libEs5/components/PushNotifications/index.js +96 -0
- package/libEs5/components/PushNotifications/request/createSendPushSubscriptionPayload.js +62 -0
- package/libEs5/components/PushNotifications/request/createSendPushSubscriptionRequest.js +35 -0
- package/libEs5/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +88 -0
- package/libEs5/components/PushNotifications/types.js +14 -0
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/componentCreators.js +8 -1
- package/libEs5/core/consent/createConsent.js +10 -0
- package/libEs5/core/consent/createConsentStateMachine.js +36 -0
- package/libEs5/core/consent/types.js +24 -0
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +20 -0
- package/libEs5/core/edgeNetwork/types.js +10 -0
- package/libEs5/core/identity/createIdentity.js +82 -0
- package/libEs5/core/identity/types.js +15 -0
- package/libEs5/core/index.js +8 -0
- package/libEs5/core/injectCreateResponse.js +9 -7
- package/libEs5/core/types.js +101 -11
- package/libEs5/utils/bytes.js +38 -0
- package/libEs5/{components/Identity → utils}/createDecodeKndctrCookie.js +12 -20
- package/libEs5/utils/createLoggingCookieJar.js +14 -1
- package/libEs5/utils/createMerger.js +5 -4
- package/libEs5/utils/index.js +13 -0
- package/libEs5/utils/injectStorage.js +19 -0
- package/libEs5/utils/request/createDataCollectionRequestPayload.js +16 -8
- package/libEs5/utils/request/createRequest.js +28 -1
- package/libEs5/utils/request/createRequestPayload.js +68 -4
- package/libEs5/utils/request/types.js +52 -0
- package/libEs5/utils/types.js +39 -0
- package/libEs6/components/ActivityCollector/utils/dom/findClickableElement.js +4 -0
- package/libEs6/components/Advertising/createComponent.js +1 -5
- package/libEs6/components/Advertising/handlers/clickThroughHandler.js +2 -1
- package/libEs6/components/Advertising/handlers/sendAdConversion.js +6 -8
- package/libEs6/components/Advertising/handlers/viewThroughHandler.js +4 -3
- package/libEs6/components/Consent/createConsentRequestPayload.js +16 -3
- package/libEs6/components/Consent/types.js +15 -0
- package/libEs6/components/Identity/createComponent.js +5 -4
- package/libEs6/components/Identity/index.js +4 -9
- package/libEs6/components/Personalization/dom-actions/action.js +7 -4
- package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +10 -10
- package/libEs6/components/PushNotifications/helpers/getPushSubscriptionDetails.js +110 -0
- package/libEs6/components/PushNotifications/index.js +93 -0
- package/libEs6/components/PushNotifications/request/createSendPushSubscriptionPayload.js +61 -0
- package/libEs6/components/PushNotifications/request/createSendPushSubscriptionRequest.js +34 -0
- package/libEs6/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +84 -0
- package/libEs6/components/PushNotifications/types.js +11 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/componentCreators.js +2 -1
- package/libEs6/core/consent/createConsent.js +12 -0
- package/libEs6/core/consent/createConsentStateMachine.js +36 -0
- package/libEs6/core/consent/types.js +21 -0
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +20 -0
- package/libEs6/core/edgeNetwork/types.js +7 -0
- package/libEs6/core/identity/createIdentity.js +81 -0
- package/libEs6/core/identity/types.js +12 -0
- package/libEs6/core/index.js +8 -0
- package/libEs6/core/injectCreateResponse.js +11 -7
- package/libEs6/core/types.js +101 -11
- package/libEs6/utils/bytes.js +33 -0
- package/libEs6/{components/Identity → utils}/createDecodeKndctrCookie.js +11 -19
- package/libEs6/utils/createLoggingCookieJar.js +15 -1
- package/libEs6/utils/createMerger.js +5 -4
- package/libEs6/utils/index.js +1 -0
- package/libEs6/utils/injectStorage.js +20 -0
- package/libEs6/utils/request/createDataCollectionRequestPayload.js +19 -8
- package/libEs6/utils/request/createRequest.js +29 -1
- package/libEs6/utils/request/createRequestPayload.js +67 -4
- package/libEs6/utils/request/types.js +49 -0
- package/libEs6/utils/types.js +36 -0
- package/package.json +30 -30
- package/types/components/ActivityCollector/utils/dom/findClickableElement.d.ts.map +1 -1
- package/types/components/Advertising/createComponent.d.ts +1 -1
- package/types/components/Advertising/createComponent.d.ts.map +1 -1
- package/types/components/Advertising/handlers/sendAdConversion.d.ts.map +1 -1
- package/types/components/Advertising/handlers/viewThroughHandler.d.ts.map +1 -1
- package/types/components/Advertising/index.d.ts +1 -1
- package/types/components/Consent/createConsentRequest.d.ts +1 -11
- package/types/components/Consent/createConsentRequest.d.ts.map +1 -1
- package/types/components/Consent/createConsentRequestPayload.d.ts +2 -9
- package/types/components/Consent/createConsentRequestPayload.d.ts.map +1 -1
- package/types/components/Consent/types.d.ts +28 -0
- package/types/components/Consent/types.d.ts.map +1 -0
- package/types/components/Identity/createComponent.d.ts +2 -2
- package/types/components/Identity/createComponent.d.ts.map +1 -1
- package/types/components/Identity/getIdentity/createIdentityRequest.d.ts +1 -11
- package/types/components/Identity/getIdentity/createIdentityRequest.d.ts.map +1 -1
- package/types/components/Identity/getIdentity/createIdentityRequestPayload.d.ts +1 -9
- package/types/components/Identity/getIdentity/createIdentityRequestPayload.d.ts.map +1 -1
- package/types/components/Identity/index.d.ts +2 -1
- package/types/components/Identity/index.d.ts.map +1 -1
- package/types/components/Personalization/dom-actions/action.d.ts +1 -1
- package/types/components/Personalization/dom-actions/action.d.ts.map +1 -1
- package/types/components/PushNotifications/helpers/getPushSubscriptionDetails.d.ts +30 -0
- package/types/components/PushNotifications/helpers/getPushSubscriptionDetails.d.ts.map +1 -0
- package/types/components/PushNotifications/index.d.ts +43 -0
- package/types/components/PushNotifications/index.d.ts.map +1 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts +10 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts.map +1 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts +7 -0
- package/types/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts.map +1 -0
- package/types/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts +20 -0
- package/types/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts.map +1 -0
- package/types/components/PushNotifications/types.d.ts +23 -0
- package/types/components/PushNotifications/types.d.ts.map +1 -0
- package/types/components/StreamingMedia/createMediaRequest.d.ts +1 -11
- package/types/components/StreamingMedia/createMediaRequest.d.ts.map +1 -1
- package/types/core/componentCreators.d.ts +1 -0
- package/types/core/consent/createConsent.d.ts +4 -10
- package/types/core/consent/createConsent.d.ts.map +1 -1
- package/types/core/consent/createConsentStateMachine.d.ts +4 -12
- package/types/core/consent/createConsentStateMachine.d.ts.map +1 -1
- package/types/core/consent/types.d.ts +42 -0
- package/types/core/consent/types.d.ts.map +1 -0
- package/types/core/edgeNetwork/injectSendEdgeNetworkRequest.d.ts +15 -13
- package/types/core/edgeNetwork/injectSendEdgeNetworkRequest.d.ts.map +1 -1
- package/types/core/edgeNetwork/types.d.ts +12 -0
- package/types/core/edgeNetwork/types.d.ts.map +1 -0
- package/types/core/identity/createIdentity.d.ts +12 -0
- package/types/core/identity/createIdentity.d.ts.map +1 -0
- package/types/core/identity/types.d.ts +23 -0
- package/types/core/identity/types.d.ts.map +1 -0
- package/types/core/index.d.ts.map +1 -1
- package/types/core/injectCreateResponse.d.ts +3 -27
- package/types/core/injectCreateResponse.d.ts.map +1 -1
- package/types/core/types.d.ts +209 -22
- package/types/core/types.d.ts.map +1 -1
- package/types/utils/bytes.d.ts +3 -0
- package/types/utils/bytes.d.ts.map +1 -0
- package/types/utils/createDecodeKndctrCookie.d.ts.map +1 -0
- package/types/utils/createLoggingCookieJar.d.ts +5 -3
- package/types/utils/createLoggingCookieJar.d.ts.map +1 -1
- package/types/utils/createMerger.d.ts +1 -1
- package/types/utils/createMerger.d.ts.map +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/injectStorage.d.ts +2 -40
- package/types/utils/injectStorage.d.ts.map +1 -1
- package/types/utils/request/createDataCollectionRequest.d.ts +1 -11
- package/types/utils/request/createDataCollectionRequest.d.ts.map +1 -1
- package/types/utils/request/createDataCollectionRequestPayload.d.ts +2 -9
- package/types/utils/request/createDataCollectionRequestPayload.d.ts.map +1 -1
- package/types/utils/request/createRequest.d.ts +13 -11
- package/types/utils/request/createRequest.d.ts.map +1 -1
- package/types/utils/request/createRequestPayload.d.ts +7 -9
- package/types/utils/request/createRequestPayload.d.ts.map +1 -1
- package/types/utils/request/types.d.ts +91 -0
- package/types/utils/request/types.d.ts.map +1 -0
- package/types/utils/types.d.ts +91 -0
- package/types/utils/types.d.ts.map +1 -0
- package/types/components/Identity/createDecodeKndctrCookie.d.ts.map +0 -1
- /package/types/{components/Identity → utils}/createDecodeKndctrCookie.d.ts +0 -0
|
@@ -9,12 +9,21 @@ 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
|
+
|
|
13
|
+
/** @import { ResponseCreator } from './types.js' */
|
|
14
|
+
|
|
12
15
|
import { ADOBE_EDGE } from "../constants/httpHeaderNames.js";
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Creates a representation of a gateway response with the addition of
|
|
16
19
|
* helper methods.
|
|
17
|
-
*
|
|
20
|
+
*
|
|
21
|
+
* @function
|
|
22
|
+
*
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {function(string): Object} options.extractEdgeInfo
|
|
25
|
+
*
|
|
26
|
+
* @returns {ResponseCreator}
|
|
18
27
|
*/
|
|
19
28
|
export default ({
|
|
20
29
|
extractEdgeInfo
|
|
@@ -27,15 +36,10 @@ export default ({
|
|
|
27
36
|
errors = [],
|
|
28
37
|
warnings = []
|
|
29
38
|
} = content;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Response object.
|
|
33
|
-
* @typedef {Object} Response
|
|
34
|
-
*/
|
|
35
39
|
return {
|
|
36
40
|
/**
|
|
37
41
|
* Returns matching fragments of the response by type.
|
|
38
|
-
* @param {
|
|
42
|
+
* @param {string} type A string with the current format: <namespace:action>
|
|
39
43
|
*
|
|
40
44
|
* @example
|
|
41
45
|
* getPayloadsByType("identity:persist")
|
package/libEs6/core/types.js
CHANGED
|
@@ -1,16 +1,106 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {object} AlloyMonitor
|
|
3
|
-
* @property {function(
|
|
4
|
-
* @property {function(
|
|
5
|
-
* @property {function(
|
|
6
|
-
* @property {function(
|
|
7
|
-
* @property {function(
|
|
8
|
-
* @property {function(
|
|
9
|
-
* @property {function(
|
|
10
|
-
* @property {function(
|
|
11
|
-
* @property {function(
|
|
12
|
-
* @property {function(
|
|
13
|
-
* @property {function(
|
|
3
|
+
* @property {function(any): void} [onBeforeLog]
|
|
4
|
+
* @property {function(any): void} [onInstanceCreated]
|
|
5
|
+
* @property {function(any): void} [onInstanceConfigured]
|
|
6
|
+
* @property {function(any): void} [onBeforeCommand]
|
|
7
|
+
* @property {function(any): void} [onCommandResolved]
|
|
8
|
+
* @property {function(any): void} [onCommandRejected]
|
|
9
|
+
* @property {function(any): void} [onBeforeNetworkRequest]
|
|
10
|
+
* @property {function(any): void} [onNetworkResponse]
|
|
11
|
+
* @property {function(any): void} [onNetworkError]
|
|
12
|
+
* @property {function(any): void} [onContentHiding]
|
|
13
|
+
* @property {function(any): void} [onContentRendering]
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {object} Logger
|
|
18
|
+
* @property {boolean} enabled
|
|
19
|
+
* @property {function(any): void} logOnInstanceCreated
|
|
20
|
+
* @property {function(any): void} logOnInstanceConfigured
|
|
21
|
+
* @property {function(any): void} logOnBeforeCommand
|
|
22
|
+
* @property {function(any): void} logOnCommandResolved
|
|
23
|
+
* @property {function(any): void} logOnCommandRejected
|
|
24
|
+
* @property {function(any): void} logOnBeforeNetworkRequest
|
|
25
|
+
* @property {function(any): void} logOnNetworkResponse
|
|
26
|
+
* @property {function(any): void} logOnNetworkError
|
|
27
|
+
* @property {function(any): void} logOnContentHiding
|
|
28
|
+
* @property {function(any): void} logOnContentRendering
|
|
29
|
+
* @property {function(...any): void} info
|
|
30
|
+
* @property {function(...any): void} warn
|
|
31
|
+
* @property {function(...any): void} error
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {object} Event
|
|
36
|
+
* @property {function(): boolean} hasQuery
|
|
37
|
+
* @property {function(): object} getContent
|
|
38
|
+
* @property {function(object): void} setUserXdm
|
|
39
|
+
* @property {function(object): void} setUserData
|
|
40
|
+
* @property {function(object): void} mergeXdm
|
|
41
|
+
* @property {function(object): void} mergeData
|
|
42
|
+
* @property {function(object): void} mergeMeta
|
|
43
|
+
* @property {function(object): void} mergeQuery
|
|
44
|
+
* @property {function(): void} documentMayUnload
|
|
45
|
+
* @property {function(function=): void} finalize
|
|
46
|
+
* @property {function(): boolean} getDocumentMayUnload
|
|
47
|
+
* @property {function(): boolean} isEmpty
|
|
48
|
+
* @property {function(): boolean} shouldSend
|
|
49
|
+
* @property {function(): string|undefined} getViewName
|
|
50
|
+
* @property {function(): object} toJSON
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @typedef {object} SendEventOptions
|
|
55
|
+
* @property {object} [edgeConfigOverrides]
|
|
56
|
+
configuration
|
|
57
|
+
* @property {boolean} [renderDecisions]
|
|
58
|
+
* @property {string[]} [decisionScopes]
|
|
59
|
+
* @property {object} [decisionContext]
|
|
60
|
+
* @property {object} [personalization]
|
|
61
|
+
* @property {object} [mediaOptions]
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {object} ApplyResponseOptions
|
|
66
|
+
* @property {boolean} [renderDecisions=false]
|
|
67
|
+
* @property {object} [decisionContext={}]
|
|
68
|
+
* @property {object} [responseHeaders={}]
|
|
69
|
+
* @property {object} [responseBody={handle:[]}]
|
|
70
|
+
* @property {object} [personalization]
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @typedef {object} EventManager
|
|
75
|
+
* @property {function(): Event} createEvent
|
|
76
|
+
* @property {function(Event, SendEventOptions=): Promise<any>} sendEvent
|
|
77
|
+
* @property {function(Event, ApplyResponseOptions=): Promise<any>} applyResponse
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @typedef {Object} ResponseContent
|
|
82
|
+
* @property {Array<{type: string, payload: Array<Object>}>} [handle] - Array of response fragments with type and payload
|
|
83
|
+
* @property {Array<object>} [errors] - Array of error objects
|
|
84
|
+
* @property {Array<object>} [warnings] - Array of warning objects
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {Object} ResponseFragment
|
|
89
|
+
* @property {string} type - Fragment type in format "<namespace:action>"
|
|
90
|
+
* @property {any} payload - Fragment payload data
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {Object} Response
|
|
95
|
+
* @property {function(string): Array<any>} getPayloadsByType - Returns matching fragments by type (e.g., "identity:persist")
|
|
96
|
+
* @property {function(): Array<object>} getErrors - Returns all error objects from the response
|
|
97
|
+
* @property {function(): Array<object>} getWarnings - Returns all warning objects from the response
|
|
98
|
+
* @property {function(): object} getEdge - Returns object containing regionId from x-adobe-edge header
|
|
99
|
+
* @property {function(): ResponseContent} toJSON
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @typedef {function({content?: ResponseContent, getHeader: function(string): string|undefined}): Response} ResponseCreator
|
|
14
104
|
*/
|
|
15
105
|
|
|
16
106
|
export const Types = {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 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
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Takes a base64 string of bytes and returns a Uint8Array.
|
|
15
|
+
* @param {string} base64String
|
|
16
|
+
* @returns {Uint8Array}
|
|
17
|
+
*/
|
|
18
|
+
export const base64ToBytes = base64String => {
|
|
19
|
+
// Add padding if needed
|
|
20
|
+
const padding = "=".repeat((4 - base64String.length % 4) % 4);
|
|
21
|
+
|
|
22
|
+
// Convert URL-safe base64 to regular base64
|
|
23
|
+
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
|
24
|
+
const binString = atob(base64);
|
|
25
|
+
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Takes a Uint8Array and returns a base64 string.
|
|
30
|
+
* @param {Uint8Array} bytes
|
|
31
|
+
* @returns {string}
|
|
32
|
+
*/
|
|
33
|
+
export const bytesToBase64 = bytes => btoa(String.fromCharCode(...bytes));
|
|
@@ -10,7 +10,8 @@ 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
|
/* eslint-disable no-bitwise */
|
|
13
|
-
import { getNamespacedCookieName } from "
|
|
13
|
+
import { getNamespacedCookieName } from "./index.js";
|
|
14
|
+
import { base64ToBytes } from "./bytes.js";
|
|
14
15
|
|
|
15
16
|
// #region decode protobuf
|
|
16
17
|
|
|
@@ -26,39 +27,39 @@ import { getNamespacedCookieName } from "../../utils/index.js";
|
|
|
26
27
|
* and https://git.corp.adobe.com/experience-edge/konductor/blob/master/feature-identity/src/main/kotlin/com/adobe/edge/features/identity/data/StoredIdentity.kt#L16
|
|
27
28
|
|
|
28
29
|
* syntax = "proto3";
|
|
29
|
-
*
|
|
30
|
+
*
|
|
30
31
|
* // Device-level identity for Experience Edge
|
|
31
32
|
* message Identity {
|
|
32
33
|
* // The Experience Cloud ID value
|
|
33
34
|
* string ecid = 1;
|
|
34
|
-
*
|
|
35
|
+
*
|
|
35
36
|
* IdentityMetadata metadata = 10;
|
|
36
|
-
*
|
|
37
|
+
*
|
|
37
38
|
* // Used only in the 3rd party domain context.
|
|
38
39
|
* // It stores the UNIX timestamp and some metadata about the last identity sync triggered by Experience Edge.
|
|
39
40
|
* int64 last_sync = 20;
|
|
40
41
|
* int64 sync_hash = 21;
|
|
41
42
|
* int32 id_sync_container_id = 22;
|
|
42
|
-
*
|
|
43
|
+
*
|
|
43
44
|
* // UNIX timestamp when the Identity was last returned in a `state:store` instruction.
|
|
44
45
|
* // The Identity is written at most once every 24h with a large TTL, to ensure it does not expire.
|
|
45
46
|
* int64 write_time = 30;
|
|
46
47
|
* }
|
|
47
|
-
*
|
|
48
|
+
*
|
|
48
49
|
* message IdentityMetadata {
|
|
49
50
|
* // UNIX timestamp when this identity was minted.
|
|
50
51
|
* int64 created_at = 1;
|
|
51
|
-
*
|
|
52
|
+
*
|
|
52
53
|
* // Whether or not the identity is random (new) or based on an existing seed.
|
|
53
54
|
* bool is_new = 2;
|
|
54
|
-
*
|
|
55
|
+
*
|
|
55
56
|
* // Type of device for which the identity was generated.
|
|
56
57
|
* // 0 = UNKNOWN, 1 = BROWSER, 2 = MOBILE
|
|
57
58
|
* int32 device_type = 3;
|
|
58
|
-
*
|
|
59
|
+
*
|
|
59
60
|
* // The Experience Edge region in which the identity was minted.
|
|
60
61
|
* string region = 5;
|
|
61
|
-
*
|
|
62
|
+
*
|
|
62
63
|
* // More details on the source of the ECID identity.
|
|
63
64
|
* // Invariant: when `is_new` = true, the source must be set to `RANDOM`.
|
|
64
65
|
* // 0 = RANDOM, 1 = THIRD_PARTY_ID, 2 = FIRST_PARTY_ID, 3 = RECEIVED_IN_REQUEST
|
|
@@ -220,15 +221,6 @@ const decodeKndctrProtobuf = buffer => {
|
|
|
220
221
|
throw new Error("No ECID found in cookie.");
|
|
221
222
|
};
|
|
222
223
|
|
|
223
|
-
/**
|
|
224
|
-
* takes a base64 string of bytes and returns a Uint8Array
|
|
225
|
-
* @param {string} base64
|
|
226
|
-
* @returns {Uint8Array}
|
|
227
|
-
*/
|
|
228
|
-
const base64ToBytes = base64 => {
|
|
229
|
-
const binString = atob(base64);
|
|
230
|
-
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
231
|
-
};
|
|
232
224
|
// #endregion
|
|
233
225
|
|
|
234
226
|
// #region decode cookie
|
|
@@ -10,6 +10,20 @@ 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
|
|
|
13
|
+
/** @import { Logger } from '../core/types.js' */
|
|
14
|
+
/** @import { CookieJar } from './types.js' */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a logging wrapper around a cookie jar that logs cookie operations.
|
|
18
|
+
*
|
|
19
|
+
* @function
|
|
20
|
+
*
|
|
21
|
+
* @param {object} options
|
|
22
|
+
* @param {Logger} options.logger
|
|
23
|
+
* @param {CookieJar} options.cookieJar
|
|
24
|
+
*
|
|
25
|
+
* @returns {CookieJar}
|
|
26
|
+
*/
|
|
13
27
|
export default ({
|
|
14
28
|
logger,
|
|
15
29
|
cookieJar
|
|
@@ -22,7 +36,7 @@ export default ({
|
|
|
22
36
|
value,
|
|
23
37
|
...options
|
|
24
38
|
});
|
|
25
|
-
cookieJar.set(key, value, options);
|
|
39
|
+
return cookieJar.set(key, value, options);
|
|
26
40
|
}
|
|
27
41
|
};
|
|
28
42
|
};
|
|
@@ -15,10 +15,11 @@ import deepAssign from "./deepAssign.js";
|
|
|
15
15
|
/**
|
|
16
16
|
* Creates a function that, when passed an object of updates, will merge
|
|
17
17
|
* the updates onto the current value of a payload property.
|
|
18
|
-
*
|
|
19
|
-
* @param {
|
|
20
|
-
* can be a dot-notation property path.
|
|
21
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* @param {object} content The base object to modify
|
|
20
|
+
* @param {string} key The property to merge updates into. This can be a dot-notation property path.
|
|
21
|
+
*
|
|
22
|
+
* @returns {function(object): void}
|
|
22
23
|
*/
|
|
23
24
|
export default (content, key) => updates => {
|
|
24
25
|
const propertyPath = key.split(".");
|
package/libEs6/utils/index.js
CHANGED
|
@@ -12,6 +12,7 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
|
|
13
13
|
// Please keep in alphabetical order.
|
|
14
14
|
export { default as assignConcatArrayValues } from "./assignConcatArrayValues.js";
|
|
15
|
+
export { base64ToBytes, bytesToBase64 } from "./bytes.js";
|
|
15
16
|
export { default as clone } from "./clone.js";
|
|
16
17
|
export { default as cookieJar } from "./cookieJar.js";
|
|
17
18
|
export { default as createMerger } from "./createMerger.js";
|
|
@@ -10,7 +10,18 @@ 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
|
|
|
13
|
+
/** @import { Storage, StorageCreator } from './types.js' */
|
|
14
|
+
|
|
13
15
|
import baseNamespace from "../constants/namespace.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a storage interface for a specific storage type with namespaced keys.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} context - The context object (typically window) that provides storage APIs.
|
|
21
|
+
* @param {string} storageType - The type of storage to use ('localStorage' or 'sessionStorage').
|
|
22
|
+
* @param {string} namespace - The namespace prefix to prepend to all storage keys.
|
|
23
|
+
* @returns {Storage}
|
|
24
|
+
*/
|
|
14
25
|
const getStorageByType = (context, storageType, namespace) => {
|
|
15
26
|
// When storage is disabled on Safari, the mere act of referencing
|
|
16
27
|
// window.localStorage or window.sessionStorage throws an error.
|
|
@@ -59,6 +70,15 @@ const getStorageByType = (context, storageType, namespace) => {
|
|
|
59
70
|
}
|
|
60
71
|
};
|
|
61
72
|
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a storage factory function that provides access to both session and persistent storage
|
|
76
|
+
* with namespaced keys. This is a higher-order function that returns a function which can be
|
|
77
|
+
* used to create storage instances with additional namespace suffixes.
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} context - The context object (typically window) that provides storage APIs.
|
|
80
|
+
* @returns {StorageCreator}
|
|
81
|
+
*/
|
|
62
82
|
export default context => additionalNamespace => {
|
|
63
83
|
const finalNamespace = baseNamespace + additionalNamespace;
|
|
64
84
|
return {
|
|
@@ -9,22 +9,33 @@ 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
|
+
|
|
13
|
+
/** @import { DataCollectionRequestPayload } from './types.js' */
|
|
14
|
+
|
|
12
15
|
import createRequestPayload from "./createRequestPayload.js";
|
|
13
16
|
import createAddIdentity from "./createAddIdentity.js";
|
|
14
17
|
import createHasIdentity from "./createHasIdentity.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @function
|
|
21
|
+
*
|
|
22
|
+
* @returns {DataCollectionRequestPayload}
|
|
23
|
+
*/
|
|
15
24
|
export default () => {
|
|
16
25
|
const content = {};
|
|
17
|
-
const
|
|
26
|
+
const requestPayload = createRequestPayload({
|
|
18
27
|
content,
|
|
19
28
|
addIdentity: createAddIdentity(content),
|
|
20
29
|
hasIdentity: createHasIdentity(content)
|
|
21
30
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
return {
|
|
32
|
+
...requestPayload,
|
|
33
|
+
addEvent: event => {
|
|
34
|
+
content.events = content.events || [];
|
|
35
|
+
content.events.push(event);
|
|
36
|
+
},
|
|
37
|
+
getDocumentMayUnload: () => {
|
|
38
|
+
return (content.events || []).some(event => event.getDocumentMayUnload());
|
|
39
|
+
}
|
|
28
40
|
};
|
|
29
|
-
return payload;
|
|
30
41
|
};
|
|
@@ -10,9 +10,37 @@ 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
|
|
|
13
|
+
/** @import { Request, RequestPayload } from './types.js' */
|
|
14
|
+
|
|
13
15
|
import { uuid } from "../index.js";
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Creates a request object with methods to access and modify request properties.
|
|
19
|
+
*
|
|
20
|
+
* @function
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} options
|
|
23
|
+
* @param {RequestPayload} options.payload
|
|
24
|
+
* @param {function({isIdentityEstablished: boolean}): string} options.getAction
|
|
25
|
+
* @param {function({isIdentityEstablished: boolean}): boolean} options.getUseSendBeacon
|
|
26
|
+
* @param {string} [options.datastreamIdOverride]
|
|
27
|
+
* @param {string} [options.edgeSubPath]
|
|
28
|
+
*
|
|
29
|
+
* @returns {Request}
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const request = createRequest({
|
|
33
|
+
* payload: { event: 'pageView' },
|
|
34
|
+
* getAction: ({ isIdentityEstablished }) => isIdentityEstablished ? 'send' : 'queue',
|
|
35
|
+
* getUseSendBeacon: ({ isIdentityEstablished }) => isIdentityEstablished,
|
|
36
|
+
* datastreamIdOverride: 'custom-datastream-id',
|
|
37
|
+
* edgeSubPath: 'custom/path'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* console.log(request.getId()); // Returns unique UUID
|
|
41
|
+
* request.setIsIdentityEstablished();
|
|
42
|
+
* console.log(request.getAction()); // Returns action based on identity status
|
|
43
|
+
*/
|
|
16
44
|
export default options => {
|
|
17
45
|
const {
|
|
18
46
|
payload,
|
|
@@ -10,22 +10,85 @@ 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
|
|
|
13
|
+
/** @import { RequestPayload, Identity } from './types.js' */
|
|
14
|
+
|
|
13
15
|
import { createMerger, prepareConfigOverridesForEdge } from "../index.js";
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* createMerger creates a function that does a deep merge. Example:
|
|
19
|
+
* ```js
|
|
20
|
+
* payload.mergeConfigOverride({
|
|
21
|
+
* com_adobe_analytics: {
|
|
22
|
+
* reportSuites: ["reportSuite1"],
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* payload.mergeConfigOverride({
|
|
27
|
+
* com_adobe_analytics: {
|
|
28
|
+
* enabled: false,
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
*
|
|
33
|
+
* // payload.meta.configOverrides is now:
|
|
34
|
+
* // {
|
|
35
|
+
* // com_adobe_analytics: {
|
|
36
|
+
* // enabled: false,
|
|
37
|
+
* // reportSuites: ["reportSuite1"],
|
|
38
|
+
* // },
|
|
39
|
+
* // }
|
|
40
|
+
* ```
|
|
41
|
+
* however, we need the result to be:
|
|
42
|
+
* ```js
|
|
43
|
+
* // {
|
|
44
|
+
* // com_adobe_analytics: {
|
|
45
|
+
* // enabled: false,
|
|
46
|
+
* // },
|
|
47
|
+
* // }
|
|
48
|
+
* ```
|
|
49
|
+
* aka a shallow merge, where the second object overwrites the first.
|
|
50
|
+
* This is because order matters and we don't want to send reportSuites when something is
|
|
51
|
+
* disabled.
|
|
52
|
+
* This function does that.
|
|
53
|
+
*
|
|
54
|
+
* @param {Object} content
|
|
55
|
+
* @param {string} key
|
|
56
|
+
* @returns {(updates: Object) => void}
|
|
57
|
+
*/
|
|
58
|
+
const createMergeConfigOverride = (content, key) => updates => {
|
|
59
|
+
const propertyPath = key.split(".");
|
|
60
|
+
const hostObjectForUpdates = propertyPath.reduce((obj, propertyName) => {
|
|
61
|
+
obj[propertyName] = obj[propertyName] || {};
|
|
62
|
+
return obj[propertyName];
|
|
63
|
+
}, content);
|
|
64
|
+
Object.assign(hostObjectForUpdates, updates);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates a request payload object with methods for merging different types of data.
|
|
69
|
+
* This provides the base functionality that all types of request payloads share.
|
|
70
|
+
*
|
|
71
|
+
* @function
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} options
|
|
74
|
+
* @param {Object} options.content
|
|
75
|
+
* @param {function(string, Identity): void} options.addIdentity
|
|
76
|
+
* @param {function(string): boolean} options.hasIdentity
|
|
77
|
+
*
|
|
78
|
+
* @returns {RequestPayload}
|
|
79
|
+
*/
|
|
17
80
|
export default options => {
|
|
18
81
|
const {
|
|
19
82
|
content,
|
|
20
83
|
addIdentity,
|
|
21
84
|
hasIdentity
|
|
22
85
|
} = options;
|
|
23
|
-
const
|
|
86
|
+
const mergeConfigOverrides = createMergeConfigOverride(content, "meta.configOverrides");
|
|
24
87
|
return {
|
|
25
88
|
mergeMeta: createMerger(content, "meta"),
|
|
26
89
|
mergeState: createMerger(content, "meta.state"),
|
|
27
90
|
mergeQuery: createMerger(content, "query"),
|
|
28
|
-
mergeConfigOverride: updates =>
|
|
91
|
+
mergeConfigOverride: updates => mergeConfigOverrides(prepareConfigOverridesForEdge(updates)),
|
|
29
92
|
addIdentity,
|
|
30
93
|
hasIdentity,
|
|
31
94
|
toJSON() {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request object with methods to access and modify request properties.
|
|
3
|
+
*
|
|
4
|
+
* @typedef {Object} Request
|
|
5
|
+
* @property {function(): string} getId
|
|
6
|
+
* @property {function(): RequestPayload} getPayload
|
|
7
|
+
* @property {function({isIdentityEstablished: boolean}): string} getAction
|
|
8
|
+
* @property {function(): string|undefined} getDatastreamIdOverride
|
|
9
|
+
* @property {Function} getUseSendBeacon
|
|
10
|
+
* @property {function(): string|undefined} getEdgeSubPath
|
|
11
|
+
* @property {Function} getUseIdThirdPartyDomain
|
|
12
|
+
* @property {Function} setUseIdThirdPartyDomain
|
|
13
|
+
* @property {Function} setIsIdentityEstablished
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Request payload object with methods for merging different types of data.
|
|
18
|
+
*
|
|
19
|
+
* @typedef {Object} RequestPayload
|
|
20
|
+
* @property {function(object): void} mergeMeta
|
|
21
|
+
* @property {function(object): void} mergeState
|
|
22
|
+
* @property {function(object): void} mergeQuery
|
|
23
|
+
* @property {function(object): void} mergeConfigOverride
|
|
24
|
+
* @property {function(string, Identity): void} options.addIdentity
|
|
25
|
+
* @property {function(string): boolean} options.hasIdentity
|
|
26
|
+
* @property {function(): object} toJSON
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Request payload object with methods for merging different types of data.
|
|
31
|
+
*
|
|
32
|
+
* @typedef {Object} DataCollectionRequestPayload
|
|
33
|
+
* @property {function(object): void} mergeMeta
|
|
34
|
+
* @property {function(object): void} mergeState
|
|
35
|
+
* @property {function(object): void} mergeQuery
|
|
36
|
+
* @property {function(object): void} mergeConfigOverride
|
|
37
|
+
* @property {function(string, Identity): void} options.addIdentity
|
|
38
|
+
* @property {function(string): boolean} options.hasIdentity
|
|
39
|
+
* @property {function(object): void} addEvent
|
|
40
|
+
* @property {function(): boolean} getDocumentMayUnload
|
|
41
|
+
* @property {function(): object} toJSON
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {Object} Identity
|
|
46
|
+
* @property {string} id
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
export const Types = {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Storage
|
|
3
|
+
* @property {function(string): string|null} getItem
|
|
4
|
+
* @property {function(string, string): void} setItem
|
|
5
|
+
* @property {function(): void} clear
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} CookieAttributes
|
|
10
|
+
* @property {number|Date} [expires] - Cookie expiration (number of days or Date object)
|
|
11
|
+
* @property {string} [path] - Cookie path (default: "/")
|
|
12
|
+
* @property {string} [domain] - Cookie domain
|
|
13
|
+
* @property {boolean} [secure] - Requires HTTPS transmission
|
|
14
|
+
* @property {"strict"|"lax"|"none"} [sameSite] - SameSite attribute
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {Object} CookieConverter
|
|
19
|
+
* @property {function(string, string): string} [read] - Custom decoder function
|
|
20
|
+
* @property {function(string, string): string} [write] - Custom encoder function
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {Object} CookieJar
|
|
25
|
+
* @property {function(string): string|undefined} get - Get cookie value by name, or get all cookies as object if no name provided
|
|
26
|
+
* @property {function(): Object<string, string>} get - Get all cookies as key-value object when called with no arguments
|
|
27
|
+
* @property {function(string, string, CookieAttributes=): string|undefined} set - Set cookie with optional attributes
|
|
28
|
+
* @property {function(string, CookieAttributes=): void} remove - Remove cookie with optional attributes (must match set attributes)
|
|
29
|
+
* @property {function(CookieConverter): CookieJar} withConverter - Create new instance with custom encoding/decoding
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {function(string): { session: Storage, persistent: Storage }} StorageCreator
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
export const Types = {};
|