cordova-plugin-insider 3.0.1 → 3.0.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.
@@ -0,0 +1,36 @@
1
+ # Git Hooks
2
+
3
+ ## 📌 Purpose
4
+ This directory uses Git hooks to enforce standards and automate tasks during the development workflow.
5
+ The main example included is a **`commit-msg`** hook that enforces [Conventional Commits v1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) rules with additional project-specific logic.
6
+
7
+ ---
8
+
9
+ ## 📂 Hooks Included
10
+
11
+ ### 1. `commit-msg`
12
+ Ensures commit messages follow the Conventional Commits specification, with custom rules:
13
+
14
+ - **Bypasses**:
15
+ - `Merge branch ...` commits (merge commits)
16
+ - `pick ...`, `reword ...`, `edit ...`, `squash ...`, `fixup ...`, `exec ...` messages (interactive rebase auto-generated commits)
17
+ - **JIRA Reference**:
18
+ - If the branch name contains a JIRA ID in the form `MOB-1234`, it will automatically append
19
+ `#Ref: MOB-1234` to the end of the commit message (if not already present).
20
+ - **Optional Description**:
21
+ - `<type>[<scope>][!]: <description>` — the description can be empty.
22
+ - **Header length**:
23
+ - Max 120 characters (hard limit)
24
+ - Warning if over 50 or 72 characters.
25
+
26
+ ---
27
+
28
+ ## 🔧 Installation
29
+
30
+ ### 1. Copy Hooks to `.git/hooks/`
31
+
32
+ Run the following commands under project's directory:
33
+ ```bash
34
+ cp .git-hooks/commit-msg .git/hooks/commit-msg
35
+ chmod +x .git/hooks/commit-msg
36
+ ```
@@ -0,0 +1,83 @@
1
+ #!/bin/sh
2
+
3
+ COMMIT_MSG_FILE="$1"
4
+ COMMIT_MSG_FIRST_LINE=$(head -n1 "$COMMIT_MSG_FILE")
5
+
6
+ # 1. Skip "Merge branch ..." commits
7
+ if echo "$COMMIT_MSG_FIRST_LINE" | grep -qE "^Merge branch "; then
8
+ exit 0
9
+ fi
10
+
11
+ # 2. Skip interactive rebase auto-commits
12
+ if echo "$COMMIT_MSG_FIRST_LINE" | grep -qE "^(pick|reword|edit|squash|fixup|exec) "; then
13
+ exit 0
14
+ fi
15
+
16
+ # Allowed Conventional Commit types (v1.0.0 + release)
17
+ ALLOWED_TYPES="feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|release"
18
+
19
+ # Regex – type(scope)!?: description (description required)
20
+ FIRST_LINE_REGEX="^(${ALLOWED_TYPES})(\([^\)]+\))?(!)?: [^ ].+$"
21
+
22
+ error() {
23
+ echo "⛔ Error: $1"
24
+ }
25
+
26
+ warn() {
27
+ echo "⚠️ Warning: $1"
28
+ }
29
+
30
+ # 3. Validate header format
31
+ if ! echo "$COMMIT_MSG_FIRST_LINE" | grep -qE "${FIRST_LINE_REGEX}"; then
32
+ error "Commit mesajı başlığı Conventional Commits v1.0.0 formatına uymuyor."
33
+ echo "Mevcut mesaj: \"$COMMIT_MSG_FIRST_LINE\""
34
+ echo ""
35
+ echo "Beklenen format: <tip>[<scope>][!]: <açıklama>"
36
+ echo "Geçerli tipler: ${ALLOWED_TYPES}"
37
+ exit 1
38
+ fi
39
+
40
+ # 4. Header length check (max 120 chars)
41
+ HEADER_LENGTH=${#COMMIT_MSG_FIRST_LINE}
42
+ if [ "$HEADER_LENGTH" -gt 120 ]; then
43
+ error "İlk satır 120 karakteri aşıyor. (Mevcut uzunluk: $HEADER_LENGTH)"
44
+ exit 1
45
+ elif [ "$HEADER_LENGTH" -gt 72 ]; then
46
+ warn "İlk satır 72 karakterden uzun. (Mevcut uzunluk: $HEADER_LENGTH)"
47
+ fi
48
+
49
+ # 5. Body check (optional)
50
+ LINE_NO=0
51
+ while IFS= read -r line; do
52
+ LINE_NO=$((LINE_NO + 1))
53
+ # Second line should be empty if body exists
54
+ if [ "$LINE_NO" -eq 2 ] && [ -n "$line" ]; then
55
+ warn "İkinci satır boş olmalı (body varsa)."
56
+ fi
57
+ done < "$COMMIT_MSG_FILE"
58
+
59
+ # 6. BREAKING CHANGE footer check
60
+ if grep -qE '^BREAKING CHANGE: ' "$COMMIT_MSG_FILE"; then
61
+ if ! grep -qE '^BREAKING CHANGE: .{1,}' "$COMMIT_MSG_FILE"; then
62
+ error "BREAKING CHANGE açıklaması boş olamaz."
63
+ exit 1
64
+ fi
65
+ fi
66
+
67
+ # 7. Append JIRA ID from branch name
68
+ BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
69
+ JIRA_ID=$(echo "$BRANCH_NAME" | grep -oE 'MOB-[0-9]+')
70
+
71
+ if [ -n "$JIRA_ID" ]; then
72
+ if ! grep -q "$JIRA_ID" "$COMMIT_MSG_FILE"; then
73
+ {
74
+ echo ""
75
+ echo "#Ref: $JIRA_ID"
76
+ } >> "$COMMIT_MSG_FILE"
77
+ echo "ℹ️ Task ID referans olarak eklendi: $JIRA_ID"
78
+ fi
79
+ fi
80
+
81
+ echo "✅ Commit mesajı Conventional Commits v1.0.0 kurallarına uygun."
82
+ exit 0
83
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-insider",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "A plugin that you can use Insider SDK with Cordova and Ionic",
5
5
  "cordova_name": "Insider Cordova Plugin",
6
6
  "cordova": {
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-insider" version="3.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin id="cordova-plugin-insider" version="3.0.2" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
3
  <name>Insider</name>
4
4
  <description>Insider Cordova Plugin</description>
5
5
  <keywords>insider,cordova,cordova-ios,cordova-android</keywords>
@@ -70,9 +70,9 @@
70
70
  <source url="https://cdn.cocoapods.org/" />
71
71
  </config>
72
72
  <pods use-frameworks="true">
73
- <pod name="InsiderMobile" spec="14.0.4" />
74
- <pod name="InsiderGeofence" spec="1.2.3" />
75
- <pod name="InsiderHybrid" spec="1.7.5" />
73
+ <pod name="InsiderMobile" spec="14.2.2" />
74
+ <pod name="InsiderGeofence" spec="1.2.4" />
75
+ <pod name="InsiderHybrid" spec="1.7.6" />
76
76
  </pods>
77
77
  </podspec>
78
78
 
@@ -584,6 +584,29 @@ public class InsiderPlugin extends CordovaPlugin {
584
584
  Insider.Instance.getCurrentUser().login(insiderIdentifiers);
585
585
  } else if (action.equals(InsiderHybridMethods.LOGOUT)) {
586
586
  Insider.Instance.getCurrentUser().logout();
587
+ // TODO: Use InsiderHybridMethods.LOGOUT_RESETTING_INSIDER_ID constant when insiderhybrid is upgraded to version with this constant
588
+ } else if (action.equals("logoutResettingInsiderID")) {
589
+ InsiderIdentifiers[] identifiers = null;
590
+
591
+ if (args.get(0) != null && !args.isNull(0)) {
592
+ identifiers = convertJSONArrayToInsiderIdentifiersArray(args.getJSONArray(0));
593
+ }
594
+
595
+ if (args.length() > 1) {
596
+ final CallbackContext finalCallbackContext = callbackContext;
597
+ Insider.Instance.getCurrentUser().logoutResettingInsiderID(identifiers, new InsiderUser.InsiderIDResult() {
598
+ @Override
599
+ public void insiderIDResult(String insiderID) {
600
+ if (insiderID != null) {
601
+ callbackSuccess(finalCallbackContext, insiderID);
602
+ } else {
603
+ callbackSuccess(finalCallbackContext, "");
604
+ }
605
+ }
606
+ });
607
+ } else {
608
+ Insider.Instance.getCurrentUser().logoutResettingInsiderID(identifiers);
609
+ }
587
610
  } else if (action.equals(Constants.HANDLE_NOTIFICATION)) {
588
611
  if (args.get(0) == null)
589
612
  return false;
@@ -1030,4 +1053,36 @@ public class InsiderPlugin extends CordovaPlugin {
1030
1053
  Insider.Instance.putException(e);
1031
1054
  }
1032
1055
  }
1056
+
1057
+ private InsiderIdentifiers[] convertJSONArrayToInsiderIdentifiersArray(JSONArray identifiersArray) throws JSONException {
1058
+ if (identifiersArray == null || identifiersArray.length() == 0) {
1059
+ return null;
1060
+ }
1061
+
1062
+ InsiderIdentifiers[] identifiers = new InsiderIdentifiers[identifiersArray.length()];
1063
+ for (int i = 0; i < identifiersArray.length(); i++) {
1064
+ JSONObject identifierMap = identifiersArray.getJSONObject(i);
1065
+ InsiderIdentifiers insiderIdentifiers = new InsiderIdentifiers();
1066
+
1067
+ Map<String, Object> identifierData = CDVUtils.convertJSONToMap(identifierMap.toString());
1068
+ for (String key : identifierData.keySet()) {
1069
+ switch (key) {
1070
+ case InsiderHybridMethods.ADD_EMAIL:
1071
+ insiderIdentifiers.addEmail(String.valueOf(identifierData.get(key)));
1072
+ break;
1073
+ case InsiderHybridMethods.ADD_PHONE_NUMBER:
1074
+ insiderIdentifiers.addPhoneNumber(String.valueOf(identifierData.get(key)));
1075
+ break;
1076
+ case InsiderHybridMethods.ADD_USER_ID:
1077
+ insiderIdentifiers.addUserID(String.valueOf(identifierData.get(key)));
1078
+ break;
1079
+ default:
1080
+ insiderIdentifiers.addCustomIdentifier(key, String.valueOf(identifierData.get(key)));
1081
+ break;
1082
+ }
1083
+ }
1084
+ identifiers[i] = insiderIdentifiers;
1085
+ }
1086
+ return identifiers;
1087
+ }
1033
1088
  }
@@ -16,8 +16,8 @@ android {
16
16
  }
17
17
 
18
18
  dependencies {
19
- implementation 'com.useinsider:insider:15.1.3'
20
- implementation 'com.useinsider:insiderhybrid:1.3.3'
19
+ implementation 'com.useinsider:insider:15.2.1'
20
+ implementation 'com.useinsider:insiderhybrid:1.3.4'
21
21
 
22
22
  implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4'
23
23
  implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.4'
@@ -61,6 +61,7 @@
61
61
  - (void) unsetCustomAttribute:(CDVInvokedUrlCommand *)command;
62
62
  - (void) login:(CDVInvokedUrlCommand *)command;
63
63
  - (void) logout:(CDVInvokedUrlCommand *)command;
64
+ - (void) logoutResettingInsiderID:(CDVInvokedUrlCommand *)command;
64
65
  - (void) signUpConfirmation:(CDVInvokedUrlCommand *)command;
65
66
  - (void) putException:(CDVInvokedUrlCommand *)command;
66
67
  - (void) handleNotification:(CDVInvokedUrlCommand *)command;
@@ -772,6 +772,31 @@
772
772
  }
773
773
  }
774
774
 
775
+ - (void)logoutResettingInsiderID:(CDVInvokedUrlCommand *)command {
776
+ @try {
777
+ dispatch_async(dispatch_get_main_queue(), ^{
778
+ NSArray *identifiersArray = nil;
779
+ if ([command.arguments count] > 0 && [command.arguments objectAtIndex:0] != [NSNull null]) {
780
+ identifiersArray = [command.arguments objectAtIndex:0];
781
+ }
782
+
783
+ NSArray<InsiderIdentifiers *> *identifiers = [self convertArrayToInsiderIdentifiersArray:identifiersArray];
784
+
785
+ if ([command.arguments count] > 1) {
786
+ [[Insider getCurrentUser] logoutResettingInsiderID:identifiers insiderIDResult:^(NSString *insiderID) {
787
+ NSString *insiderIDToPass = insiderID ? insiderID : @"";
788
+ [self sendSuccessResultWithString:insiderIDToPass andCommand:command];
789
+ }];
790
+ } else {
791
+ [[Insider getCurrentUser] logoutResettingInsiderID:identifiers];
792
+ [self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
793
+ }
794
+ });
795
+ } @catch (NSException *e) {
796
+ [Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
797
+ }
798
+ }
799
+
775
800
  - (void)signUpConfirmation:(CDVInvokedUrlCommand *)command {
776
801
  @try {
777
802
  dispatch_async(dispatch_get_main_queue(), ^{
@@ -979,4 +1004,28 @@
979
1004
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
980
1005
  }
981
1006
 
1007
+ - (NSArray<InsiderIdentifiers *> *)convertArrayToInsiderIdentifiersArray:(NSArray *)identifiersArray {
1008
+ if (identifiersArray == nil || identifiersArray.count == 0) {
1009
+ return nil;
1010
+ }
1011
+
1012
+ NSMutableArray<InsiderIdentifiers *> *identifiers = [NSMutableArray array];
1013
+ for (NSDictionary *identifierDict in identifiersArray) {
1014
+ InsiderIdentifiers *insiderIdentifiers = [[InsiderIdentifiers alloc] init];
1015
+ for (NSString *key in identifierDict.allKeys) {
1016
+ if ([key isEqualToString:@"addEmail"]) {
1017
+ insiderIdentifiers.addEmail([identifierDict objectForKey:key]);
1018
+ } else if ([key isEqualToString:@"addPhoneNumber"]) {
1019
+ insiderIdentifiers.addPhoneNumber([identifierDict objectForKey:key]);
1020
+ } else if ([key isEqualToString:@"addUserID"]) {
1021
+ insiderIdentifiers.addUserID([identifierDict objectForKey:key]);
1022
+ } else {
1023
+ insiderIdentifiers.addCustomIdentifier(key, [identifierDict objectForKey:key]);
1024
+ }
1025
+ }
1026
+ [identifiers addObject:insiderIdentifiers];
1027
+ }
1028
+ return identifiers;
1029
+ }
1030
+
982
1031
  @end
package/types/User.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface User {
17
17
  setWhatsappOptin(whatsappOptin: boolean): User;
18
18
  login(identifiers:object, insiderIDResult: Function): void;
19
19
  logout(): void;
20
+ logoutResettingInsiderID(identifiers?: object[] | null, insiderIDResult?: (insiderID: string) => void): void;
20
21
  setCustomAttributeWithString(key: string, value: string): User;
21
22
  setCustomAttributeWithInt(key: string, value: number): User;
22
23
  setCustomAttributeWithDouble(key: string, value: number): User;
package/www/Constants.js CHANGED
@@ -22,6 +22,7 @@ module.exports = {
22
22
  SET_WHATSAPP_OPTIN: 'setWhatsappOptin',
23
23
  LOGIN: 'login',
24
24
  LOGOUT: 'logout',
25
+ LOGOUT_RESETTING_INSIDER_ID: 'logoutResettingInsiderID',
25
26
  SET_CUSTOM_ATTRIBUTE_WITH_STRING: 'setCustomAttributeWithString',
26
27
  SET_CUSTOM_ATTRIBUTE_WITH_INT: 'setCustomAttributeWithInt',
27
28
  SET_CUSTOM_ATTRIBUTE_WITH_DOUBLE: 'setCustomAttributeWithDouble',
@@ -109,5 +110,5 @@ module.exports = {
109
110
  // Reinit
110
111
  REINIT_WITH_PARTNER_NAME: 'reinitWithPartnerName',
111
112
  // SDK Version
112
- SDK_VERSION: 'CDV-3.0.1'
113
+ SDK_VERSION: 'CDV-3.0.2'
113
114
  };
package/www/User.js CHANGED
@@ -319,6 +319,27 @@ var User = /*#__PURE__*/function () {
319
319
  Utils.asyncExec(InsiderCordovaPlugin, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
320
320
  }
321
321
  }
322
+ }, {
323
+ key: "logoutResettingInsiderID",
324
+ value: function logoutResettingInsiderID(identifiers, insiderIDResult) {
325
+ try {
326
+ var identifiersArray = identifiers && Array.isArray(identifiers) ? identifiers.map(function (id) {
327
+ return id.identifiers;
328
+ }) : null;
329
+ if (!Utils.checkParameters([{
330
+ type: 'function',
331
+ value: insiderIDResult
332
+ }])) {
333
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGOUT_RESETTING_INSIDER_ID, [identifiersArray, insiderIDResult]).then(function (id) {
334
+ return insiderIDResult(id);
335
+ });
336
+ } else {
337
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.LOGOUT_RESETTING_INSIDER_ID, [identifiersArray]);
338
+ }
339
+ } catch (error) {
340
+ Utils.asyncExec(InsiderConstants.CLASS, InsiderConstants.PUT_ERROR_LOG, [Utils.generateJSONErrorString(error)]);
341
+ }
342
+ }
322
343
  }, {
323
344
  key: "setCustomAttributeWithString",
324
345
  value: function setCustomAttributeWithString(key, value) {
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="JAVA_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$">
6
- <sourceFolder url="file://$MODULE_DIR$/src/android" isTestSource="false" packagePrefix="com.useinsider.cordova" />
7
- </content>
8
- <orderEntry type="inheritedJdk" />
9
- <orderEntry type="sourceFolder" forTests="false" />
10
- </component>
11
- </module>