duodealer_app 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +7 -0
  2. data/.!66854!duodealer_app.gemspec +0 -0
  3. data/.babelrc +5 -0
  4. data/.gitignore +16 -0
  5. data/.nvmrc +1 -0
  6. data/.rubocop.yml +263 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +27 -0
  9. data/Gemfile +8 -0
  10. data/LICENSE +19 -0
  11. data/README.md +553 -0
  12. data/Rakefile +6 -0
  13. data/app/assets/images/storage_access.svg +2 -0
  14. data/app/assets/javascripts/duodealer_app/enable_cookies.js +3 -0
  15. data/app/assets/javascripts/duodealer_app/itp_helper.js +40 -0
  16. data/app/assets/javascripts/duodealer_app/partition_cookies.js +8 -0
  17. data/app/assets/javascripts/duodealer_app/redirect.js +33 -0
  18. data/app/assets/javascripts/duodealer_app/request_storage_access.js +3 -0
  19. data/app/assets/javascripts/duodealer_app/storage_access.js +153 -0
  20. data/app/assets/javascripts/duodealer_app/storage_access_redirect.js +17 -0
  21. data/app/assets/javascripts/duodealer_app/top_level.js +2 -0
  22. data/app/assets/javascripts/duodealer_app/top_level_interaction.js +11 -0
  23. data/app/controllers/concerns/duodealer_app/authenticated.rb +15 -0
  24. data/app/controllers/concerns/duodealer_app/authenticated.rb-e +15 -0
  25. data/app/controllers/duodealer_app/authenticated_controller.rb +9 -0
  26. data/app/controllers/duodealer_app/authenticated_controller.rb-e +9 -0
  27. data/app/controllers/duodealer_app/callback_controller.rb +104 -0
  28. data/app/controllers/duodealer_app/callback_controller.rb-e +104 -0
  29. data/app/controllers/duodealer_app/extension_verification_controller.rb +19 -0
  30. data/app/controllers/duodealer_app/extension_verification_controller.rb-e +19 -0
  31. data/app/controllers/duodealer_app/sessions_controller.rb +159 -0
  32. data/app/controllers/duodealer_app/sessions_controller.rb-e +159 -0
  33. data/app/controllers/duodealer_app/webhooks_controller.rb +37 -0
  34. data/app/controllers/duodealer_app/webhooks_controller.rb-e +37 -0
  35. data/app/views/duodealer_app/partials/_button_styles.html.erb +104 -0
  36. data/app/views/duodealer_app/partials/_button_styles.html.erb-e +104 -0
  37. data/app/views/duodealer_app/partials/_card_styles.html.erb +33 -0
  38. data/app/views/duodealer_app/partials/_card_styles.html.erb-e +33 -0
  39. data/app/views/duodealer_app/partials/_empty_state_styles.html.erb +129 -0
  40. data/app/views/duodealer_app/partials/_empty_state_styles.html.erb-e +129 -0
  41. data/app/views/duodealer_app/partials/_layout_styles.html.erb +167 -0
  42. data/app/views/duodealer_app/partials/_layout_styles.html.erb-e +167 -0
  43. data/app/views/duodealer_app/partials/_typography_styles.html.erb +35 -0
  44. data/app/views/duodealer_app/partials/_typography_styles.html.erb-e +35 -0
  45. data/app/views/duodealer_app/sessions/enable_cookies.html.erb +75 -0
  46. data/app/views/duodealer_app/sessions/enable_cookies.html.erb-e +75 -0
  47. data/app/views/duodealer_app/sessions/new.html.erb +123 -0
  48. data/app/views/duodealer_app/sessions/new.html.erb-e +123 -0
  49. data/app/views/duodealer_app/sessions/request_storage_access.html.erb +68 -0
  50. data/app/views/duodealer_app/sessions/request_storage_access.html.erb-e +68 -0
  51. data/app/views/duodealer_app/sessions/top_level_interaction.html.erb +64 -0
  52. data/app/views/duodealer_app/sessions/top_level_interaction.html.erb-e +64 -0
  53. data/app/views/duodealer_app/shared/redirect.html.erb +23 -0
  54. data/app/views/duodealer_app/shared/redirect.html.erb-e +23 -0
  55. data/config/locales/cs.yml +23 -0
  56. data/config/locales/da.yml +20 -0
  57. data/config/locales/de.yml +22 -0
  58. data/config/locales/en.yml +15 -0
  59. data/config/locales/es.yml +22 -0
  60. data/config/locales/fi.yml +20 -0
  61. data/config/locales/fr.yml +23 -0
  62. data/config/locales/hi.yml +23 -0
  63. data/config/locales/it.yml +21 -0
  64. data/config/locales/ja.yml +17 -0
  65. data/config/locales/ko.yml +19 -0
  66. data/config/locales/ms.yml +22 -0
  67. data/config/locales/nb.yml +21 -0
  68. data/config/locales/nl.yml +21 -0
  69. data/config/locales/pl.yml +21 -0
  70. data/config/locales/pt-BR.yml +21 -0
  71. data/config/locales/pt-PT.yml +22 -0
  72. data/config/locales/sv.yml +21 -0
  73. data/config/locales/th.yml +20 -0
  74. data/config/locales/tr.yml +22 -0
  75. data/config/locales/zh-CN.yml +16 -0
  76. data/config/locales/zh-TW.yml +16 -0
  77. data/config/routes.rb +22 -0
  78. data/docs/.!20385!test-your-app.png +0 -0
  79. data/docs/.!20388!install-on-dev-shop.png +0 -0
  80. data/docs/.!62511!test-your-app.png +0 -0
  81. data/docs/.!62512!install-on-dev-shop.png +0 -0
  82. data/docs/.!62763!test-your-app.png +0 -0
  83. data/docs/.!62765!install-on-dev-shop.png +0 -0
  84. data/docs/.!63018!test-your-app.png +0 -0
  85. data/docs/.!63020!install-on-dev-shop.png +0 -0
  86. data/docs/.!63289!test-your-app.png +0 -0
  87. data/docs/.!63291!install-on-dev-shop.png +0 -0
  88. data/docs/.!63562!test-your-app.png +0 -0
  89. data/docs/.!63564!install-on-dev-shop.png +0 -0
  90. data/docs/.!63872!test-your-app.png +0 -0
  91. data/docs/.!63874!install-on-dev-shop.png +0 -0
  92. data/docs/.!64151!test-your-app.png +0 -0
  93. data/docs/.!64153!install-on-dev-shop.png +0 -0
  94. data/docs/.!64428!test-your-app.png +0 -0
  95. data/docs/.!64431!install-on-dev-shop.png +0 -0
  96. data/docs/.!64737!test-your-app.png +0 -0
  97. data/docs/.!64740!install-on-dev-shop.png +0 -0
  98. data/docs/.!65025!test-your-app.png +0 -0
  99. data/docs/.!65028!install-on-dev-shop.png +0 -0
  100. data/docs/.!65324!test-your-app.png +0 -0
  101. data/docs/.!65327!install-on-dev-shop.png +0 -0
  102. data/docs/.!65626!test-your-app.png +0 -0
  103. data/docs/.!65629!install-on-dev-shop.png +0 -0
  104. data/docs/.!65942!test-your-app.png +0 -0
  105. data/docs/.!65945!install-on-dev-shop.png +0 -0
  106. data/docs/.!66760!test-your-app.png +0 -0
  107. data/docs/.!66763!install-on-dev-shop.png +0 -0
  108. data/docs/.!67028!test-your-app.png +0 -0
  109. data/docs/.!67031!install-on-dev-shop.png +0 -0
  110. data/docs/.!67657!test-your-app.png +0 -0
  111. data/docs/.!67660!install-on-dev-shop.png +0 -0
  112. data/docs/.!68031!test-your-app.png +0 -0
  113. data/docs/.!68034!install-on-dev-shop.png +0 -0
  114. data/docs/.!68363!test-your-app.png +0 -0
  115. data/docs/.!68366!install-on-dev-shop.png +0 -0
  116. data/docs/Quickstart.md +103 -0
  117. data/docs/Releasing.md +17 -0
  118. data/docs/Troubleshooting.md +16 -0
  119. data/docs/install-on-dev-shop.png +0 -0
  120. data/docs/test-your-app.png +0 -0
  121. data/duodealer_app.gemspec +34 -0
  122. data/images/.!20334!app-proxy-screenshot.png +0 -0
  123. data/images/.!62504!app-proxy-screenshot.png +0 -0
  124. data/images/.!62754!app-proxy-screenshot.png +0 -0
  125. data/images/.!63008!app-proxy-screenshot.png +0 -0
  126. data/images/.!63277!app-proxy-screenshot.png +0 -0
  127. data/images/.!63548!app-proxy-screenshot.png +0 -0
  128. data/images/.!63855!app-proxy-screenshot.png +0 -0
  129. data/images/.!64132!app-proxy-screenshot.png +0 -0
  130. data/images/.!64407!app-proxy-screenshot.png +0 -0
  131. data/images/.!64714!app-proxy-screenshot.png +0 -0
  132. data/images/.!65000!app-proxy-screenshot.png +0 -0
  133. data/images/.!65296!app-proxy-screenshot.png +0 -0
  134. data/images/.!65594!app-proxy-screenshot.png +0 -0
  135. data/images/.!65908!app-proxy-screenshot.png +0 -0
  136. data/images/.!66724!app-proxy-screenshot.png +0 -0
  137. data/images/.!66989!app-proxy-screenshot.png +0 -0
  138. data/images/.!67614!app-proxy-screenshot.png +0 -0
  139. data/images/.!67986!app-proxy-screenshot.png +0 -0
  140. data/images/.!68314!app-proxy-screenshot.png +0 -0
  141. data/images/app-proxy-screenshot.png +0 -0
  142. data/karma.conf.js +44 -0
  143. data/lib/duodealer_app.rb +54 -0
  144. data/lib/duodealer_app/configuration.rb +85 -0
  145. data/lib/duodealer_app/controller_concerns/app_proxy_verification.rb +39 -0
  146. data/lib/duodealer_app/controller_concerns/embedded_app.rb +20 -0
  147. data/lib/duodealer_app/controller_concerns/itp.rb +44 -0
  148. data/lib/duodealer_app/controller_concerns/localization.rb +23 -0
  149. data/lib/duodealer_app/controller_concerns/login_protection.rb +180 -0
  150. data/lib/duodealer_app/controller_concerns/webhook_verification.rb +39 -0
  151. data/lib/duodealer_app/engine.rb +22 -0
  152. data/lib/duodealer_app/jobs/scripttags_manager_job.rb +17 -0
  153. data/lib/duodealer_app/jobs/webhooks_manager_job.rb +17 -0
  154. data/lib/duodealer_app/managers/scripttags_manager.rb +78 -0
  155. data/lib/duodealer_app/managers/webhooks_manager.rb +62 -0
  156. data/lib/duodealer_app/middleware/same_site_cookie_middleware.rb +69 -0
  157. data/lib/duodealer_app/session/in_memory_session_store.rb +29 -0
  158. data/lib/duodealer_app/session/session_repository.rb +33 -0
  159. data/lib/duodealer_app/session/session_storage.rb +31 -0
  160. data/lib/duodealer_app/session/storage_strategies/shop_storage_strategy.rb +25 -0
  161. data/lib/duodealer_app/session/storage_strategies/user_storage_strategy.rb +26 -0
  162. data/lib/duodealer_app/utils.rb +24 -0
  163. data/lib/duodealer_app/version.rb +5 -0
  164. data/lib/generators/duodealer_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +46 -0
  165. data/lib/generators/duodealer_app/add_after_authenticate_job/templates/after_authenticate_job.rb +10 -0
  166. data/lib/generators/duodealer_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +40 -0
  167. data/lib/generators/duodealer_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +62 -0
  168. data/lib/generators/duodealer_app/add_webhook/add_webhook_generator.rb +69 -0
  169. data/lib/generators/duodealer_app/add_webhook/templates/webhook_job.rb +8 -0
  170. data/lib/generators/duodealer_app/app_proxy_controller/app_proxy_controller_generator.rb +27 -0
  171. data/lib/generators/duodealer_app/app_proxy_controller/templates/app_proxy_controller.rb +9 -0
  172. data/lib/generators/duodealer_app/app_proxy_controller/templates/app_proxy_route.rb +10 -0
  173. data/lib/generators/duodealer_app/app_proxy_controller/templates/index.html.erb +19 -0
  174. data/lib/generators/duodealer_app/authenticated_controller/authenticated_controller_generator.rb +15 -0
  175. data/lib/generators/duodealer_app/authenticated_controller/templates/authenticated_controller.rb +5 -0
  176. data/lib/generators/duodealer_app/controllers/controllers_generator.rb +30 -0
  177. data/lib/generators/duodealer_app/duodealer_app_generator.rb +19 -0
  178. data/lib/generators/duodealer_app/home_controller/home_controller_generator.rb +27 -0
  179. data/lib/generators/duodealer_app/home_controller/templates/home_controller.rb +8 -0
  180. data/lib/generators/duodealer_app/home_controller/templates/index.html.erb +21 -0
  181. data/lib/generators/duodealer_app/install/install_generator.rb +83 -0
  182. data/lib/generators/duodealer_app/install/templates/_flash_messages.html.erb +3 -0
  183. data/lib/generators/duodealer_app/install/templates/duodealer_app.js +15 -0
  184. data/lib/generators/duodealer_app/install/templates/duodealer_app.rb +15 -0
  185. data/lib/generators/duodealer_app/install/templates/duodealer_app_index.js +2 -0
  186. data/lib/generators/duodealer_app/install/templates/duodealer_provider.rb +20 -0
  187. data/lib/generators/duodealer_app/install/templates/embedded_app.html.erb +41 -0
  188. data/lib/generators/duodealer_app/install/templates/flash_messages.js +26 -0
  189. data/lib/generators/duodealer_app/install/templates/omniauth.rb +2 -0
  190. data/lib/generators/duodealer_app/install/templates/session_store.rb +4 -0
  191. data/lib/generators/duodealer_app/install/templates/user_agent.rb +5 -0
  192. data/lib/generators/duodealer_app/rotate_duodealer_token_job/rotate_duodealer_token_job_generator.rb +16 -0
  193. data/lib/generators/duodealer_app/rotate_duodealer_token_job/templates/rotate_duodealer_token.rake +17 -0
  194. data/lib/generators/duodealer_app/rotate_duodealer_token_job/templates/rotate_duodealer_token_job.rb +42 -0
  195. data/lib/generators/duodealer_app/routes/routes_generator.rb +32 -0
  196. data/lib/generators/duodealer_app/routes/templates/routes.rb +11 -0
  197. data/lib/generators/duodealer_app/shop_model/shop_model_generator.rb +39 -0
  198. data/lib/generators/duodealer_app/shop_model/templates/db/migrate/create_shops.erb +15 -0
  199. data/lib/generators/duodealer_app/shop_model/templates/shop.rb +7 -0
  200. data/lib/generators/duodealer_app/shop_model/templates/shops.yml +3 -0
  201. data/lib/generators/duodealer_app/user_model/templates/db/migrate/create_users.erb +16 -0
  202. data/lib/generators/duodealer_app/user_model/templates/user.rb +7 -0
  203. data/lib/generators/duodealer_app/user_model/templates/users.yml +4 -0
  204. data/lib/generators/duodealer_app/user_model/user_model_generator.rb +39 -0
  205. data/lib/generators/duodealer_app/views/views_generator.rb +30 -0
  206. data/package-lock.json +7224 -0
  207. data/package.json +28 -0
  208. data/shipit.rubygems.yml +4 -0
  209. data/translation.yml +7 -0
  210. data/webpack.config.js +24 -0
  211. data/yarn.lock +5263 -0
  212. metadata +447 -0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,103 @@
1
+ Quickstart
2
+ ==========
3
+
4
+ Get started building and deploying a new Duo Dealer App to Heroku in just a few minutes. This guide assumes you have Ruby/Rails installed on your computer already; if you haven't done that already start with [this guide.](https://guides.rubyonrails.org/v5.0/getting_started.html#installing-rails)
5
+
6
+ 1. New Rails App (with postgres)
7
+ --------------------------------
8
+
9
+ To create a new Rails app and use this generator, open your terminal and run the following commands:
10
+
11
+ ```sh
12
+ $ rails new test-app --database=postgresql
13
+ $ cd test-app
14
+ $ git init
15
+ $ git add .
16
+ $ git commit -m 'new rails app'
17
+ ```
18
+
19
+ 2. Create a new Heroku app
20
+ --------------------------
21
+
22
+ The next step is to create a new Heroku app to host your application. If you haven't got a Heroku account yet, create a free account [here](https://www.heroku.com/).
23
+
24
+ Head to the Heroku dashboard and create a new app, or run the following commands with the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli#download-and-install) installed, substituting `name` for the name of your own app:
25
+
26
+ CLI:
27
+ ```sh
28
+ $ heroku create name
29
+ $ heroku git:remote -a name
30
+ ```
31
+
32
+ Once you have created an app on Heroku, we need to let Git know where the Heroku server is so we can deploy to it later. Copy the app's name from your Heroku dashboard and substitute `appname.git` with the name you chose earlier:
33
+
34
+ web:
35
+ ```sh
36
+ # https://dashboard.heroku.com/new
37
+ $ git remote add heroku git@heroku.com:appname.git
38
+ ```
39
+
40
+ 3. Create a new App in the Duo Dealer Partner dashboard
41
+ -----------------------------------------
42
+ * Create a Duo Dealer app in the [Partners dashboard](https://partner.duodealer.com). For this tutorial, you can choose either a public or custom app, but you can [learn about App Types here.](https://help.duodealer.com/en/manual/apps/app-types)
43
+ [https://app.duodealer.com/services/partners/api_clients](https://app.duodealer.com/services/partners/api_clients)
44
+ * Set the callback url to `https://<appname>.herokuapp.com/`
45
+ * Choose an embedded app
46
+ * Set the app's `redirect_uri` to `https://<appname>.herokuapp.com/auth/duodealer/callback`
47
+
48
+ 4. Add DuodealerApp to Gemfile
49
+ ----------------------------
50
+
51
+ Run these commands to add the `duodealer_app` Gem to your app:
52
+
53
+ ```sh
54
+ $ echo "gem 'duodealer_app'" >> Gemfile
55
+ $ bundle install
56
+ ```
57
+
58
+ **Note:** we recommend using the latest version of Duo Dealer Gem. Check the [Git tags](https://gitlab.com/duodealer/duodealer_app/tags) to see the latest release version and then add it to your Gemfile e.g `gem 'duodealer_app', '~> 7.0.0'`
59
+
60
+ 5. Run the DuodealerApp generator
61
+ -------------------------------
62
+
63
+ Generate the code for your app by running these commands:
64
+
65
+ ```sh
66
+ # Use the keys from your app you created in the partners area
67
+ $ rails generate duodealer_app --api_key <duodealer_api_key> --secret <duodealer_api_secret>
68
+ $ git add .
69
+ $ git commit -m 'generated duodealer app'
70
+ ```
71
+
72
+ If you forget to set your keys or redirect uri above, you will find them in the duodealer_app initializer at: `/config/initializers/duodealer_app.rb`.
73
+
74
+ We recommend adding a gem or utilizing environment variables (`.env`) to handle your keys before releasing your app. [Learn more about using environment variables.](https://www.honeybadger.io/blog/ruby-guide-environment-variables/)
75
+
76
+ 6. Deploy your app
77
+ ---------
78
+
79
+ Once you've generated your app, push it into your Heroku environment to see it up and running:
80
+ ```sh
81
+ $ git push heroku
82
+ $ heroku run rake db:migrate
83
+ ```
84
+
85
+ 7. Install the App!
86
+ -------------------
87
+
88
+ Ensure you have created a [development store](https://help.duodealer.com/en/api/getting-started/making-your-first-request#create-a-development-store) using the Duo Dealer Partner Dashboard. If you don't already have one, [create one by following these instructions](https://help.duodealer.com/en/api/getting-started/making-your-first-request#create-a-development-store).
89
+
90
+ ##### Note: The following step will cause your store to become `transfer-disabled.` Read more about store transfer and why it's important [here](https://help.duodealer.com/en/api/guides/store-transfers#transfer-disabled-stores). This is an irreversible change, so be sure you don't plan to transfer this store to a merchant.
91
+
92
+ Install the app onto your new development store using the Partner Dashboard. Log in to your account, visit the apps page, click the app you created earlier, and looking for the `Test your app` instructions where you can select a store to install your app on.
93
+
94
+ ![Installing an app on the partners dashboard dropdown](/docs/install-on-dev-shop.png)
95
+
96
+ ### OR
97
+
98
+ ![Installing an app on the partners dashboard card](/docs/test-your-app.png)
99
+
100
+ 8. Great work!
101
+ -------------------
102
+
103
+ You're done creating your first app on Duo Dealer. Keep going and learn more.
data/docs/Releasing.md ADDED
@@ -0,0 +1,17 @@
1
+ Releasing DuodealerApp
2
+
3
+ 1. Check the Semantic Versioning page for info on how to version the new release: http://semver.org
4
+ 2. Create a pull request with the following changes:
5
+ * Update the version of DuodealerApp in lib/duodealer_app/version.rb
6
+ * Add a CHANGELOG entry for the new release with the date
7
+ * Change the title of the PR to something like: "Packaging for release X.Y.Z"
8
+ 3. Merge your pull request
9
+ 4. Pull from master so you have the latest version of the duodealer_app
10
+ 5. Tag the HEAD with the version (Leave REV blank for HEAD or provide a SHA)
11
+ $ git tag vX.Y.Z
12
+ 6. Push out your tags
13
+ $ git push --tags
14
+ 7. Use Shipit to build and push the gem
15
+
16
+ If you see an error like 'You need to create the vX.Y.X tag first', clear GIT
17
+ cache in Shipit settings
@@ -0,0 +1,16 @@
1
+ Troubleshooting Duo Dealer App
2
+ ===========
3
+
4
+ ### Generator duodealer_app:install hangs
5
+
6
+ Rails uses spring by default to speed up development. To run the generator, spring has to be stopped:
7
+
8
+ ```sh
9
+ $ bundle exec spring stop
10
+ ```
11
+
12
+ Run duodealer_app generator again.
13
+
14
+ ### App installation fails with 'The page you’re looking for could not be found' if the app was installed before
15
+
16
+ This issue can occur when the session (the model you set as `DuodealerApp::SessionRepository.storage`) isn't deleted when the user uninstalls your app. A possible fix for this is listening to the `app/uninstalled` webhook and deleting the corresponding session in the webhook handler.
Binary file
Binary file
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push(File.expand_path("../lib", __FILE__))
4
+ require "duodealer_app/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "duodealer_app"
8
+ s.version = DuodealerApp::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.author = "Eric Raio"
11
+ s.summary = "This gem is used to get quickly started with the Duo Dealer API"
12
+
13
+ s.required_ruby_version = ">= 2.3.1"
14
+
15
+ s.add_runtime_dependency("browser_sniffer", "~> 1.1.3")
16
+ s.add_runtime_dependency("rails", "> 5.2.1")
17
+ s.add_runtime_dependency("duodealer_api", "~> 1.0")
18
+ s.add_runtime_dependency("omniauth-duodealer-oauth2", "~> 1.0.0")
19
+
20
+ s.add_development_dependency("rake")
21
+ s.add_development_dependency("byebug")
22
+ s.add_development_dependency("pry")
23
+ s.add_development_dependency("pry-nav")
24
+ s.add_development_dependency("pry-stack_explorer")
25
+ s.add_development_dependency("rb-readline")
26
+ s.add_development_dependency("sqlite3", "~> 1.4")
27
+ s.add_development_dependency("minitest")
28
+ s.add_development_dependency("mocha")
29
+ s.add_development_dependency("webmock")
30
+
31
+ s.files = %x(git ls-files).split("\n").reject { |f| f.match(%r{^(test|example)/}) }
32
+ s.test_files = %x(git ls-files -- {test}/*).split("\n")
33
+ s.require_paths = ["lib"]
34
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
Binary file
data/karma.conf.js ADDED
@@ -0,0 +1,44 @@
1
+ const karmaReporters = ['mocha-clean'];
2
+
3
+ function isDebug(argument) {
4
+ return argument === '--debug';
5
+ }
6
+
7
+ module.exports = function(config) {
8
+ config.set({
9
+ mode: 'development',
10
+ basePath: '',
11
+ frameworks: ['mocha-debug', 'mocha', 'chai-sinon'],
12
+ files: [
13
+ 'app/assets/javascripts/**/*.js',
14
+ 'test/javascripts/**/*test.js',
15
+ ],
16
+ exclude: [
17
+ // Exclude JS files that create 'DOMContentLoaded' event listeners
18
+ 'app/assets/javascripts/**/redirect.js',
19
+ 'app/assets/javascripts/**/storage_access_redirect.js',
20
+ 'app/assets/javascripts/**/top_level_interaction.js',
21
+ 'app/assets/javascripts/**/partition_cookies.js',
22
+ ],
23
+ mochaReporter: {
24
+ output: 'autowatch',
25
+ },
26
+ preprocessors: {
27
+ 'test/javascripts/**/*test.js': ['webpack'],
28
+ },
29
+ webpack: {},
30
+ reporters: karmaReporters,
31
+ port: 9876,
32
+ colors: true,
33
+ logLevel: config.LOG_WARN,
34
+ autoWatch: false,
35
+ browsers: ['ChromeHeadless'],
36
+ singleRun: true,
37
+ client: {
38
+ mocha: {
39
+ ui: 'tdd',
40
+ grep: config.grep,
41
+ },
42
+ },
43
+ });
44
+ };
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "duodealer_app/version"
4
+
5
+ # deps
6
+ require "duodealer_api"
7
+ require "omniauth-duodealer-oauth2"
8
+
9
+ module DuodealerApp
10
+ def self.rails6?
11
+ Rails::VERSION::MAJOR >= 6
12
+ end
13
+
14
+ def self.use_webpacker?
15
+ rails6? &&
16
+ defined?(Webpacker) == "constant" &&
17
+ !configuration.disable_webpacker
18
+ end
19
+
20
+ # config
21
+ require "duodealer_app/configuration"
22
+
23
+ # engine
24
+ require "duodealer_app/engine"
25
+
26
+ # utils
27
+ require "duodealer_app/utils"
28
+
29
+ # controller concerns
30
+ require "duodealer_app/controller_concerns/localization"
31
+ require "duodealer_app/controller_concerns/itp"
32
+ require "duodealer_app/controller_concerns/login_protection"
33
+ require "duodealer_app/controller_concerns/embedded_app"
34
+ require "duodealer_app/controller_concerns/webhook_verification"
35
+ require "duodealer_app/controller_concerns/app_proxy_verification"
36
+
37
+ # jobs
38
+ require "duodealer_app/jobs/webhooks_manager_job"
39
+ require "duodealer_app/jobs/scripttags_manager_job"
40
+
41
+ # managers
42
+ require "duodealer_app/managers/webhooks_manager"
43
+ require "duodealer_app/managers/scripttags_manager"
44
+
45
+ # middleware
46
+ require "duodealer_app/middleware/same_site_cookie_middleware"
47
+
48
+ # session
49
+ require "duodealer_app/session/storage_strategies/shop_storage_strategy"
50
+ require "duodealer_app/session/storage_strategies/user_storage_strategy"
51
+ require "duodealer_app/session/session_storage"
52
+ require "duodealer_app/session/session_repository"
53
+ require "duodealer_app/session/in_memory_session_store"
54
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DuodealerApp
4
+ class Configuration
5
+ # Duo Dealer App settings. These values should match the configuration
6
+ # for the app in your Duo Dealer Partners page. Change your settings in
7
+ # `config/initializers/duodealer_app.rb`
8
+ attr_accessor :application_name
9
+ attr_accessor :api_key
10
+ attr_accessor :secret
11
+ attr_accessor :old_secret
12
+ attr_accessor :scope
13
+ attr_accessor :embedded_app
14
+ alias_method :embedded_app?, :embedded_app
15
+ attr_accessor :webhooks
16
+ attr_accessor :scripttags
17
+ attr_accessor :after_authenticate_job
18
+ attr_reader :session_repository
19
+ attr_accessor :per_user_tokens
20
+ alias_method :per_user_tokens?, :per_user_tokens
21
+ attr_accessor :api_version
22
+
23
+ # customise urls
24
+ attr_accessor :root_url
25
+ attr_accessor :login_url
26
+
27
+ # customise ActiveJob queue names
28
+ attr_accessor :scripttags_manager_queue_name
29
+ attr_accessor :webhooks_manager_queue_name
30
+
31
+ # configure duodealer domain for local duodealer development
32
+ attr_accessor :duodealer_domain
33
+
34
+ # ability to have webpacker installed but not used in this gem and the generators
35
+ attr_accessor :disable_webpacker
36
+
37
+ # allow namespacing webhook jobs
38
+ attr_accessor :webhook_jobs_namespace
39
+
40
+ # allow enabling of same site none on cookies
41
+ attr_accessor :enable_same_site_none
42
+
43
+ def initialize
44
+ @root_url = "/"
45
+ @duodealer_domain = "duodealer.com"
46
+ @scripttags_manager_queue_name = Rails.application.config.active_job.queue_name
47
+ @webhooks_manager_queue_name = Rails.application.config.active_job.queue_name
48
+ @per_user_tokens = false
49
+ @disable_webpacker = ENV["DUODEALER_APP_DISABLE_WEBPACKER"].present?
50
+ end
51
+
52
+ def login_url
53
+ @login_url || File.join(@root_url, "login")
54
+ end
55
+
56
+ def session_repository=(klass)
57
+ @session_repository = klass
58
+ DuodealerApp::SessionRepository.storage = klass
59
+ end
60
+
61
+ def has_webhooks?
62
+ webhooks.present?
63
+ end
64
+
65
+ def has_scripttags?
66
+ scripttags.present?
67
+ end
68
+
69
+ def enable_same_site_none
70
+ !Rails.env.test? && (@enable_same_site_none.nil? ? embedded_app? : @enable_same_site_none)
71
+ end
72
+ end
73
+
74
+ def self.configuration
75
+ @configuration ||= Configuration.new
76
+ end
77
+
78
+ def self.configuration=(config)
79
+ @configuration = config
80
+ end
81
+
82
+ def self.configure
83
+ yield configuration
84
+ end
85
+ end