@mparticle/web-id5-kit 1.0.4 → 3.1.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/dist/ID5Kit.common.js +71 -51
- package/package.json +53 -47
package/dist/ID5Kit.common.js
CHANGED
|
@@ -1023,11 +1023,11 @@ var sha256 = createCommonjsModule(function (module, exports) {
|
|
|
1023
1023
|
|
|
1024
1024
|
function Common() {}
|
|
1025
1025
|
|
|
1026
|
-
Common.prototype.exampleMethod = function
|
|
1026
|
+
Common.prototype.exampleMethod = function() {
|
|
1027
1027
|
return 'I am an example';
|
|
1028
1028
|
};
|
|
1029
1029
|
|
|
1030
|
-
Common.prototype.logId5Id = function
|
|
1030
|
+
Common.prototype.logId5Id = function(id5Id) {
|
|
1031
1031
|
if (!id5Id) {
|
|
1032
1032
|
return;
|
|
1033
1033
|
}
|
|
@@ -1038,15 +1038,20 @@ Common.prototype.logId5Id = function (id5Id) {
|
|
|
1038
1038
|
partnerId: this.partnerId.toString(),
|
|
1039
1039
|
};
|
|
1040
1040
|
|
|
1041
|
-
window.mParticle.setIntegrationAttribute(
|
|
1041
|
+
window.mParticle.setIntegrationAttribute(
|
|
1042
|
+
this.moduleId,
|
|
1043
|
+
integrationAttributes
|
|
1044
|
+
);
|
|
1042
1045
|
};
|
|
1043
1046
|
|
|
1044
|
-
Common.prototype.buildPartnerData = function
|
|
1047
|
+
Common.prototype.buildPartnerData = function(mParticleUser) {
|
|
1045
1048
|
var pdKeys = {};
|
|
1046
1049
|
var userIdentities = mParticleUser.getUserIdentities();
|
|
1047
1050
|
|
|
1048
1051
|
var email = this.normalizeEmail(userIdentities.userIdentities['email']);
|
|
1049
|
-
var phone = this.normalizePhone(
|
|
1052
|
+
var phone = this.normalizePhone(
|
|
1053
|
+
userIdentities.userIdentities['mobile_number']
|
|
1054
|
+
);
|
|
1050
1055
|
|
|
1051
1056
|
if (!email && !phone) {
|
|
1052
1057
|
return null;
|
|
@@ -1057,12 +1062,14 @@ Common.prototype.buildPartnerData = function (mParticleUser) {
|
|
|
1057
1062
|
}
|
|
1058
1063
|
|
|
1059
1064
|
if (phone) {
|
|
1060
|
-
pdKeys[2]= sha256(phone);
|
|
1065
|
+
pdKeys[2] = sha256(phone);
|
|
1061
1066
|
}
|
|
1062
1067
|
|
|
1063
|
-
var pdRaw = Object.keys(pdKeys)
|
|
1064
|
-
|
|
1065
|
-
|
|
1068
|
+
var pdRaw = Object.keys(pdKeys)
|
|
1069
|
+
.map(function(key) {
|
|
1070
|
+
return key + '=' + pdKeys[key];
|
|
1071
|
+
})
|
|
1072
|
+
.join('&');
|
|
1066
1073
|
|
|
1067
1074
|
return btoa(pdRaw);
|
|
1068
1075
|
};
|
|
@@ -1071,14 +1078,14 @@ Common.prototype.normalizeEmail = function(email) {
|
|
|
1071
1078
|
if (!email || !this.validateEmail(email)) {
|
|
1072
1079
|
return null;
|
|
1073
1080
|
}
|
|
1074
|
-
var parts = email.split(
|
|
1081
|
+
var parts = email.split('@');
|
|
1075
1082
|
var charactersToRemove = ['+', '.'];
|
|
1076
1083
|
|
|
1077
1084
|
if (parts[1] != 'gmail.com') {
|
|
1078
1085
|
return email;
|
|
1079
1086
|
}
|
|
1080
1087
|
|
|
1081
|
-
parts[0]= this.replace(parts[0], charactersToRemove);
|
|
1088
|
+
parts[0] = this.replace(parts[0], charactersToRemove);
|
|
1082
1089
|
|
|
1083
1090
|
return parts.join('@');
|
|
1084
1091
|
};
|
|
@@ -1102,25 +1109,25 @@ Common.prototype.normalizePhone = function(phone) {
|
|
|
1102
1109
|
|
|
1103
1110
|
Common.prototype.replace = function(string, targets) {
|
|
1104
1111
|
var newString = '';
|
|
1105
|
-
for(var i = 0; i < string.length; i++){
|
|
1112
|
+
for (var i = 0; i < string.length; i++) {
|
|
1106
1113
|
var char = string[i];
|
|
1107
|
-
if (!targets.includes(char)){
|
|
1114
|
+
if (!targets.includes(char)) {
|
|
1108
1115
|
newString += char;
|
|
1109
1116
|
}
|
|
1110
1117
|
}
|
|
1111
1118
|
return newString.toLowerCase();
|
|
1112
1119
|
};
|
|
1113
1120
|
|
|
1114
|
-
Common.prototype.validateEmail = function(email){
|
|
1121
|
+
Common.prototype.validateEmail = function(email) {
|
|
1115
1122
|
if (!email) {
|
|
1116
1123
|
return false;
|
|
1117
1124
|
}
|
|
1118
|
-
var emailRegex =
|
|
1125
|
+
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1119
1126
|
return emailRegex.test(email);
|
|
1120
1127
|
};
|
|
1121
1128
|
|
|
1122
1129
|
Common.prototype.validatePhone = function(phone) {
|
|
1123
|
-
if (!phone){
|
|
1130
|
+
if (!phone) {
|
|
1124
1131
|
return false;
|
|
1125
1132
|
}
|
|
1126
1133
|
var e164Regex = /^\+?[1-9]\d{1,14}$/;
|
|
@@ -1259,41 +1266,42 @@ IdentityHandler.prototype.onUserIdentified = function() {};
|
|
|
1259
1266
|
IdentityHandler.prototype.onIdentifyComplete = function() {};
|
|
1260
1267
|
|
|
1261
1268
|
//Must re-initialize ID5 with partner identities(pd) in the config to collect an updated ID5 ID
|
|
1262
|
-
IdentityHandler.prototype.onLoginComplete = function(
|
|
1263
|
-
mParticleUser
|
|
1264
|
-
) {
|
|
1269
|
+
IdentityHandler.prototype.onLoginComplete = function(mParticleUser) {
|
|
1265
1270
|
var partnerData = this.common.buildPartnerData(mParticleUser);
|
|
1266
1271
|
|
|
1267
1272
|
if (partnerData) {
|
|
1268
1273
|
var id5Instance = window.ID5.init({
|
|
1269
|
-
partnerId: this.common.partnerId,
|
|
1274
|
+
partnerId: this.common.partnerId,
|
|
1270
1275
|
pd: partnerData,
|
|
1271
1276
|
consentData: {
|
|
1272
|
-
allowedVendors: this.common.allowedVendors
|
|
1273
|
-
}
|
|
1277
|
+
allowedVendors: this.common.allowedVendors,
|
|
1278
|
+
},
|
|
1274
1279
|
});
|
|
1275
1280
|
var logId5Id = this.common.logId5Id;
|
|
1276
1281
|
|
|
1277
|
-
id5Instance.onAvailable(
|
|
1278
|
-
|
|
1279
|
-
|
|
1282
|
+
id5Instance.onAvailable(
|
|
1283
|
+
function(status) {
|
|
1284
|
+
logId5Id(status.getUserId());
|
|
1285
|
+
}.bind(logId5Id)
|
|
1286
|
+
);
|
|
1280
1287
|
}
|
|
1281
1288
|
};
|
|
1282
1289
|
|
|
1283
1290
|
//Must re-initialize ID5 without partner identities (pd) in the config to revert to an anonymous ID5 ID
|
|
1284
|
-
IdentityHandler.prototype.onLogoutComplete = function(
|
|
1285
|
-
) {
|
|
1291
|
+
IdentityHandler.prototype.onLogoutComplete = function() {
|
|
1286
1292
|
var id5Instance = window.ID5.init({
|
|
1287
1293
|
partnerId: this.common.partnerId,
|
|
1288
1294
|
consentData: {
|
|
1289
|
-
allowedVendors: this.common.allowedVendors
|
|
1290
|
-
}
|
|
1295
|
+
allowedVendors: this.common.allowedVendors,
|
|
1296
|
+
},
|
|
1291
1297
|
});
|
|
1292
1298
|
var logId5Id = this.common.logId5Id;
|
|
1293
1299
|
|
|
1294
|
-
id5Instance.onAvailable(
|
|
1295
|
-
|
|
1296
|
-
|
|
1300
|
+
id5Instance.onAvailable(
|
|
1301
|
+
function(status) {
|
|
1302
|
+
logId5Id(status.getUserId());
|
|
1303
|
+
}.bind(logId5Id)
|
|
1304
|
+
);
|
|
1297
1305
|
};
|
|
1298
1306
|
|
|
1299
1307
|
IdentityHandler.prototype.onModifyComplete = function() {};
|
|
@@ -1309,7 +1317,7 @@ var identityHandler = IdentityHandler;
|
|
|
1309
1317
|
var initialization = {
|
|
1310
1318
|
name: 'ID5',
|
|
1311
1319
|
moduleId: 248,
|
|
1312
|
-
vendors: [
|
|
1320
|
+
vendors: ['131', 'ID5-1747'],
|
|
1313
1321
|
/* ****** Fill out initForwarder to load your SDK ******
|
|
1314
1322
|
Note that not all arguments may apply to your SDK initialization.
|
|
1315
1323
|
These are passed from mParticle, but leave them even if they are not being used.
|
|
@@ -1318,7 +1326,16 @@ var initialization = {
|
|
|
1318
1326
|
userIdentities example: { 1: 'customerId', 2: 'facebookId', 7: 'emailid@email.com' }
|
|
1319
1327
|
additional identityTypes can be found at https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/src/types.js#L88-L101
|
|
1320
1328
|
*/
|
|
1321
|
-
initForwarder: function(
|
|
1329
|
+
initForwarder: function(
|
|
1330
|
+
forwarderSettings,
|
|
1331
|
+
testMode,
|
|
1332
|
+
userAttributes,
|
|
1333
|
+
userIdentities,
|
|
1334
|
+
processEvent,
|
|
1335
|
+
eventQueue,
|
|
1336
|
+
isInitialized,
|
|
1337
|
+
common
|
|
1338
|
+
) {
|
|
1322
1339
|
/* `forwarderSettings` contains your SDK specific settings such as apiKey that your customer needs in order to initialize your SDK properly */
|
|
1323
1340
|
common.partnerId = forwarderSettings.partnerId;
|
|
1324
1341
|
common.id5IdType = forwarderSettings.id5IdType;
|
|
@@ -1332,41 +1349,44 @@ var initialization = {
|
|
|
1332
1349
|
//ID5 docs on initialization can be found here: https://github.com/id5io/id5-api.js/blob/master/README.md
|
|
1333
1350
|
var id5Script = document.createElement('script');
|
|
1334
1351
|
id5Script.src = 'https://cdn.id5-sync.com/api/1.0/id5-api.js';
|
|
1335
|
-
(
|
|
1352
|
+
(
|
|
1353
|
+
document.getElementsByTagName('head')[0] ||
|
|
1354
|
+
document.getElementsByTagName('body')[0]
|
|
1355
|
+
).appendChild(id5Script);
|
|
1336
1356
|
|
|
1337
1357
|
id5Script.onload = function() {
|
|
1338
1358
|
|
|
1339
1359
|
var id5Instance = window.ID5.init({
|
|
1340
1360
|
partnerId: common.partnerId,
|
|
1341
1361
|
consentData: {
|
|
1342
|
-
allowedVendors: common.allowedVendors
|
|
1343
|
-
}
|
|
1362
|
+
allowedVendors: common.allowedVendors,
|
|
1363
|
+
},
|
|
1344
1364
|
});
|
|
1345
1365
|
|
|
1346
|
-
id5Instance.onAvailable(
|
|
1347
|
-
|
|
1348
|
-
|
|
1366
|
+
id5Instance.onAvailable(
|
|
1367
|
+
function(status) {
|
|
1368
|
+
common.logId5Id(status.getUserId());
|
|
1369
|
+
}.bind(common)
|
|
1370
|
+
);
|
|
1349
1371
|
};
|
|
1350
1372
|
} else {
|
|
1351
1373
|
|
|
1352
|
-
var id5Instance = window.ID5.init({partnerId: common.partnerId});
|
|
1374
|
+
var id5Instance = window.ID5.init({ partnerId: common.partnerId });
|
|
1353
1375
|
|
|
1354
|
-
id5Instance.onAvailable(
|
|
1355
|
-
|
|
1356
|
-
|
|
1376
|
+
id5Instance.onAvailable(
|
|
1377
|
+
function(status) {
|
|
1378
|
+
common.logId5Id(status.getUserId());
|
|
1379
|
+
}.bind(common)
|
|
1380
|
+
);
|
|
1357
1381
|
}
|
|
1358
|
-
}
|
|
1382
|
+
},
|
|
1359
1383
|
};
|
|
1360
1384
|
|
|
1361
1385
|
var initialization_1 = initialization;
|
|
1362
1386
|
|
|
1363
1387
|
var sessionHandler = {
|
|
1364
|
-
onSessionStart: function() {
|
|
1365
|
-
|
|
1366
|
-
},
|
|
1367
|
-
onSessionEnd: function() {
|
|
1368
|
-
|
|
1369
|
-
}
|
|
1388
|
+
onSessionStart: function() {},
|
|
1389
|
+
onSessionEnd: function() {},
|
|
1370
1390
|
};
|
|
1371
1391
|
|
|
1372
1392
|
var sessionHandler_1 = sessionHandler;
|
package/package.json
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@mparticle/web-id5-kit",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"main": "dist/ID5Kit.common.js",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/ID5Kit.common.js"
|
|
7
|
+
],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "ENVIRONMENT=production rollup --config rollup.config.js",
|
|
10
|
+
"build:test": "rollup --config rollup.test.config.js",
|
|
11
|
+
"lint": "eslint src/ test/src/",
|
|
12
|
+
"lint:fix": "eslint src/ test/src/ --fix",
|
|
13
|
+
"watch": "ENVIRONMENT=production rollup --config rollup.config.js -w",
|
|
14
|
+
"test": "npm run build && npm run build:test && DEBUG=false karma start test/karma.config.js",
|
|
15
|
+
"test:debug": "npm run build && npm run build:test && DEBUG=true karma start test/karma.config.js",
|
|
16
|
+
"testEndToEnd": "ENVIRONMENT=testEndToEnd rollup --config rollup.config.js && open http://localhost:8082/node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/index.html && node node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/server"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@mparticle/eslint-config-sdks": "^0.0.4",
|
|
20
|
+
"@mparticle/web-kit-wrapper": "^1.0.5",
|
|
21
|
+
"@semantic-release/changelog": "^5.0.1",
|
|
22
|
+
"@semantic-release/exec": "^5.0.0",
|
|
23
|
+
"@semantic-release/git": "^9.0.0",
|
|
24
|
+
"chai": "^4.2.0",
|
|
25
|
+
"crypto-js": "^4.2.0",
|
|
26
|
+
"eslint": "^7.25.0",
|
|
27
|
+
"eslint-config-prettier": "9.1.0",
|
|
28
|
+
"karma": "^5.1.0",
|
|
29
|
+
"karma-chai": "^0.1.0",
|
|
30
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
31
|
+
"karma-firefox-launcher": "^2.1.0",
|
|
32
|
+
"karma-mocha": "^2.0.1",
|
|
33
|
+
"mocha": "^5.2.0",
|
|
34
|
+
"prettier": "^2.4.1",
|
|
35
|
+
"rollup": "^1.15.6",
|
|
36
|
+
"rollup-plugin-commonjs": "^10.0.0",
|
|
37
|
+
"rollup-plugin-node-resolve": "^5.0.3",
|
|
38
|
+
"shelljs": "0.8.3",
|
|
39
|
+
"should": "13.2.3",
|
|
40
|
+
"watchify": "^3.11.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@mparticle/web-sdk": "^3.0.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"license": "Apache-2.0",
|
|
49
|
+
"homepage": "https://github.com/mParticle/mparticle-web-sdk/tree/main/kits/id5/id5-1#readme",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/mParticle/mparticle-web-sdk",
|
|
53
|
+
"directory": "kits/id5/id5-1"
|
|
54
|
+
}
|
|
49
55
|
}
|