e class="language-json">+ }, 44
+          "configurations": {
45
+            "production": {
46
+              "fileReplacements": [
47
+                {
48
+                  "replace": "src/environments/environment.ts",
49
+                  "with": "src/environments/environment.prod.ts"
50
+                }
51
+              ],
52
+              "optimization": true,
53
+              "outputHashing": "all",
54
+              "sourceMap": false,
55
+              "namedChunks": false,
56
+              "aot": true,
57
+              "extractLicenses": true,
58
+              "vendorChunk": false,
59
+              "buildOptimizer": true,
60
+              "budgets": [
61
+                {
62
+                  "type": "initial",
63
+                  "maximumWarning": "2mb",
64
+                  "maximumError": "5mb"
65
+                }
66
+              ]
67
+            },
68
+            "ci": {
69
+              "progress": false
70
+            }
71
+          }
72
+        },
73
+        "serve": {
74
+          "builder": "@angular-devkit/build-angular:dev-server",
75
+          "options": {
76
+            "browserTarget": "app:build"
77
+          },
78
+          "configurations": {
79
+            "production": {
80
+              "browserTarget": "app:build:production"
81
+            },
82
+            "ci": {
83
+              "progress": false
84
+            }
85
+          }
86
+        },
87
+        "extract-i18n": {
88
+          "builder": "@angular-devkit/build-angular:extract-i18n",
89
+          "options": {
90
+            "browserTarget": "app:build"
91
+          }
92
+        },
93
+        "test": {
94
+          "builder": "@angular-devkit/build-angular:karma",
95
+          "options": {
96
+            "main": "src/test.ts",
97
+            "polyfills": "src/polyfills.ts",
98
+            "tsConfig": "tsconfig.spec.json",
99
+            "karmaConfig": "karma.conf.js",
100
+            "styles": [],
101
+            "scripts": [],
102
+            "assets": [
103
+              {
104
+                "glob": "favicon.ico",
105
+                "input": "src/",
106
+                "output": "/"
107
+              },
108
+              {
109
+                "glob": "**/*",
110
+                "input": "src/assets",
111
+                "output": "/assets"
112
+              }
113
+            ]
114
+          },
115
+          "configurations": {
116
+            "ci": {
117
+              "progress": false,
118
+              "watch": false
119
+            }
120
+          }
121
+        },
122
+        "lint": {
123
+          "builder": "@angular-eslint/builder:lint",
124
+          "options": {
125
+            "lintFilePatterns": [
126
+              "src/**/*.ts",
127
+              "src/**/*.html"
128
+            ]
129
+          }
130
+        },
131
+        "e2e": {
132
+          "builder": "@angular-devkit/build-angular:protractor",
133
+          "options": {
134
+            "protractorConfig": "e2e/protractor.conf.js",
135
+            "devServerTarget": "app:serve"
136
+          },
137
+          "configurations": {
138
+            "production": {
139
+              "devServerTarget": "app:serve:production"
140
+            },
141
+            "ci": {
142
+              "devServerTarget": "app:serve:ci"
143
+            }
144
+          }
145
+        },
146
+        "ionic-cordova-build": {
147
+          "builder": "@ionic/angular-toolkit:cordova-build",
148
+          "options": {
149
+            "browserTarget": "app:build"
150
+          },
151
+          "configurations": {
152
+            "production": {
153
+              "browserTarget": "app:build:production"
154
+            }
155
+          }
156
+        },
157
+        "ionic-cordova-serve": {
158
+          "builder": "@ionic/angular-toolkit:cordova-serve",
159
+          "options": {
160
+            "cordovaBuildTarget": "app:ionic-cordova-build",
161
+            "devServerTarget": "app:serve"
162
+          },
163
+          "configurations": {
164
+            "production": {
165
+              "cordovaBuildTarget": "app:ionic-cordova-build:production",
166
+              "devServerTarget": "app:serve:production"
167
+            }
168
+          }
169
+        }
170
+      }
171
+    }
172
+  },
173
+  "cli": {
174
+    "analytics": false,
175
+    "defaultCollection": "@ionic/angular-toolkit"
176
+  },
177
+  "schematics": {
178
+    "@ionic/angular-toolkit:component": {
179
+      "styleext": "scss"
180
+    },
181
+    "@ionic/angular-toolkit:page": {
182
+      "styleext": "scss"
183
+    }
184
+  }
185
+}

+ 107 - 0
config.xml

@@ -0,0 +1,107 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<widget id="net.simplico.farmster" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3
+    <name>FarmSter</name>
4
+    <description>We are the Best Friend of All Farmers</description>
5
+    <author email="patumos@gmail.com" href="https://www.simplico.net">Simplico Team</author>
6
+    <content src="index.html" />
7
+    <access origin="*" />
8
+    <allow-intent href="http://*/*" />
9
+    <allow-intent href="https://*/*" />
10
+    <allow-intent href="tel:*" />
11
+    <allow-intent href="sms:*" />
12
+    <allow-intent href="mailto:*" />
13
+    <allow-intent href="geo:*" />
14
+    <preference name="ScrollEnabled" value="false" />
15
+    <preference name="BackupWebStorage" value="none" />
16
+    <preference name="SplashMaintainAspectRatio" value="true" />
17
+    <preference name="FadeSplashScreenDuration" value="300" />
18
+    <preference name="SplashShowOnlyFirstTime" value="false" />
19
+    <preference name="SplashScreen" value="screen" />
20
+    <preference name="SplashScreenDelay" value="3000" />
21
+    <preference name="android-targetSdkVersion" value="30" />
22
+    <preference name="android-minSdkVersion" value="16" />
23
+    <platform name="android">
24
+        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
25
+            <application android:networkSecurityConfig="@xml/network_security_config" />
26
+        </edit-config>
27
+        <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
28
+        <allow-intent href="market:*" />
29
+        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
30
+        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
31
+        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
32
+        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
33
+        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
34
+        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
35
+        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
36
+        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
37
+        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
38
+        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
39
+        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
40
+        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
41
+        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
42
+        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
43
+        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
44
+        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
45
+        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
46
+        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
47
+    </platform>
48
+    <platform name="ios">
49
+        <allow-intent href="itms:*" />
50
+        <allow-intent href="itms-apps:*" />
51
+        <allow-intent href="tel:*" />
52
+        <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
53
+            <string>Use current location to find nearby businesses</string>
54
+        </edit-config>
55
+        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
56
+        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
57
+        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
58
+        <icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
59
+        <icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
60
+        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
61
+        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
62
+        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
63
+        <icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
64
+        <icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
65
+        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
66
+        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
67
+        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
68
+        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
69
+        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
70
+        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
71
+        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
72
+        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
73
+        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
74
+        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
75
+        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
76
+        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
77
+        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
78
+        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
79
+        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
80
+        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
81
+        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
82
+        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
83
+        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
84
+        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
85
+        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
86
+        <splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
87
+        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
88
+        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
89
+        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
90
+        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
91
+        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
92
+        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
93
+        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
94
+        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
95
+        <splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
96
+        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
97
+        <icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
98
+        <splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
99
+        <splash height="1242" src="resources/ios/splash/Default-Landscape-2688h~iphone.png" width="2688" />
100
+        <splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
101
+        <splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
102
+    </platform>
103
+    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
104
+    <allow-navigation href="http://172.16.112.36:8102" sessionid="56964c11" />
105
+    <allow-navigation href="http://localhost:8101" sessionid="9c146598" />
106
+    <allow-navigation href="http://localhost:8100" sessionid="39e2137c" />
107
+</widget>

+ 37 - 0
e2e/protractor.conf.js

@@ -0,0 +1,37 @@
1
+// @ts-check
2
+// Protractor configuration file, see link for more information
3
+// https://github.com/angular/protractor/blob/master/lib/config.ts
4
+
5
+const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
6
+
7
+/**
8
+ * @type { import("protractor").Config }
9
+ */
10
+exports.config = {
11
+  allScriptsTimeout: 11000,
12
+  specs: [
13
+    './src/**/*.e2e-spec.ts'
14
+  ],
15
+  capabilities: {
16
+    browserName: 'chrome'
17
+  },
18
+  directConnect: true,
19
+  SELENIUM_PROMISE_MANAGER: false,
20
+  baseUrl: 'http://localhost:4200/',
21
+  framework: 'jasmine',
22
+  jasmineNodeOpts: {
23
+    showColors: true,
24
+    defaultTimeoutInterval: 30000,
25
+    print: function() {}
26
+  },
27
+  onPrepare() {
28
+    require('ts-node').register({
29
+      project: require('path').join(__dirname, './tsconfig.json')
30
+    });
31
+    jasmine.getEnv().addReporter(new SpecReporter({
32
+      spec: {
33
+        displayStacktrace: StacktraceOption.PRETTY
34
+      }
35
+    }));
36
+  }
37
+};

+ 14 - 0
e2e/src/app.e2e-spec.ts

@@ -0,0 +1,14 @@
1
+import { AppPage } from './app.po';
2
+
3
+describe('new App', () => {
4
+  let page: AppPage;
5
+
6
+  beforeEach(() => {
7
+    page = new AppPage();
8
+  });
9
+
10
+  it('should display welcome message', () => {
11
+    page.navigateTo();
12
+    expect(page.getPageTitle()).toContain('Tab 1');
13
+  });
14
+});

+ 11 - 0
e2e/src/app.po.ts

@@ -0,0 +1,11 @@
1
+import { browser, by, element } from 'protractor';
2
+
3
+export class AppPage {
4
+  navigateTo() {
5
+    return browser.get('/');
6
+  }
7
+
8
+  getPageTitle() {
9
+    return element(by.css('ion-title')).getText();
10
+  }
11
+}

+ 12 - 0
e2e/tsconfig.json

@@ -0,0 +1,12 @@
1
+{
2
+  "extends": "../tsconfig.json",
3
+  "compilerOptions": {
4
+    "outDir": "../out-tsc/e2e",
5
+    "module": "commonjs",
6
+    "target": "es2018",
7
+    "types": [
8
+      "jasmine",
9
+      "node"
10
+    ]
11
+  }
12
+}

+ 39 - 0
google-services.json

@@ -0,0 +1,39 @@
1
+{
2
+  "project_info": {
3
+    "project_number": "1031089119738",
4
+    "project_id": "farmster-c87c8",
5
+    "storage_bucket": "farmster-c87c8.appspot.com"
6
+  },
7
+  "client": [
8
+    {
9
+      "client_info": {
10
+        "mobilesdk_app_id": "1:1031089119738:android:cf99beb19818a7e4d0c443",
11
+        "android_client_info": {
12
+          "package_name": "net.simplico.farmster"
13
+        }
14
+      },
15
+      "oauth_client": [
16
+        {
17
+          "client_id": "1031089119738-pc9qukqqd30aebdh33q51asvbvn6ndhf.apps.googleusercontent.com",
18
+          "client_type": 3
19
+        }
20
+      ],
21
+      "api_key": [
22
+        {
23
+          "current_key": "AIzaSyCviHmTUdl_TL_pR8catbY-gyibTnooUv0"
24
+        }
25
+      ],
26
+      "services": {
27
+        "appinvite_service": {
28
+          "other_platform_oauth_client": [
29
+            {
30
+              "client_id": "1031089119738-pc9qukqqd30aebdh33q51asvbvn6ndhf.apps.googleusercontent.com",
31
+              "client_type": 3
32
+            }
33
+          ]
34
+        }
35
+      }
36
+    }
37
+  ],
38
+  "configuration_version": "1"
39
+}

+ 7 - 0
ionic.config.json

@@ -0,0 +1,7 @@
1
+{
2
+  "name": "hp",
3
+  "integrations": {
4
+    "cordova": {}
5
+  },
6
+  "type": "angular"
7
+}

+ 44 - 0
karma.conf.js

@@ -0,0 +1,44 @@
1
+// Karma configuration file, see link for more information
2
+// https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+module.exports = function (config) {
5
+  config.set({
6
+    basePath: '',
7
+    frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+    plugins: [
9
+      require('karma-jasmine'),
10
+      require('karma-chrome-launcher'),
11
+      require('karma-jasmine-html-reporter'),
12
+      require('karma-coverage'),
13
+      require('@angular-devkit/build-angular/plugins/karma')
14
+    ],
15
+    client: {
16
+      jasmine: {
17
+        // you can add configuration options for Jasmine here
18
+        // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+        // for example, you can disable the random execution with `random: false`
20
+        // or set a specific seed with `seed: 4321`
21
+      },
22
+      clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+    },
24
+    jasmineHtmlReporter: {
25
+      suppressAll: true // removes the duplicated traces
26
+    },
27
+    coverageReporter: {
28
+      dir: require('path').join(__dirname, './coverage/ngv'),
29
+      subdir: '.',
30
+      reporters: [
31
+        { type: 'html' },
32
+        { type: 'text-summary' }
33
+      ]
34
+    },
35
+    reporters: ['progress', 'kjhtml'],
36
+    port: 9876,
37
+    colors: true,
38
+    logLevel: config.LOG_INFO,
39
+    autoWatch: true,
40
+    browsers: ['Chrome'],
41
+    singleRun: false,
42
+    restartOnFileChange: true
43
+  });
44
+};

BIN
my-release-key.keystore


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 18344 - 0
package-lock.json


+ 180 - 0
package.json

@@ -0,0 +1,180 @@
1
+{
2
+  "name": "hp",
3
+  "version": "0.0.1",
4
+  "author": "Ionic Framework",
5
+  "homepage": "https://ionicframework.com/",
6
+  "scripts": {
7
+    "ng": "ng",
8
+    "start": "ng serve",
9
+    "build": "ng build",
10
+    "test": "ng test",
11
+    "lint": "ng lint",
12
+    "e2e": "ng e2e"
13
+  },
14
+  "private": true,
15
+  "dependencies": {
16
+    "@angular/common": "~13.0.3",
17
+    "@angular/compiler": "~13.0.3",
18
+    "@angular/core": "~13.0.3",
19
+    "@angular/forms": "~13.0.3",
20
+    "@angular/platform-browser": "~13.0.3",
21
+    "@angular/platform-browser-dynamic": "~13.0.3",
22
+    "@angular/router": "~13.0.3",
23
+    "@awesome-cordova-plugins/barcode-scanner": "^5.37.1",
24
+    "@awesome-cordova-plugins/core": "^5.37.1",
25
+    "@awesome-cordova-plugins/file-transfer": "^5.37.1",
26
+    "@awesome-cordova-plugins/push": "^5.37.1",
27
+    "@awesome-cordova-plugins/status-bar": "^5.37.2",
28
+    "@awesome-cordova-plugins/stripe": "^5.37.1",
29
+    "@capacitor/app": "1.0.6",
30
+    "@capacitor/core": "3.3.2",
31
+    "@capacitor/haptics": "1.1.3",
32
+    "@capacitor/ios": "^3.3.2",
33
+    "@capacitor/keyboard": "1.1.3",
34
+    "@capacitor/status-bar": "1.0.6",
35
+    "@fortawesome/angular-fontawesome": "^0.10.1",
36
+    "@fortawesome/fontawesome-free": "^5.15.4",
37
+    "@fortawesome/fontawesome-svg-core": "^1.2.36",
38
+    "@fortawesome/free-brands-svg-icons": "^5.15.4",
39
+    "@fortawesome/free-regular-svg-icons": "^5.15.4",
40
+    "@fortawesome/free-solid-svg-icons": "^5.15.4",
41
+    "@ionic-native/android-permissions": "^5.30.0",
42
+    "@ionic-native/call-number": "^5.36.0",
43
+    "@ionic-native/core": "^5.36.0",
44
+    "@ionic-native/device": "^5.30.0",
45
+    "@ionic-native/email-composer": "^5.36.0",
46
+    "@ionic-native/facebook": "^5.36.0",
47
+    "@ionic-native/geolocation": "^5.36.0",
48
+    "@ionic-native/http": "^5.36.0",
49
+    "@ionic-native/in-app-browser": "^5.36.0",
50
+    "@ionic-native/native-geocoder": "^5.36.0",
51
+    "@ionic-native/paypal": "^5.30.0",
52
+    "@ionic-native/push": "^5.36.0",
53
+    "@ionic-native/sign-in-with-apple": "^5.36.0",
54
+    "@ionic-native/uid": "^5.30.0",
55
+    "@ionic/angular": "^5.9.1",
56
+    "@ionic/storage": "^3.0.6",
57
+    "@ionic/storage-angular": "^3.0.6",
58
+    "abbrev": "^1.1.1",
59
+    "cordova-plugin-device": "2.0.3",
60
+    "cordova-plugin-ionic-webview": "5.0.0",
61
+    "cordova-plugin-splashscreen": "6.0.0",
62
+    "cordova-plugin-whitelist": "1.3.5",
63
+    "ionic-img-viewer": "^2.9.0",
64
+    "lru-cache": "^6.0.0",
65
+    "mimic-fn": "^4.0.0",
66
+    "onetime": "^6.0.0",
67
+    "osenv": "^0.1.5",
68
+    "resolve-url": "^0.2.1",
69
+    "rxjs": "~7.4.0",
70
+    "sharp": "^0.29.3",
71
+    "string.prototype.codepointat": "^1.0.0",
72
+    "tslib": "^2.3.1",
73
+    "yallist": "^4.0.0",
74
+    "zone.js": "~0.11.4"
75
+  },
76
+  "devDependencies": {
77
+    "@angular-devkit/build-angular": "~13.0.4",
78
+    "@angular-eslint/builder": "~13.0.1",
79
+    "@angular-eslint/eslint-plugin": "~13.0.1",
80
+    "@angular-eslint/eslint-plugin-template": "~13.0.1",
81
+    "@angular-eslint/template-parser": "~13.0.1",
82
+    "@angular/cli": "^13.0.4",
83
+    "@angular/compiler": "~13.0.3",
84
+    "@angular/compiler-cli": "~13.0.3",
85
+    "@angular/language-service": "~13.0.3",
86
+    "@capacitor/cli": "3.3.2",
87
+    "@ionic/angular-toolkit": "^5.0.3",
88
+    "@types/jasmine": "~3.10.2",
89
+    "@types/jasminewd2": "~2.0.10",
90
+    "@types/node": "^16.11.11",
91
+    "@typescript-eslint/eslint-plugin": "4.16.1",
92
+    "@typescript-eslint/parser": "4.16.1",
93
+    "call-number": "^1.0.1",
94
+    "card.io.cordova.mobilesdk": "^2.1.0",
95
+    "com.paypal.cordova.mobilesdk": "^3.5.0",
96
+    "cordova-android": "^9.1.0",
97
+    "cordova-ios": "^6.2.0",
98
+    "cordova-plugin-add-swift-support": "^2.0.2",
99
+    "cordova-plugin-advanced-http": "^3.2.2",
100
+    "cordova-plugin-android-permissions": "^1.1.2",
101
+    "cordova-plugin-androidx": "^3.0.0",
102
+    "cordova-plugin-androidx-adapter": "^1.1.3",
103
+    "cordova-plugin-email-composer": "^0.10.0",
104
+    "cordova-plugin-facebook-connect": "^3.2.0",
105
+    "cordova-plugin-file": "^6.0.2",
106
+    "cordova-plugin-file-transfer": "^1.7.1",
107
+    "cordova-plugin-geolocation": "^4.1.0",
108
+    "cordova-plugin-googlemaps": "^2.7.1",
109
+    "cordova-plugin-googlemaps-sdk": "github:mapsplugin/cordova-plugin-googlemaps-sdk",
110
+    "cordova-plugin-inappbrowser": "^5.0.0",
111
+    "cordova-plugin-ionic-keyboard": "^2.2.0",
112
+    "cordova-plugin-nativegeocoder": "^3.4.1",
113
+    "cordova-plugin-sign-in-with-apple": "^0.1.2",
114
+    "cordova-plugin-stripe": "^1.5.3",
115
+    "cordova-plugin-uid": "^1.3.0",
116
+    "cordova-support-google-services": "^1.4.1",
117
+    "eslint": "^8.3.0",
118
+    "eslint-plugin-import": "2.25.3",
119
+    "eslint-plugin-jsdoc": "37.1.0",
120
+    "eslint-plugin-prefer-arrow": "1.2.3",
121
+    "jasmine-core": "~3.10.1",
122
+    "jasmine-spec-reporter": "~7.0.0",
123
+    "karma": "~6.3.9",
124
+    "karma-chrome-launcher": "~3.1.0",
125
+    "karma-coverage": "~2.1.0",
126
+    "karma-coverage-istanbul-reporter": "~3.0.3",
127
+    "karma-jasmine": "~4.0.1",
128
+    "karma-jasmine-html-reporter": "^1.7.0",
129
+    "mx.ferreyra.callnumber": "0.0.2",
130
+    "phonegap-plugin-multidex": "^1.0.0",
131
+    "phonegap-plugin-push": "^2.3.0",
132
+    "protractor": "~7.0.0",
133
+    "ts-node": "~10.4.0",
134
+    "typescript": "~4.2.4"
135
+  },
136
+  "description": "An Ionic project",
137
+  "cordova": {
138
+    "plugins": {
139
+      "cordova-plugin-ionic-keyboard": {},
140
+      "cordova-plugin-geolocation": {},
141
+      "cordova-plugin-nativegeocoder": {
142
+        "LOCATION_WHEN_IN_USE_DESCRIPTION": "Use geocoder service"
143
+      },
144
+      "mx.ferreyra.callnumber": {},
145
+      "cordova-plugin-email-composer": {},
146
+      "call-number": {},
147
+      "cordova-plugin-inappbrowser": {},
148
+      "cordova-plugin-sign-in-with-apple": {},
149
+      "cordova-plugin-androidx": {},
150
+      "cordova-plugin-androidx-adapter": {},
151
+      "phonegap-plugin-push": {},
152
+      "cordova-plugin-file-transfer": {},
153
+      "cordova-plugin-stripe": {},
154
+      "com.paypal.cordova.mobilesdk": {},
155
+      "cordova-plugin-whitelist": {},
156
+      "cordova-plugin-device": {},
157
+      "cordova-plugin-splashscreen": {},
158
+      "cordova-plugin-ionic-webview": {},
159
+      "cordova-plugin-facebook-connect": {
160
+        "APP_ID": "4746807965342529",
161
+        "APP_NAME": "FarmSter",
162
+        "FACEBOOK_URL_SCHEME_SUFFIX": " ",
163
+        "OTHER_APP_SCHEMES": " ",
164
+        "FACEBOOK_AUTO_LOG_APP_EVENTS": "true",
165
+        "FACEBOOK_HYBRID_APP_EVENTS": "false",
166
+        "FACEBOOK_ADVERTISER_ID_COLLECTION": "true",
167
+        "FACEBOOK_ANDROID_SDK_VERSION": "11.3.0",
168
+        "FACEBOOK_IOS_SDK_VERSION": "11.1.0",
169
+        "FACEBOOK_BROWSER_SDK_VERSION": "v11.0"
170
+      },
171
+      "cordova-plugin-statusbar": {},
172
+      "cordova-plugin-android-permissions": {},
173
+      "cordova-plugin-dreamover-uid": {}
174
+    },
175
+    "platforms": [
176
+      "ios",
177
+      "android"
178
+    ]
179
+  }
180
+}

+ 8 - 0
resources/README.md

@@ -0,0 +1,8 @@
1
+These are Cordova resources. You can replace icon.png and splash.png and run
2
+`ionic cordova resources` to generate custom icons and splash screens for your
3
+app. See `ionic cordova resources --help` for details.
4
+
5
+Cordova reference documentation:
6
+
7
+- Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html
8
+- Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/

BIN
resources/android/icon/drawable-hdpi-icon.png


BIN
resources/android/icon/drawable-ldpi-icon.png


BIN
resources/android/icon/drawable-mdpi-icon.png


BIN
resources/android/icon/drawable-xhdpi-icon.png


BIN
resources/android/icon/drawable-xxhdpi-icon.png


BIN
resources/android/icon/drawable-xxxhdpi-icon.png


BIN
resources/android/splash/drawable-land-hdpi-screen.png


BIN
resources/android/splash/drawable-land-ldpi-screen.png


BIN
resources/android/splash/drawable-land-mdpi-screen.png


BIN
resources/android/splash/drawable-land-xhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxxhdpi-screen.png


BIN
resources/android/splash/drawable-port-hdpi-screen.png


BIN
resources/android/splash/drawable-port-ldpi-screen.png


BIN
resources/android/splash/drawable-port-mdpi-screen.png


BIN
resources/android/splash/drawable-port-xhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxxhdpi-screen.png


+ 7 - 0
resources/android/xml/network_security_config.xml

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<network-security-config>
3
+    <domain-config cleartextTrafficPermitted="true">
4
+        <domain includeSubdomains="true">localhost</domain>
5
+        <domain includeSubdomains="true">tamtime.iamarray.xyz</domain>
6
+    </domain-config>
7
+</network-security-config>

BIN
resources/icon.png


BIN
resources/ios/icon/icon-1024.png


BIN
resources/ios/icon/icon-108@2x.png


BIN
resources/ios/icon/icon-20.png


BIN
resources/ios/icon/icon-20@2x.png


BIN
resources/ios/icon/icon-20@3x.png


BIN
resources/ios/icon/icon-24@2x.png


BIN
resources/ios/icon/icon-27.5@2x.png


BIN
resources/ios/icon/icon-29.png


BIN
resources/ios/icon/icon-29@2x.png


BIN
resources/ios/icon/icon-29@3x.png


BIN
resources/ios/icon/icon-40.png


BIN
resources/ios/icon/icon-40@2x.png


BIN
resources/ios/icon/icon-40@3x.png


BIN
resources/ios/icon/icon-44@2x.png


BIN
resources/ios/icon/icon-50.png


BIN
resources/ios/icon/icon-50@2x.png


BIN
resources/ios/icon/icon-60.png


BIN
resources/ios/icon/icon-60@2x.png


BIN
resources/ios/icon/icon-60@3x.png


BIN
resources/ios/icon/icon-72.png


BIN
resources/ios/icon/icon-72@2x.png


BIN
resources/ios/icon/icon-76.png


BIN
resources/ios/icon/icon-76@2x.png


BIN
resources/ios/icon/icon-83.5@2x.png


BIN
resources/ios/icon/icon-86@2x.png


BIN
resources/ios/icon/icon-98@2x.png


BIN
resources/ios/icon/icon.png


BIN
resources/ios/icon/icon@2x.png


BIN
resources/ios/splash/Default-1792h~iphone.png


BIN
resources/ios/splash/Default-2436h.png


BIN
resources/ios/splash/Default-2688h~iphone.png


BIN
resources/ios/splash/Default-568h@2x~iphone.png


BIN
resources/ios/splash/Default-667h.png


BIN
resources/ios/splash/Default-736h.png


BIN
resources/ios/splash/Default-Landscape-1792h~iphone.png


BIN
resources/ios/splash/Default-Landscape-2436h.png


BIN
resources/ios/splash/Default-Landscape-2688h~iphone.png


BIN
resources/ios/splash/Default-Landscape-736h.png


BIN
resources/ios/splash/Default-Landscape@2x~ipad.png


BIN
resources/ios/splash/Default-Landscape@~ipadpro.png


BIN
resources/ios/splash/Default-Landscape~ipad.png


BIN
resources/ios/splash/Default-Portrait@2x~ipad.png


BIN
resources/ios/splash/Default-Portrait@~ipadpro.png


BIN
resources/ios/splash/Default-Portrait~ipad.png


BIN
resources/ios/splash/Default@2x~iphone.png


BIN
resources/ios/splash/Default@2x~universal~anyany.png


BIN
resources/ios/splash/Default~iphone.png


BIN
resources/splash.png


+ 92 - 0
src/app/app-routing.module.ts

@@ -0,0 +1,92 @@
1
+import { NgModule } from '@angular/core';
2
+import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
3
+
4
+const routes: Routes = [
5
+  {
6
+    path: '',
7
+    loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
8
+  },
9
+  {
10
+    path: 'home',
11
+    loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)
12
+  },
13
+  {
14
+    path: 'register',
15
+    loadChildren: () => import('./register/register.module').then( m => m.RegisterPageModule)
16
+  },
17
+  {
18
+    path: 'login',
19
+    loadChildren: () => import('./login/login.module').then( m => m.LoginPageModule)
20
+  },
21
+  {
22
+    path: 'forgot-password',
23
+    loadChildren: () => import('./forgot-password/forgot-password.module').then( m => m.ForgotPasswordPageModule)
24
+  },
25
+  {
26
+    path: 'register-form',
27
+    loadChildren: () => import('./register-form/register-form.module').then( m => m.RegisterFormPageModule)
28
+  },
29
+  {
30
+    path: 'profile',
31
+    loadChildren: () => import('./profile/profile.module').then( m => m.ProfilePageModule)
32
+  },
33
+  {
34
+    path: 'reset-password',
35
+    loadChildren: () => import('./reset-password/reset-password.module').then( m => m.ResetPasswordPageModule)
36
+  },
37
+  {
38
+    path: 'placedetail',
39
+    loadChildren: () => import('./placedetail/placedetail.module').then( m => m.PlacedetailPageModule)
40
+  },
41
+  {
42
+    path: 'place',
43
+    loadChildren: () => import('./place/place.module').then( m => m.PlacePageModule)
44
+  },
45
+  {
46
+    path: 'province',
47
+    loadChildren: () => import('./province/province.module').then( m => m.ProvincePageModule)
48
+  },
49
+  {
50
+    path: 'gmap',
51
+    loadChildren: () => import('./gmap/gmap.module').then( m => m.GmapPageModule)
52
+  },
53
+  {
54
+    path: 'nearme',
55
+    loadChildren: () => import('./nearme/nearme.module').then( m => m.NearmePageModule)
56
+  },
57
+  {
58
+    path: 'sample',
59
+    loadChildren: () => import('./sample/sample.module').then( m => m.SamplePageModule)
60
+  },
61
+  {
62
+    path: 'product',
63
+    loadChildren: () => import('./product/product.module').then( m => m.ProductPageModule)
64
+  },
65
+  {
66
+    path: 'product-detail',
67
+    loadChildren: () => import('./product-detail/product-detail.module').then( m => m.ProductDetailPageModule)
68
+  },
69
+  {
70
+    path: 'tracking',
71
+    loadChildren: () => import('./tracking/tracking.module').then( m => m.TrackingPageModule)
72
+  },
73
+  {
74
+    path: 'news',
75
+    loadChildren: () => import('./news/news.module').then( m => m.NewsPageModule)
76
+  },
77
+  {
78
+    path: 'checkout',
79
+    loadChildren: () => import('./checkout/checkout.module').then( m => m.CheckoutPageModule)
80
+  },
81
+  {
82
+    path: 'pay',
83
+    loadChildren: () => import('./pay/pay.module').then( m => m.PayPageModule)
84
+  }
85
+];
86
+@NgModule({
87
+  imports: [
88
+    RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
89
+  ],
90
+  exports: [RouterModule]
91
+})
92
+export class AppRoutingModule {}

+ 3 - 0
src/app/app.component.html

@@ -0,0 +1,3 @@
1
+<ion-app>
2
+  <ion-router-outlet></ion-router-outlet>
3
+</ion-app>

+ 4 - 0
src/app/app.component.scss

@@ -0,0 +1,4 @@
1
+.product-title {
2
+    font-weight:bold;
3
+    font-size:20px;
4
+}

+ 23 - 0
src/app/app.component.spec.ts

@@ -0,0 +1,23 @@
1
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2
+import { TestBed, waitForAsync } from '@angular/core/testing';
3
+
4
+import { AppComponent } from './app.component';
5
+
6
+describe('AppComponent', () => {
7
+
8
+  beforeEach(waitForAsync(() => {
9
+
10
+    TestBed.configureTestingModule({
11
+      declarations: [AppComponent],
12
+      schemas: [CUSTOM_ELEMENTS_SCHEMA],
13
+    }).compileComponents();
14
+  }));
15
+
16
+  it('should create the app', () => {
17
+    const fixture = TestBed.createComponent(AppComponent);
18
+    const app = fixture.debugElement.componentInstance;
19
+    expect(app).toBeTruthy();
20
+  });
21
+  // TODO: add more tests!
22
+
23
+});

+ 52 - 0
src/app/app.component.ts

@@ -0,0 +1,52 @@
1
+import { Component } from '@angular/core';
2
+import { Storage } from '@ionic/storage-angular';
3
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
4
+import { Uid } from '@ionic-native/uid/ngx';
5
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
6
+
7
+
8
+@Component({
9
+  selector: 'app-root',
10
+  templateUrl: 'app.component.html',
11
+  styleUrls: ['app.component.scss'],
12
+})
13
+export class AppComponent {
14
+    constructor(private storage: Storage, private statusBar:StatusBar, private uid: Uid, private androidPermissions: AndroidPermissions) {
15
+
16
+        this.statusBar.overlaysWebView(true);
17
+
18
+
19
+    }
20
+    openQRCode() {
21
+        console.log("open QR Code");
22
+    }
23
+    async ngOnInit() {
24
+        // If using a custom driver:
25
+        // await this.storage.defineDriver(MyCustomDriver)
26
+        await this.storage.create();
27
+        //await this.getImei();
28
+    }
29
+    async getImei() {
30
+        const { hasPermission } = await this.androidPermissions.checkPermission(
31
+            this.androidPermissions.PERMISSION.READ_PHONE_STATE
32
+        );
33
+        console.log(hasPermission);
34
+
35
+        if (!hasPermission) {
36
+            const result = await this.androidPermissions.requestPermission(
37
+                this.androidPermissions.PERMISSION.READ_PHONE_STATE
38
+            );
39
+
40
+            if (!result.hasPermission) {
41
+                throw new Error('Permissions required');
42
+            }
43
+
44
+            // ok, a user gave us permission, we can get him identifiers after restart app
45
+            return;
46
+        }
47
+        console.log("UUID");
48
+        console.log(this.uid.UUID);
49
+        await this.storage.set('uid', this.uid.UUID);
50
+        return this.uid.IMEI
51
+    }
52
+}

+ 77 - 0
src/app/app.module.ts

@@ -0,0 +1,77 @@
1
+import { NgModule } from '@angular/core';
2
+import { BrowserModule } from '@angular/platform-browser';
3
+import { RouteReuseStrategy } from '@angular/router';
4
+
5
+import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
6
+
7
+import { AppRoutingModule } from './app-routing.module';
8
+import { AppComponent } from './app.component';
9
+
10
+import { HttpClientModule, HttpClient} from '@angular/common/http';
11
+
12
+// import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
13
+// import { library } from '@fortawesome/fontawesome-svg-core';
14
+import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
15
+import { fas } from '@fortawesome/free-solid-svg-icons';
16
+import { far } from '@fortawesome/free-regular-svg-icons';
17
+import { fab } from '@fortawesome/free-brands-svg-icons';
18
+
19
+import { Geolocation } from '@ionic-native/geolocation/ngx';
20
+import { NativeGeocoder } from '@ionic-native/native-geocoder/ngx';
21
+
22
+import { CallNumber } from '@ionic-native/call-number/ngx';
23
+import { EmailComposer } from '@ionic-native/email-composer/ngx';
24
+import { HTTP } from '@ionic-native/http/ngx';
25
+import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
26
+
27
+import { IonicStorageModule } from '@ionic/storage-angular';
28
+import { SignInWithApple } from '@ionic-native/sign-in-with-apple/ngx';
29
+
30
+import { PipeModule } from './pipe/pipe.module';
31
+import { Facebook } from '@ionic-native/facebook/ngx';
32
+
33
+import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
34
+import { PayPal } from '@ionic-native/paypal/ngx';
35
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
36
+import { Uid } from '@ionic-native/uid/ngx';
37
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
38
+import { Device } from '@ionic-native/device/ngx';
39
+
40
+//import { Stripe } from '@awesome-cordova-plugins/stripe/ngx';
41
+
42
+
43
+// import { IonicImageViewerModule } from 'ionic-img-viewer';
44
+
45
+
46
+// library.add(fas,far,fab);
47
+
48
+@NgModule({
49
+    declarations: [AppComponent],
50
+    entryComponents: [],
51
+    imports: [HttpClientModule, BrowserModule, PipeModule,IonicModule.forRoot({_forceStatusbarPadding: true}), AppRoutingModule, FontAwesomeModule,   IonicStorageModule.forRoot()],
52
+    providers: [
53
+        Geolocation,
54
+        NativeGeocoder,
55
+        CallNumber,
56
+        EmailComposer,
57
+        InAppBrowser,
58
+        HTTP,
59
+        Facebook, 
60
+        StatusBar,
61
+        BarcodeScanner,
62
+        SignInWithApple,
63
+        PayPal,
64
+        AndroidPermissions,
65
+        Uid,
66
+        Device,
67
+        //Stripe,
68
+        { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
69
+    ],
70
+    bootstrap: [AppComponent],
71
+})
72
+export class AppModule {
73
+    constructor(library: FaIconLibrary) {
74
+        library.addIconPacks(fas, fab, far);
75
+    }
76
+
77
+}

+ 17 - 0
src/app/checkout/checkout-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { CheckoutPage } from './checkout.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: CheckoutPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class CheckoutPageRoutingModule {}

+ 20 - 0
src/app/checkout/checkout.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { CheckoutPageRoutingModule } from './checkout-routing.module';
8
+
9
+import { CheckoutPage } from './checkout.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    CheckoutPageRoutingModule
17
+  ],
18
+  declarations: [CheckoutPage]
19
+})
20
+export class CheckoutPageModule {}

+ 0 - 0
src/app/checkout/checkout.page.html


Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels

tum/whitesports - Gogs: Simplico Git Service

Нема описа

class-wc-rest-authentication.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <?php
  2. /**
  3. * REST API Authentication
  4. *
  5. * @package WooCommerce\RestApi
  6. * @since 2.6.0
  7. */
  8. defined( 'ABSPATH' ) || exit;
  9. /**
  10. * REST API authentication class.
  11. */
  12. class WC_REST_Authentication {
  13. /**
  14. * Authentication error.
  15. *
  16. * @var WP_Error
  17. */
  18. protected $error = null;
  19. /**
  20. * Logged in user data.
  21. *
  22. * @var stdClass
  23. */
  24. protected $user = null;
  25. /**
  26. * Current auth method.
  27. *
  28. * @var string
  29. */
  30. protected $auth_method = '';
  31. /**
  32. * Initialize authentication actions.
  33. */
  34. public function __construct() {
  35. add_filter( 'determine_current_user', array( $this, 'authenticate' ), 15 );
  36. add_filter( 'rest_authentication_errors', array( $this, 'authentication_fallback' ) );
  37. add_filter( 'rest_authentication_errors', array( $this, 'check_authentication_error' ), 15 );
  38. add_filter( 'rest_post_dispatch', array( $this, 'send_unauthorized_headers' ), 50 );
  39. add_filter( 'rest_pre_dispatch', array( $this, 'check_user_permissions' ), 10, 3 );
  40. }
  41. /**
  42. * Check if is request to our REST API.
  43. *
  44. * @return bool
  45. */
  46. protected function is_request_to_rest_api() {
  47. if ( empty( $_SERVER['REQUEST_URI'] ) ) {
  48. return false;
  49. }
  50. $rest_prefix = trailingslashit( rest_get_url_prefix() );
  51. $request_uri = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
  52. // Check if the request is to the WC API endpoints.
  53. $woocommerce = ( false !== strpos( $request_uri, $rest_prefix . 'wc/' ) );
  54. // Allow third party plugins use our authentication methods.
  55. $third_party = ( false !== strpos( $request_uri, $rest_prefix . 'wc-' ) );
  56. return apply_filters( 'woocommerce_rest_is_request_to_rest_api', $woocommerce || $third_party );
  57. }
  58. /**
  59. * Authenticate user.
  60. *
  61. * @param int|false $user_id User ID if one has been determined, false otherwise.
  62. * @return int|false
  63. */
  64. public function authenticate( $user_id ) {
  65. // Do not authenticate twice and check if is a request to our endpoint in the WP REST API.
  66. if ( ! empty( $user_id ) || ! $this->is_request_to_rest_api() ) {
  67. return $user_id;
  68. }
  69. if ( is_ssl() ) {
  70. $user_id = $this->perform_basic_authentication();
  71. }
  72. if ( $user_id ) {
  73. return $user_id;
  74. }
  75. return $this->perform_oauth_authentication();
  76. }
  77. /**
  78. * Authenticate the user if authentication wasn't performed during the
  79. * determine_current_user action.
  80. *
  81. * Necessary in cases where wp_get_current_user() is called before WooCommerce is loaded.
  82. *
  83. * @see https://github.com/woocommerce/woocommerce/issues/26847
  84. *
  85. * @param WP_Error|null|bool $error Error data.
  86. * @return WP_Error|null|bool
  87. */
  88. public function authentication_fallback( $error ) {
  89. if ( ! empty( $error ) ) {
  90. // Another plugin has already declared a failure.
  91. return $error;
  92. }
  93. if ( empty( $this->error ) && empty( $this->auth_method ) && empty( $this->user ) && 0 === get_current_user_id() ) {
  94. // Authentication hasn't occurred during `determine_current_user`, so check auth.
  95. $user_id = $this->authenticate( false );
  96. if ( $user_id ) {
  97. wp_set_current_user( $user_id );
  98. return true;
  99. }
  100. }
  101. return $error;
  102. }
  103. /**
  104. * Check for authentication error.
  105. *
  106. * @param WP_Error|null|bool $error Error data.
  107. * @return WP_Error|null|bool
  108. */
  109. public function check_authentication_error( $error ) {
  110. // Pass through other errors.
  111. if ( ! empty( $error ) ) {
  112. return $error;
  113. }
  114. return $this->get_error();
  115. }
  116. /**
  117. * Set authentication error.
  118. *
  119. * @param WP_Error $error Authentication error data.
  120. */
  121. protected function set_error( $error ) {
  122. // Reset user.
  123. $this->user = null;
  124. $this->error = $error;
  125. }
  126. /**
  127. * Get authentication error.
  128. *
  129. * @return WP_Error|null.
  130. */
  131. protected function get_error() {
  132. return $this->error;
  133. }
  134. /**
  135. * Basic Authentication.
  136. *
  137. * SSL-encrypted requests are not subject to sniffing or man-in-the-middle
  138. * attacks, so the request can be authenticated by simply looking up the user
  139. * associated with the given consumer key and confirming the consumer secret
  140. * provided is valid.
  141. *
  142. * @return int|bool
  143. */
  144. private function perform_basic_authentication() {
  145. $this->auth_method = 'basic_auth';
  146. $consumer_key = '';
  147. $consumer_secret = '';
  148. // If the $_GET parameters are present, use those first.
  149. if ( ! empty( $_GET['consumer_key'] ) && ! empty( $_GET['consumer_secret'] ) ) { // WPCS: CSRF ok.
  150. $consumer_key = $_GET['consumer_key']; // WPCS: CSRF ok, sanitization ok.
  151. $consumer_secret = $_GET['consumer_secret']; // WPCS: CSRF ok, sanitization ok.
  152. }
  153. // If the above is not present, we will do full basic auth.
  154. if ( ! $consumer_key && ! empty( $_SERVER['PHP_AUTH_USER'] ) && ! empty( $_SERVER['PHP_AUTH_PW'] ) ) {
  155. $consumer_key = $_SERVER['PHP_AUTH_USER']; // WPCS: CSRF ok, sanitization ok.
  156. $consumer_secret = $_SERVER['PHP_AUTH_PW']; // WPCS: CSRF ok, sanitization ok.
  157. }
  158. // Stop if don't have any key.
  159. if ( ! $consumer_key || ! $consumer_secret ) {
  160. return false;
  161. }
  162. // Get user data.
  163. $this->user = $this->get_user_data_by_consumer_key( $consumer_key );
  164. if ( empty( $this->user ) ) {
  165. return false;
  166. }
  167. // Validate user secret.
  168. if ( ! hash_equals( $this->user->consumer_secret, $consumer_secret ) ) { // @codingStandardsIgnoreLine
  169. $this->set_error( new WP_Error( 'woocommerce_rest_authentication_error', __( 'Consumer secret is invalid.', 'woocommerce' ), array( 'status' => 401 ) ) );
  170. return false;
  171. }
  172. return $this->user->user_id;
  173. }
  174. /**
  175. * Parse the Authorization header into parameters.
  176. *
  177. * @since 3.0.0
  178. *
  179. * @param string $header Authorization header value (not including "Authorization: " prefix).
  180. *
  181. * @return array Map of parameter values.
  182. */
  183. public function parse_header( $header ) {
  184. if ( 'OAuth ' !== substr( $header, 0, 6 ) ) {
  185. return array();
  186. }
  187. // From OAuth PHP library, used under MIT license.
  188. $params = array();
  189. if ( preg_match_all( '/(oauth_[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches ) ) {
  190. foreach ( $matches[1] as $i => $h ) {
  191. $params[ $h ] = urldecode( empty( $matches[3][ $i ] ) ? $matches[4][ $i ] : $matches[3][ $i ] );
  192. }
  193. if ( isset( $params['realm'] ) ) {
  194. unset( $params['realm'] );
  195. }
  196. }
  197. return $params;
  198. }
  199. /**
  200. * Get the authorization header.
  201. *
  202. * On certain systems and configurations, the Authorization header will be
  203. * stripped out by the server or PHP. Typically this is then used to
  204. * generate `PHP_AUTH_USER`/`PHP_AUTH_PASS` but not passed on. We use
  205. * `getallheaders` here to try and grab it out instead.
  206. *
  207. * @since 3.0.0
  208. *
  209. * @return string Authorization header if set.
  210. */
  211. public function get_authorization_header() {
  212. if ( ! empty( $_SERVER['HTTP_AUTHORIZATION'] ) ) {
  213. return wp_unslash( $_SERVER['HTTP_AUTHORIZATION'] ); // WPCS: sanitization ok.
  214. }
  215. if ( function_exists( 'getallheaders' ) ) {
  216. $headers = getallheaders();
  217. // Check for the authoization header case-insensitively.
  218. foreach ( $headers as $key => $value ) {
  219. if ( 'authorization' === strtolower( $key ) ) {
  220. return $value;
  221. }
  222. }
  223. }
  224. return '';
  225. }
  226. /**
  227. * Get oAuth parameters from $_GET, $_POST or request header.
  228. *
  229. * @since 3.0.0
  230. *
  231. * @return array|WP_Error
  232. */
  233. public function get_oauth_parameters() {
  234. $params = array_merge( $_GET, $_POST ); // WPCS: CSRF ok.
  235. $params = wp_unslash( $params );
  236. $header = $this->get_authorization_header();
  237. if ( ! empty( $header ) ) {
  238. // Trim leading spaces.
  239. $header = trim( $header );
  240. $header_params = $this->parse_header( $header );
  241. if ( ! empty( $header_params ) ) {
  242. $params = array_merge( $params, $header_params );
  243. }
  244. }
  245. $param_names = array(
  246. 'oauth_consumer_key',
  247. 'oauth_timestamp',
  248. 'oauth_nonce',
  249. 'oauth_signature',
  250. 'oauth_signature_method',
  251. );
  252. $errors = array();
  253. $have_one = false;
  254. // Check for required OAuth parameters.
  255. foreach ( $param_names as $param_name ) {
  256. if ( empty( $params[ $param_name ] ) ) {
  257. $errors[] = $param_name;
  258. } else {
  259. $have_one = true;
  260. }
  261. }
  262. // All keys are missing, so we're probably not even trying to use OAuth.
  263. if ( ! $have_one ) {
  264. return array();
  265. }
  266. // If we have at least one supplied piece of data, and we have an error,
  267. // then it's a failed authentication.
  268. if ( ! empty( $errors ) ) {
  269. $message = sprintf(
  270. /* translators: %s: amount of errors */
  271. _n( 'Missing OAuth parameter %s', 'Missing OAuth parameters %s', count( $errors ), 'woocommerce' ),
  272. implode( ', ', $errors )
  273. );
  274. $this->set_error( new WP_Error( 'woocommerce_rest_authentication_missing_parameter', $message, array( 'status' => 401 ) ) );
  275. return array();
  276. }
  277. return $params;
  278. }
  279. /**
  280. * Perform OAuth 1.0a "one-legged" (http://oauthbible.com/#oauth-10a-one-legged) authentication for non-SSL requests.
  281. *
  282. * This is required so API credentials cannot be sniffed or intercepted when making API requests over plain HTTP.
  283. *
  284. * This follows the spec for simple OAuth 1.0a authentication (RFC 5849) as closely as possible, with two exceptions:
  285. *
  286. * 1) There is no token associated with request/responses, only consumer keys/secrets are used.
  287. *
  288. * 2) The OAuth parameters are included as part of the request query string instead of part of the Authorization header,
  289. * This is because there is no cross-OS function within PHP to get the raw Authorization header.
  290. *
  291. * @link http://tools.ietf.org/html/rfc5849 for the full spec.
  292. *
  293. * @return int|bool
  294. */
  295. private function perform_oauth_authentication() {
  296. $this->auth_method = 'oauth1';
  297. $params = $this->get_oauth_parameters();
  298. if ( empty( $params ) ) {
  299. return false;
  300. }
  301. // Fetch WP user by consumer key.
  302. $this->user = $this->get_user_data_by_consumer_key( $params['oauth_consumer_key'] );
  303. if ( empty( $this->user ) ) {
  304. $this->set_error( new WP_Error( 'woocommerce_rest_authentication_error', __( 'Consumer key is invalid.', 'woocommerce' ), array( 'status' => 401 ) ) );
  305. return false;
  306. }
  307. // Perform OAuth validation.
  308. $signature = $this->check_oauth_signature( $this->user, $params );
  309. if ( is_wp_error( $signature ) ) {
  310. $this->set_error( $signature );
  311. return false;
  312. }
  313. $timestamp_and_nonce = $this->check_oauth_timestamp_and_nonce( $this->user, $params['oauth_timestamp'], $params['oauth_nonce'] );
  314. if ( is_wp_error( $timestamp_and_nonce ) ) {
  315. $this->set_error( $timestamp_and_nonce );
  316. return false;
  317. }
  318. return $this->user->user_id;
  319. }
  320. /**
  321. * Verify that the consumer-provided request signature matches our generated signature,
  322. * this ensures the consumer has a valid key/secret.
  323. *
  324. * @param stdClass $user User data.
  325. * @param array $params The request parameters.
  326. * @return true|WP_Error
  327. */
  328. private function check_oauth_signature( $user, $params ) {
  329. $http_method = isset( $_SERVER['REQUEST_METHOD'] ) ? strtoupper( $_SERVER['REQUEST_METHOD'] ) : ''; // WPCS: sanitization ok.
  330. $request_path = isset( $_SERVER['REQUEST_URI'] ) ? wp_parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) : ''; // WPCS: sanitization ok.
  331. $wp_base = get_home_url( null, '/', 'relative' );
  332. if ( substr( $request_path, 0, strlen( $wp_base ) ) === $wp_base ) {
  333. $request_path = substr( $request_path, strlen( $wp_base ) );
  334. }
  335. $base_request_uri = rawurlencode( get_home_url( null, $request_path, is_ssl() ? 'https' : 'http' ) );
  336. // Get the signature provided by the consumer and remove it from the parameters prior to checking the signature.
  337. $consumer_signature = rawurldecode( str_replace( ' ', '+', $params['oauth_signature'] ) );
  338. unset( $params['oauth_signature'] );
  339. // Sort parameters.
  340. if ( ! uksort( $params, 'strcmp' ) ) {
  341. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid signature - failed to sort parameters.', 'woocommerce' ), array( 'status' => 401 ) );
  342. }
  343. // Normalize parameter key/values.
  344. $params = $this->normalize_parameters( $params );
  345. $query_string = implode( '%26', $this->join_with_equals_sign( $params ) ); // Join with ampersand.
  346. $string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string;
  347. if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) {
  348. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid signature - signature method is invalid.', 'woocommerce' ), array( 'status' => 401 ) );
  349. }
  350. $hash_algorithm = strtolower( str_replace( 'HMAC-', '', $params['oauth_signature_method'] ) );
  351. $secret = $user->consumer_secret . '&';
  352. $signature = base64_encode( hash_hmac( $hash_algorithm, $string_to_sign, $secret, true ) );
  353. if ( ! hash_equals( $signature, $consumer_signature ) ) { // @codingStandardsIgnoreLine
  354. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid signature - provided signature does not match.', 'woocommerce' ), array( 'status' => 401 ) );
  355. }
  356. return true;
  357. }
  358. /**
  359. * Creates an array of urlencoded strings out of each array key/value pairs.
  360. *
  361. * @param array $params Array of parameters to convert.
  362. * @param array $query_params Array to extend.
  363. * @param string $key Optional Array key to append.
  364. * @return string Array of urlencoded strings.
  365. */
  366. private function join_with_equals_sign( $params, $query_params = array(), $key = '' ) {
  367. foreach ( $params as $param_key => $param_value ) {
  368. if ( $key ) {
  369. $param_key = $key . '%5B' . $param_key . '%5D'; // Handle multi-dimensional array.
  370. }
  371. if ( is_array( $param_value ) ) {
  372. $query_params = $this->join_with_equals_sign( $param_value, $query_params, $param_key );
  373. } else {
  374. $string = $param_key . '=' . $param_value; // Join with equals sign.
  375. $query_params[] = wc_rest_urlencode_rfc3986( $string );
  376. }
  377. }
  378. return $query_params;
  379. }
  380. /**
  381. * Normalize each parameter by assuming each parameter may have already been
  382. * encoded, so attempt to decode, and then re-encode according to RFC 3986.
  383. *
  384. * Note both the key and value is normalized so a filter param like:
  385. *
  386. * 'filter[period]' => 'week'
  387. *
  388. * is encoded to:
  389. *
  390. * 'filter%255Bperiod%255D' => 'week'
  391. *
  392. * This conforms to the OAuth 1.0a spec which indicates the entire query string
  393. * should be URL encoded.
  394. *
  395. * @see rawurlencode()
  396. * @param array $parameters Un-normalized parameters.
  397. * @return array Normalized parameters.
  398. */
  399. private function normalize_parameters( $parameters ) {
  400. $keys = wc_rest_urlencode_rfc3986( array_keys( $parameters ) );
  401. $values = wc_rest_urlencode_rfc3986( array_values( $parameters ) );
  402. $parameters = array_combine( $keys, $values );
  403. return $parameters;
  404. }
  405. /**
  406. * Verify that the timestamp and nonce provided with the request are valid. This prevents replay attacks where
  407. * an attacker could attempt to re-send an intercepted request at a later time.
  408. *
  409. * - A timestamp is valid if it is within 15 minutes of now.
  410. * - A nonce is valid if it has not been used within the last 15 minutes.
  411. *
  412. * @param stdClass $user User data.
  413. * @param int $timestamp The unix timestamp for when the request was made.
  414. * @param string $nonce A unique (for the given user) 32 alphanumeric string, consumer-generated.
  415. * @return bool|WP_Error
  416. */
  417. private function check_oauth_timestamp_and_nonce( $user, $timestamp, $nonce ) {
  418. global $wpdb;
  419. $valid_window = 15 * 60; // 15 minute window.
  420. if ( ( $timestamp < time() - $valid_window ) || ( $timestamp > time() + $valid_window ) ) {
  421. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid timestamp.', 'woocommerce' ), array( 'status' => 401 ) );
  422. }
  423. $used_nonces = maybe_unserialize( $user->nonces );
  424. if ( empty( $used_nonces ) ) {
  425. $used_nonces = array();
  426. }
  427. if ( in_array( $nonce, $used_nonces, true ) ) {
  428. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid nonce - nonce has already been used.', 'woocommerce' ), array( 'status' => 401 ) );
  429. }
  430. $used_nonces[ $timestamp ] = $nonce;
  431. // Remove expired nonces.
  432. foreach ( $used_nonces as $nonce_timestamp => $nonce ) {
  433. if ( $nonce_timestamp < ( time() - $valid_window ) ) {
  434. unset( $used_nonces[ $nonce_timestamp ] );
  435. }
  436. }
  437. $used_nonces = maybe_serialize( $used_nonces );
  438. $wpdb->update(
  439. $wpdb->prefix . 'woocommerce_api_keys',
  440. array( 'nonces' => $used_nonces ),
  441. array( 'key_id' => $user->key_id ),
  442. array( '%s' ),
  443. array( '%d' )
  444. );
  445. return true;
  446. }
  447. /**
  448. * Return the user data for the given consumer_key.
  449. *
  450. * @param string $consumer_key Consumer key.
  451. * @return array
  452. */
  453. private function get_user_data_by_consumer_key( $consumer_key ) {
  454. global $wpdb;
  455. $consumer_key = wc_api_hash( sanitize_text_field( $consumer_key ) );
  456. $user = $wpdb->get_row(
  457. $wpdb->prepare(
  458. "
  459. SELECT key_id, user_id, permissions, consumer_key, consumer_secret, nonces
  460. FROM {$wpdb->prefix}woocommerce_api_keys
  461. WHERE consumer_key = %s
  462. ",
  463. $consumer_key
  464. )
  465. );
  466. return $user;
  467. }
  468. /**
  469. * Check that the API keys provided have the proper key-specific permissions to either read or write API resources.
  470. *
  471. * @param string $method Request method.
  472. * @return bool|WP_Error
  473. */
  474. private function check_permissions( $method ) {
  475. $permissions = $this->user->permissions;
  476. switch ( $method ) {
  477. case 'HEAD':
  478. case 'GET':
  479. if ( 'read' !== $permissions && 'read_write' !== $permissions ) {
  480. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'The API key provided does not have read permissions.', 'woocommerce' ), array( 'status' => 401 ) );
  481. }
  482. break;
  483. case 'POST':
  484. case 'PUT':
  485. case 'PATCH':
  486. case 'DELETE':
  487. if ( 'write' !== $permissions && 'read_write' !== $permissions ) {
  488. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'The API key provided does not have write permissions.', 'woocommerce' ), array( 'status' => 401 ) );
  489. }
  490. break;
  491. case 'OPTIONS':
  492. return true;
  493. default:
  494. return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Unknown request method.', 'woocommerce' ), array( 'status' => 401 ) );
  495. }
  496. return true;
  497. }
  498. /**
  499. * Updated API Key last access datetime.
  500. */
  501. private function update_last_access() {
  502. global $wpdb;
  503. $wpdb->update(
  504. $wpdb->prefix . 'woocommerce_api_keys',
  505. array( 'last_access' => current_time( 'mysql' ) ),
  506. array( 'key_id' => $this->user->key_id ),
  507. array( '%s' ),
  508. array( '%d' )
  509. );
  510. }
  511. /**
  512. * If the consumer_key and consumer_secret $_GET parameters are NOT provided
  513. * and the Basic auth headers are either not present or the consumer secret does not match the consumer
  514. * key provided, then return the correct Basic headers and an error message.
  515. *
  516. * @param WP_REST_Response $response Current response being served.
  517. * @return WP_REST_Response
  518. */
  519. public function send_unauthorized_headers( $response ) {
  520. if ( is_wp_error( $this->get_error() ) && 'basic_auth' === $this->auth_method ) {
  521. $auth_message = __( 'WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field.', 'woocommerce' );
  522. $response->header( 'WWW-Authenticate', 'Basic realm="' . $auth_message . '"', true );
  523. }
  524. return $response;
  525. }
  526. /**
  527. * Check for user permissions and register last access.
  528. *
  529. * @param mixed $result Response to replace the requested version with.
  530. * @param WP_REST_Server $server Server instance.
  531. * @param WP_REST_Request $request Request used to generate the response.
  532. * @return mixed
  533. */
  534. public function check_user_permissions( $result, $server, $request ) {
  535. if ( $this->user ) {
  536. // Check API Key permissions.
  537. $allowed = $this->check_permissions( $request->get_method() );
  538. if ( is_wp_error( $allowed ) ) {
  539. return $allowed;
  540. }
  541. // Register last access.
  542. $this->update_last_access();
  543. }
  544. return $result;
  545. }
  546. }
  547. new WC_REST_Authentication();