@adobe/alloy 2.29.0-beta.5 → 2.29.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/libEs5/components/ActivityCollector/utils/dom/findClickableElement.js +4 -0
- package/libEs5/components/Advertising/handlers/clickThroughHandler.js +2 -1
- package/libEs5/components/Advertising/handlers/onBeforeSendEventHandler.js +8 -3
- package/libEs5/components/Advertising/handlers/viewThroughHandler.js +2 -1
- package/libEs5/components/Advertising/identities/collectID5Id.js +1 -1
- package/libEs5/components/Advertising/identities/collectRampId.js +1 -1
- package/libEs5/components/Consent/createConsentRequestPayload.js +14 -3
- package/libEs5/components/Consent/types.js +18 -0
- 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 +116 -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 +36 -0
- package/libEs5/core/identity/types.js +15 -0
- package/libEs5/core/injectCreateResponse.js +9 -7
- package/libEs5/core/types.js +101 -11
- package/libEs5/utils/bytes.js +12 -1
- package/libEs5/utils/createLoggingCookieJar.js +14 -1
- package/libEs5/utils/createMerger.js +5 -4
- 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 +15 -2
- 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/handlers/clickThroughHandler.js +2 -1
- package/libEs6/components/Advertising/handlers/onBeforeSendEventHandler.js +8 -3
- package/libEs6/components/Advertising/handlers/viewThroughHandler.js +2 -1
- package/libEs6/components/Advertising/identities/collectID5Id.js +1 -1
- package/libEs6/components/Advertising/identities/collectRampId.js +1 -1
- package/libEs6/components/Consent/createConsentRequestPayload.js +16 -3
- package/libEs6/components/Consent/types.js +15 -0
- 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 +114 -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 +38 -0
- package/libEs6/core/identity/types.js +12 -0
- package/libEs6/core/injectCreateResponse.js +11 -7
- package/libEs6/core/types.js +101 -11
- package/libEs6/utils/bytes.js +12 -1
- package/libEs6/utils/createLoggingCookieJar.js +15 -1
- package/libEs6/utils/createMerger.js +5 -4
- 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 +15 -2
- 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/handlers/onBeforeSendEventHandler.d.ts.map +1 -1
- package/types/components/Advertising/handlers/viewThroughHandler.d.ts.map +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/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/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 +9 -9
- package/types/core/identity/createIdentity.d.ts.map +1 -1
- package/types/core/identity/types.d.ts +23 -0
- package/types/core/identity/types.d.ts.map +1 -0
- 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 -1
- package/types/utils/bytes.d.ts.map +1 -1
- 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/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
|
@@ -14,17 +14,53 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/** @import { Logger } from '../../core/types.js' */
|
|
18
|
+
/** @import { ConsentStateMachineUtils, ConsentStateMachine } from './types.js' */
|
|
19
|
+
|
|
17
20
|
const DECLINED_CONSENT = exports.DECLINED_CONSENT = "The user declined consent.";
|
|
18
21
|
const DECLINED_CONSENT_ERROR_CODE = exports.DECLINED_CONSENT_ERROR_CODE = "declinedConsent";
|
|
19
22
|
const CONSENT_SOURCE_DEFAULT = exports.CONSENT_SOURCE_DEFAULT = "default";
|
|
20
23
|
const CONSENT_SOURCE_INITIAL = exports.CONSENT_SOURCE_INITIAL = "initial";
|
|
21
24
|
const CONSENT_SOURCE_NEW = exports.CONSENT_SOURCE_NEW = "new";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @private
|
|
28
|
+
* @param {string} errorMessage
|
|
29
|
+
* @returns {Error}
|
|
30
|
+
*/
|
|
22
31
|
const createDeclinedConsentError = errorMessage => {
|
|
23
32
|
const error = new Error(errorMessage);
|
|
24
33
|
error.code = DECLINED_CONSENT_ERROR_CODE;
|
|
25
34
|
error.message = errorMessage;
|
|
26
35
|
return error;
|
|
27
36
|
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a consent state machine that manages user consent preferences and
|
|
40
|
+
* coordinates deferred operations that require consent.
|
|
41
|
+
*
|
|
42
|
+
* The state machine supports the following states:
|
|
43
|
+
* - "in": User has provided consent (with default or explicit consent)
|
|
44
|
+
* - "out": User has declined consent (with default or explicit decline)
|
|
45
|
+
* - "pending": Consent decision is awaiting user input
|
|
46
|
+
*
|
|
47
|
+
* @param {object} options
|
|
48
|
+
* @param {Logger} options.logger
|
|
49
|
+
*
|
|
50
|
+
* @returns {ConsentStateMachine}
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const consentStateMachine = createConsentStateMachine({ logger });
|
|
54
|
+
*
|
|
55
|
+
* // Set consent state
|
|
56
|
+
* consentStateMachine.in('new');
|
|
57
|
+
*
|
|
58
|
+
* // Wait for consent
|
|
59
|
+
* await consentStateMachine.awaitConsent();
|
|
60
|
+
*
|
|
61
|
+
* // Check current state
|
|
62
|
+
* const { state, wasSet } = consentStateMachine.current();
|
|
63
|
+
*/
|
|
28
64
|
var _default = ({
|
|
29
65
|
logger
|
|
30
66
|
}) => {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} ConsentStateMachine
|
|
6
|
+
* @property {function(string): void} in
|
|
7
|
+
* @property {function(string): void} out
|
|
8
|
+
* @property {function(string): void} pending
|
|
9
|
+
* @property {function(boolean=): Promise<void>} awaitConsent
|
|
10
|
+
* @property {function(): Promise<void>} withConsent
|
|
11
|
+
* @property {function(): {state: string, wasSet: boolean}} current
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {Object} ConsentManager
|
|
16
|
+
* @property {function(Object, Object): void} initializeConsent
|
|
17
|
+
* @property {function(Object): void} setConsent
|
|
18
|
+
* @property {function(): void} suspend
|
|
19
|
+
* @property {function(): Promise<void>} awaitConsent
|
|
20
|
+
* @property {function(): Promise<void>} withConsent
|
|
21
|
+
* @property {function(): {state: string, wasSet: boolean}} current
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const Types = exports.Types = {};
|
|
@@ -19,9 +19,29 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
19
19
|
governing permissions and limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
/** @import { EdgeRequestExecutor } from './types.js' */
|
|
23
|
+
/** @import { ResponseCreator } from '../types.js' */
|
|
24
|
+
|
|
22
25
|
const isDemdexBlockedError = (error, request) => {
|
|
23
26
|
return request.getUseIdThirdPartyDomain() && (0, _networkErrors.isNetworkError)(error);
|
|
24
27
|
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @function
|
|
31
|
+
*
|
|
32
|
+
* @param {object} options
|
|
33
|
+
* @param {{edgeDomain: string, edgeBasePath: string, datastreamId: string}} options.config
|
|
34
|
+
* @param {object} options.lifecycle
|
|
35
|
+
* @param {object} options.cookieTransfer
|
|
36
|
+
* @param {function(object): Promise<Object>} options.sendNetworkRequest
|
|
37
|
+
* @param {ResponseCreator} options.createResponse
|
|
38
|
+
* @param {function(object): void} options.processWarningsAndErrors
|
|
39
|
+
* @param {function(): string|undefined} options.getLocationHint
|
|
40
|
+
* @param {function(): string} options.getAssuranceValidationTokenParams
|
|
41
|
+
|
|
42
|
+
*
|
|
43
|
+
* @returns {EdgeRequestExecutor} A function that sends edge network requests with lifecycle management
|
|
44
|
+
*/
|
|
25
45
|
var _default = ({
|
|
26
46
|
config,
|
|
27
47
|
lifecycle,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/** @import { Request } from '../../utils/request/types.js' */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {function({request: Request, runOnResponseCallbacks?: function(): void, runOnRequestFailureCallbacks?: function(): void}): Promise<Object>} EdgeRequestExecutor
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const Types = exports.Types = {};
|
|
@@ -13,6 +13,42 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
13
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/** @import { IdentityManager } from './types.js' */
|
|
17
|
+
/** @import { Logger } from '../types.js' */
|
|
18
|
+
/** @import { CookieJar } from '../../utils/types.js' */
|
|
19
|
+
/**
|
|
20
|
+
* Creates an identity management service for handling ECID (Experience Cloud ID) resolution and tracking.
|
|
21
|
+
*
|
|
22
|
+
* This factory function creates an identity manager service that manages the state of identity resolution,
|
|
23
|
+
* provides methods to check for existing identity cookies, and handles the asynchronous nature
|
|
24
|
+
* of identity acquisition in Adobe Experience Platform Web SDK.
|
|
25
|
+
*
|
|
26
|
+
* @function
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} options
|
|
29
|
+
* @param {Logger} options.logger
|
|
30
|
+
* @param {CookieJar} options.loggingCookieJar
|
|
31
|
+
* @param {{orgId: string}} options.config
|
|
32
|
+
*
|
|
33
|
+
* @returns {IdentityManager}
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Create an identity service
|
|
37
|
+
* const identityManager = createIdentity({
|
|
38
|
+
* logger: myLogger,
|
|
39
|
+
* loggingCookieJar: myCookieJar,
|
|
40
|
+
* config: { orgId: 'myOrgId@AdobeOrg' }
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Initialize and check for existing identity
|
|
44
|
+
* identityManager.initialize();
|
|
45
|
+
*
|
|
46
|
+
* // Wait for identity to be available
|
|
47
|
+
* await identityManager.awaitIdentity();
|
|
48
|
+
*
|
|
49
|
+
* // Get ECID from cookie
|
|
50
|
+
* const ecid = identityManager.getEcidFromCookie();
|
|
51
|
+
*/
|
|
16
52
|
var _default = ({
|
|
17
53
|
logger,
|
|
18
54
|
loggingCookieJar,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/** @import { Logger } from '../../core/types.js' */
|
|
5
|
+
/** @import { CookieJar } from '../../utils/types.js' */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} IdentityManager
|
|
9
|
+
* @property {Function} initialize
|
|
10
|
+
* @property {Function} setIdentityAcquired - Marks identity as acquired and resolves any pending identity promises
|
|
11
|
+
* @property {Function} awaitIdentity - Returns a promise that resolves when identity is acquired
|
|
12
|
+
* @property {Function} getEcidFromCookie
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const Types = exports.Types = {};
|
|
@@ -13,10 +13,17 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
13
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/** @import { ResponseCreator } from './types.js' */
|
|
16
17
|
/**
|
|
17
18
|
* Creates a representation of a gateway response with the addition of
|
|
18
19
|
* helper methods.
|
|
19
|
-
*
|
|
20
|
+
*
|
|
21
|
+
* @function
|
|
22
|
+
*
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {function(string): Object} options.extractEdgeInfo
|
|
25
|
+
*
|
|
26
|
+
* @returns {ResponseCreator}
|
|
20
27
|
*/
|
|
21
28
|
var _default = ({
|
|
22
29
|
extractEdgeInfo
|
|
@@ -29,15 +36,10 @@ var _default = ({
|
|
|
29
36
|
errors = [],
|
|
30
37
|
warnings = []
|
|
31
38
|
} = content;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Response object.
|
|
35
|
-
* @typedef {Object} Response
|
|
36
|
-
*/
|
|
37
39
|
return {
|
|
38
40
|
/**
|
|
39
41
|
* Returns matching fragments of the response by type.
|
|
40
|
-
* @param {
|
|
42
|
+
* @param {string} type A string with the current format: <namespace:action>
|
|
41
43
|
*
|
|
42
44
|
* @example
|
|
43
45
|
* getPayloadsByType("identity:persist")
|
package/libEs5/core/types.js
CHANGED
|
@@ -3,17 +3,107 @@
|
|
|
3
3
|
exports.Types = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {object} AlloyMonitor
|
|
6
|
-
* @property {function(
|
|
7
|
-
* @property {function(
|
|
8
|
-
* @property {function(
|
|
9
|
-
* @property {function(
|
|
10
|
-
* @property {function(
|
|
11
|
-
* @property {function(
|
|
12
|
-
* @property {function(
|
|
13
|
-
* @property {function(
|
|
14
|
-
* @property {function(
|
|
15
|
-
* @property {function(
|
|
16
|
-
* @property {function(
|
|
6
|
+
* @property {function(any): void} [onBeforeLog]
|
|
7
|
+
* @property {function(any): void} [onInstanceCreated]
|
|
8
|
+
* @property {function(any): void} [onInstanceConfigured]
|
|
9
|
+
* @property {function(any): void} [onBeforeCommand]
|
|
10
|
+
* @property {function(any): void} [onCommandResolved]
|
|
11
|
+
* @property {function(any): void} [onCommandRejected]
|
|
12
|
+
* @property {function(any): void} [onBeforeNetworkRequest]
|
|
13
|
+
* @property {function(any): void} [onNetworkResponse]
|
|
14
|
+
* @property {function(any): void} [onNetworkError]
|
|
15
|
+
* @property {function(any): void} [onContentHiding]
|
|
16
|
+
* @property {function(any): void} [onContentRendering]
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} Logger
|
|
21
|
+
* @property {boolean} enabled
|
|
22
|
+
* @property {function(any): void} logOnInstanceCreated
|
|
23
|
+
* @property {function(any): void} logOnInstanceConfigured
|
|
24
|
+
* @property {function(any): void} logOnBeforeCommand
|
|
25
|
+
* @property {function(any): void} logOnCommandResolved
|
|
26
|
+
* @property {function(any): void} logOnCommandRejected
|
|
27
|
+
* @property {function(any): void} logOnBeforeNetworkRequest
|
|
28
|
+
* @property {function(any): void} logOnNetworkResponse
|
|
29
|
+
* @property {function(any): void} logOnNetworkError
|
|
30
|
+
* @property {function(any): void} logOnContentHiding
|
|
31
|
+
* @property {function(any): void} logOnContentRendering
|
|
32
|
+
* @property {function(...any): void} info
|
|
33
|
+
* @property {function(...any): void} warn
|
|
34
|
+
* @property {function(...any): void} error
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {object} Event
|
|
39
|
+
* @property {function(): boolean} hasQuery
|
|
40
|
+
* @property {function(): object} getContent
|
|
41
|
+
* @property {function(object): void} setUserXdm
|
|
42
|
+
* @property {function(object): void} setUserData
|
|
43
|
+
* @property {function(object): void} mergeXdm
|
|
44
|
+
* @property {function(object): void} mergeData
|
|
45
|
+
* @property {function(object): void} mergeMeta
|
|
46
|
+
* @property {function(object): void} mergeQuery
|
|
47
|
+
* @property {function(): void} documentMayUnload
|
|
48
|
+
* @property {function(function=): void} finalize
|
|
49
|
+
* @property {function(): boolean} getDocumentMayUnload
|
|
50
|
+
* @property {function(): boolean} isEmpty
|
|
51
|
+
* @property {function(): boolean} shouldSend
|
|
52
|
+
* @property {function(): string|undefined} getViewName
|
|
53
|
+
* @property {function(): object} toJSON
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {object} SendEventOptions
|
|
58
|
+
* @property {object} [edgeConfigOverrides]
|
|
59
|
+
configuration
|
|
60
|
+
* @property {boolean} [renderDecisions]
|
|
61
|
+
* @property {string[]} [decisionScopes]
|
|
62
|
+
* @property {object} [decisionContext]
|
|
63
|
+
* @property {object} [personalization]
|
|
64
|
+
* @property {object} [mediaOptions]
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @typedef {object} ApplyResponseOptions
|
|
69
|
+
* @property {boolean} [renderDecisions=false]
|
|
70
|
+
* @property {object} [decisionContext={}]
|
|
71
|
+
* @property {object} [responseHeaders={}]
|
|
72
|
+
* @property {object} [responseBody={handle:[]}]
|
|
73
|
+
* @property {object} [personalization]
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @typedef {object} EventManager
|
|
78
|
+
* @property {function(): Event} createEvent
|
|
79
|
+
* @property {function(Event, SendEventOptions=): Promise<any>} sendEvent
|
|
80
|
+
* @property {function(Event, ApplyResponseOptions=): Promise<any>} applyResponse
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {Object} ResponseContent
|
|
85
|
+
* @property {Array<{type: string, payload: Array<Object>}>} [handle] - Array of response fragments with type and payload
|
|
86
|
+
* @property {Array<object>} [errors] - Array of error objects
|
|
87
|
+
* @property {Array<object>} [warnings] - Array of warning objects
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {Object} ResponseFragment
|
|
92
|
+
* @property {string} type - Fragment type in format "<namespace:action>"
|
|
93
|
+
* @property {any} payload - Fragment payload data
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {Object} Response
|
|
98
|
+
* @property {function(string): Array<any>} getPayloadsByType - Returns matching fragments by type (e.g., "identity:persist")
|
|
99
|
+
* @property {function(): Array<object>} getErrors - Returns all error objects from the response
|
|
100
|
+
* @property {function(): Array<object>} getWarnings - Returns all warning objects from the response
|
|
101
|
+
* @property {function(): object} getEdge - Returns object containing regionId from x-adobe-edge header
|
|
102
|
+
* @property {function(): ResponseContent} toJSON
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @typedef {function({content?: ResponseContent, getHeader: function(string): string|undefined}): Response} ResponseCreator
|
|
17
107
|
*/
|
|
18
108
|
|
|
19
109
|
const Types = exports.Types = {};
|
package/libEs5/utils/bytes.js
CHANGED
|
@@ -31,8 +31,19 @@ const base64ToBytes = base64String => {
|
|
|
31
31
|
/**
|
|
32
32
|
* Takes a Uint8Array and returns a base64 string.
|
|
33
33
|
* @param {Uint8Array} bytes
|
|
34
|
+
* @param {Object} [options={}] - Options for encoding
|
|
35
|
+
* @param {boolean} [options.urlSafe=false] - Whether to return URL-safe base64 (no padding, + becomes -, / becomes _)
|
|
34
36
|
* @returns {string}
|
|
35
37
|
*/
|
|
36
38
|
exports.base64ToBytes = base64ToBytes;
|
|
37
|
-
const bytesToBase64 = bytes =>
|
|
39
|
+
const bytesToBase64 = (bytes, options = {}) => {
|
|
40
|
+
const {
|
|
41
|
+
urlSafe = false
|
|
42
|
+
} = options || {};
|
|
43
|
+
const base64 = btoa(String.fromCharCode(...bytes));
|
|
44
|
+
if (urlSafe) {
|
|
45
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
46
|
+
}
|
|
47
|
+
return base64;
|
|
48
|
+
};
|
|
38
49
|
exports.bytesToBase64 = bytesToBase64;
|
|
@@ -12,6 +12,19 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
12
12
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
13
|
governing permissions and limitations under the License.
|
|
14
14
|
*/
|
|
15
|
+
/** @import { Logger } from '../core/types.js' */
|
|
16
|
+
/** @import { CookieJar } from './types.js' */
|
|
17
|
+
/**
|
|
18
|
+
* Creates a logging wrapper around a cookie jar that logs cookie operations.
|
|
19
|
+
*
|
|
20
|
+
* @function
|
|
21
|
+
*
|
|
22
|
+
* @param {object} options
|
|
23
|
+
* @param {Logger} options.logger
|
|
24
|
+
* @param {CookieJar} options.cookieJar
|
|
25
|
+
*
|
|
26
|
+
* @returns {CookieJar}
|
|
27
|
+
*/
|
|
15
28
|
var _default = ({
|
|
16
29
|
logger,
|
|
17
30
|
cookieJar
|
|
@@ -24,7 +37,7 @@ var _default = ({
|
|
|
24
37
|
value,
|
|
25
38
|
...options
|
|
26
39
|
});
|
|
27
|
-
cookieJar.set(key, value, options);
|
|
40
|
+
return cookieJar.set(key, value, options);
|
|
28
41
|
}
|
|
29
42
|
};
|
|
30
43
|
};
|
|
@@ -16,10 +16,11 @@ governing permissions and limitations under the License.
|
|
|
16
16
|
/**
|
|
17
17
|
* Creates a function that, when passed an object of updates, will merge
|
|
18
18
|
* the updates onto the current value of a payload property.
|
|
19
|
-
*
|
|
20
|
-
* @param {
|
|
21
|
-
* can be a dot-notation property path.
|
|
22
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* @param {object} content The base object to modify
|
|
21
|
+
* @param {string} key The property to merge updates into. This can be a dot-notation property path.
|
|
22
|
+
*
|
|
23
|
+
* @returns {function(object): void}
|
|
23
24
|
*/
|
|
24
25
|
var _default = (content, key) => updates => {
|
|
25
26
|
const propertyPath = key.split(".");
|
|
@@ -14,6 +14,16 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/** @import { Storage, StorageCreator } from './types.js' */
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a storage interface for a specific storage type with namespaced keys.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} context - The context object (typically window) that provides storage APIs.
|
|
23
|
+
* @param {string} storageType - The type of storage to use ('localStorage' or 'sessionStorage').
|
|
24
|
+
* @param {string} namespace - The namespace prefix to prepend to all storage keys.
|
|
25
|
+
* @returns {Storage}
|
|
26
|
+
*/
|
|
17
27
|
const getStorageByType = (context, storageType, namespace) => {
|
|
18
28
|
// When storage is disabled on Safari, the mere act of referencing
|
|
19
29
|
// window.localStorage or window.sessionStorage throws an error.
|
|
@@ -62,6 +72,15 @@ const getStorageByType = (context, storageType, namespace) => {
|
|
|
62
72
|
}
|
|
63
73
|
};
|
|
64
74
|
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Creates a storage factory function that provides access to both session and persistent storage
|
|
78
|
+
* with namespaced keys. This is a higher-order function that returns a function which can be
|
|
79
|
+
* used to create storage instances with additional namespace suffixes.
|
|
80
|
+
*
|
|
81
|
+
* @param {Object} context - The context object (typically window) that provides storage APIs.
|
|
82
|
+
* @returns {StorageCreator}
|
|
83
|
+
*/
|
|
65
84
|
var _default = context => additionalNamespace => {
|
|
66
85
|
const finalNamespace = _namespace.default + additionalNamespace;
|
|
67
86
|
return {
|
|
@@ -15,20 +15,28 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
15
15
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
16
|
governing permissions and limitations under the License.
|
|
17
17
|
*/
|
|
18
|
+
/** @import { DataCollectionRequestPayload } from './types.js' */
|
|
19
|
+
/**
|
|
20
|
+
* @function
|
|
21
|
+
*
|
|
22
|
+
* @returns {DataCollectionRequestPayload}
|
|
23
|
+
*/
|
|
18
24
|
var _default = () => {
|
|
19
25
|
const content = {};
|
|
20
|
-
const
|
|
26
|
+
const requestPayload = (0, _createRequestPayload.default)({
|
|
21
27
|
content,
|
|
22
28
|
addIdentity: (0, _createAddIdentity.default)(content),
|
|
23
29
|
hasIdentity: (0, _createHasIdentity.default)(content)
|
|
24
30
|
});
|
|
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
|
-
payload.getDocumentMayUnload = () => {
|
|
30
|
-
return (content.events || []).some(event => event.getDocumentMayUnload());
|
|
31
|
-
};
|
|
32
|
-
return payload;
|
|
33
41
|
};
|
|
34
42
|
exports.default = _default;
|
|
@@ -13,7 +13,34 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
13
13
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
/** @import { Request, RequestPayload } from './types.js' */
|
|
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
|
+
*/
|
|
17
44
|
var _default = options => {
|
|
18
45
|
const {
|
|
19
46
|
payload,
|
|
@@ -14,6 +14,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
14
14
|
governing permissions and limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/** @import { RequestPayload, Identity } from './types.js' */
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* createMerger creates a function that does a deep merge. Example:
|
|
19
21
|
* ```js
|
|
@@ -64,8 +66,19 @@ const createMergeConfigOverride = (content, key) => updates => {
|
|
|
64
66
|
Object.assign(hostObjectForUpdates, updates);
|
|
65
67
|
};
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Creates a request payload object with methods for merging different types of data.
|
|
71
|
+
* This provides the base functionality that all types of request payloads share.
|
|
72
|
+
*
|
|
73
|
+
* @function
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} options
|
|
76
|
+
* @param {Object} options.content
|
|
77
|
+
* @param {function(string, Identity): void} options.addIdentity
|
|
78
|
+
* @param {function(string): boolean} options.hasIdentity
|
|
79
|
+
*
|
|
80
|
+
* @returns {RequestPayload}
|
|
81
|
+
*/
|
|
69
82
|
var _default = options => {
|
|
70
83
|
const {
|
|
71
84
|
content,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Request object with methods to access and modify request properties.
|
|
6
|
+
*
|
|
7
|
+
* @typedef {Object} Request
|
|
8
|
+
* @property {function(): string} getId
|
|
9
|
+
* @property {function(): RequestPayload} getPayload
|
|
10
|
+
* @property {function({isIdentityEstablished: boolean}): string} getAction
|
|
11
|
+
* @property {function(): string|undefined} getDatastreamIdOverride
|
|
12
|
+
* @property {Function} getUseSendBeacon
|
|
13
|
+
* @property {function(): string|undefined} getEdgeSubPath
|
|
14
|
+
* @property {Function} getUseIdThirdPartyDomain
|
|
15
|
+
* @property {Function} setUseIdThirdPartyDomain
|
|
16
|
+
* @property {Function} setIsIdentityEstablished
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Request payload object with methods for merging different types of data.
|
|
21
|
+
*
|
|
22
|
+
* @typedef {Object} RequestPayload
|
|
23
|
+
* @property {function(object): void} mergeMeta
|
|
24
|
+
* @property {function(object): void} mergeState
|
|
25
|
+
* @property {function(object): void} mergeQuery
|
|
26
|
+
* @property {function(object): void} mergeConfigOverride
|
|
27
|
+
* @property {function(string, Identity): void} options.addIdentity
|
|
28
|
+
* @property {function(string): boolean} options.hasIdentity
|
|
29
|
+
* @property {function(): object} toJSON
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Request payload object with methods for merging different types of data.
|
|
34
|
+
*
|
|
35
|
+
* @typedef {Object} DataCollectionRequestPayload
|
|
36
|
+
* @property {function(object): void} mergeMeta
|
|
37
|
+
* @property {function(object): void} mergeState
|
|
38
|
+
* @property {function(object): void} mergeQuery
|
|
39
|
+
* @property {function(object): void} mergeConfigOverride
|
|
40
|
+
* @property {function(string, Identity): void} options.addIdentity
|
|
41
|
+
* @property {function(string): boolean} options.hasIdentity
|
|
42
|
+
* @property {function(object): void} addEvent
|
|
43
|
+
* @property {function(): boolean} getDocumentMayUnload
|
|
44
|
+
* @property {function(): object} toJSON
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {Object} Identity
|
|
49
|
+
* @property {string} id
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
const Types = exports.Types = {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} Storage
|
|
6
|
+
* @property {function(string): string|null} getItem
|
|
7
|
+
* @property {function(string, string): void} setItem
|
|
8
|
+
* @property {function(): void} clear
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} CookieAttributes
|
|
13
|
+
* @property {number|Date} [expires] - Cookie expiration (number of days or Date object)
|
|
14
|
+
* @property {string} [path] - Cookie path (default: "/")
|
|
15
|
+
* @property {string} [domain] - Cookie domain
|
|
16
|
+
* @property {boolean} [secure] - Requires HTTPS transmission
|
|
17
|
+
* @property {"strict"|"lax"|"none"} [sameSite] - SameSite attribute
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} CookieConverter
|
|
22
|
+
* @property {function(string, string): string} [read] - Custom decoder function
|
|
23
|
+
* @property {function(string, string): string} [write] - Custom encoder function
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {Object} CookieJar
|
|
28
|
+
* @property {function(string): string|undefined} get - Get cookie value by name, or get all cookies as object if no name provided
|
|
29
|
+
* @property {function(): Object<string, string>} get - Get all cookies as key-value object when called with no arguments
|
|
30
|
+
* @property {function(string, string, CookieAttributes=): string|undefined} set - Set cookie with optional attributes
|
|
31
|
+
* @property {function(string, CookieAttributes=): void} remove - Remove cookie with optional attributes (must match set attributes)
|
|
32
|
+
* @property {function(CookieConverter): CookieJar} withConverter - Create new instance with custom encoding/decoding
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {function(string): { session: Storage, persistent: Storage }} StorageCreator
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const Types = exports.Types = {};
|
|
@@ -17,6 +17,10 @@ import isButtonSubmitElement from "./isButtonSubmitElement.js";
|
|
|
17
17
|
export default element => {
|
|
18
18
|
let node = element;
|
|
19
19
|
while (node) {
|
|
20
|
+
// Stop looking when BODY is reached
|
|
21
|
+
if (node.nodeName && node.nodeName === "BODY") {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
20
24
|
if (isSupportedAnchorElement(node) || elementHasClickHandler(node) || isInputSubmitElement(node) || isButtonSubmitElement(node)) {
|
|
21
25
|
return node;
|
|
22
26
|
}
|
|
@@ -62,7 +62,8 @@ export default async function handleClickThrough({
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
eventType: AD_CONVERSION_CLICK_EVENT_TYPE
|
|
65
|
+
eventType: AD_CONVERSION_CLICK_EVENT_TYPE,
|
|
66
|
+
timestamp: new Date().toISOString()
|
|
66
67
|
};
|
|
67
68
|
event.setUserXdm(xdm);
|
|
68
69
|
cookieManager.setValue(LAST_CONVERSION_TIME_KEY);
|