shopify_app 7.4.0 → 8.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/.babelrc +5 -0
  3. data/.github/CODEOWNERS +1 -0
  4. data/.github/probots.yml +2 -0
  5. data/.gitignore +5 -0
  6. data/.nvmrc +1 -0
  7. data/.rubocop.yml +10 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +26 -3
  10. data/CHANGELOG.md +95 -0
  11. data/Gemfile +2 -0
  12. data/README.md +113 -56
  13. data/app/assets/images/storage_access.svg +2 -0
  14. data/app/assets/javascripts/shopify_app/enable_cookies.js +3 -0
  15. data/app/assets/javascripts/shopify_app/itp_helper.js +40 -0
  16. data/app/assets/javascripts/shopify_app/partition_cookies.js +7 -0
  17. data/app/assets/javascripts/shopify_app/redirect.js +33 -0
  18. data/app/assets/javascripts/shopify_app/request_storage_access.js +3 -0
  19. data/app/assets/javascripts/shopify_app/storage_access.js +121 -0
  20. data/app/assets/javascripts/shopify_app/storage_access_redirect.js +17 -0
  21. data/app/assets/javascripts/shopify_app/top_level.js +2 -0
  22. data/app/assets/javascripts/shopify_app/top_level_interaction.js +11 -0
  23. data/app/controllers/shopify_app/authenticated_controller.rb +3 -4
  24. data/{lib/shopify_app/sessions_concern.rb → app/controllers/shopify_app/callback_controller.rb} +27 -38
  25. data/app/controllers/shopify_app/sessions_controller.rb +120 -2
  26. data/app/controllers/shopify_app/webhooks_controller.rb +11 -3
  27. data/app/views/shopify_app/partials/_button_styles.html.erb +104 -0
  28. data/app/views/shopify_app/partials/_card_styles.html.erb +33 -0
  29. data/app/views/shopify_app/partials/_empty_state_styles.html.erb +129 -0
  30. data/app/views/shopify_app/partials/_layout_styles.html.erb +167 -0
  31. data/app/views/shopify_app/partials/_typography_styles.html.erb +35 -0
  32. data/app/views/shopify_app/sessions/enable_cookies.html.erb +59 -0
  33. data/app/views/shopify_app/sessions/new.html.erb +88 -60
  34. data/app/views/shopify_app/sessions/request_storage_access.html.erb +67 -0
  35. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +63 -0
  36. data/app/views/shopify_app/shared/redirect.html.erb +22 -0
  37. data/config/locales/de.yml +21 -2
  38. data/config/locales/en.yml +12 -0
  39. data/config/locales/es.yml +21 -2
  40. data/config/locales/fr.yml +22 -2
  41. data/config/locales/it.yml +22 -0
  42. data/config/locales/ja.yml +16 -2
  43. data/config/locales/nl.yml +21 -0
  44. data/config/locales/pt-BR.yml +22 -0
  45. data/config/locales/zh-CN.yml +16 -0
  46. data/config/locales/zh-TW.yml +17 -0
  47. data/config/routes.rb +11 -1
  48. data/docs/Quickstart.md +26 -23
  49. data/docs/Releasing.md +1 -0
  50. data/karma.conf.js +43 -0
  51. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +3 -1
  52. data/lib/generators/shopify_app/home_controller/templates/home_controller.rb +1 -0
  53. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +14 -0
  54. data/lib/generators/shopify_app/home_controller/templates/shopify_app_ready_script.html.erb +1 -5
  55. data/lib/generators/shopify_app/install/install_generator.rb +3 -13
  56. data/lib/generators/shopify_app/install/templates/_flash_messages.html.erb +13 -9
  57. data/lib/generators/shopify_app/install/templates/shopify_app.rb +4 -1
  58. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +19 -4
  59. data/lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb +16 -0
  60. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake +17 -0
  61. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb +42 -0
  62. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +3 -3
  63. data/lib/generators/shopify_app/shop_model/templates/shop.rb +0 -1
  64. data/lib/shopify_app.rb +21 -17
  65. data/lib/shopify_app/configuration.rb +26 -8
  66. data/lib/shopify_app/{app_proxy_verification.rb → controller_concerns/app_proxy_verification.rb} +1 -1
  67. data/lib/shopify_app/controller_concerns/embedded_app.rb +19 -0
  68. data/lib/shopify_app/controller_concerns/itp.rb +45 -0
  69. data/lib/shopify_app/{localization.rb → controller_concerns/localization.rb} +6 -0
  70. data/lib/shopify_app/controller_concerns/login_protection.rb +135 -0
  71. data/lib/shopify_app/{webhook_verification.rb → controller_concerns/webhook_verification.rb} +10 -6
  72. data/lib/shopify_app/engine.rb +10 -0
  73. data/lib/shopify_app/{scripttags_manager_job.rb → jobs/scripttags_manager_job.rb} +0 -0
  74. data/lib/shopify_app/{webhooks_manager_job.rb → jobs/webhooks_manager_job.rb} +0 -0
  75. data/lib/shopify_app/{scripttags_manager.rb → managers/scripttags_manager.rb} +0 -0
  76. data/lib/shopify_app/{webhooks_manager.rb → managers/webhooks_manager.rb} +0 -0
  77. data/lib/shopify_app/session/in_memory_session_store.rb +27 -0
  78. data/lib/shopify_app/{shopify_session_repository.rb → session/session_repository.rb} +0 -0
  79. data/lib/shopify_app/{session_storage.rb → session/session_storage.rb} +9 -0
  80. data/lib/shopify_app/utils.rb +2 -2
  81. data/lib/shopify_app/version.rb +1 -1
  82. data/package-lock.json +23 -0
  83. data/package.json +28 -0
  84. data/service.yml +7 -0
  85. data/shipit.rubygems.yml +2 -0
  86. data/shopify_app.gemspec +5 -4
  87. data/translation.yml +7 -0
  88. data/webpack.config.js +24 -0
  89. data/yarn.lock +4594 -0
  90. metadata +80 -27
  91. data/lib/generators/shopify_app/install/templates/shopify_session_repository.rb +0 -23
  92. data/lib/generators/shopify_app/shop_model/templates/shopify_session_repository.rb +0 -9
  93. data/lib/shopify_app/in_memory_session_store.rb +0 -25
  94. data/lib/shopify_app/login_protection.rb +0 -119
  95. data/lib/shopify_app/shop.rb +0 -15
@@ -1,11 +1,11 @@
1
1
  module ShopifyApp
2
- class WebhooksController < ApplicationController
2
+ class WebhooksController < ActionController::Base
3
3
  include ShopifyApp::WebhookVerification
4
4
 
5
5
  class ShopifyApp::MissingWebhookJobError < StandardError; end
6
6
 
7
7
  def receive
8
- params.try(:permit!)
8
+ params.permit!
9
9
  job_args = {shop_domain: shop_domain, webhook: webhook_params.to_h}
10
10
  webhook_job_klass.perform_later(job_args)
11
11
  head :no_content
@@ -18,11 +18,19 @@ module ShopifyApp
18
18
  end
19
19
 
20
20
  def webhook_job_klass
21
- "#{webhook_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError
21
+ webhook_job_klass_name.safe_constantize or raise ShopifyApp::MissingWebhookJobError
22
+ end
23
+
24
+ def webhook_job_klass_name(type = webhook_type)
25
+ [webhook_namespace, "#{type}_job"].compact.join('/').classify
22
26
  end
23
27
 
24
28
  def webhook_type
25
29
  params[:type]
26
30
  end
31
+
32
+ def webhook_namespace
33
+ ShopifyApp.configuration.webhook_jobs_namespace
34
+ end
27
35
  end
28
36
  end
@@ -0,0 +1,104 @@
1
+ <style>
2
+ .Polaris-Button {
3
+ fill:#637381;
4
+ position:relative;
5
+ display:-webkit-inline-box;
6
+ display:-ms-inline-flexbox;
7
+ display:inline-flex;
8
+ -webkit-box-align:center;
9
+ -ms-flex-align:center;
10
+ align-items:center;
11
+ -webkit-box-pack:center;
12
+ -ms-flex-pack:center;
13
+ justify-content:center;
14
+ min-height:3.6rem;
15
+ min-width:3.6rem;
16
+ margin:0;
17
+ padding:0.7rem 1.6rem;
18
+ background:linear-gradient(to bottom, white, #f9fafb);
19
+ border:1px solid #c4cdd5;
20
+ box-shadow:0 1px 0 0 rgba(22, 29, 37, 0.05);
21
+ border-radius:3px;
22
+ line-height:1;
23
+ color:#212b36;
24
+ text-align:center;
25
+ cursor:pointer;
26
+ -webkit-user-select:none;
27
+ -moz-user-select:none;
28
+ -ms-user-select:none;
29
+ user-select:none;
30
+ text-decoration:none;
31
+ transition-property:background, border, box-shadow;
32
+ transition-duration:200ms;
33
+ transition-timing-function:cubic-bezier(0.64, 0, 0.35, 1);
34
+ }
35
+
36
+ .Polaris-Button:hover {
37
+ background:linear-gradient(to bottom, #f9fafb, #f4f6f8);
38
+ border-color:#c4cdd5;
39
+ }
40
+
41
+ .Polaris-Button:focus {
42
+ border-color:#5c6ac4;
43
+ outline:0;
44
+ box-shadow:0 0 0 1px #5c6ac4;
45
+ }
46
+
47
+ .Polaris-Button:active {
48
+ background:linear-gradient(to bottom, #f4f6f8, #f4f6f8);
49
+ border-color:#c4cdd5;
50
+ box-shadow:0 0 0 0 transparent, inset 0 1px 1px 0 rgba(99, 115, 129, 0.1), inset 0 1px 4px 0 rgba(99, 115, 129, 0.2);
51
+ }
52
+
53
+ .Polaris-Button__Content {
54
+ font-size:1.5rem;
55
+ font-weight:400;
56
+ line-height:1.6rem;
57
+ text-transform:initial;
58
+ letter-spacing:initial;
59
+ position:relative;
60
+ display:-webkit-box;
61
+ display:-ms-flexbox;
62
+ display:flex;
63
+ -webkit-box-pack:center;
64
+ -ms-flex-pack:center;
65
+ justify-content:center;
66
+ -webkit-box-align:center;
67
+ -ms-flex-align:center;
68
+ align-items:center;
69
+ min-width:1px;
70
+ min-height:1px;
71
+ }
72
+
73
+ @media (min-width: 40em) {
74
+ .Polaris-Button__Content {
75
+ font-size:1.4rem;
76
+ }
77
+ }
78
+
79
+ .Polaris-Button--primary {
80
+ background:linear-gradient(to bottom, #6371c7, #5563c1);
81
+ border-color:#3f4eae;
82
+ box-shadow:inset 0 1px 0 0 #6774c8, 0 1px 0 0 rgba(22, 29, 37, 0.05), 0 0 0 0 transparent;
83
+ color:white;
84
+ fill:white;
85
+ }
86
+
87
+ .Polaris-Button--primary:hover {
88
+ background:linear-gradient(to bottom, #5c6ac4, #4959bd);
89
+ border-color:#3f4eae;
90
+ color:white;
91
+ text-decoration:none;
92
+ }
93
+
94
+ .Polaris-Button--primary:focus {
95
+ border-color:#202e78;
96
+ box-shadow:inset 0 1px 0 0 #6f7bcb, 0 1px 0 0 rgba(22, 29, 37, 0.05), 0 0 0 1px #202e78;
97
+ }
98
+
99
+ .Polaris-Button--primary:active {
100
+ background:linear-gradient(to bottom, #3f4eae, #3f4eae);
101
+ border-color:#38469b;
102
+ box-shadow:inset 0 0 0 0 transparent, 0 1px 0 0 rgba(22, 29, 37, 0.05), 0 0 1px 0 #38469b;
103
+ }
104
+ </style>
@@ -0,0 +1,33 @@
1
+ <style>
2
+ .Polaris-Card {
3
+ overflow:hidden;
4
+ background-color:white;
5
+ box-shadow:0 0 0 1px rgba(63, 63, 68, 0.05), 0 1px 3px 0 rgba(63, 63, 68, 0.15);
6
+ }
7
+
8
+ .Polaris-Card + .Polaris-Card {
9
+ margin-top:2rem;
10
+ }
11
+
12
+ @media (min-width: 30.625em) {
13
+ .Polaris-Card {
14
+ border-radius:3px;
15
+ }
16
+ }
17
+
18
+ .Polaris-Card__Header {
19
+ padding:2rem 2rem 0;
20
+ }
21
+
22
+ .Polaris-Card__Section {
23
+ padding:2rem;
24
+ }
25
+
26
+ .Polaris-Card__Section + .Polaris-Card__Section {
27
+ border-top:1px solid #dfe3e8;
28
+ }
29
+
30
+ .Polaris-Card__Section--subdued {
31
+ background-color:#f9fafb;
32
+ }
33
+ </style>
@@ -0,0 +1,129 @@
1
+ <style>
2
+ .Polaris-EmptyState {
3
+ display:-webkit-box;
4
+ display:-ms-flexbox;
5
+ display:flex;
6
+ -webkit-box-orient:vertical;
7
+ -webkit-box-direction:normal;
8
+ -ms-flex-direction:column;
9
+ flex-direction:column;
10
+ -webkit-box-align:center;
11
+ -ms-flex-align:center;
12
+ align-items:center;
13
+ width:100%;
14
+ margin:2rem auto 0 auto;
15
+ padding:2rem 0;
16
+ max-width:99.8rem;
17
+ }
18
+
19
+ @media (min-width: 46.5em) {
20
+ .Polaris-EmptyState--imageContained .Polaris-EmptyState__Image {
21
+ position:initial;
22
+ width:100%;
23
+ }
24
+ }
25
+
26
+ .Polaris-EmptyState__Section {
27
+ position:relative;
28
+ display:-webkit-box;
29
+ display:-ms-flexbox;
30
+ display:flex;
31
+ -webkit-box-orient:vertical;
32
+ -webkit-box-direction:normal;
33
+ -ms-flex-direction:column;
34
+ flex-direction:column;
35
+ -webkit-box-flex:1;
36
+ -ms-flex:1 1 auto;
37
+ flex:1 1 auto;
38
+ width:100%;
39
+ }
40
+
41
+ @media (min-width: 46.5em) {
42
+ .Polaris-EmptyState__Section {
43
+ left:2rem;
44
+ -webkit-box-orient:horizontal;
45
+ -webkit-box-direction:normal;
46
+ -ms-flex-direction:row;
47
+ flex-direction:row;
48
+ -webkit-box-align:center;
49
+ -ms-flex-align:center;
50
+ align-items:center;
51
+ }
52
+ }
53
+
54
+ .Polaris-EmptyState__ImageContainer,
55
+ .Polaris-EmptyState__DetailsContainer {
56
+ -webkit-box-flex:1;
57
+ -ms-flex:1 1 auto;
58
+ flex:1 1 auto;
59
+ padding:0;
60
+ margin:0;
61
+ }
62
+
63
+ @media (min-width: 46.5em) {
64
+ .Polaris-EmptyState__ImageContainer,
65
+ .Polaris-EmptyState__DetailsContainer {
66
+ -ms-flex-preferred-size:50%;
67
+ flex-basis:50%;
68
+ }
69
+ }
70
+
71
+ @media (max-width: 30.625em) {
72
+ .Polaris-EmptyState__ImageContainer,
73
+ .Polaris-EmptyState__DetailsContainer {
74
+ overflow-x:hidden;
75
+ }
76
+ }
77
+
78
+ .Polaris-EmptyState__Details {
79
+ position:relative;
80
+ z-index:10;
81
+ padding:0 1.6rem;
82
+ width:33.6rem;
83
+ }
84
+
85
+ @media (min-width: 30.625em) {
86
+ .Polaris-EmptyState__Details {
87
+ padding:0;
88
+ }
89
+ }
90
+
91
+ .Polaris-EmptyState__Content {
92
+ font-size:1.6rem;
93
+ font-weight:400;
94
+ line-height:2.4rem;
95
+ color:#637381;
96
+ }
97
+
98
+ @media (min-width: 40em) {
99
+ .Polaris-EmptyState__Content {
100
+ font-size:2rem;
101
+ line-height:2.8rem;
102
+ }
103
+ }
104
+
105
+ .Polaris-EmptyState__Actions {
106
+ margin-top:1.6rem;
107
+ }
108
+
109
+ .Polaris-EmptyState__Image {
110
+ display: none;
111
+ }
112
+
113
+ @media (min-width: 30.625em) {
114
+ .Polaris-EmptyState__Image {
115
+ display: block;
116
+ margin-left:-60%;
117
+ margin-top:-30%;
118
+ width:200%;
119
+ }
120
+ }
121
+
122
+ @media (min-width: 46.5em) {
123
+ .Polaris-EmptyState__Image {
124
+ margin-top:0;
125
+ margin-left:-90%;
126
+ width:200%;
127
+ }
128
+ }
129
+ </style>
@@ -0,0 +1,167 @@
1
+ <style>
2
+ html,
3
+ body {
4
+ min-height:100%;
5
+ height:100%;
6
+ font-size:1.5rem;
7
+ font-weight:400;
8
+ line-height:2rem;
9
+ text-transform:initial;
10
+ letter-spacing:initial;
11
+ font-weight:400;
12
+ color:#212b36;
13
+ font-family:-apple-system, BlinkMacSystemFont, San Francisco, Roboto, Segoe UI, Helvetica Neue, sans-serif;
14
+ }
15
+
16
+ @media (min-width: 40em) {
17
+ html,
18
+ body {
19
+ font-size:1.4rem;
20
+ }
21
+ }
22
+
23
+ html {
24
+ position:relative;
25
+ font-size:62.5%;
26
+ -webkit-font-smoothing:antialiased;
27
+ -moz-osx-font-smoothing:grayscale;
28
+ -webkit-text-size-adjust:100%;
29
+ -ms-text-size-adjust:100%;
30
+ text-size-adjust:100%;
31
+ text-rendering:optimizeLegibility;
32
+ }
33
+
34
+ body {
35
+ min-height:100%;
36
+ margin:0;
37
+ padding:0;
38
+ background-color:#f4f6f8;
39
+ }
40
+
41
+ *,
42
+ *::before,
43
+ *::after{
44
+ box-sizing:border-box; }
45
+
46
+ h1,
47
+ h2,
48
+ h3,
49
+ h4,
50
+ h5,
51
+ h6,
52
+ p {
53
+ margin:0;
54
+ font-size:1em;
55
+ font-weight:400;
56
+ }
57
+
58
+ .Polaris-Page {
59
+ margin:0 auto;
60
+ padding:0;
61
+ max-width:99.8rem;
62
+ }
63
+
64
+ @media (min-width: 30.625em) {
65
+ .Polaris-Page {
66
+ padding:0 2rem;
67
+ }
68
+ }
69
+ @media (min-width: 46.5em) {
70
+ .Polaris-Page {
71
+ padding:0 3.2rem;
72
+ }
73
+ }
74
+
75
+ .Polaris-Page__Content {
76
+ margin:2rem 0;
77
+ }
78
+
79
+ @media (min-width: 46.5em) {
80
+ .Polaris-Page__Content {
81
+ margin-top:2rem;
82
+ }
83
+ }
84
+
85
+ @media (min-width: 46.5em) {
86
+ .Polaris-Page {
87
+ display: flex;
88
+ justify-content: center;
89
+ align-items: center;
90
+ height: 100vh;
91
+ }
92
+ }
93
+
94
+ .Polaris-Layout {
95
+ display:-webkit-box;
96
+ display:-ms-flexbox;
97
+ display:flex;
98
+ -ms-flex-wrap:wrap;
99
+ flex-wrap:wrap;
100
+ -webkit-box-pack:center;
101
+ -ms-flex-pack:center;
102
+ justify-content:center;
103
+ -webkit-box-align:start;
104
+ -ms-flex-align:start;
105
+ align-items:flex-start;
106
+ margin-top:-2rem;
107
+ margin-left:-2rem;
108
+ }
109
+
110
+ .Polaris-Layout__Section {
111
+ -webkit-box-flex:2;
112
+ -ms-flex:2 2 48rem;
113
+ flex:2 2 48rem;
114
+ min-width:51%;
115
+ }
116
+
117
+ .Polaris-Layout__Section--fullWidth {
118
+ -webkit-box-flex:1;
119
+ -ms-flex:1 1 100%;
120
+ flex:1 1 100%;
121
+ }
122
+
123
+ .Polaris-Layout__Section {
124
+ max-width:calc(100% - 2rem);
125
+ margin-top:2rem;
126
+ margin-left:2rem;
127
+ }
128
+
129
+ .Polaris-Stack {
130
+ margin-top:-1.6rem;
131
+ margin-left:-1.6rem;
132
+ display:-webkit-box;
133
+ display:-ms-flexbox;
134
+ display:flex;
135
+ -ms-flex-wrap:wrap;
136
+ flex-wrap:wrap;
137
+ -webkit-box-align:stretch;
138
+ -ms-flex-align:stretch;
139
+ align-items:stretch;
140
+ }
141
+
142
+ .Polaris-Stack > .Polaris-Stack__Item {
143
+ margin-top:1.6rem;
144
+ margin-left:1.6rem;
145
+ max-width:calc(100% - 1.6rem);
146
+ }
147
+
148
+ .Polaris-Stack__Item {
149
+ -webkit-box-flex:0;
150
+ -ms-flex:0 0 auto;
151
+ flex:0 0 auto;
152
+ min-width:0;
153
+ }
154
+
155
+ .Polaris-Stack--distributionTrailing {
156
+ -webkit-box-pack:end;
157
+ -ms-flex-pack:end;
158
+ justify-content:flex-end;
159
+ }
160
+
161
+ .Polaris-Stack--vertical {
162
+ -webkit-box-orient:vertical;
163
+ -webkit-box-direction:normal;
164
+ -ms-flex-direction:column;
165
+ flex-direction:column;
166
+ }
167
+ </style>