@braze/web-sdk 6.10.2 → 6.12.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/index.d.ts +61 -6
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +12 -12
- package/shared-lib/indexed-db-adapter.js +52 -52
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +10 -10
- package/src/Core/logout.js +2 -2
- package/src/DUST/dust-config-store.js +89 -0
- package/src/DUST/dust-connection-core.js +7 -21
- package/src/DUST/dust-message-dedup.js +33 -0
- package/src/DUST/dust-provider.js +367 -397
- package/src/DUST/dust-tab-identity.js +30 -0
- package/src/DUST/index.js +7 -9
- package/src/DUST/subscribe-to-dust.js +5 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +5 -5
- package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
- package/src/FeatureFlags/feature-flags-provider.js +74 -74
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
- package/src/InAppMessage/constants.js +39 -47
- package/src/InAppMessage/defer-in-app-message.js +2 -2
- package/src/InAppMessage/display/get-animation-effect.js +1 -1
- package/src/InAppMessage/display/html-message-display-utils.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +68 -66
- package/src/InAppMessage/display/modal-utils.js +14 -14
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +101 -80
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +25 -25
- package/src/InAppMessage/models/html-message.js +14 -14
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +100 -98
- package/src/InAppMessage/models/modal-message.js +23 -23
- package/src/InAppMessage/models/slide-up-message.js +29 -29
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +2 -2
- package/src/InAppMessage/ui/show-in-app-message.js +42 -40
- package/src/Push/index.js +1 -0
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +6 -6
- package/src/Push/push-manager.js +228 -185
- package/src/Push/register-push.js +9 -0
- package/src/Push/unregister-push-token-on-server.js +4 -4
- package/src/Push/utils/push-utils.js +16 -16
- package/src/User/user-manager.js +19 -19
- package/src/User/user.js +36 -36
- package/src/common/constants.js +1 -1
- package/src/common/content-cards-display.js +21 -21
- package/src/common/event-logger.js +2 -2
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +5 -5
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +70 -66
- package/src/managers/device-manager.js +12 -12
- package/src/managers/network-manager.js +118 -118
- package/src/managers/server-config-manager.js +84 -84
- package/src/managers/session-manager.js +10 -10
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +138 -136
- package/src/managers/subscription-manager.js +1 -1
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +6 -6
- package/src/models/push-token.js +6 -6
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +91 -91
- package/src/triggers/models/filter.js +58 -58
- package/src/triggers/models/in-app-message-click-data.js +4 -4
- package/src/triggers/models/push-click-data.js +2 -2
- package/src/triggers/models/trigger-condition.js +35 -35
- package/src/triggers/models/trigger.js +37 -37
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +61 -53
- package/src/types.js +1 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +2 -2
- package/src/ui/js/iam-css.js +2 -2
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/component-utils.js +4 -4
- package/src/util/dom-utils.js +5 -5
- package/src/util/ecommerce-event-validation.js +77 -48
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +20 -20
- package/src/util/string-utils.js +5 -0
- package/src/util/user-agent-parser.js +15 -15
- package/src/util/validation-utils.js +9 -9
- package/src/util/window-utils.js +2 -2
- package/src/DUST/dust-shared-worker-code.js +0 -2
- package/src/DUST/dust-shared-worker-impl.js +0 -234
- package/src/DUST/dust-worker-bridge.js +0 -151
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ve from "../models/braze-event.js";
|
|
2
2
|
import _t from "../models/identifier.js";
|
|
3
3
|
import {
|
|
4
4
|
isArray as g,
|
|
5
5
|
keys as C,
|
|
6
6
|
validateValueIsFromEnum as ta,
|
|
7
|
-
values as
|
|
7
|
+
values as Yt,
|
|
8
8
|
} from "../util/code-utils.js";
|
|
9
9
|
import { logger as b, EventTypes as p } from "../../shared-lib/index.js";
|
|
10
10
|
import { User } from "../User/index.js";
|
|
11
11
|
import ro from "../util/browser-detector.js";
|
|
12
|
-
import { getErrorMessage as
|
|
12
|
+
import { getErrorMessage as ci } from "../util/error-utils.js";
|
|
13
13
|
export const STORAGE_KEYS = {
|
|
14
14
|
Ou: {
|
|
15
15
|
Cu: "ab.storage.userId",
|
|
@@ -18,72 +18,74 @@ export const STORAGE_KEYS = {
|
|
|
18
18
|
},
|
|
19
19
|
It: {
|
|
20
20
|
ac: "ab.test",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
tS: "ab.storage.events",
|
|
22
|
+
eS: "ab.storage.attributes",
|
|
23
|
+
sS: "ab.storage.attributes.anonymous_user",
|
|
24
|
+
Aa: "ab.storage.device",
|
|
25
|
+
Ka: "ab.storage.sdk_metadata",
|
|
26
|
+
Pa: "ab.storage.session_id_for_cached_metadata",
|
|
27
|
+
xu: "ab.storage.pushToken",
|
|
28
|
+
rS: "ab.storage.cardImpressions",
|
|
29
|
+
Zl: "ab.storage.serverConfig",
|
|
30
|
+
oS: "ab.storage.triggers",
|
|
31
|
+
nS: "ab.storage.triggers.ts",
|
|
32
32
|
dm: "ab.storage.messagingSessionStart",
|
|
33
33
|
bi: "ab.storage.cc",
|
|
34
34
|
ji: "ab.storage.ccLastFullSync",
|
|
35
35
|
yi: "ab.storage.ccLastCardUpdated",
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
zl: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
37
|
+
Xl: "ab.storage.dynamicRateLimitCurrentTokenCount",
|
|
38
38
|
Zt: "ab.storage.ccClicks",
|
|
39
39
|
ps: "ab.storage.ccImpressions",
|
|
40
40
|
fs: "ab.storage.ccDismissals",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
aS: "ab.storage.lastDisplayedTriggerTimesById",
|
|
42
|
+
iS: "ab.storage.lastDisplayedTriggerTime",
|
|
43
|
+
SS: "ab.storage.triggerFireInstancesById",
|
|
44
44
|
fh: "ab.storage.signature",
|
|
45
|
-
|
|
45
|
+
ES: "ab.storage.brazeSyncRetryCount",
|
|
46
46
|
zi: "ab.storage.sdkVersion",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
Vr: "ab.storage.ff",
|
|
48
|
+
Zr: "ab.storage.ffImpressions",
|
|
49
|
+
bo: "ab.storage.ffLastRefreshAt",
|
|
50
|
+
jo: "ab.storage.ff.sessionId",
|
|
51
|
+
lS: "ab.storage.lastReqToEndpoint",
|
|
52
|
+
_S: "ab.storage.requestAttempts",
|
|
53
|
+
la: "ab.storage.deferredIam",
|
|
54
|
+
wl: "ab.storage.lastSdkReq",
|
|
55
|
+
uS: "ab.storage.alias",
|
|
56
56
|
Tt: "ab.storage.banners",
|
|
57
57
|
At: "ab.storage.banners.impressions",
|
|
58
58
|
Xt: "ab.storage.banners.dismissals",
|
|
59
59
|
kt: "ab.storage.banners.sessionId",
|
|
60
60
|
Ht: "ab.storage.banners.lastRequestedTime",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
_i: "ab.storage.dust.mite",
|
|
62
|
+
Oi: "ab.storage.dust.host",
|
|
63
|
+
Gi: "ab.storage.dust.auth",
|
|
64
|
+
Hi: "ab.storage.dust.expiration",
|
|
65
|
+
Zi: "ab.storage.dust.refreshLock",
|
|
66
|
+
_r: "ab.storage.dust.msgClaims",
|
|
65
67
|
},
|
|
66
68
|
ce: "ab.optOut",
|
|
67
69
|
};
|
|
68
70
|
export default class ne {
|
|
69
71
|
constructor(t, e) {
|
|
70
|
-
(this.
|
|
72
|
+
(this.cS = t), (this.TS = e), (this.cS = t), (this.TS = e);
|
|
71
73
|
}
|
|
72
74
|
hl(t) {
|
|
73
75
|
const e = C(STORAGE_KEYS.Ou),
|
|
74
76
|
s = new ne.le(t);
|
|
75
77
|
for (const t of e) s.remove(STORAGE_KEYS.Ou[t]);
|
|
76
78
|
}
|
|
77
|
-
|
|
79
|
+
Ju(t, e) {
|
|
78
80
|
let s = null;
|
|
79
|
-
null != e && e instanceof _t && (s = e.qt()), this.
|
|
81
|
+
null != e && e instanceof _t && (s = e.qt()), this.cS.store(t, s);
|
|
80
82
|
}
|
|
81
|
-
|
|
83
|
+
hS(t) {
|
|
82
84
|
const e = this.$u(t);
|
|
83
|
-
null != e && ((e.pm = new Date().valueOf()), this.
|
|
85
|
+
null != e && ((e.pm = new Date().valueOf()), this.Ju(t, e));
|
|
84
86
|
}
|
|
85
87
|
$u(t) {
|
|
86
|
-
const e = this.
|
|
88
|
+
const e = this.cS.wr(t),
|
|
87
89
|
s = ((t) => {
|
|
88
90
|
let e;
|
|
89
91
|
try {
|
|
@@ -94,44 +96,44 @@ export default class ne {
|
|
|
94
96
|
return e;
|
|
95
97
|
})(e);
|
|
96
98
|
let r;
|
|
97
|
-
if (s) (r = _t._u(s) || null), r && this.
|
|
99
|
+
if (s) (r = _t._u(s) || null), r && this.Ju(t, r);
|
|
98
100
|
else {
|
|
99
|
-
const s = _t.
|
|
100
|
-
(r = _t._u(s) || null), s !== e && r && this.
|
|
101
|
+
const s = _t.AS(e);
|
|
102
|
+
(r = _t._u(s) || null), s !== e && r && this.Ju(t, r);
|
|
101
103
|
}
|
|
102
104
|
return r;
|
|
103
105
|
}
|
|
104
106
|
jm(t) {
|
|
105
|
-
this.
|
|
107
|
+
this.cS.remove(t);
|
|
106
108
|
}
|
|
107
109
|
ll() {
|
|
108
110
|
const t = C(STORAGE_KEYS.Ou);
|
|
109
111
|
let e;
|
|
110
112
|
for (const s of t)
|
|
111
113
|
(e = this.$u(STORAGE_KEYS.Ou[s])),
|
|
112
|
-
null != e && this.
|
|
114
|
+
null != e && this.Ju(STORAGE_KEYS.Ou[s], e);
|
|
113
115
|
}
|
|
114
116
|
ol(t) {
|
|
115
117
|
let e;
|
|
116
118
|
if (null == t || 0 === t.length) return !1;
|
|
117
119
|
e = g(t) ? t : [t];
|
|
118
|
-
let s = this.
|
|
120
|
+
let s = this.TS.wr(STORAGE_KEYS.It.tS);
|
|
119
121
|
(null != s && g(s)) || (s = []);
|
|
120
122
|
for (let t = 0; t < e.length; t++) s.push(e[t].qt());
|
|
121
|
-
return this.
|
|
123
|
+
return this.TS.store(STORAGE_KEYS.It.tS, s);
|
|
122
124
|
}
|
|
123
125
|
gm(t) {
|
|
124
126
|
return null != t && this.ol([t]);
|
|
125
127
|
}
|
|
126
|
-
|
|
127
|
-
let t = this.
|
|
128
|
-
this.
|
|
128
|
+
gS() {
|
|
129
|
+
let t = this.TS.wr(STORAGE_KEYS.It.tS);
|
|
130
|
+
this.TS.remove(STORAGE_KEYS.It.tS), null == t && (t = []);
|
|
129
131
|
const e = [];
|
|
130
132
|
let s = !1,
|
|
131
133
|
r = null;
|
|
132
134
|
if (g(t))
|
|
133
135
|
for (let s = 0; s < t.length; s++)
|
|
134
|
-
|
|
136
|
+
ve.RS(t[s]) ? e.push(ve._u(t[s])) : (r = s);
|
|
135
137
|
else s = !0;
|
|
136
138
|
if (s || null != r) {
|
|
137
139
|
let o = "Stored events could not be deserialized as Events";
|
|
@@ -144,7 +146,7 @@ export default class ne {
|
|
|
144
146
|
typeof t +
|
|
145
147
|
": " +
|
|
146
148
|
JSON.stringify(t)),
|
|
147
|
-
e.push(new
|
|
149
|
+
e.push(new ve(null, p._a, new Date().valueOf(), null, { e: o }));
|
|
148
150
|
}
|
|
149
151
|
return e;
|
|
150
152
|
}
|
|
@@ -155,7 +157,7 @@ export default class ne {
|
|
|
155
157
|
t,
|
|
156
158
|
"StorageManager cannot store object.",
|
|
157
159
|
"STORAGE_KEYS.OBJECTS",
|
|
158
|
-
) && this.
|
|
160
|
+
) && this.TS.store(t, e)
|
|
159
161
|
);
|
|
160
162
|
}
|
|
161
163
|
St(t) {
|
|
@@ -165,7 +167,7 @@ export default class ne {
|
|
|
165
167
|
t,
|
|
166
168
|
"StorageManager cannot retrieve object.",
|
|
167
169
|
"STORAGE_KEYS.OBJECTS",
|
|
168
|
-
) && this.
|
|
170
|
+
) && this.TS.wr(t)
|
|
169
171
|
);
|
|
170
172
|
}
|
|
171
173
|
Vt(t) {
|
|
@@ -175,7 +177,7 @@ export default class ne {
|
|
|
175
177
|
t,
|
|
176
178
|
"StorageManager cannot remove object.",
|
|
177
179
|
"STORAGE_KEYS.OBJECTS",
|
|
178
|
-
) && (this.
|
|
180
|
+
) && (this.TS.remove(t), !0)
|
|
179
181
|
);
|
|
180
182
|
}
|
|
181
183
|
clearData() {
|
|
@@ -183,121 +185,121 @@ export default class ne {
|
|
|
183
185
|
e = C(STORAGE_KEYS.It);
|
|
184
186
|
for (let e = 0; e < t.length; e++) {
|
|
185
187
|
const s = t[e];
|
|
186
|
-
this.
|
|
188
|
+
this.cS.remove(STORAGE_KEYS.Ou[s]);
|
|
187
189
|
}
|
|
188
190
|
for (let t = 0; t < e.length; t++) {
|
|
189
191
|
const s = e[t];
|
|
190
|
-
this.
|
|
192
|
+
this.TS.remove(STORAGE_KEYS.It[s]);
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
|
-
|
|
194
|
-
return t || STORAGE_KEYS.It.
|
|
195
|
+
dS(t) {
|
|
196
|
+
return t || STORAGE_KEYS.It.sS;
|
|
195
197
|
}
|
|
196
|
-
|
|
197
|
-
let e = this.
|
|
198
|
+
fl(t) {
|
|
199
|
+
let e = this.TS.wr(STORAGE_KEYS.It.eS);
|
|
198
200
|
null == e && (e = {});
|
|
199
|
-
const s = this.
|
|
201
|
+
const s = this.dS(t[User.Sa]),
|
|
200
202
|
r = e[s];
|
|
201
203
|
for (const o in t)
|
|
202
204
|
o !== User.Sa &&
|
|
203
205
|
(null == e[s] || (r && null == r[o])) &&
|
|
204
|
-
this.
|
|
206
|
+
this.Fu(t[User.Sa], o, t[o]);
|
|
205
207
|
}
|
|
206
|
-
|
|
207
|
-
let r = this.
|
|
208
|
+
Fu(t, e, s) {
|
|
209
|
+
let r = this.TS.wr(STORAGE_KEYS.It.eS);
|
|
208
210
|
null == r && (r = {});
|
|
209
|
-
const o = this.
|
|
211
|
+
const o = this.dS(t);
|
|
210
212
|
let n = r[o];
|
|
211
213
|
if (
|
|
212
|
-
(null == n && ((n = {}), null != t && (n[User.Sa] = t)), e === User.
|
|
214
|
+
(null == n && ((n = {}), null != t && (n[User.Sa] = t)), e === User.Eu)
|
|
213
215
|
) {
|
|
214
216
|
null == n[e] && (n[e] = {});
|
|
215
217
|
for (const t in s) n[e][t] = s[t];
|
|
216
218
|
} else n[e] = s;
|
|
217
|
-
return (r[o] = n), this.
|
|
219
|
+
return (r[o] = n), this.TS.store(STORAGE_KEYS.It.eS, r);
|
|
218
220
|
}
|
|
219
|
-
|
|
220
|
-
const t = this.
|
|
221
|
-
this.
|
|
221
|
+
IS() {
|
|
222
|
+
const t = this.TS.wr(STORAGE_KEYS.It.eS);
|
|
223
|
+
this.TS.remove(STORAGE_KEYS.It.eS);
|
|
222
224
|
const e = [];
|
|
223
225
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
224
226
|
return e;
|
|
225
227
|
}
|
|
226
|
-
|
|
227
|
-
const e = this.
|
|
228
|
+
qu(t) {
|
|
229
|
+
const e = this.TS.wr(STORAGE_KEYS.It.eS);
|
|
228
230
|
if (null != e) {
|
|
229
|
-
const s = this.
|
|
231
|
+
const s = this.dS(null),
|
|
230
232
|
r = e[s];
|
|
231
233
|
null != r &&
|
|
232
234
|
((e[s] = void 0),
|
|
233
|
-
this.
|
|
235
|
+
this.TS.store(STORAGE_KEYS.It.eS, e),
|
|
234
236
|
(r[User.Sa] = t),
|
|
235
|
-
this.
|
|
237
|
+
this.fl(r));
|
|
236
238
|
}
|
|
237
239
|
const s = this.$u(STORAGE_KEYS.Ou.um);
|
|
238
240
|
let r = null;
|
|
239
|
-
null != s && (r = s.
|
|
240
|
-
const o = this.
|
|
241
|
+
null != s && (r = s.Iu);
|
|
242
|
+
const o = this.gS();
|
|
241
243
|
if (null != o)
|
|
242
244
|
for (let e = 0; e < o.length; e++) {
|
|
243
245
|
const s = o[e];
|
|
244
246
|
null == s.userId && s.sessionId == r && (s.userId = t), this.gm(s);
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
|
-
|
|
248
|
-
return this.
|
|
249
|
+
bS() {
|
|
250
|
+
return this.TS.fS;
|
|
249
251
|
}
|
|
250
252
|
}
|
|
251
253
|
(ne.ec = class {
|
|
252
254
|
constructor(t) {
|
|
253
|
-
(this.
|
|
255
|
+
(this.eu = t), (this.eu = t), (this.fS = ro.mS() ? 3 : 10);
|
|
254
256
|
}
|
|
255
|
-
|
|
256
|
-
return t + "." + this.
|
|
257
|
+
KS(t) {
|
|
258
|
+
return t + "." + this.eu;
|
|
257
259
|
}
|
|
258
260
|
store(t, e) {
|
|
259
261
|
const s = { v: e };
|
|
260
262
|
try {
|
|
261
|
-
return localStorage.setItem(this.
|
|
263
|
+
return localStorage.setItem(this.KS(t), JSON.stringify(s)), !0;
|
|
262
264
|
} catch (t) {
|
|
263
|
-
return b.info("Storage failure: " +
|
|
265
|
+
return b.info("Storage failure: " + ci(t)), !1;
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
268
|
wr(t) {
|
|
267
269
|
try {
|
|
268
270
|
let e = null;
|
|
269
|
-
const s = localStorage.getItem(this.
|
|
271
|
+
const s = localStorage.getItem(this.KS(t));
|
|
270
272
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
271
273
|
} catch (t) {
|
|
272
|
-
return b.info("Storage retrieval failure: " +
|
|
274
|
+
return b.info("Storage retrieval failure: " + ci(t)), null;
|
|
273
275
|
}
|
|
274
276
|
}
|
|
275
277
|
remove(t) {
|
|
276
278
|
try {
|
|
277
|
-
localStorage.removeItem(this.
|
|
279
|
+
localStorage.removeItem(this.KS(t));
|
|
278
280
|
} catch (t) {
|
|
279
|
-
return b.info("Storage removal failure: " +
|
|
281
|
+
return b.info("Storage removal failure: " + ci(t)), !1;
|
|
280
282
|
}
|
|
281
283
|
}
|
|
282
284
|
}),
|
|
283
285
|
(ne.rc = class {
|
|
284
286
|
constructor() {
|
|
285
|
-
(this.
|
|
287
|
+
(this.NS = {}), (this.YS = 5242880), (this.fS = 3);
|
|
286
288
|
}
|
|
287
289
|
store(t, e) {
|
|
288
290
|
const s = { value: e },
|
|
289
|
-
r = this.
|
|
290
|
-
return r > this.
|
|
291
|
+
r = this.DS(e);
|
|
292
|
+
return r > this.YS
|
|
291
293
|
? (b.info(
|
|
292
294
|
"Storage failure: object is ≈" +
|
|
293
295
|
r +
|
|
294
296
|
" bytes which is greater than the max of " +
|
|
295
|
-
this.
|
|
297
|
+
this.YS,
|
|
296
298
|
),
|
|
297
299
|
!1)
|
|
298
|
-
: ((this.
|
|
300
|
+
: ((this.NS[t] = s), !0);
|
|
299
301
|
}
|
|
300
|
-
|
|
302
|
+
DS(t) {
|
|
301
303
|
const e = [],
|
|
302
304
|
s = [t];
|
|
303
305
|
let r = 0;
|
|
@@ -315,23 +317,23 @@ export default class ne {
|
|
|
315
317
|
return r;
|
|
316
318
|
}
|
|
317
319
|
wr(t) {
|
|
318
|
-
const e = this.
|
|
320
|
+
const e = this.NS[t];
|
|
319
321
|
return null == e ? null : e.value;
|
|
320
322
|
}
|
|
321
323
|
remove(t) {
|
|
322
|
-
this.
|
|
324
|
+
this.NS[t] = null;
|
|
323
325
|
}
|
|
324
326
|
}),
|
|
325
327
|
(ne.le = class {
|
|
326
328
|
constructor(t, e, s) {
|
|
327
|
-
(this.
|
|
329
|
+
(this.eu = t), (this.CS = e), (this.eu = t), (this.GS = this.MS());
|
|
328
330
|
const r = "number" == typeof s && s > 0 ? s : 400;
|
|
329
|
-
(this.
|
|
331
|
+
(this.US = 24 * r * 60), (this.pS = {}), (this.CS = !!e);
|
|
330
332
|
}
|
|
331
|
-
|
|
332
|
-
return null != this.
|
|
333
|
+
KS(t) {
|
|
334
|
+
return null != this.eu ? t + "." + this.eu : t;
|
|
333
335
|
}
|
|
334
|
-
|
|
336
|
+
MS() {
|
|
335
337
|
let t = 0,
|
|
336
338
|
e = document.location.hostname;
|
|
337
339
|
const s = e.split("."),
|
|
@@ -348,10 +350,10 @@ export default class ne {
|
|
|
348
350
|
}
|
|
349
351
|
me() {
|
|
350
352
|
const t = new Date();
|
|
351
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
353
|
+
return t.setTime(t.getTime() + 60 * this.US * 1e3), t.getFullYear();
|
|
352
354
|
}
|
|
353
|
-
|
|
354
|
-
const t =
|
|
355
|
+
vS() {
|
|
356
|
+
const t = Yt(STORAGE_KEYS.Ou),
|
|
355
357
|
e = document.cookie.split(";");
|
|
356
358
|
for (let s = 0; s < e.length; s++) {
|
|
357
359
|
let r = e[s];
|
|
@@ -364,19 +366,19 @@ export default class ne {
|
|
|
364
366
|
}
|
|
365
367
|
if (o) {
|
|
366
368
|
const t = r.split("=")[0];
|
|
367
|
-
-1 === t.indexOf("." + this.
|
|
369
|
+
-1 === t.indexOf("." + this.eu) && this.yS(t);
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
store(t, e) {
|
|
372
|
-
this.
|
|
373
|
-
const s = this.
|
|
374
|
+
this.vS();
|
|
375
|
+
const s = this.KS(t),
|
|
374
376
|
r = new Date();
|
|
375
|
-
r.setTime(r.getTime() + 60 * this.
|
|
377
|
+
r.setTime(r.getTime() + 60 * this.US * 1e3);
|
|
376
378
|
const o = "expires=" + r.toUTCString(),
|
|
377
|
-
n = "domain=" + this.
|
|
379
|
+
n = "domain=" + this.GS;
|
|
378
380
|
let a;
|
|
379
|
-
a = this.
|
|
381
|
+
a = this.CS ? e : encodeURIComponent(e);
|
|
380
382
|
const i = s + "=" + a + ";" + o + ";" + n + ";path=/";
|
|
381
383
|
if (i.length >= 4093)
|
|
382
384
|
return (
|
|
@@ -385,30 +387,30 @@ export default class ne {
|
|
|
385
387
|
i.length +
|
|
386
388
|
" chars which is too large to store as a cookie.",
|
|
387
389
|
),
|
|
388
|
-
(this.
|
|
389
|
-
this.
|
|
390
|
+
(this.pS[s] = !0),
|
|
391
|
+
this.yS(s),
|
|
390
392
|
!1
|
|
391
393
|
);
|
|
392
394
|
try {
|
|
393
395
|
document.cookie = i;
|
|
394
396
|
} catch (t) {
|
|
395
|
-
return b.info("Storage failure: " +
|
|
397
|
+
return b.info("Storage failure: " + ci(t)), (this.pS[s] = !0), !1;
|
|
396
398
|
}
|
|
397
|
-
const
|
|
398
|
-
return this.
|
|
399
|
+
const S = this.CS ? String(a) : decodeURIComponent(a);
|
|
400
|
+
return this.LS(s) !== S
|
|
399
401
|
? (b.info(
|
|
400
402
|
`Storage failure: unable to verify cookie write for "${s}". Falling back to other storage.`,
|
|
401
403
|
),
|
|
402
|
-
(this.
|
|
403
|
-
this.
|
|
404
|
+
(this.pS[s] = !0),
|
|
405
|
+
this.yS(s),
|
|
404
406
|
!1)
|
|
405
|
-
: (delete this.
|
|
407
|
+
: (delete this.pS[s], !0);
|
|
406
408
|
}
|
|
407
409
|
wr(t) {
|
|
408
|
-
const e = this.
|
|
409
|
-
return this.
|
|
410
|
+
const e = this.KS(t);
|
|
411
|
+
return this.pS[e] ? null : this.LS(e);
|
|
410
412
|
}
|
|
411
|
-
|
|
413
|
+
LS(t) {
|
|
412
414
|
const e = [],
|
|
413
415
|
s = t + "=",
|
|
414
416
|
r = document.cookie.split(";");
|
|
@@ -418,50 +420,50 @@ export default class ne {
|
|
|
418
420
|
if (0 === n.indexOf(s))
|
|
419
421
|
try {
|
|
420
422
|
let t;
|
|
421
|
-
(t = this.
|
|
423
|
+
(t = this.CS
|
|
422
424
|
? n.substring(s.length, n.length)
|
|
423
425
|
: decodeURIComponent(n.substring(s.length, n.length))),
|
|
424
426
|
e.push(t);
|
|
425
427
|
} catch (e) {
|
|
426
428
|
return (
|
|
427
|
-
b.info("Storage retrieval failure: " +
|
|
429
|
+
b.info("Storage retrieval failure: " + ci(e)), this.yS(t), null
|
|
428
430
|
);
|
|
429
431
|
}
|
|
430
432
|
}
|
|
431
433
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
432
434
|
}
|
|
433
435
|
remove(t) {
|
|
434
|
-
this.
|
|
436
|
+
this.yS(this.KS(t));
|
|
435
437
|
}
|
|
436
|
-
|
|
438
|
+
yS(t) {
|
|
437
439
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
438
440
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
439
|
-
const s = e + ";domain=" + this.
|
|
441
|
+
const s = e + ";domain=" + this.GS;
|
|
440
442
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
441
443
|
}
|
|
442
444
|
}),
|
|
443
445
|
(ne.tc = class {
|
|
444
446
|
constructor(t, e, s, r) {
|
|
445
|
-
(this.
|
|
446
|
-
(this.
|
|
447
|
-
e && this.
|
|
448
|
-
s && this.
|
|
449
|
-
this.
|
|
447
|
+
(this.eu = t),
|
|
448
|
+
(this.BS = []),
|
|
449
|
+
e && this.BS.push(new ne.le(t, void 0, r)),
|
|
450
|
+
s && this.BS.push(new ne.ec(t)),
|
|
451
|
+
this.BS.push(new ne.rc());
|
|
450
452
|
}
|
|
451
453
|
store(t, e) {
|
|
452
454
|
let s = !0;
|
|
453
|
-
for (let r = 0; r < this.
|
|
455
|
+
for (let r = 0; r < this.BS.length; r++) s = this.BS[r].store(t, e) && s;
|
|
454
456
|
return s;
|
|
455
457
|
}
|
|
456
458
|
wr(t) {
|
|
457
|
-
for (let e = 0; e < this.
|
|
458
|
-
const s = this.
|
|
459
|
+
for (let e = 0; e < this.BS.length; e++) {
|
|
460
|
+
const s = this.BS[e].wr(t);
|
|
459
461
|
if (null != s) return s;
|
|
460
462
|
}
|
|
461
463
|
return null;
|
|
462
464
|
}
|
|
463
465
|
remove(t) {
|
|
464
|
-
new ne.le(this.
|
|
465
|
-
for (let e = 0; e < this.
|
|
466
|
+
new ne.le(this.eu).remove(t);
|
|
467
|
+
for (let e = 0; e < this.BS.length; e++) this.BS[e].remove(t);
|
|
466
468
|
}
|
|
467
469
|
});
|
package/src/managers/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Ya: "invalid_api_key",
|
|
3
|
+
Qa: "blacklisted",
|
|
4
|
+
Va: "no_device_identifier",
|
|
5
|
+
Wa: "invalid_json_response",
|
|
6
|
+
Ha: "empty_response",
|
|
7
7
|
__: "sdk_auth_error",
|
|
8
8
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { getAlias as
|
|
2
|
+
import { getAlias as Te } from "../managers/utils.js";
|
|
3
3
|
import { isObject as Ct } from "../util/code-utils.js";
|
|
4
4
|
import {
|
|
5
5
|
convertMsToSeconds as X,
|
|
6
6
|
timestampOrNow as is,
|
|
7
7
|
} from "../util/date-utils.js";
|
|
8
|
-
export default class
|
|
8
|
+
export default class ve {
|
|
9
9
|
constructor(t, s, i, r, e) {
|
|
10
10
|
(this.userId = t),
|
|
11
11
|
(this.type = s),
|
|
@@ -18,7 +18,7 @@ export default class Ie {
|
|
|
18
18
|
(this.sessionId = r),
|
|
19
19
|
(this.data = e);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
Uo() {
|
|
22
22
|
var t;
|
|
23
23
|
const s = {
|
|
24
24
|
name: this.type,
|
|
@@ -29,7 +29,7 @@ export default class Ie {
|
|
|
29
29
|
null != this.userId && (s.user_id = this.userId);
|
|
30
30
|
const i = (null === (t = r.Er()) || void 0 === t ? void 0 : t.Fh()) || !1;
|
|
31
31
|
if (!s.user_id && !i) {
|
|
32
|
-
const t =
|
|
32
|
+
const t = Te(r.p());
|
|
33
33
|
t && (s.alias = t);
|
|
34
34
|
}
|
|
35
35
|
return s;
|
|
@@ -44,12 +44,12 @@ export default class Ie {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
static fromJson(t) {
|
|
47
|
-
return new
|
|
47
|
+
return new ve(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
48
48
|
}
|
|
49
|
-
static
|
|
49
|
+
static RS(t) {
|
|
50
50
|
return null != t && Ct(t) && null != t.t && "" !== t.t;
|
|
51
51
|
}
|
|
52
52
|
static _u(t) {
|
|
53
|
-
return new
|
|
53
|
+
return new ve(t.u, t.t, t.ts, t.s, t.d);
|
|
54
54
|
}
|
|
55
55
|
}
|