Module: RubyNative
- Defined in:
- lib/ruby_native.rb,
lib/ruby_native/cli.rb,
lib/ruby_native/engine.rb,
lib/ruby_native/helper.rb,
lib/ruby_native/version.rb,
lib/ruby_native/cli/login.rb,
lib/ruby_native/iap/event.rb,
lib/ruby_native/cli/deploy.rb,
lib/ruby_native/cli/preview.rb,
lib/ruby_native/iap/decodable.rb,
lib/ruby_native/iap/verifiable.rb,
lib/ruby_native/native_version.rb,
lib/ruby_native/cli/credentials.rb,
lib/ruby_native/inertia_support.rb,
lib/ruby_native/iap/normalizable.rb,
lib/ruby_native/native_detection.rb,
lib/ruby_native/oauth_middleware.rb,
lib/generators/ruby_native/iap_generator.rb,
lib/ruby_native/tunnel_cookie_middleware.rb,
app/models/ruby_native/iap/purchase_intent.rb,
lib/ruby_native/screenshots/sign_in_helper.rb,
app/controllers/ruby_native/aasa_controller.rb,
lib/ruby_native/iap/apple_webhook_processor.rb,
lib/generators/ruby_native/install_generator.rb,
app/controllers/ruby_native/config_controller.rb,
app/controllers/ruby_native/auth/start_controller.rb,
app/controllers/ruby_native/iap/restores_controller.rb,
app/controllers/ruby_native/push/devices_controller.rb,
app/controllers/ruby_native/auth/sessions_controller.rb,
app/controllers/ruby_native/iap/purchases_controller.rb,
app/controllers/ruby_native/webhooks/apple_controller.rb,
app/controllers/ruby_native/iap/completions_controller.rb,
app/controllers/ruby_native/screenshots/sessions_controller.rb
Defined Under Namespace
Modules: Auth, Generators, Helper, IAP, InertiaSupport, NativeDetection, Push, Screenshots, Webhooks
Classes: AasaController, CLI, ConfigController, Engine, NativeVersion, OAuthMiddleware, TunnelCookieMiddleware
Constant Summary
collapse
- VERSION =
"0.10.3"
Class Method Summary
collapse
Class Method Details
.backfill_tab_icons ⇒ Object
Mirrors per-platform ‘icons:` into the legacy flat `icon:` field so native binaries that only read `tab.icon` keep rendering an icon. Explicit `icon:` wins; otherwise falls back to `icons.ios`, then `icons.android`.
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/ruby_native.rb', line 51
def self.backfill_tab_icons
Array(self.config[:tabs]).each do |tab|
next unless tab.is_a?(Hash)
icons = tab[:icons]
next unless icons.is_a?(Hash)
tab[:icon] ||= icons[:ios] || icons[:android]
end
end
|
24
25
26
|
# File 'lib/ruby_native.rb', line 24
def self.configure
yield self
end
|
.fire_subscription_callbacks(event) ⇒ Object
32
33
34
|
# File 'lib/ruby_native.rb', line 32
def self.fire_subscription_callbacks(event)
subscription_callbacks.each { |cb| cb.call(event) }
end
|
.load_config ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/ruby_native.rb', line 36
def self.load_config
path = Rails.root.join("config", "ruby_native.yml")
return unless path.exist?
self.config = YAML.load_file(path).deep_symbolize_keys
self.config[:app] ||= {}
self.config[:app][:entry_path] ||= self.config.dig(:tabs, 0, :path) || "/"
self.config[:auth] ||= {}
normalize_oauth_paths
backfill_tab_icons
end
|
.normalize_oauth_paths ⇒ Object
‘auth.oauth_paths` must list only OAuth authorize paths, never their callbacks. The native app treats every listed path as a sign-in trigger and derives the provider from the last path segment, so a callback entry like “/auth/google/callback” would launch a bogus flow for a provider named “callback” and send sign-in into a loop. The callback round-trip is handled automatically by OAuthMiddleware’s tracking cookie, so it never needs listing. Drop any entry that is the “/callback” child of another listed path and warn, so a copied-in callback can’t break native sign-in.
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/ruby_native.rb', line 70
def self.normalize_oauth_paths
paths = Array(self.config.dig(:auth, :oauth_paths))
callbacks = paths.select { |path| paths.any? { |start| path == "#{start}/callback" } }
return if callbacks.empty?
Rails.logger.warn(
"[RubyNative] Ignoring OAuth callback path(s) in config/ruby_native.yml " \
"(#{callbacks.join(", ")}). List only the authorize path; callbacks are handled automatically."
)
self.config[:auth][:oauth_paths] = paths - callbacks
end
|
.on_subscription_change(&block) ⇒ Object
28
29
30
|
# File 'lib/ruby_native.rb', line 28
def self.on_subscription_change(&block)
subscription_callbacks << block
end
|