@adobe/alloy 2.34.0-beta.0 → 2.34.0-beta.2
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/dist/alloy.js +483 -169
- package/dist/alloy.min.js +2 -2
- package/dist/types/browser/src/services/createBrowserCookieService.d.ts +15 -0
- package/dist/types/browser/src/services/createBrowserGlobalsService.d.ts +5 -0
- package/dist/types/browser/src/services/createBrowserLegacyService.d.ts +4 -0
- package/dist/types/browser/src/services/createBrowserNetworkService.d.ts +9 -0
- package/dist/types/browser/src/services/createBrowserPlatformServices.d.ts +9 -0
- package/dist/types/browser/src/services/createBrowserRuntimeService.d.ts +5 -0
- package/dist/types/browser/src/services/createBrowserStorageService.d.ts +4 -0
- package/dist/types/browser/src/services/index.d.ts +7 -0
- package/dist/types/core/src/components/BrandConcierge/createBuildEndpointUrl.d.ts +1 -2
- package/dist/types/core/src/components/BrandConcierge/createConversationServiceRequest.d.ts +2 -1
- package/dist/types/core/src/core/createLogController.d.ts +1 -2
- package/dist/types/core/src/core/index.d.ts +7 -12
- package/dist/types/core/src/index.d.ts +7 -2
- package/dist/types/core/src/services/index.d.ts +27 -0
- package/dist/types/core/src/services/types.d.ts +91 -0
- package/dist/types/core/src/utils/getApexDomain.d.ts +1 -1
- package/dist/types/core/src/utils/request/createGetAssuranceValidationTokenParams.d.ts +2 -2
- package/package.json +2 -2
- package/src/index.js +8 -4
- package/src/services/createBrowserCookieService.js +34 -0
- package/src/services/createBrowserGlobalsService.js +30 -0
- package/src/services/createBrowserLegacyService.js +91 -0
- package/src/services/createBrowserNetworkService.js +41 -0
- package/src/services/createBrowserPlatformServices.js +35 -0
- package/src/services/createBrowserRuntimeService.js +26 -0
- package/src/services/createBrowserStorageService.js +74 -0
- package/src/services/index.js +19 -0
- package/dist/types/core/src/core/createInstanceFunction.d.ts +0 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default createBrowserCookieService;
|
|
2
|
+
/**
|
|
3
|
+
* The optional `jar` parameter is the recursion seam for `withConverter` —
|
|
4
|
+
* every converted js-cookie instance must itself satisfy `CookieService`.
|
|
5
|
+
*
|
|
6
|
+
* @param {{ get: Function, set: Function, remove: Function, withConverter: Function }} [jar]
|
|
7
|
+
* @returns {CookieService}
|
|
8
|
+
*/
|
|
9
|
+
declare function createBrowserCookieService(jar?: {
|
|
10
|
+
get: Function;
|
|
11
|
+
set: Function;
|
|
12
|
+
remove: Function;
|
|
13
|
+
withConverter: Function;
|
|
14
|
+
}): CookieService;
|
|
15
|
+
import type { CookieService } from "@adobe/alloy-core/services";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export default createBrowserGlobalsService;
|
|
2
|
+
/** @import { GlobalsService } from "@adobe/alloy-core/services" */
|
|
3
|
+
/** @returns {GlobalsService} */
|
|
4
|
+
declare function createBrowserGlobalsService(): GlobalsService;
|
|
5
|
+
import type { GlobalsService } from "@adobe/alloy-core/services";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default createBrowserNetworkService;
|
|
2
|
+
/**
|
|
3
|
+
* @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
|
|
4
|
+
* @returns {NetworkService}
|
|
5
|
+
*/
|
|
6
|
+
declare function createBrowserNetworkService({ logger }: {
|
|
7
|
+
logger: import("@adobe/alloy-core/core/types.js").Logger;
|
|
8
|
+
}): NetworkService;
|
|
9
|
+
import type { NetworkService } from "@adobe/alloy-core/services";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default createBrowserPlatformServices;
|
|
2
|
+
/**
|
|
3
|
+
* @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
|
|
4
|
+
* @returns {PlatformServices}
|
|
5
|
+
*/
|
|
6
|
+
declare function createBrowserPlatformServices({ logger }: {
|
|
7
|
+
logger: import("@adobe/alloy-core/core/types.js").Logger;
|
|
8
|
+
}): PlatformServices;
|
|
9
|
+
import type { PlatformServices } from "@adobe/alloy-core/services";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export default createBrowserRuntimeService;
|
|
2
|
+
/** @import { RuntimeService } from "@adobe/alloy-core/services" */
|
|
3
|
+
/** @returns {RuntimeService} */
|
|
4
|
+
declare function createBrowserRuntimeService(): RuntimeService;
|
|
5
|
+
import type { RuntimeService } from "@adobe/alloy-core/services";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as createBrowserNetworkService } from "./createBrowserNetworkService.js";
|
|
2
|
+
export { default as createBrowserStorageService } from "./createBrowserStorageService.js";
|
|
3
|
+
export { default as createBrowserCookieService } from "./createBrowserCookieService.js";
|
|
4
|
+
export { default as createBrowserRuntimeService } from "./createBrowserRuntimeService.js";
|
|
5
|
+
export { default as createBrowserLegacyService } from "./createBrowserLegacyService.js";
|
|
6
|
+
export { default as createBrowserGlobalsService } from "./createBrowserGlobalsService.js";
|
|
7
|
+
export { default as createBrowserPlatformServices } from "./createBrowserPlatformServices.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
declare function _default({ payload, action, sessionId, voiceEnabled, }: {
|
|
1
|
+
declare function _default({ payload, action, sessionId, voiceEnabled, region, }: {
|
|
2
2
|
payload: any;
|
|
3
3
|
action?: string | undefined;
|
|
4
4
|
sessionId: any;
|
|
5
5
|
voiceEnabled?: boolean | undefined;
|
|
6
|
+
region: any;
|
|
6
7
|
}): import("../../utils/request/types.js").Request;
|
|
7
8
|
export default _default;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
declare function _default({ console,
|
|
1
|
+
declare function _default({ console, createLogger, instanceName, createNamespacedStorage, getMonitors, }: {
|
|
2
2
|
console: any;
|
|
3
|
-
locationSearch: any;
|
|
4
3
|
createLogger: any;
|
|
5
4
|
instanceName: any;
|
|
6
5
|
createNamespacedStorage: any;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
export function createExecuteCommand({ instanceName,
|
|
2
|
-
instanceName:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
components: any;
|
|
1
|
+
export function createExecuteCommand({ instanceName, monitors, components, createPlatformServices, }: {
|
|
2
|
+
instanceName: string;
|
|
3
|
+
monitors?: import("./types.js").AlloyMonitor[] | undefined;
|
|
4
|
+
components: Array<Function>;
|
|
5
|
+
createPlatformServices: (deps: {
|
|
6
|
+
logger: import("./types.js").Logger;
|
|
7
|
+
}) => import("../services/index.js").PlatformServices;
|
|
9
8
|
}): (commandName: any, options?: {}) => Promise<any>;
|
|
10
|
-
declare function _default({ components }: {
|
|
11
|
-
components: any;
|
|
12
|
-
}): void;
|
|
13
|
-
export default _default;
|
|
@@ -2,8 +2,13 @@ export function createCustomInstance(options?: {
|
|
|
2
2
|
name?: string | undefined;
|
|
3
3
|
monitors?: import("./core/types.js").AlloyMonitor[] | undefined;
|
|
4
4
|
components?: Function[] | undefined;
|
|
5
|
-
}): (commandName: string, options?: Object) => Promise<any>;
|
|
5
|
+
}, createPlatformServices?: CreatePlatformServices): (commandName: string, options?: Object) => Promise<any>;
|
|
6
6
|
export function createInstance(options?: {
|
|
7
7
|
name?: string | undefined;
|
|
8
8
|
monitors?: import("./core/types.js").AlloyMonitor[] | undefined;
|
|
9
|
-
}): (commandName: string, options?: Object) => Promise<any>;
|
|
9
|
+
}, createPlatformServices?: CreatePlatformServices): (commandName: string, options?: Object) => Promise<any>;
|
|
10
|
+
export type CreatePlatformServices = (deps: {
|
|
11
|
+
logger: Logger;
|
|
12
|
+
}) => PlatformServices;
|
|
13
|
+
import type { Logger } from './core/types.js';
|
|
14
|
+
import type { PlatformServices } from './services/index.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./types.js").NetworkResponse} NetworkResponse
|
|
3
|
+
* @typedef {import("./types.js").NetworkService} NetworkService
|
|
4
|
+
* @typedef {import("./types.js").Storage} Storage
|
|
5
|
+
* @typedef {import("./types.js").NamespacedStorage} NamespacedStorage
|
|
6
|
+
* @typedef {import("./types.js").StorageService} StorageService
|
|
7
|
+
* @typedef {import("./types.js").CookieAttributes} CookieAttributes
|
|
8
|
+
* @typedef {import("./types.js").CookieConverter} CookieConverter
|
|
9
|
+
* @typedef {import("./types.js").CookieService} CookieService
|
|
10
|
+
* @typedef {import("./types.js").RuntimeService} RuntimeService
|
|
11
|
+
* @typedef {import("./types.js").LegacyService} LegacyService
|
|
12
|
+
* @typedef {import("./types.js").GlobalsService} GlobalsService
|
|
13
|
+
* @typedef {import("./types.js").PlatformServices} PlatformServices
|
|
14
|
+
*/
|
|
15
|
+
export const Services: {};
|
|
16
|
+
export type NetworkResponse = import("./types.js").NetworkResponse;
|
|
17
|
+
export type NetworkService = import("./types.js").NetworkService;
|
|
18
|
+
export type Storage = import("./types.js").Storage;
|
|
19
|
+
export type NamespacedStorage = import("./types.js").NamespacedStorage;
|
|
20
|
+
export type StorageService = import("./types.js").StorageService;
|
|
21
|
+
export type CookieAttributes = import("./types.js").CookieAttributes;
|
|
22
|
+
export type CookieConverter = import("./types.js").CookieConverter;
|
|
23
|
+
export type CookieService = import("./types.js").CookieService;
|
|
24
|
+
export type RuntimeService = import("./types.js").RuntimeService;
|
|
25
|
+
export type LegacyService = import("./types.js").LegacyService;
|
|
26
|
+
export type GlobalsService = import("./types.js").GlobalsService;
|
|
27
|
+
export type PlatformServices = import("./types.js").PlatformServices;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export type NetworkResponse = {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
body: string;
|
|
4
|
+
getHeader: (name: string) => (string | null);
|
|
5
|
+
};
|
|
6
|
+
export type SendFetchRequest = (url: string, body: string) => Promise<NetworkResponse>;
|
|
7
|
+
export type SendBeaconRequest = (url: string, body: string) => Promise<NetworkResponse>;
|
|
8
|
+
export type NetworkService = {
|
|
9
|
+
/**
|
|
10
|
+
* Must send cookies (`credentials: "include"` in browsers).
|
|
11
|
+
*/
|
|
12
|
+
sendFetchRequest: SendFetchRequest;
|
|
13
|
+
/**
|
|
14
|
+
* May fall back to `sendFetchRequest` when the underlying transport is
|
|
15
|
+
* unavailable.
|
|
16
|
+
*/
|
|
17
|
+
sendBeaconRequest: SendBeaconRequest;
|
|
18
|
+
};
|
|
19
|
+
export type Storage = {
|
|
20
|
+
getItem: (name: string) => Promise<string | null>;
|
|
21
|
+
setItem: (name: string, value: string) => Promise<boolean>;
|
|
22
|
+
removeItem: (name: string) => Promise<boolean>;
|
|
23
|
+
clear: () => Promise<boolean>;
|
|
24
|
+
};
|
|
25
|
+
export type NamespacedStorage = {
|
|
26
|
+
session: Storage;
|
|
27
|
+
persistent: Storage;
|
|
28
|
+
};
|
|
29
|
+
export type StorageService = {
|
|
30
|
+
createNamespacedStorage: (namespace: string) => NamespacedStorage;
|
|
31
|
+
};
|
|
32
|
+
export type CookieAttributes = {
|
|
33
|
+
domain?: string | undefined;
|
|
34
|
+
path?: string | undefined;
|
|
35
|
+
expires?: number | Date | undefined;
|
|
36
|
+
secure?: boolean | undefined;
|
|
37
|
+
sameSite?: "strict" | "lax" | "none" | undefined;
|
|
38
|
+
};
|
|
39
|
+
export type CookieConverter = {
|
|
40
|
+
read?: ((value: string, name: string) => string) | undefined;
|
|
41
|
+
write?: ((value: string, name: string) => string) | undefined;
|
|
42
|
+
};
|
|
43
|
+
export type CookieService = {
|
|
44
|
+
get: (name: string) => (string | undefined);
|
|
45
|
+
set: (name: string, value: string, options?: CookieAttributes) => (string | undefined);
|
|
46
|
+
remove: (name: string, options?: CookieAttributes) => void;
|
|
47
|
+
withConverter: (converter: CookieConverter) => CookieService;
|
|
48
|
+
};
|
|
49
|
+
export type RuntimeService = {
|
|
50
|
+
setTimeout: (handler: Function, timeout?: number, ...args: any[]) => any;
|
|
51
|
+
clearTimeout: (id: any) => void;
|
|
52
|
+
atob: (data: string) => string;
|
|
53
|
+
btoa: (data: string) => string;
|
|
54
|
+
TextEncoder: typeof TextEncoder;
|
|
55
|
+
TextDecoder: typeof TextDecoder;
|
|
56
|
+
/**
|
|
57
|
+
* Epoch-millisecond timestamp.
|
|
58
|
+
*/
|
|
59
|
+
now: () => number;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Bridge to legacy Adobe libraries (Visitor.js, `adobe.optIn`).
|
|
63
|
+
*/
|
|
64
|
+
export type LegacyService = {
|
|
65
|
+
getEcidFromVisitor: (params: {
|
|
66
|
+
orgId: string;
|
|
67
|
+
logger: import("../core/types.js").Logger;
|
|
68
|
+
}) => Promise<string | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* Resolves immediately when no legacy opt-in object is present.
|
|
71
|
+
*/
|
|
72
|
+
awaitVisitorOptIn: (params: {
|
|
73
|
+
logger: import("../core/types.js").Logger;
|
|
74
|
+
}) => Promise<void>;
|
|
75
|
+
};
|
|
76
|
+
export type GlobalsService = {
|
|
77
|
+
getInstanceNames: () => string[];
|
|
78
|
+
getInstanceQueue: (instanceName: string) => any[];
|
|
79
|
+
getMonitors: () => import("../core/types.js").AlloyMonitor[];
|
|
80
|
+
getLocationSearch: () => string;
|
|
81
|
+
getUserAgent: () => string;
|
|
82
|
+
getHostname: () => string;
|
|
83
|
+
};
|
|
84
|
+
export type PlatformServices = {
|
|
85
|
+
network: NetworkService;
|
|
86
|
+
storage: StorageService;
|
|
87
|
+
cookie: CookieService;
|
|
88
|
+
runtime: RuntimeService;
|
|
89
|
+
legacy: LegacyService;
|
|
90
|
+
globals: GlobalsService;
|
|
91
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function _default(
|
|
1
|
+
declare function _default(hostname: string, cookieJar: Object): string;
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.34.0-beta.
|
|
3
|
+
"version": "2.34.0-beta.2",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"commander": "^14.0.2",
|
|
69
69
|
"rollup": "^4.60.3",
|
|
70
70
|
"rollup-plugin-license": "^3.7.1",
|
|
71
|
-
"@adobe/alloy-core": "^1.2.0-beta.
|
|
71
|
+
"@adobe/alloy-core": "^1.2.0-beta.2"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"glob": "^13.0.6",
|
package/src/index.js
CHANGED
|
@@ -12,12 +12,16 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
import { createCustomInstance as createCoreCustomInstance } from "@adobe/alloy-core";
|
|
13
13
|
import * as allOptionalComponents from "./allOptionalComponents.js";
|
|
14
14
|
import * as allRequiredComponents from "./components/requiredComponentCreators.js";
|
|
15
|
+
import createBrowserPlatformServices from "./services/createBrowserPlatformServices.js";
|
|
15
16
|
|
|
16
17
|
export const createCustomInstance = ({ components = [], ...options } = {}) =>
|
|
17
|
-
createCoreCustomInstance(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
createCoreCustomInstance(
|
|
19
|
+
{
|
|
20
|
+
...options,
|
|
21
|
+
components: [...Object.values(allRequiredComponents), ...components],
|
|
22
|
+
},
|
|
23
|
+
createBrowserPlatformServices,
|
|
24
|
+
);
|
|
21
25
|
|
|
22
26
|
export const createInstance = (options = {}) =>
|
|
23
27
|
createCustomInstance({
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 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
|
+
/** @import { CookieService } from "@adobe/alloy-core/services" */
|
|
14
|
+
|
|
15
|
+
import cookieJar from "@adobe/alloy-core/utils/cookieJar.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The optional `jar` parameter is the recursion seam for `withConverter` —
|
|
19
|
+
* every converted js-cookie instance must itself satisfy `CookieService`.
|
|
20
|
+
*
|
|
21
|
+
* @param {{ get: Function, set: Function, remove: Function, withConverter: Function }} [jar]
|
|
22
|
+
* @returns {CookieService}
|
|
23
|
+
*/
|
|
24
|
+
const createBrowserCookieService = (jar = cookieJar) => ({
|
|
25
|
+
get: (name) => jar.get(name),
|
|
26
|
+
set: (name, value, options) => jar.set(name, value, options),
|
|
27
|
+
remove: (name, options) => {
|
|
28
|
+
jar.remove(name, options);
|
|
29
|
+
},
|
|
30
|
+
withConverter: (converter) =>
|
|
31
|
+
createBrowserCookieService(jar.withConverter(converter)),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export default createBrowserCookieService;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 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
|
+
/* eslint-disable dot-notation */
|
|
14
|
+
|
|
15
|
+
/** @import { GlobalsService } from "@adobe/alloy-core/services" */
|
|
16
|
+
|
|
17
|
+
/** @returns {GlobalsService} */
|
|
18
|
+
const createBrowserGlobalsService = () => ({
|
|
19
|
+
getInstanceNames: () => window["__alloyNS"] || [],
|
|
20
|
+
getInstanceQueue: (instanceName) => {
|
|
21
|
+
const namespace = window[instanceName];
|
|
22
|
+
return (namespace && namespace.q) || [];
|
|
23
|
+
},
|
|
24
|
+
getMonitors: () => window["__alloyMonitors"] || [],
|
|
25
|
+
getLocationSearch: () => window.location.search,
|
|
26
|
+
getUserAgent: () => window.navigator.userAgent,
|
|
27
|
+
getHostname: () => window.location.hostname,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export default createBrowserGlobalsService;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 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
|
+
/** @import { LegacyService } from "@adobe/alloy-core/services" */
|
|
14
|
+
|
|
15
|
+
import { isFunction, isObject } from "@adobe/alloy-core/utils/index.js";
|
|
16
|
+
|
|
17
|
+
const getVisitor = () => {
|
|
18
|
+
const { Visitor } = window;
|
|
19
|
+
return isFunction(Visitor) && isFunction(Visitor.getInstance) && Visitor;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} params
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
const awaitVisitorOptIn = ({ logger }) =>
|
|
27
|
+
new Promise((resolve, reject) => {
|
|
28
|
+
if (isObject(window.adobe) && isObject(window.adobe.optIn)) {
|
|
29
|
+
const optInOld = window.adobe.optIn;
|
|
30
|
+
logger.info(
|
|
31
|
+
"Delaying request while waiting for legacy opt-in to let Visitor retrieve ECID from server.",
|
|
32
|
+
);
|
|
33
|
+
optInOld.fetchPermissions(() => {
|
|
34
|
+
if (optInOld.isApproved([optInOld.Categories.ECID])) {
|
|
35
|
+
logger.info(
|
|
36
|
+
"Received legacy opt-in approval to let Visitor retrieve ECID from server.",
|
|
37
|
+
);
|
|
38
|
+
resolve();
|
|
39
|
+
} else {
|
|
40
|
+
reject(new Error("Legacy opt-in was declined."));
|
|
41
|
+
}
|
|
42
|
+
}, true);
|
|
43
|
+
} else {
|
|
44
|
+
resolve();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {{ orgId: string, logger: import('@adobe/alloy-core/core/types.js').Logger }} params
|
|
50
|
+
* @returns {Promise<string | undefined>}
|
|
51
|
+
*/
|
|
52
|
+
const getEcidFromVisitor = async ({ orgId, logger }) => {
|
|
53
|
+
const Visitor = getVisitor();
|
|
54
|
+
if (!Visitor) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
await awaitVisitorOptIn({ logger });
|
|
59
|
+
logger.info(
|
|
60
|
+
"Delaying request while using Visitor to retrieve ECID from server.",
|
|
61
|
+
);
|
|
62
|
+
return await new Promise((resolve) => {
|
|
63
|
+
const visitor = Visitor.getInstance(orgId, {});
|
|
64
|
+
visitor.getMarketingCloudVisitorID((ecid) => {
|
|
65
|
+
logger.info(
|
|
66
|
+
"Resuming previously delayed request that was waiting for ECID from Visitor.",
|
|
67
|
+
);
|
|
68
|
+
resolve(ecid);
|
|
69
|
+
}, true);
|
|
70
|
+
});
|
|
71
|
+
} catch (error) {
|
|
72
|
+
// If consent was denied, fall back to retrieving the ECID from the
|
|
73
|
+
// experience edge. OptIn and AEP Web SDK consent should operate
|
|
74
|
+
// independently, but during ID migration AEP Web SDK needs to wait for
|
|
75
|
+
// optIn so that only one ECID is generated.
|
|
76
|
+
if (error) {
|
|
77
|
+
logger.info(`${error.message}, retrieving ECID from experience edge`);
|
|
78
|
+
} else {
|
|
79
|
+
logger.info("An error occurred while obtaining the ECID from Visitor.");
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** @returns {LegacyService} */
|
|
86
|
+
const createBrowserLegacyService = () => ({
|
|
87
|
+
getEcidFromVisitor,
|
|
88
|
+
awaitVisitorOptIn,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export default createBrowserLegacyService;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 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
|
+
/** @import { NetworkService } from "@adobe/alloy-core/services" */
|
|
14
|
+
|
|
15
|
+
import injectSendFetchRequest from "@adobe/alloy-core/core/network/requestMethods/injectSendFetchRequest.js";
|
|
16
|
+
import injectSendBeaconRequest from "@adobe/alloy-core/core/network/requestMethods/injectSendBeaconRequest.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
|
|
20
|
+
* @returns {NetworkService}
|
|
21
|
+
*/
|
|
22
|
+
const createBrowserNetworkService = ({ logger }) => {
|
|
23
|
+
const { fetch, navigator } = window;
|
|
24
|
+
const sendFetchRequest = injectSendFetchRequest({ fetch });
|
|
25
|
+
const sendBeaconRequest =
|
|
26
|
+
typeof navigator.sendBeacon === "function"
|
|
27
|
+
? injectSendBeaconRequest({
|
|
28
|
+
// bind() avoids "illegal invocation" when sendBeacon loses its receiver.
|
|
29
|
+
sendBeacon: navigator.sendBeacon.bind(navigator),
|
|
30
|
+
sendFetchRequest,
|
|
31
|
+
logger,
|
|
32
|
+
})
|
|
33
|
+
: sendFetchRequest;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
sendFetchRequest,
|
|
37
|
+
sendBeaconRequest,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default createBrowserNetworkService;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 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
|
+
/** @import { PlatformServices } from "@adobe/alloy-core/services" */
|
|
14
|
+
|
|
15
|
+
import createBrowserNetworkService from "./createBrowserNetworkService.js";
|
|
16
|
+
import createBrowserStorageService from "./createBrowserStorageService.js";
|
|
17
|
+
import createBrowserCookieService from "./createBrowserCookieService.js";
|
|
18
|
+
import createBrowserRuntimeService from "./createBrowserRuntimeService.js";
|
|
19
|
+
import createBrowserLegacyService from "./createBrowserLegacyService.js";
|
|
20
|
+
import createBrowserGlobalsService from "./createBrowserGlobalsService.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
|
|
24
|
+
* @returns {PlatformServices}
|
|
25
|
+
*/
|
|
26
|
+
const createBrowserPlatformServices = ({ logger }) => ({
|
|
27
|
+
network: createBrowserNetworkService({ logger }),
|
|
28
|
+
storage: createBrowserStorageService(),
|
|
29
|
+
cookie: createBrowserCookieService(),
|
|
30
|
+
runtime: createBrowserRuntimeService(),
|
|
31
|
+
legacy: createBrowserLegacyService(),
|
|
32
|
+
globals: createBrowserGlobalsService(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export default createBrowserPlatformServices;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 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
|
+
/** @import { RuntimeService } from "@adobe/alloy-core/services" */
|
|
14
|
+
|
|
15
|
+
/** @returns {RuntimeService} */
|
|
16
|
+
const createBrowserRuntimeService = () => ({
|
|
17
|
+
setTimeout: window.setTimeout.bind(window),
|
|
18
|
+
clearTimeout: window.clearTimeout.bind(window),
|
|
19
|
+
atob: window.atob.bind(window),
|
|
20
|
+
btoa: window.btoa.bind(window),
|
|
21
|
+
TextEncoder: window.TextEncoder,
|
|
22
|
+
TextDecoder: window.TextDecoder,
|
|
23
|
+
now: () => Date.now(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default createBrowserRuntimeService;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 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
|
+
/** @import { NamespacedStorage, Storage, StorageService } from "@adobe/alloy-core/services" */
|
|
14
|
+
|
|
15
|
+
import baseNamespace from "@adobe/alloy-core/constants/namespace.js";
|
|
16
|
+
|
|
17
|
+
// On Safari with storage disabled, even referencing `window.localStorage`
|
|
18
|
+
// throws — hence the try/catch around every access.
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} storageType - "localStorage" or "sessionStorage".
|
|
21
|
+
* @param {string} namespace
|
|
22
|
+
* @returns {Storage}
|
|
23
|
+
*/
|
|
24
|
+
const wrapStorageArea = (storageType, namespace) => ({
|
|
25
|
+
getItem(name) {
|
|
26
|
+
try {
|
|
27
|
+
return Promise.resolve(window[storageType].getItem(namespace + name));
|
|
28
|
+
} catch {
|
|
29
|
+
return Promise.resolve(null);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
setItem(name, value) {
|
|
33
|
+
try {
|
|
34
|
+
window[storageType].setItem(namespace + name, value);
|
|
35
|
+
return Promise.resolve(true);
|
|
36
|
+
} catch {
|
|
37
|
+
return Promise.resolve(false);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
removeItem(name) {
|
|
41
|
+
try {
|
|
42
|
+
window[storageType].removeItem(namespace + name);
|
|
43
|
+
return Promise.resolve(true);
|
|
44
|
+
} catch {
|
|
45
|
+
return Promise.resolve(false);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
clear() {
|
|
49
|
+
try {
|
|
50
|
+
Object.keys(window[storageType]).forEach((key) => {
|
|
51
|
+
if (key.startsWith(namespace)) {
|
|
52
|
+
window[storageType].removeItem(key);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return Promise.resolve(true);
|
|
56
|
+
} catch {
|
|
57
|
+
return Promise.resolve(false);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/** @returns {StorageService} */
|
|
63
|
+
const createBrowserStorageService = () => ({
|
|
64
|
+
createNamespacedStorage(additionalNamespace) {
|
|
65
|
+
const finalNamespace = baseNamespace + additionalNamespace;
|
|
66
|
+
/** @type {NamespacedStorage} */
|
|
67
|
+
return {
|
|
68
|
+
session: wrapStorageArea("sessionStorage", finalNamespace),
|
|
69
|
+
persistent: wrapStorageArea("localStorage", finalNamespace),
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export default createBrowserStorageService;
|