@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
|
@@ -10,18 +10,54 @@ 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 { ConsentStateMachineUtils, ConsentStateMachine } from './types.js' */
|
|
15
|
+
|
|
13
16
|
import { defer } from "../../utils/index.js";
|
|
14
17
|
export const DECLINED_CONSENT = "The user declined consent.";
|
|
15
18
|
export const DECLINED_CONSENT_ERROR_CODE = "declinedConsent";
|
|
16
19
|
export const CONSENT_SOURCE_DEFAULT = "default";
|
|
17
20
|
export const CONSENT_SOURCE_INITIAL = "initial";
|
|
18
21
|
export const CONSENT_SOURCE_NEW = "new";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
* @param {string} errorMessage
|
|
26
|
+
* @returns {Error}
|
|
27
|
+
*/
|
|
19
28
|
const createDeclinedConsentError = errorMessage => {
|
|
20
29
|
const error = new Error(errorMessage);
|
|
21
30
|
error.code = DECLINED_CONSENT_ERROR_CODE;
|
|
22
31
|
error.message = errorMessage;
|
|
23
32
|
return error;
|
|
24
33
|
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a consent state machine that manages user consent preferences and
|
|
37
|
+
* coordinates deferred operations that require consent.
|
|
38
|
+
*
|
|
39
|
+
* The state machine supports the following states:
|
|
40
|
+
* - "in": User has provided consent (with default or explicit consent)
|
|
41
|
+
* - "out": User has declined consent (with default or explicit decline)
|
|
42
|
+
* - "pending": Consent decision is awaiting user input
|
|
43
|
+
*
|
|
44
|
+
* @param {object} options
|
|
45
|
+
* @param {Logger} options.logger
|
|
46
|
+
*
|
|
47
|
+
* @returns {ConsentStateMachine}
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const consentStateMachine = createConsentStateMachine({ logger });
|
|
51
|
+
*
|
|
52
|
+
* // Set consent state
|
|
53
|
+
* consentStateMachine.in('new');
|
|
54
|
+
*
|
|
55
|
+
* // Wait for consent
|
|
56
|
+
* await consentStateMachine.awaitConsent();
|
|
57
|
+
*
|
|
58
|
+
* // Check current state
|
|
59
|
+
* const { state, wasSet } = consentStateMachine.current();
|
|
60
|
+
*/
|
|
25
61
|
export default ({
|
|
26
62
|
logger
|
|
27
63
|
}) => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} ConsentStateMachine
|
|
3
|
+
* @property {function(string): void} in
|
|
4
|
+
* @property {function(string): void} out
|
|
5
|
+
* @property {function(string): void} pending
|
|
6
|
+
* @property {function(boolean=): Promise<void>} awaitConsent
|
|
7
|
+
* @property {function(): Promise<void>} withConsent
|
|
8
|
+
* @property {function(): {state: string, wasSet: boolean}} current
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} ConsentManager
|
|
13
|
+
* @property {function(Object, Object): void} initializeConsent
|
|
14
|
+
* @property {function(Object): void} setConsent
|
|
15
|
+
* @property {function(): void} suspend
|
|
16
|
+
* @property {function(): Promise<void>} awaitConsent
|
|
17
|
+
* @property {function(): Promise<void>} withConsent
|
|
18
|
+
* @property {function(): {state: string, wasSet: boolean}} current
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const Types = {};
|
|
@@ -10,6 +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
|
|
|
13
|
+
/** @import { EdgeRequestExecutor } from './types.js' */
|
|
14
|
+
/** @import { ResponseCreator } from '../types.js' */
|
|
15
|
+
|
|
13
16
|
import { ID_THIRD_PARTY as ID_THIRD_PARTY_DOMAIN } from "../../constants/domain.js";
|
|
14
17
|
import apiVersion from "../../constants/apiVersion.js";
|
|
15
18
|
import { createCallbackAggregator, noop } from "../../utils/index.js";
|
|
@@ -19,6 +22,23 @@ import handleRequestFailure from "./handleRequestFailure.js";
|
|
|
19
22
|
const isDemdexBlockedError = (error, request) => {
|
|
20
23
|
return request.getUseIdThirdPartyDomain() && isNetworkError(error);
|
|
21
24
|
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @function
|
|
28
|
+
*
|
|
29
|
+
* @param {object} options
|
|
30
|
+
* @param {{edgeDomain: string, edgeBasePath: string, datastreamId: string}} options.config
|
|
31
|
+
* @param {object} options.lifecycle
|
|
32
|
+
* @param {object} options.cookieTransfer
|
|
33
|
+
* @param {function(object): Promise<Object>} options.sendNetworkRequest
|
|
34
|
+
* @param {ResponseCreator} options.createResponse
|
|
35
|
+
* @param {function(object): void} options.processWarningsAndErrors
|
|
36
|
+
* @param {function(): string|undefined} options.getLocationHint
|
|
37
|
+
* @param {function(): string} options.getAssuranceValidationTokenParams
|
|
38
|
+
|
|
39
|
+
*
|
|
40
|
+
* @returns {EdgeRequestExecutor} A function that sends edge network requests with lifecycle management
|
|
41
|
+
*/
|
|
22
42
|
export default ({
|
|
23
43
|
config,
|
|
24
44
|
lifecycle,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @import { Request } from '../../utils/request/types.js' */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {function({request: Request, runOnResponseCallbacks?: function(): void, runOnRequestFailureCallbacks?: function(): void}): Promise<Object>} EdgeRequestExecutor
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const Types = {};
|
|
@@ -10,7 +10,45 @@ 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 { IdentityManager } from './types.js' */
|
|
14
|
+
/** @import { Logger } from '../types.js' */
|
|
15
|
+
/** @import { CookieJar } from '../../utils/types.js' */
|
|
16
|
+
|
|
13
17
|
import createDecodeKndctrCookie from "../../utils/createDecodeKndctrCookie.js";
|
|
18
|
+
|
|
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
|
+
*/
|
|
14
52
|
export default ({
|
|
15
53
|
logger,
|
|
16
54
|
loggingCookieJar,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @import { Logger } from '../../core/types.js' */
|
|
2
|
+
/** @import { CookieJar } from '../../utils/types.js' */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} IdentityManager
|
|
6
|
+
* @property {Function} initialize
|
|
7
|
+
* @property {Function} setIdentityAcquired - Marks identity as acquired and resolves any pending identity promises
|
|
8
|
+
* @property {Function} awaitIdentity - Returns a promise that resolves when identity is acquired
|
|
9
|
+
* @property {Function} getEcidFromCookie
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const Types = {};
|
|
@@ -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 = {};
|
package/libEs6/utils/bytes.js
CHANGED
|
@@ -28,6 +28,17 @@ export const base64ToBytes = base64String => {
|
|
|
28
28
|
/**
|
|
29
29
|
* Takes a Uint8Array and returns a base64 string.
|
|
30
30
|
* @param {Uint8Array} bytes
|
|
31
|
+
* @param {Object} [options={}] - Options for encoding
|
|
32
|
+
* @param {boolean} [options.urlSafe=false] - Whether to return URL-safe base64 (no padding, + becomes -, / becomes _)
|
|
31
33
|
* @returns {string}
|
|
32
34
|
*/
|
|
33
|
-
export const bytesToBase64 = bytes =>
|
|
35
|
+
export const bytesToBase64 = (bytes, options = {}) => {
|
|
36
|
+
const {
|
|
37
|
+
urlSafe = false
|
|
38
|
+
} = options || {};
|
|
39
|
+
const base64 = btoa(String.fromCharCode(...bytes));
|
|
40
|
+
if (urlSafe) {
|
|
41
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
42
|
+
}
|
|
43
|
+
return base64;
|
|
44
|
+
};
|
|
@@ -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(".");
|
|
@@ -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,6 +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
|
|
|
13
|
+
/** @import { RequestPayload, Identity } from './types.js' */
|
|
14
|
+
|
|
13
15
|
import { createMerger, prepareConfigOverridesForEdge } from "../index.js";
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -62,8 +64,19 @@ const createMergeConfigOverride = (content, key) => updates => {
|
|
|
62
64
|
Object.assign(hostObjectForUpdates, updates);
|
|
63
65
|
};
|
|
64
66
|
|
|
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
|
+
*/
|
|
67
80
|
export default options => {
|
|
68
81
|
const {
|
|
69
82
|
content,
|
|
@@ -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 = {};
|