smoothcode 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8e7e0fae66b76e618b07a4e4f3d06a9161cb92f44246df839d86270a4f32c54d
4
+ data.tar.gz: dfe44d8f39efb6a9eb76fa5b382223155010f6fed96aa5cd220d52f3c6baa0c3
5
+ SHA512:
6
+ metadata.gz: c97fecb2c4f4ebe7fd6a44b9a35c66659d29de61f92ed73b7f52e88fa96addf4c36bd9229ec3d619e319cc43f2fdd25a96b7d74f00d110e54b43fc5e91849132
7
+ data.tar.gz: 8807f300371134157d93ca7d89392e3a23c08539b844999f53b9725da2e8bf071e504788266f3915aa5341375b8f89c4afcb71a7309ce9543ae44a7486e8d747
@@ -0,0 +1,17 @@
1
+ require_relative 'utils'
2
+ require 'json'
3
+
4
+ class SmoothCodeAuth
5
+ def initialize(request_hmac, client_secret)
6
+ @request_hmac = request_hmac
7
+ @client_secret = client_secret
8
+ end
9
+
10
+ def dashboard_request?(shop)
11
+ generate_hmac(@client_secret, shop) == @request_hmac
12
+ end
13
+
14
+ def webhook_request?(webhook_data)
15
+ generate_hmac(@client_secret, webhook_data.to_json) == @request_hmac
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'openssl'
2
+
3
+ def generate_hmac(secret, base_string, digest_alg = 'sha256')
4
+ digest = OpenSSL::Digest.new(digest_alg)
5
+
6
+ OpenSSL::HMAC.hexdigest(digest, secret, base_string)
7
+ end
data/lib/smoothcode.rb ADDED
@@ -0,0 +1 @@
1
+ require 'smoothcode/auth'
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smoothcode
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - SmoothCode
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client to interact with SmoothCode
14
+ email: hello@smoothcode.io
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/smoothcode.rb
20
+ - lib/smoothcode/auth.rb
21
+ - lib/smoothcode/utils.rb
22
+ homepage: https://github.com/Smooth-Code-IO/smoothcode-client-ruby
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.0.3.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Ruby client to interact with SmoothCode
45
+ test_files: []