@adobe/alloy 2.29.0-beta.0 → 2.29.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/libEs5/components/Identity/createComponent.js +5 -4
- package/libEs5/components/Identity/index.js +4 -9
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/identity/createIdentity.js +46 -0
- package/libEs5/core/index.js +8 -0
- package/libEs5/utils/bytes.js +38 -0
- package/libEs5/{components/Identity → utils}/createDecodeKndctrCookie.js +12 -20
- package/libEs5/utils/index.js +13 -0
- package/libEs6/components/Identity/createComponent.js +5 -4
- package/libEs6/components/Identity/index.js +4 -9
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/identity/createIdentity.js +43 -0
- package/libEs6/core/index.js +8 -0
- package/libEs6/utils/bytes.js +33 -0
- package/libEs6/{components/Identity → utils}/createDecodeKndctrCookie.js +11 -19
- package/libEs6/utils/index.js +1 -0
- package/package.json +2 -2
- package/types/components/Identity/createComponent.d.ts +2 -2
- package/types/components/Identity/createComponent.d.ts.map +1 -1
- package/types/components/Identity/index.d.ts +2 -1
- package/types/components/Identity/index.d.ts.map +1 -1
- package/types/core/identity/createIdentity.d.ts +12 -0
- package/types/core/identity/createIdentity.d.ts.map +1 -0
- package/types/core/index.d.ts.map +1 -1
- package/types/utils/bytes.d.ts +3 -0
- package/types/utils/bytes.d.ts.map +1 -0
- package/types/utils/createDecodeKndctrCookie.d.ts.map +1 -0
- package/types/utils/index.d.ts +1 -0
- package/types/components/Identity/createDecodeKndctrCookie.d.ts.map +0 -1
- /package/types/{components/Identity → utils}/createDecodeKndctrCookie.d.ts +0 -0
|
@@ -25,8 +25,8 @@ var _default = ({
|
|
|
25
25
|
consent,
|
|
26
26
|
appendIdentityToUrl,
|
|
27
27
|
logger,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
identity,
|
|
29
|
+
getIdentityOptionsValidator
|
|
30
30
|
}) => {
|
|
31
31
|
let namespaces;
|
|
32
32
|
let edge = {};
|
|
@@ -68,6 +68,7 @@ var _default = ({
|
|
|
68
68
|
...edge,
|
|
69
69
|
...response.getEdge()
|
|
70
70
|
};
|
|
71
|
+
identity.setIdentityAcquired();
|
|
71
72
|
return handleResponseForIdSyncs(response);
|
|
72
73
|
}
|
|
73
74
|
},
|
|
@@ -82,7 +83,7 @@ var _default = ({
|
|
|
82
83
|
if (namespaces) {
|
|
83
84
|
return undefined;
|
|
84
85
|
}
|
|
85
|
-
const ecidFromCookie =
|
|
86
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
86
87
|
if (ecidFromCookie && requestedNamespaces.includes(_ecidNamespace.default)) {
|
|
87
88
|
if (!namespaces) {
|
|
88
89
|
namespaces = {};
|
|
@@ -113,7 +114,7 @@ var _default = ({
|
|
|
113
114
|
if (namespaces) {
|
|
114
115
|
return undefined;
|
|
115
116
|
}
|
|
116
|
-
const ecidFromCookie =
|
|
117
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
117
118
|
if (ecidFromCookie) {
|
|
118
119
|
if (!namespaces) {
|
|
119
120
|
namespaces = {};
|
|
@@ -22,7 +22,6 @@ var _createIdentityRequest = require("./getIdentity/createIdentityRequest.js");
|
|
|
22
22
|
var _createIdentityRequestPayload = require("./getIdentity/createIdentityRequestPayload.js");
|
|
23
23
|
var _injectAppendIdentityToUrl = require("./appendIdentityToUrl/injectAppendIdentityToUrl.js");
|
|
24
24
|
var _createGetIdentityOptionsValidator = require("./getIdentity/createGetIdentityOptionsValidator.js");
|
|
25
|
-
var _createDecodeKndctrCookie = require("./createDecodeKndctrCookie.js");
|
|
26
25
|
/*
|
|
27
26
|
Copyright 2019 Adobe. All rights reserved.
|
|
28
27
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -42,7 +41,8 @@ const createIdentity = ({
|
|
|
42
41
|
fireReferrerHideableImage,
|
|
43
42
|
sendEdgeNetworkRequest,
|
|
44
43
|
apexDomain,
|
|
45
|
-
getBrowser
|
|
44
|
+
getBrowser,
|
|
45
|
+
identity
|
|
46
46
|
}) => {
|
|
47
47
|
const {
|
|
48
48
|
orgId,
|
|
@@ -122,11 +122,6 @@ const createIdentity = ({
|
|
|
122
122
|
thirdPartyCookiesEnabled,
|
|
123
123
|
areThirdPartyCookiesSupportedByDefault
|
|
124
124
|
});
|
|
125
|
-
const decodeKndctrCookie = (0, _createDecodeKndctrCookie.default)({
|
|
126
|
-
orgId,
|
|
127
|
-
cookieJar: loggingCookieJar,
|
|
128
|
-
logger
|
|
129
|
-
});
|
|
130
125
|
return (0, _createComponent.default)({
|
|
131
126
|
addEcidQueryToPayload,
|
|
132
127
|
addQueryStringIdentityToPayload,
|
|
@@ -136,11 +131,11 @@ const createIdentity = ({
|
|
|
136
131
|
getNamespacesFromResponse: _getNamespacesFromResponse.default,
|
|
137
132
|
getIdentity,
|
|
138
133
|
consent,
|
|
134
|
+
identity,
|
|
139
135
|
appendIdentityToUrl,
|
|
140
136
|
logger,
|
|
141
137
|
config,
|
|
142
|
-
getIdentityOptionsValidator
|
|
143
|
-
decodeKndctrCookie
|
|
138
|
+
getIdentityOptionsValidator
|
|
144
139
|
});
|
|
145
140
|
};
|
|
146
141
|
createIdentity.namespace = "Identity";
|
|
@@ -14,4 +14,4 @@ governing permissions and limitations under the License.
|
|
|
14
14
|
*/
|
|
15
15
|
// The __VERSION__ keyword will be replace at alloy build time with the package.json version.
|
|
16
16
|
// see babel-plugin-version
|
|
17
|
-
var _default = exports.default = "2.29.0-beta.
|
|
17
|
+
var _default = exports.default = "2.29.0-beta.2";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _createDecodeKndctrCookie = require("../../utils/createDecodeKndctrCookie.js");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = ({
|
|
17
|
+
logger,
|
|
18
|
+
loggingCookieJar,
|
|
19
|
+
config
|
|
20
|
+
}) => {
|
|
21
|
+
let awaitIdentityResolve = null;
|
|
22
|
+
const awaitIdentityPromise = new Promise(resolve => {
|
|
23
|
+
awaitIdentityResolve = resolve;
|
|
24
|
+
});
|
|
25
|
+
const decodeKndctrCookie = (0, _createDecodeKndctrCookie.default)({
|
|
26
|
+
orgId: config.orgId,
|
|
27
|
+
cookieJar: loggingCookieJar,
|
|
28
|
+
logger
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
initialize() {
|
|
32
|
+
const ecidFromCookie = decodeKndctrCookie();
|
|
33
|
+
if (ecidFromCookie) {
|
|
34
|
+
this.setIdentityAcquired();
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
setIdentityAcquired() {
|
|
38
|
+
awaitIdentityResolve();
|
|
39
|
+
},
|
|
40
|
+
awaitIdentity() {
|
|
41
|
+
return awaitIdentityPromise;
|
|
42
|
+
},
|
|
43
|
+
getEcidFromCookie: () => decodeKndctrCookie()
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.default = _default;
|
package/libEs5/core/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var _createLifecycle = require("./createLifecycle.js");
|
|
|
8
8
|
var _createComponentRegistry = require("./createComponentRegistry.js");
|
|
9
9
|
var _injectSendNetworkRequest = require("./network/injectSendNetworkRequest.js");
|
|
10
10
|
var _injectExtractEdgeInfo = require("./edgeNetwork/injectExtractEdgeInfo.js");
|
|
11
|
+
var _createIdentity = require("./identity/createIdentity.js");
|
|
11
12
|
var _createConsent = require("./consent/createConsent.js");
|
|
12
13
|
var _createConsentStateMachine = require("./consent/createConsentStateMachine.js");
|
|
13
14
|
var _createEvent = require("./createEvent.js");
|
|
@@ -159,6 +160,12 @@ const createExecuteCommand = ({
|
|
|
159
160
|
generalConsentState,
|
|
160
161
|
logger
|
|
161
162
|
});
|
|
163
|
+
const identity = (0, _createIdentity.default)({
|
|
164
|
+
config,
|
|
165
|
+
logger,
|
|
166
|
+
loggingCookieJar
|
|
167
|
+
});
|
|
168
|
+
identity.initialize();
|
|
162
169
|
const eventManager = (0, _createEventManager.default)({
|
|
163
170
|
config,
|
|
164
171
|
logger,
|
|
@@ -180,6 +187,7 @@ const createExecuteCommand = ({
|
|
|
180
187
|
config,
|
|
181
188
|
componentRegistry,
|
|
182
189
|
consent,
|
|
190
|
+
identity,
|
|
183
191
|
eventManager,
|
|
184
192
|
fireReferrerHideableImage,
|
|
185
193
|
logger: componentLogger,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.bytesToBase64 = exports.base64ToBytes = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
6
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Takes a base64 string of bytes and returns a Uint8Array.
|
|
18
|
+
* @param {string} base64String
|
|
19
|
+
* @returns {Uint8Array}
|
|
20
|
+
*/
|
|
21
|
+
const base64ToBytes = base64String => {
|
|
22
|
+
// Add padding if needed
|
|
23
|
+
const padding = "=".repeat((4 - base64String.length % 4) % 4);
|
|
24
|
+
|
|
25
|
+
// Convert URL-safe base64 to regular base64
|
|
26
|
+
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
|
27
|
+
const binString = atob(base64);
|
|
28
|
+
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Takes a Uint8Array and returns a base64 string.
|
|
33
|
+
* @param {Uint8Array} bytes
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
exports.base64ToBytes = base64ToBytes;
|
|
37
|
+
const bytesToBase64 = bytes => btoa(String.fromCharCode(...bytes));
|
|
38
|
+
exports.bytesToBase64 = bytesToBase64;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.default = exports.decodeVarint = void 0;
|
|
4
|
-
var _index = require("
|
|
4
|
+
var _index = require("./index.js");
|
|
5
|
+
var _bytes = require("./bytes.js");
|
|
5
6
|
/*
|
|
6
7
|
Copyright 2024 Adobe. All rights reserved.
|
|
7
8
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -29,39 +30,39 @@ governing permissions and limitations under the License.
|
|
|
29
30
|
* and https://git.corp.adobe.com/experience-edge/konductor/blob/master/feature-identity/src/main/kotlin/com/adobe/edge/features/identity/data/StoredIdentity.kt#L16
|
|
30
31
|
|
|
31
32
|
* syntax = "proto3";
|
|
32
|
-
*
|
|
33
|
+
*
|
|
33
34
|
* // Device-level identity for Experience Edge
|
|
34
35
|
* message Identity {
|
|
35
36
|
* // The Experience Cloud ID value
|
|
36
37
|
* string ecid = 1;
|
|
37
|
-
*
|
|
38
|
+
*
|
|
38
39
|
* IdentityMetadata metadata = 10;
|
|
39
|
-
*
|
|
40
|
+
*
|
|
40
41
|
* // Used only in the 3rd party domain context.
|
|
41
42
|
* // It stores the UNIX timestamp and some metadata about the last identity sync triggered by Experience Edge.
|
|
42
43
|
* int64 last_sync = 20;
|
|
43
44
|
* int64 sync_hash = 21;
|
|
44
45
|
* int32 id_sync_container_id = 22;
|
|
45
|
-
*
|
|
46
|
+
*
|
|
46
47
|
* // UNIX timestamp when the Identity was last returned in a `state:store` instruction.
|
|
47
48
|
* // The Identity is written at most once every 24h with a large TTL, to ensure it does not expire.
|
|
48
49
|
* int64 write_time = 30;
|
|
49
50
|
* }
|
|
50
|
-
*
|
|
51
|
+
*
|
|
51
52
|
* message IdentityMetadata {
|
|
52
53
|
* // UNIX timestamp when this identity was minted.
|
|
53
54
|
* int64 created_at = 1;
|
|
54
|
-
*
|
|
55
|
+
*
|
|
55
56
|
* // Whether or not the identity is random (new) or based on an existing seed.
|
|
56
57
|
* bool is_new = 2;
|
|
57
|
-
*
|
|
58
|
+
*
|
|
58
59
|
* // Type of device for which the identity was generated.
|
|
59
60
|
* // 0 = UNKNOWN, 1 = BROWSER, 2 = MOBILE
|
|
60
61
|
* int32 device_type = 3;
|
|
61
|
-
*
|
|
62
|
+
*
|
|
62
63
|
* // The Experience Edge region in which the identity was minted.
|
|
63
64
|
* string region = 5;
|
|
64
|
-
*
|
|
65
|
+
*
|
|
65
66
|
* // More details on the source of the ECID identity.
|
|
66
67
|
* // Invariant: when `is_new` = true, the source must be set to `RANDOM`.
|
|
67
68
|
* // 0 = RANDOM, 1 = THIRD_PARTY_ID, 2 = FIRST_PARTY_ID, 3 = RECEIVED_IN_REQUEST
|
|
@@ -224,15 +225,6 @@ const decodeKndctrProtobuf = buffer => {
|
|
|
224
225
|
throw new Error("No ECID found in cookie.");
|
|
225
226
|
};
|
|
226
227
|
|
|
227
|
-
/**
|
|
228
|
-
* takes a base64 string of bytes and returns a Uint8Array
|
|
229
|
-
* @param {string} base64
|
|
230
|
-
* @returns {Uint8Array}
|
|
231
|
-
*/
|
|
232
|
-
const base64ToBytes = base64 => {
|
|
233
|
-
const binString = atob(base64);
|
|
234
|
-
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
235
|
-
};
|
|
236
228
|
// #endregion
|
|
237
229
|
|
|
238
230
|
// #region decode cookie
|
|
@@ -256,7 +248,7 @@ var _default = ({
|
|
|
256
248
|
// cookie is a base64 encoded byte representation of a Identity protobuf message
|
|
257
249
|
// and we need to get it to a Uint8Array in order to decode it
|
|
258
250
|
|
|
259
|
-
const cookieBytes = base64ToBytes(decodedCookie);
|
|
251
|
+
const cookieBytes = (0, _bytes.base64ToBytes)(decodedCookie);
|
|
260
252
|
return decodeKndctrProtobuf(cookieBytes);
|
|
261
253
|
} catch (error) {
|
|
262
254
|
logger.warn("Unable to decode ECID from " + kndctrCookieName + " cookie", error);
|
package/libEs5/utils/index.js
CHANGED
|
@@ -6,6 +6,18 @@ Object.defineProperty(exports, "assignConcatArrayValues", {
|
|
|
6
6
|
return _assignConcatArrayValues.default;
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
|
+
Object.defineProperty(exports, "base64ToBytes", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _bytes.base64ToBytes;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "bytesToBase64", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _bytes.bytesToBase64;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
9
21
|
Object.defineProperty(exports, "clone", {
|
|
10
22
|
enumerable: true,
|
|
11
23
|
get: function () {
|
|
@@ -301,6 +313,7 @@ Object.defineProperty(exports, "validateIdentityMap", {
|
|
|
301
313
|
}
|
|
302
314
|
});
|
|
303
315
|
var _assignConcatArrayValues = require("./assignConcatArrayValues.js");
|
|
316
|
+
var _bytes = require("./bytes.js");
|
|
304
317
|
var _clone = require("./clone.js");
|
|
305
318
|
var _cookieJar = require("./cookieJar.js");
|
|
306
319
|
var _createMerger = require("./createMerger.js");
|
|
@@ -22,8 +22,8 @@ export default ({
|
|
|
22
22
|
consent,
|
|
23
23
|
appendIdentityToUrl,
|
|
24
24
|
logger,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
identity,
|
|
26
|
+
getIdentityOptionsValidator
|
|
27
27
|
}) => {
|
|
28
28
|
let namespaces;
|
|
29
29
|
let edge = {};
|
|
@@ -65,6 +65,7 @@ export default ({
|
|
|
65
65
|
...edge,
|
|
66
66
|
...response.getEdge()
|
|
67
67
|
};
|
|
68
|
+
identity.setIdentityAcquired();
|
|
68
69
|
return handleResponseForIdSyncs(response);
|
|
69
70
|
}
|
|
70
71
|
},
|
|
@@ -79,7 +80,7 @@ export default ({
|
|
|
79
80
|
if (namespaces) {
|
|
80
81
|
return undefined;
|
|
81
82
|
}
|
|
82
|
-
const ecidFromCookie =
|
|
83
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
83
84
|
if (ecidFromCookie && requestedNamespaces.includes(ecidNamespace)) {
|
|
84
85
|
if (!namespaces) {
|
|
85
86
|
namespaces = {};
|
|
@@ -110,7 +111,7 @@ export default ({
|
|
|
110
111
|
if (namespaces) {
|
|
111
112
|
return undefined;
|
|
112
113
|
}
|
|
113
|
-
const ecidFromCookie =
|
|
114
|
+
const ecidFromCookie = identity.getEcidFromCookie();
|
|
114
115
|
if (ecidFromCookie) {
|
|
115
116
|
if (!namespaces) {
|
|
116
117
|
namespaces = {};
|
|
@@ -31,7 +31,6 @@ import createIdentityRequest from "./getIdentity/createIdentityRequest.js";
|
|
|
31
31
|
import createIdentityRequestPayload from "./getIdentity/createIdentityRequestPayload.js";
|
|
32
32
|
import injectAppendIdentityToUrl from "./appendIdentityToUrl/injectAppendIdentityToUrl.js";
|
|
33
33
|
import createGetIdentityOptionsValidator from "./getIdentity/createGetIdentityOptionsValidator.js";
|
|
34
|
-
import createGetEcidFromCookie from "./createDecodeKndctrCookie.js";
|
|
35
34
|
const createIdentity = ({
|
|
36
35
|
config,
|
|
37
36
|
logger,
|
|
@@ -39,7 +38,8 @@ const createIdentity = ({
|
|
|
39
38
|
fireReferrerHideableImage,
|
|
40
39
|
sendEdgeNetworkRequest,
|
|
41
40
|
apexDomain,
|
|
42
|
-
getBrowser
|
|
41
|
+
getBrowser,
|
|
42
|
+
identity
|
|
43
43
|
}) => {
|
|
44
44
|
const {
|
|
45
45
|
orgId,
|
|
@@ -119,11 +119,6 @@ const createIdentity = ({
|
|
|
119
119
|
thirdPartyCookiesEnabled,
|
|
120
120
|
areThirdPartyCookiesSupportedByDefault
|
|
121
121
|
});
|
|
122
|
-
const decodeKndctrCookie = createGetEcidFromCookie({
|
|
123
|
-
orgId,
|
|
124
|
-
cookieJar: loggingCookieJar,
|
|
125
|
-
logger
|
|
126
|
-
});
|
|
127
122
|
return createComponent({
|
|
128
123
|
addEcidQueryToPayload,
|
|
129
124
|
addQueryStringIdentityToPayload,
|
|
@@ -133,11 +128,11 @@ const createIdentity = ({
|
|
|
133
128
|
getNamespacesFromResponse,
|
|
134
129
|
getIdentity,
|
|
135
130
|
consent,
|
|
131
|
+
identity,
|
|
136
132
|
appendIdentityToUrl,
|
|
137
133
|
logger,
|
|
138
134
|
config,
|
|
139
|
-
getIdentityOptionsValidator
|
|
140
|
-
decodeKndctrCookie
|
|
135
|
+
getIdentityOptionsValidator
|
|
141
136
|
});
|
|
142
137
|
};
|
|
143
138
|
createIdentity.namespace = "Identity";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import createDecodeKndctrCookie from "../../utils/createDecodeKndctrCookie.js";
|
|
14
|
+
export default ({
|
|
15
|
+
logger,
|
|
16
|
+
loggingCookieJar,
|
|
17
|
+
config
|
|
18
|
+
}) => {
|
|
19
|
+
let awaitIdentityResolve = null;
|
|
20
|
+
const awaitIdentityPromise = new Promise(resolve => {
|
|
21
|
+
awaitIdentityResolve = resolve;
|
|
22
|
+
});
|
|
23
|
+
const decodeKndctrCookie = createDecodeKndctrCookie({
|
|
24
|
+
orgId: config.orgId,
|
|
25
|
+
cookieJar: loggingCookieJar,
|
|
26
|
+
logger
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
initialize() {
|
|
30
|
+
const ecidFromCookie = decodeKndctrCookie();
|
|
31
|
+
if (ecidFromCookie) {
|
|
32
|
+
this.setIdentityAcquired();
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
setIdentityAcquired() {
|
|
36
|
+
awaitIdentityResolve();
|
|
37
|
+
},
|
|
38
|
+
awaitIdentity() {
|
|
39
|
+
return awaitIdentityPromise;
|
|
40
|
+
},
|
|
41
|
+
getEcidFromCookie: () => decodeKndctrCookie()
|
|
42
|
+
};
|
|
43
|
+
};
|
package/libEs6/core/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import createLifecycle from "./createLifecycle.js";
|
|
|
17
17
|
import createComponentRegistry from "./createComponentRegistry.js";
|
|
18
18
|
import injectSendNetworkRequest from "./network/injectSendNetworkRequest.js";
|
|
19
19
|
import injectExtractEdgeInfo from "./edgeNetwork/injectExtractEdgeInfo.js";
|
|
20
|
+
import createIdentity from "./identity/createIdentity.js";
|
|
20
21
|
import createConsent from "./consent/createConsent.js";
|
|
21
22
|
import createConsentStateMachine from "./consent/createConsentStateMachine.js";
|
|
22
23
|
import createEvent from "./createEvent.js";
|
|
@@ -156,6 +157,12 @@ export const createExecuteCommand = ({
|
|
|
156
157
|
generalConsentState,
|
|
157
158
|
logger
|
|
158
159
|
});
|
|
160
|
+
const identity = createIdentity({
|
|
161
|
+
config,
|
|
162
|
+
logger,
|
|
163
|
+
loggingCookieJar
|
|
164
|
+
});
|
|
165
|
+
identity.initialize();
|
|
159
166
|
const eventManager = createEventManager({
|
|
160
167
|
config,
|
|
161
168
|
logger,
|
|
@@ -177,6 +184,7 @@ export const createExecuteCommand = ({
|
|
|
177
184
|
config,
|
|
178
185
|
componentRegistry,
|
|
179
186
|
consent,
|
|
187
|
+
identity,
|
|
180
188
|
eventManager,
|
|
181
189
|
fireReferrerHideableImage,
|
|
182
190
|
logger: componentLogger,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Takes a base64 string of bytes and returns a Uint8Array.
|
|
15
|
+
* @param {string} base64String
|
|
16
|
+
* @returns {Uint8Array}
|
|
17
|
+
*/
|
|
18
|
+
export const base64ToBytes = base64String => {
|
|
19
|
+
// Add padding if needed
|
|
20
|
+
const padding = "=".repeat((4 - base64String.length % 4) % 4);
|
|
21
|
+
|
|
22
|
+
// Convert URL-safe base64 to regular base64
|
|
23
|
+
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
|
24
|
+
const binString = atob(base64);
|
|
25
|
+
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Takes a Uint8Array and returns a base64 string.
|
|
30
|
+
* @param {Uint8Array} bytes
|
|
31
|
+
* @returns {string}
|
|
32
|
+
*/
|
|
33
|
+
export const bytesToBase64 = bytes => btoa(String.fromCharCode(...bytes));
|
|
@@ -10,7 +10,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
/* eslint-disable no-bitwise */
|
|
13
|
-
import { getNamespacedCookieName } from "
|
|
13
|
+
import { getNamespacedCookieName } from "./index.js";
|
|
14
|
+
import { base64ToBytes } from "./bytes.js";
|
|
14
15
|
|
|
15
16
|
// #region decode protobuf
|
|
16
17
|
|
|
@@ -26,39 +27,39 @@ import { getNamespacedCookieName } from "../../utils/index.js";
|
|
|
26
27
|
* and https://git.corp.adobe.com/experience-edge/konductor/blob/master/feature-identity/src/main/kotlin/com/adobe/edge/features/identity/data/StoredIdentity.kt#L16
|
|
27
28
|
|
|
28
29
|
* syntax = "proto3";
|
|
29
|
-
*
|
|
30
|
+
*
|
|
30
31
|
* // Device-level identity for Experience Edge
|
|
31
32
|
* message Identity {
|
|
32
33
|
* // The Experience Cloud ID value
|
|
33
34
|
* string ecid = 1;
|
|
34
|
-
*
|
|
35
|
+
*
|
|
35
36
|
* IdentityMetadata metadata = 10;
|
|
36
|
-
*
|
|
37
|
+
*
|
|
37
38
|
* // Used only in the 3rd party domain context.
|
|
38
39
|
* // It stores the UNIX timestamp and some metadata about the last identity sync triggered by Experience Edge.
|
|
39
40
|
* int64 last_sync = 20;
|
|
40
41
|
* int64 sync_hash = 21;
|
|
41
42
|
* int32 id_sync_container_id = 22;
|
|
42
|
-
*
|
|
43
|
+
*
|
|
43
44
|
* // UNIX timestamp when the Identity was last returned in a `state:store` instruction.
|
|
44
45
|
* // The Identity is written at most once every 24h with a large TTL, to ensure it does not expire.
|
|
45
46
|
* int64 write_time = 30;
|
|
46
47
|
* }
|
|
47
|
-
*
|
|
48
|
+
*
|
|
48
49
|
* message IdentityMetadata {
|
|
49
50
|
* // UNIX timestamp when this identity was minted.
|
|
50
51
|
* int64 created_at = 1;
|
|
51
|
-
*
|
|
52
|
+
*
|
|
52
53
|
* // Whether or not the identity is random (new) or based on an existing seed.
|
|
53
54
|
* bool is_new = 2;
|
|
54
|
-
*
|
|
55
|
+
*
|
|
55
56
|
* // Type of device for which the identity was generated.
|
|
56
57
|
* // 0 = UNKNOWN, 1 = BROWSER, 2 = MOBILE
|
|
57
58
|
* int32 device_type = 3;
|
|
58
|
-
*
|
|
59
|
+
*
|
|
59
60
|
* // The Experience Edge region in which the identity was minted.
|
|
60
61
|
* string region = 5;
|
|
61
|
-
*
|
|
62
|
+
*
|
|
62
63
|
* // More details on the source of the ECID identity.
|
|
63
64
|
* // Invariant: when `is_new` = true, the source must be set to `RANDOM`.
|
|
64
65
|
* // 0 = RANDOM, 1 = THIRD_PARTY_ID, 2 = FIRST_PARTY_ID, 3 = RECEIVED_IN_REQUEST
|
|
@@ -220,15 +221,6 @@ const decodeKndctrProtobuf = buffer => {
|
|
|
220
221
|
throw new Error("No ECID found in cookie.");
|
|
221
222
|
};
|
|
222
223
|
|
|
223
|
-
/**
|
|
224
|
-
* takes a base64 string of bytes and returns a Uint8Array
|
|
225
|
-
* @param {string} base64
|
|
226
|
-
* @returns {Uint8Array}
|
|
227
|
-
*/
|
|
228
|
-
const base64ToBytes = base64 => {
|
|
229
|
-
const binString = atob(base64);
|
|
230
|
-
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
231
|
-
};
|
|
232
224
|
// #endregion
|
|
233
225
|
|
|
234
226
|
// #region decode cookie
|
package/libEs6/utils/index.js
CHANGED
|
@@ -12,6 +12,7 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
|
|
13
13
|
// Please keep in alphabetical order.
|
|
14
14
|
export { default as assignConcatArrayValues } from "./assignConcatArrayValues.js";
|
|
15
|
+
export { base64ToBytes, bytesToBase64 } from "./bytes.js";
|
|
15
16
|
export { default as clone } from "./clone.js";
|
|
16
17
|
export { default as cookieJar } from "./cookieJar.js";
|
|
17
18
|
export { default as createMerger } from "./createMerger.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.29.0-beta.
|
|
3
|
+
"version": "2.29.0-beta.2",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "libEs5/index.js",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"uuid": "^11.1.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@adobe/alloy": "^2.
|
|
97
|
+
"@adobe/alloy": "^2.29.0-beta.1",
|
|
98
98
|
"@babel/cli": "^7.27.2",
|
|
99
99
|
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|
|
100
100
|
"@babel/plugin-transform-runtime": "^7.27.4",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare function _default({ addEcidQueryToPayload, addQueryStringIdentityToPayload, ensureSingleIdentity, setLegacyEcid, handleResponseForIdSyncs, getNamespacesFromResponse, getIdentity, consent, appendIdentityToUrl, logger,
|
|
1
|
+
declare function _default({ addEcidQueryToPayload, addQueryStringIdentityToPayload, ensureSingleIdentity, setLegacyEcid, handleResponseForIdSyncs, getNamespacesFromResponse, getIdentity, consent, appendIdentityToUrl, logger, identity, getIdentityOptionsValidator, }: {
|
|
2
2
|
addEcidQueryToPayload: any;
|
|
3
3
|
addQueryStringIdentityToPayload: any;
|
|
4
4
|
ensureSingleIdentity: any;
|
|
@@ -9,8 +9,8 @@ declare function _default({ addEcidQueryToPayload, addQueryStringIdentityToPaylo
|
|
|
9
9
|
consent: any;
|
|
10
10
|
appendIdentityToUrl: any;
|
|
11
11
|
logger: any;
|
|
12
|
+
identity: any;
|
|
12
13
|
getIdentityOptionsValidator: any;
|
|
13
|
-
decodeKndctrCookie: any;
|
|
14
14
|
}): {
|
|
15
15
|
lifecycle: {
|
|
16
16
|
onBeforeRequest({ request, onResponse, onRequestFailure }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../../../src/components/Identity/createComponent.js"],"names":[],"mappings":"AAce;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../../../src/components/Identity/createComponent.js"],"names":[],"mappings":"AAce;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2Hd"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default createIdentity;
|
|
2
|
-
declare function createIdentity({ config, logger, consent, fireReferrerHideableImage, sendEdgeNetworkRequest, apexDomain, getBrowser, }: {
|
|
2
|
+
declare function createIdentity({ config, logger, consent, fireReferrerHideableImage, sendEdgeNetworkRequest, apexDomain, getBrowser, identity, }: {
|
|
3
3
|
config: any;
|
|
4
4
|
logger: any;
|
|
5
5
|
consent: any;
|
|
@@ -7,6 +7,7 @@ declare function createIdentity({ config, logger, consent, fireReferrerHideableI
|
|
|
7
7
|
sendEdgeNetworkRequest: any;
|
|
8
8
|
apexDomain: any;
|
|
9
9
|
getBrowser: any;
|
|
10
|
+
identity: any;
|
|
10
11
|
}): {
|
|
11
12
|
lifecycle: {
|
|
12
13
|
onBeforeRequest({ request, onResponse, onRequestFailure }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Identity/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Identity/index.js"],"names":[],"mappings":";AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqGC;;;;;6BA1H4B,uBAAuB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function _default({ logger, loggingCookieJar, config }: {
|
|
2
|
+
logger: any;
|
|
3
|
+
loggingCookieJar: any;
|
|
4
|
+
config: any;
|
|
5
|
+
}): {
|
|
6
|
+
initialize(): void;
|
|
7
|
+
setIdentityAcquired(): void;
|
|
8
|
+
awaitIdentity(): Promise<any>;
|
|
9
|
+
getEcidFromCookie: () => string;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=createIdentity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIdentity.d.ts","sourceRoot":"","sources":["../../../src/core/identity/createIdentity.js"],"names":[],"mappings":"AAce;;;;;;;;;EA+Bd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.js"],"names":[],"mappings":"AAwEO;;;;;;;;qDA0IN;AAEc;;SA4Bd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/utils/bytes.js"],"names":[],"mappings":"AAiBO,4CAHI,MAAM,GACJ,UAAU,CAWtB;AAOM,qCAHI,UAAU,GACR,MAAM,CAEwD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDecodeKndctrCookie.d.ts","sourceRoot":"","sources":["../../src/utils/createDecodeKndctrCookie.js"],"names":[],"mappings":"AAiGO,qCALI,UAAU,UACV,MAAM,GACJ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAuB7C;AA0Gc;;;;UAIA,MAAM,GAAC,IAAI,CAwBzB"}
|
package/types/utils/index.d.ts
CHANGED
|
@@ -48,4 +48,5 @@ export { default as uuid } from "./uuid.js";
|
|
|
48
48
|
export { default as updateErrorMessage } from "./updateErrorMessage.js";
|
|
49
49
|
export { default as validateIdentityMap } from "./validateIdentityMap.js";
|
|
50
50
|
export { default as validateConfigOverride } from "./validateConfigOverride.js";
|
|
51
|
+
export { base64ToBytes, bytesToBase64 } from "./bytes.js";
|
|
51
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createDecodeKndctrCookie.d.ts","sourceRoot":"","sources":["../../../src/components/Identity/createDecodeKndctrCookie.js"],"names":[],"mappings":"AAgGO,qCALI,UAAU,UACV,MAAM,GACJ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAuB7C;AAmHc;;;;UAIA,MAAM,GAAC,IAAI,CAwBzB"}
|
|
File without changes
|