Skip to content

Commit

Permalink
Merge branch 'main' into non-http-webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov committed Mar 22, 2023
2 parents b346c25 + 1f8db98 commit b4543b5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased
----------

* Support Unified Admin [#1658](https://github.com/Shopify/shopify_app/pull/1658)
* Set `access_scopes` column to string by default [#1636](https://github.com/Shopify/shopify_app/pull/1636)
* Fix registration of event_bridge and pub_sub webhooks [#1635](https://github.com/Shopify/shopify_app/pull/1635)

21.4.1 (Feb 21, 2023)
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ GEM
json (2.6.3)
jwt (2.6.0)
language_server-protocol (3.17.0.2)
loofah (2.19.0)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.8.0)
Expand All @@ -132,11 +132,11 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.9-arm64-darwin)
nokogiri (1.14.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-darwin)
nokogiri (1.14.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-linux)
nokogiri (1.14.2-x86_64-linux)
racc (~> 1.4)
oj (3.13.23)
openssl (3.1.0)
Expand All @@ -153,7 +153,7 @@ GEM
binding_of_caller (~> 1.0)
pry (~> 0.13)
public_suffix (5.0.1)
racc (1.6.1)
racc (1.6.2)
rack (2.2.4)
rack-test (2.0.2)
rack (>= 1.3)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddShopAccessScopesColumn < ActiveRecord::Migration[<%= rails_migration_version %>]
def change
add_column :shops, :access_scopes, :string
add_column :shops, :access_scopes, :string, default: "", null: false
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddUserAccessScopesColumn < ActiveRecord::Migration[<%= rails_migration_version %>]
def change
add_column :users, :access_scopes, :string
add_column :users, :access_scopes, :string, default: "", null: false
end
end
12 changes: 11 additions & 1 deletion lib/shopify_app/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def sanitize_shop_domain(shop_domain)
no_shop_name_in_subdomain = uri.host == trusted_domain
from_trusted_domain = trusted_domain == uri.domain

return myshopify_domain_from_unified_admin(uri) if unified_admin?(uri) && from_trusted_domain
return nil if no_shop_name_in_subdomain || uri.host&.empty?
return uri.host if from_trusted_domain
end

nil
end

Expand Down Expand Up @@ -65,6 +65,16 @@ def uri_from_shop_domain(shop_domain)
rescue Addressable::URI::InvalidURIError
nil
end

def unified_admin?(uri)
uri.host.split(".").first == "admin"
end

def myshopify_domain_from_unified_admin(uri)
shop = uri.path.split("/").last

"#{shop}.myshopify.com"
end
end
end
end
10 changes: 10 additions & 0 deletions test/shopify_app/utils_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ class UtilsTest < ActiveSupport::TestCase
assert ShopifyApp::Utils.sanitize_shop_domain("some-shoppe-over-the-rainbow.myshopify.io")
end

test "convert unified admin to old domain" do
trailing_forward_slash_url = "https://admin.shopify.com/store/store-name/"
unified_admin_url = "https://admin.shopify.com/store/store-name"

expected = "store-name.myshopify.com"

assert_equal expected, ShopifyApp::Utils.sanitize_shop_domain(trailing_forward_slash_url)
assert_equal expected, ShopifyApp::Utils.sanitize_shop_domain(unified_admin_url)
end

["myshop.com", "myshopify.com", "shopify.com", "two words", "store.myshopify.com.evil.com",
"/foo/bar", "foo.myshopify.io.evil.ru",].each do |bad_url|
test "sanitize_shop_domain for a non-myshopify URL (#{bad_url})" do
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2070,9 +2070,9 @@ decamelize@^1.2.0:
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=

decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
version "0.2.2"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==

deep-eql@^3.0.1:
version "3.0.1"
Expand Down Expand Up @@ -3171,9 +3171,9 @@ json-schema-traverse@^0.4.1:
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==

json5@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==
version "1.0.2"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593"
integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==
dependencies:
minimist "^1.2.0"

Expand Down Expand Up @@ -3317,9 +3317,9 @@ loader-runner@^2.4.0:
integrity sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw==

loader-utils@^1.1.0, loader-utils@^1.2.3, loader-utils@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613"
integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==
version "1.4.2"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.2.tgz#29a957f3a63973883eb684f10ffd3d151fec01a3"
integrity sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==
dependencies:
big.js "^5.2.2"
emojis-list "^3.0.0"
Expand Down Expand Up @@ -3515,9 +3515,9 @@ minimatch@3.0.4, minimatch@^3.0.4:
brace-expansion "^1.1.7"

minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5:
version "1.2.6"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==

mississippi@^3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -4730,9 +4730,9 @@ terser-webpack-plugin@^1.4.3:
worker-farm "^1.7.0"

terser@^4.1.2:
version "4.8.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.0.tgz#63056343d7c70bb29f3af665865a46fe03a0df17"
integrity sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==
version "4.8.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.1.tgz#a00e5634562de2239fd404c649051bf6fc21144f"
integrity sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
Expand Down

0 comments on commit b4543b5

Please sign in to comment.