@mparticle/web-id5-kit 1.0.3 → 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 +72 -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
|
}
|
|
@@ -1035,17 +1035,23 @@ Common.prototype.logId5Id = function (id5Id) {
|
|
|
1035
1035
|
var integrationAttributes = {
|
|
1036
1036
|
encryptedId5Id: id5Id,
|
|
1037
1037
|
id5IdType: this.id5IdType,
|
|
1038
|
+
partnerId: this.partnerId.toString(),
|
|
1038
1039
|
};
|
|
1039
1040
|
|
|
1040
|
-
window.mParticle.setIntegrationAttribute(
|
|
1041
|
+
window.mParticle.setIntegrationAttribute(
|
|
1042
|
+
this.moduleId,
|
|
1043
|
+
integrationAttributes
|
|
1044
|
+
);
|
|
1041
1045
|
};
|
|
1042
1046
|
|
|
1043
|
-
Common.prototype.buildPartnerData = function
|
|
1047
|
+
Common.prototype.buildPartnerData = function(mParticleUser) {
|
|
1044
1048
|
var pdKeys = {};
|
|
1045
1049
|
var userIdentities = mParticleUser.getUserIdentities();
|
|
1046
1050
|
|
|
1047
1051
|
var email = this.normalizeEmail(userIdentities.userIdentities['email']);
|
|
1048
|
-
var phone = this.normalizePhone(
|
|
1052
|
+
var phone = this.normalizePhone(
|
|
1053
|
+
userIdentities.userIdentities['mobile_number']
|
|
1054
|
+
);
|
|
1049
1055
|
|
|
1050
1056
|
if (!email && !phone) {
|
|
1051
1057
|
return null;
|
|
@@ -1056,12 +1062,14 @@ Common.prototype.buildPartnerData = function (mParticleUser) {
|
|
|
1056
1062
|
}
|
|
1057
1063
|
|
|
1058
1064
|
if (phone) {
|
|
1059
|
-
pdKeys[2]= sha256(phone);
|
|
1065
|
+
pdKeys[2] = sha256(phone);
|
|
1060
1066
|
}
|
|
1061
1067
|
|
|
1062
|
-
var pdRaw = Object.keys(pdKeys)
|
|
1063
|
-
|
|
1064
|
-
|
|
1068
|
+
var pdRaw = Object.keys(pdKeys)
|
|
1069
|
+
.map(function(key) {
|
|
1070
|
+
return key + '=' + pdKeys[key];
|
|
1071
|
+
})
|
|
1072
|
+
.join('&');
|
|
1065
1073
|
|
|
1066
1074
|
return btoa(pdRaw);
|
|
1067
1075
|
};
|
|
@@ -1070,14 +1078,14 @@ Common.prototype.normalizeEmail = function(email) {
|
|
|
1070
1078
|
if (!email || !this.validateEmail(email)) {
|
|
1071
1079
|
return null;
|
|
1072
1080
|
}
|
|
1073
|
-
var parts = email.split(
|
|
1081
|
+
var parts = email.split('@');
|
|
1074
1082
|
var charactersToRemove = ['+', '.'];
|
|
1075
1083
|
|
|
1076
1084
|
if (parts[1] != 'gmail.com') {
|
|
1077
1085
|
return email;
|
|
1078
1086
|
}
|
|
1079
1087
|
|
|
1080
|
-
parts[0]= this.replace(parts[0], charactersToRemove);
|
|
1088
|
+
parts[0] = this.replace(parts[0], charactersToRemove);
|
|
1081
1089
|
|
|
1082
1090
|
return parts.join('@');
|
|
1083
1091
|
};
|
|
@@ -1101,25 +1109,25 @@ Common.prototype.normalizePhone = function(phone) {
|
|
|
1101
1109
|
|
|
1102
1110
|
Common.prototype.replace = function(string, targets) {
|
|
1103
1111
|
var newString = '';
|
|
1104
|
-
for(var i = 0; i < string.length; i++){
|
|
1112
|
+
for (var i = 0; i < string.length; i++) {
|
|
1105
1113
|
var char = string[i];
|
|
1106
|
-
if (!targets.includes(char)){
|
|
1114
|
+
if (!targets.includes(char)) {
|
|
1107
1115
|
newString += char;
|
|
1108
1116
|
}
|
|
1109
1117
|
}
|
|
1110
1118
|
return newString.toLowerCase();
|
|
1111
1119
|
};
|
|
1112
1120
|
|
|
1113
|
-
Common.prototype.validateEmail = function(email){
|
|
1121
|
+
Common.prototype.validateEmail = function(email) {
|
|
1114
1122
|
if (!email) {
|
|
1115
1123
|
return false;
|
|
1116
1124
|
}
|
|
1117
|
-
var emailRegex =
|
|
1125
|
+
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1118
1126
|
return emailRegex.test(email);
|
|
1119
1127
|
};
|
|
1120
1128
|
|
|
1121
1129
|
Common.prototype.validatePhone = function(phone) {
|
|
1122
|
-
if (!phone){
|
|
1130
|
+
if (!phone) {
|
|
1123
1131
|
return false;
|
|
1124
1132
|
}
|
|
1125
1133
|
var e164Regex = /^\+?[1-9]\d{1,14}$/;
|
|
@@ -1258,41 +1266,42 @@ IdentityHandler.prototype.onUserIdentified = function() {};
|
|
|
1258
1266
|
IdentityHandler.prototype.onIdentifyComplete = function() {};
|
|
1259
1267
|
|
|
1260
1268
|
//Must re-initialize ID5 with partner identities(pd) in the config to collect an updated ID5 ID
|
|
1261
|
-
IdentityHandler.prototype.onLoginComplete = function(
|
|
1262
|
-
mParticleUser
|
|
1263
|
-
) {
|
|
1269
|
+
IdentityHandler.prototype.onLoginComplete = function(mParticleUser) {
|
|
1264
1270
|
var partnerData = this.common.buildPartnerData(mParticleUser);
|
|
1265
1271
|
|
|
1266
1272
|
if (partnerData) {
|
|
1267
1273
|
var id5Instance = window.ID5.init({
|
|
1268
|
-
partnerId: this.common.partnerId,
|
|
1274
|
+
partnerId: this.common.partnerId,
|
|
1269
1275
|
pd: partnerData,
|
|
1270
1276
|
consentData: {
|
|
1271
|
-
allowedVendors: this.common.allowedVendors
|
|
1272
|
-
}
|
|
1277
|
+
allowedVendors: this.common.allowedVendors,
|
|
1278
|
+
},
|
|
1273
1279
|
});
|
|
1274
1280
|
var logId5Id = this.common.logId5Id;
|
|
1275
1281
|
|
|
1276
|
-
id5Instance.onAvailable(
|
|
1277
|
-
|
|
1278
|
-
|
|
1282
|
+
id5Instance.onAvailable(
|
|
1283
|
+
function(status) {
|
|
1284
|
+
logId5Id(status.getUserId());
|
|
1285
|
+
}.bind(logId5Id)
|
|
1286
|
+
);
|
|
1279
1287
|
}
|
|
1280
1288
|
};
|
|
1281
1289
|
|
|
1282
1290
|
//Must re-initialize ID5 without partner identities (pd) in the config to revert to an anonymous ID5 ID
|
|
1283
|
-
IdentityHandler.prototype.onLogoutComplete = function(
|
|
1284
|
-
) {
|
|
1291
|
+
IdentityHandler.prototype.onLogoutComplete = function() {
|
|
1285
1292
|
var id5Instance = window.ID5.init({
|
|
1286
1293
|
partnerId: this.common.partnerId,
|
|
1287
1294
|
consentData: {
|
|
1288
|
-
allowedVendors: this.common.allowedVendors
|
|
1289
|
-
}
|
|
1295
|
+
allowedVendors: this.common.allowedVendors,
|
|
1296
|
+
},
|
|
1290
1297
|
});
|
|
1291
1298
|
var logId5Id = this.common.logId5Id;
|
|
1292
1299
|
|
|
1293
|
-
id5Instance.onAvailable(
|
|
1294
|
-
|
|
1295
|
-
|
|
1300
|
+
id5Instance.onAvailable(
|
|
1301
|
+
function(status) {
|
|
1302
|
+
logId5Id(status.getUserId());
|
|
1303
|
+
}.bind(logId5Id)
|
|
1304
|
+
);
|
|
1296
1305
|
};
|
|
1297
1306
|
|
|
1298
1307
|
IdentityHandler.prototype.onModifyComplete = function() {};
|
|
@@ -1308,7 +1317,7 @@ var identityHandler = IdentityHandler;
|
|
|
1308
1317
|
var initialization = {
|
|
1309
1318
|
name: 'ID5',
|
|
1310
1319
|
moduleId: 248,
|
|
1311
|
-
vendors: [
|
|
1320
|
+
vendors: ['131', 'ID5-1747'],
|
|
1312
1321
|
/* ****** Fill out initForwarder to load your SDK ******
|
|
1313
1322
|
Note that not all arguments may apply to your SDK initialization.
|
|
1314
1323
|
These are passed from mParticle, but leave them even if they are not being used.
|
|
@@ -1317,7 +1326,16 @@ var initialization = {
|
|
|
1317
1326
|
userIdentities example: { 1: 'customerId', 2: 'facebookId', 7: 'emailid@email.com' }
|
|
1318
1327
|
additional identityTypes can be found at https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/src/types.js#L88-L101
|
|
1319
1328
|
*/
|
|
1320
|
-
initForwarder: function(
|
|
1329
|
+
initForwarder: function(
|
|
1330
|
+
forwarderSettings,
|
|
1331
|
+
testMode,
|
|
1332
|
+
userAttributes,
|
|
1333
|
+
userIdentities,
|
|
1334
|
+
processEvent,
|
|
1335
|
+
eventQueue,
|
|
1336
|
+
isInitialized,
|
|
1337
|
+
common
|
|
1338
|
+
) {
|
|
1321
1339
|
/* `forwarderSettings` contains your SDK specific settings such as apiKey that your customer needs in order to initialize your SDK properly */
|
|
1322
1340
|
common.partnerId = forwarderSettings.partnerId;
|
|
1323
1341
|
common.id5IdType = forwarderSettings.id5IdType;
|
|
@@ -1331,41 +1349,44 @@ var initialization = {
|
|
|
1331
1349
|
//ID5 docs on initialization can be found here: https://github.com/id5io/id5-api.js/blob/master/README.md
|
|
1332
1350
|
var id5Script = document.createElement('script');
|
|
1333
1351
|
id5Script.src = 'https://cdn.id5-sync.com/api/1.0/id5-api.js';
|
|
1334
|
-
(
|
|
1352
|
+
(
|
|
1353
|
+
document.getElementsByTagName('head')[0] ||
|
|
1354
|
+
document.getElementsByTagName('body')[0]
|
|
1355
|
+
).appendChild(id5Script);
|
|
1335
1356
|
|
|
1336
1357
|
id5Script.onload = function() {
|
|
1337
1358
|
|
|
1338
1359
|
var id5Instance = window.ID5.init({
|
|
1339
1360
|
partnerId: common.partnerId,
|
|
1340
1361
|
consentData: {
|
|
1341
|
-
allowedVendors: common.allowedVendors
|
|
1342
|
-
}
|
|
1362
|
+
allowedVendors: common.allowedVendors,
|
|
1363
|
+
},
|
|
1343
1364
|
});
|
|
1344
1365
|
|
|
1345
|
-
id5Instance.onAvailable(
|
|
1346
|
-
|
|
1347
|
-
|
|
1366
|
+
id5Instance.onAvailable(
|
|
1367
|
+
function(status) {
|
|
1368
|
+
common.logId5Id(status.getUserId());
|
|
1369
|
+
}.bind(common)
|
|
1370
|
+
);
|
|
1348
1371
|
};
|
|
1349
1372
|
} else {
|
|
1350
1373
|
|
|
1351
|
-
var id5Instance = window.ID5.init({partnerId: common.partnerId});
|
|
1374
|
+
var id5Instance = window.ID5.init({ partnerId: common.partnerId });
|
|
1352
1375
|
|
|
1353
|
-
id5Instance.onAvailable(
|
|
1354
|
-
|
|
1355
|
-
|
|
1376
|
+
id5Instance.onAvailable(
|
|
1377
|
+
function(status) {
|
|
1378
|
+
common.logId5Id(status.getUserId());
|
|
1379
|
+
}.bind(common)
|
|
1380
|
+
);
|
|
1356
1381
|
}
|
|
1357
|
-
}
|
|
1382
|
+
},
|
|
1358
1383
|
};
|
|
1359
1384
|
|
|
1360
1385
|
var initialization_1 = initialization;
|
|
1361
1386
|
|
|
1362
1387
|
var sessionHandler = {
|
|
1363
|
-
onSessionStart: function() {
|
|
1364
|
-
|
|
1365
|
-
},
|
|
1366
|
-
onSessionEnd: function() {
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1388
|
+
onSessionStart: function() {},
|
|
1389
|
+
onSessionEnd: function() {},
|
|
1369
1390
|
};
|
|
1370
1391
|
|
|
1371
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
|
}
|