browser_sniffer 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: beb896967f13a26304b23513f7e2a6e334854afc3187795a7d98698a4b8a2299
4
- data.tar.gz: b3be5e1a5068b56d87685129404b8ed369644af58adbd815c6634a8500a23221
3
+ metadata.gz: d70432df386f9f1f082fe3b9154bc13b3790307c56abebc7edd54e17ef3bd81f
4
+ data.tar.gz: 778785a577de5fa60f975280722d1b3a239971c092cca05d15b8df20c88514dd
5
5
  SHA512:
6
- metadata.gz: b0f851fc4026c1f35e905daf515f68cd4755261fe6c1424825170dcaefa207605bdd825b821f865cecad5bcc4d99394b783f6078c29eb37a41d96ee41ccaff07
7
- data.tar.gz: bad8fe19eb686b1d4e698805a87790cf4e48f4b0654504c5f6d761d2b7cbc97a82746eacade1cbacd210b2459b3e3065f212315b5045bd4bcbe40be09418535f
6
+ metadata.gz: ccac49e1d7632e2bfc3de8e85cabf686edd2fcd8a9515c0ed2882b72ab6b717fc54d10fcca8b717b61692e6737209916406449eff6df0024d41d9b6cd103a7ad
7
+ data.tar.gz: ff81d4cfa552f04e05823e7b69f14a1cb1741d6d59593ebcf492167429873030911fc237edc411df18d39880efc20f3355085545a25d85f47e9983ec54f97cac
@@ -0,0 +1,36 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ push:
7
+ branches: release/v1.5.0
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ name: Ruby ${{ matrix.version }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ version:
17
+ - 2.0
18
+ - 2.1
19
+ - 2.2
20
+ - 2.3
21
+ - 2.4
22
+ - 2.5
23
+ - 2.6
24
+ - 2.7
25
+ - 3.0
26
+ - 3.1
27
+ - jruby
28
+ steps:
29
+ - uses: actions/checkout@v3
30
+ - name: Set up Ruby ${{ matrix.version }}
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ bundler-cache: true
34
+ ruby-version: ${{ matrix.version }}
35
+ - name: Run Tests
36
+ run: bundle exec rake test
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://secure.travis-ci.org/Shopify/browser_sniffer.png?branch=master)](http://travis-ci.org/Shopify/browser_sniffer)
1
+ [![Build Status](https://github.com/Shopify/browser_sniffer/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Shopify/browser_sniffer/actions/workflows/test.yml)
2
2
  [![Gem Version](https://badge.fury.io/rb/browser_sniffer.png)](http://badge.fury.io/rb/browser_sniffer)
3
3
 
4
4
  # BrowserSniffer
@@ -60,8 +60,11 @@ class BrowserSniffer
60
60
  # Shopify POS for Android (Native App)
61
61
  %r{.*(\sPOS\s-).*\s([\d+\.]+)(\/\d*)*\s}i,
62
62
  ], [[:name, 'Shopify POS'], :version], [
63
- # Shopify POS for Android (Native App) New Format
63
+ # Shopify POS for Android (React Native App)
64
64
  %r{(Shopify POS)\/([\d\.]+)[^\/]*\/(Android)\/(\d+)}i,
65
+ ], [[:name, 'Shopify POS'], :version], [
66
+ # Shopify POS for iOS (React Native App)
67
+ %r{(Shopify POS)\/([\d\.]+)[^\/]*\/(iOS)\/([\d\.]+)}i,
65
68
  ], [[:name, 'Shopify POS'], :version], [
66
69
  # Shopify POS for Android (SmartWebView)
67
70
  %r{.*(Shopify\sPOS)\s.*Android.*\s([\d+\.]+)(\/\d*)*\s}i,
@@ -174,6 +177,12 @@ class BrowserSniffer
174
177
  # Shopify POS Next for iPod touch
175
178
  %r{.*(?:Shopify POS Next|Shopify POS)/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPod)([\d,]+)}i
176
179
  ], [[:type, :handheld], :model], [
180
+ # Shopify POS for iOS iPhone/iPod (React Native App)
181
+ %r{.*Shopify POS\/[\d\.]+[^\/]*\/(iOS)\/[\d\.]+\/Apple\/((iPhone|iPod)[^\/]*)\/}i,
182
+ ], [[:type, :handheld], :model], [
183
+ # Shopify POS for iOS iPad (React Native App)
184
+ %r{.*Shopify POS\/[\d\.]+[^\/]*\/(iOS)\/[\d\.]+\/Apple\/(iPad[^\/]*)\/}i,
185
+ ], [[:type, :tablet], :model], [
177
186
  # Shopify Ping for iPhone
178
187
  %r{.*Shopify Ping/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
179
188
  ], [[:type, :handheld], :model], [
@@ -297,6 +306,9 @@ class BrowserSniffer
297
306
  # Shopify POS Next for iPhone or iPad
298
307
  %r{.*(Shopify POS Next|Shopify POS)\/(?:iPhone\sOS|iOS)[\/\d\.]* \((iPhone|iPad|iPod).*\/([\d\.]+)\)}i
299
308
  ], [[:type, :ios], [:name, 'iOS'], :version], [
309
+ # Shopify POS for iOS (React Native App)
310
+ %r{.*Shopify POS\/[\d\.]+[^\/]*\/(iOS)\/([\d\.]+)\/(Apple)\/(iPhone|iPad|iPod)[^\/]*\/}i
311
+ ], [[:type, :ios], :version, [:name, 'iOS']], [
300
312
  # Shopify Ping for iOS
301
313
  %r{.*Shopify Ping\/(iOS)\/[\d\.]+ \(.*\/([\d\.]+)\)}i
302
314
  ], [[:type, :ios], :version, [:name, 'iOS']], [
@@ -1,3 +1,3 @@
1
1
  class BrowserSniffer
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -554,7 +554,7 @@ describe "Shopify agents" do
554
554
  assert_equal sniffer.os_info, sniffer_with_suffix.os_info
555
555
  end
556
556
 
557
- it "Shopify POS on Android can be sniffed (Native App) New Format" do
557
+ it "Shopify POS on Android can be sniffed (React Native App)" do
558
558
  user_agent = "com.jadedpixel.pos Shopify POS/4.23.0/Android/12/google/Pixel 5/production MobileMiddlewareSupported"
559
559
  sniffer = BrowserSniffer.new(user_agent)
560
560
 
@@ -582,6 +582,69 @@ describe "Shopify agents" do
582
582
  assert_equal sniffer.os_info, sniffer_with_suffix.os_info
583
583
  end
584
584
 
585
+ it "Shopify POS on iPhone can be sniffed (React Native App)" do
586
+ user_agent = "com.jadedpixel.pos Shopify POS/7.0.0/iOS/15.4/Apple/iPhone 11/production"
587
+ sniffer = BrowserSniffer.new(user_agent)
588
+
589
+ assert_equal ({
590
+ name: 'Shopify POS',
591
+ version: '7.0.0',
592
+ }), sniffer.browser_info
593
+
594
+ assert_equal ({
595
+ type: :handheld,
596
+ model: 'iPhone 11',
597
+ }), sniffer.device_info
598
+
599
+ assert_equal ({
600
+ type: :ios,
601
+ version: '15.4',
602
+ name: 'iOS',
603
+ }), sniffer.os_info
604
+ end
605
+
606
+ it "Shopify POS on iPad can be sniffed (React Native App)" do
607
+ user_agent = "com.jadedpixel.pos Shopify POS/7.0.0/iOS/15.4/Apple/iPad/production"
608
+ sniffer = BrowserSniffer.new(user_agent)
609
+
610
+ assert_equal ({
611
+ name: 'Shopify POS',
612
+ version: '7.0.0',
613
+ }), sniffer.browser_info
614
+
615
+ assert_equal ({
616
+ type: :tablet,
617
+ model: 'iPad',
618
+ }), sniffer.device_info
619
+
620
+ assert_equal ({
621
+ type: :ios,
622
+ version: '15.4',
623
+ name: 'iOS',
624
+ }), sniffer.os_info
625
+ end
626
+
627
+ it "Shopify POS on iPod Touch can be sniffed (React Native App)" do
628
+ user_agent = "com.jadedpixel.pos Shopify POS/7.0.0/iOS/15.4/Apple/iPod Touch/production"
629
+ sniffer = BrowserSniffer.new(user_agent)
630
+
631
+ assert_equal ({
632
+ name: 'Shopify POS',
633
+ version: '7.0.0',
634
+ }), sniffer.browser_info
635
+
636
+ assert_equal ({
637
+ type: :handheld,
638
+ model: 'iPod Touch',
639
+ }), sniffer.device_info
640
+
641
+ assert_equal ({
642
+ type: :ios,
643
+ version: '15.4',
644
+ name: 'iOS',
645
+ }), sniffer.os_info
646
+ end
647
+
585
648
  it "Shopify Mobile in debug mode can be parsed" do
586
649
  user_agent = "Shopify Mobile/Android/6.0.0 (debug) (Build 1 with API 25 on Unknown Android SDK built for x86)"
587
650
  sniffer = BrowserSniffer.new(user_agent)
@@ -708,33 +771,68 @@ describe "Shopify agents" do
708
771
  }), sniffer.os_info
709
772
  end
710
773
 
711
- INCOMPATIBLE_USER_AGENTS = [
712
- "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko)"\
713
- " GSA/87.0.279142407 Mobile/15E148 Safari/605.1",
714
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko)"\
715
- " Version/12.1.2 Safari/605.1.15",
716
- "Mozilla/5.0 (Linux; U; Android 7.0; en-US; SM-G935F Build/NRD90M) AppleWebKit/534.30 (KHTML, like Gecko) "\
717
- "Version/4.0 UCBrowser/11.3.8.976 U3/0.8.0 Mobile Safari/534.30",
718
- ]
774
+ INCOMPATIBLE_USER_AGENTS = {
775
+ 'missing' => nil,
776
+
777
+ # Safari on iOS 12 is broken
778
+ 'iOS 12.0' => "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/87.0.279142407 Mobile/15E148 Safari/605.1",
779
+ 'iOS 12.2' => "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Mobile/15E148 Safari/604.1",
780
+
781
+ # Safari on MacOS 14 is broken
782
+ 'MacOS 10.14 Safari' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15",
783
+ 'MacOS 10.14 WebKit' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko)",
784
+
785
+ # UC Browser versions before 12.13.2 are broken
786
+ 'UC Browser 11.3.8' => "Mozilla/5.0 (Linux; U; Android 7.0; en-US; SM-G935F Build/NRD90M) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/11.3.8.976 U3/0.8.0 Mobile Safari/534.30",
787
+ 'UC Browser 12.13.0' => "Mozilla/5.0 (Linux; U; Android 8.0.0; en-US; moto g⁶ play Build/OPP27.91-88) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.13.0.1207 Mobile Safari/537.36",
719
788
 
720
- INCOMPATIBLE_USER_AGENTS.each do |user_agent|
721
- it "user agent #{user_agent} is correctly marked as incompatible" do
789
+ # Chrome and Chromium versions between 51 and 66 inclusive are broken
790
+ 'Chrome 51' => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
791
+ 'Chrome 66' => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36",
792
+
793
+ 'Chromium 51' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36",
794
+ 'Chromium 66' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36",
795
+ }
796
+
797
+ INCOMPATIBLE_USER_AGENTS.each do |label, user_agent|
798
+ it "#{label} user agent is correctly marked as incompatible" do
722
799
  sniffer = BrowserSniffer.new(user_agent)
723
800
 
724
801
  refute sniffer.same_site_none_compatible?
725
802
  end
726
803
  end
727
804
 
728
- COMPATIBLE_USER_AGENTS = [
729
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117"\
730
- " Safari/537.36",
731
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0",
732
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4"\
733
- " Safari/605.1.15",
734
- ]
805
+ COMPATIBLE_USER_AGENTS = {
806
+ 'iOS 13' => "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1",
807
+
808
+ 'MacOS 10.13 Safari' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6",
809
+
810
+ 'MacOS 10.14 Chrome' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
811
+
812
+ 'MacOS 10.15 Safari' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15",
813
+
814
+ 'MacOS 10.15 Firefox' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0",
815
+
816
+ 'UC Browser 13.3.8' => "Mozilla/5.0 (Linux; U; Android 11; en-US; SM-A715F Build/RP1A.200720.012) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 UCBrowser/13.3.8.1305 Mobile Safari/537.36",
817
+
818
+ 'Chrome 50' => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36",
819
+ 'Chrome 67' => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36",
820
+
821
+ 'Chromium 50' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/50.0.2661.102 Chrome/50.0.2661.102 Safari/537.36",
822
+ 'Chromium 67' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/67.0.3396.99 Chrome/67.0.3396.99 Safari/537.36",
823
+
824
+ # False negative: library doesn't recognise WebKit user agents that aren't Safari or Chrome
825
+ # (These may be e.g. Webkit nightly builds)
826
+ # 'MacOS 10.13 WebKit' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)",
827
+ # 'MacOS 10.15 WebKit' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko)",
828
+
829
+ # False negative: library explicitly treats iOS 11 Safari as incompatible while reference code does not:
830
+ # https://www.chromium.org/updates/same-site/incompatible-clients
831
+ # 'iOS 11' => "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1",
832
+ }
735
833
 
736
- COMPATIBLE_USER_AGENTS.each do |user_agent|
737
- it "user agent #{user_agent} is correctly marked as compatible" do
834
+ COMPATIBLE_USER_AGENTS.each do |label, user_agent|
835
+ it "#{label} user agent is correctly marked as compatible" do
738
836
  sniffer = BrowserSniffer.new(user_agent)
739
837
 
740
838
  assert sniffer.same_site_none_compatible?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_sniffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-04 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,8 +60,8 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".github/probots.yml"
63
+ - ".github/workflows/test.yml"
63
64
  - ".gitignore"
64
- - ".travis.yml"
65
65
  - Gemfile
66
66
  - LICENSE.txt
67
67
  - README.md
@@ -71,7 +71,7 @@ files:
71
71
  - lib/browser_sniffer.rb
72
72
  - lib/browser_sniffer/patterns.rb
73
73
  - lib/browser_sniffer/version.rb
74
- - shipit.rubygems.yml
74
+ - shipit.rubygems-backport.yml
75
75
  - test/browser_sniffer_test.rb
76
76
  - test/shopify_agents_test.rb
77
77
  - test/test_helper.rb
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9
4
- - 2.0
5
- - 2.1
6
- - 2.4
7
- - 2.5
8
- - 2.6
9
- - truffleruby-19.2.0.1 # like 2.6.2
10
- - jruby
11
-
12
- before_install: gem update bundler
13
- script: bundle exec rake test