sinch_auth 1.0
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 +7 -0
- data/lib/sinch_auth.rb +21 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: bdfc4a6b94c086f4ead39081287a96261bbb0fa3
|
|
4
|
+
data.tar.gz: 9784211ab127adb4585edf77750d23fd625d527c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8b4c82d928b5df95062a029618f45325d8b0d2718a84df6a90feb546cefcedb193b700e7be0e1acaefae81a5b12e4f12837f7d1e9d527567c5c465d7180706cd
|
|
7
|
+
data.tar.gz: 272220f5b27cc0562a11c348c7b9bcc69b6c63fe8f587604220b6acfff7f6893444c85f72214842dd1e65f79145bdee2537bbe723bceb92b25fc40b29d33528c
|
data/lib/sinch_auth.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "time"
|
|
2
|
+
require "json"
|
|
3
|
+
require "openssl"
|
|
4
|
+
require "base64"
|
|
5
|
+
|
|
6
|
+
class SinchAuth
|
|
7
|
+
def get_auth_ticket(username, expires_in, key, secret)
|
|
8
|
+
user_ticket = {
|
|
9
|
+
"identity" => {"type" => "username", "endpoint" => username},
|
|
10
|
+
"expiresIn" => expires_in,
|
|
11
|
+
"applicationKey" => key,
|
|
12
|
+
"created" => Time.now.utc.iso8601
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
user_ticket_json = user_ticket.to_json.gsub(/\s+/, "")
|
|
16
|
+
user_ticket_base64 = Base64.encode64(user_ticket_json).strip
|
|
17
|
+
digest = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), Base64.decode64(secret), user_ticket_json).strip
|
|
18
|
+
signature = Base64.encode64(digest).strip
|
|
19
|
+
return (user_ticket_base64 + ':' + signature).gsub(/\s+/, "")
|
|
20
|
+
end
|
|
21
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sinch_auth
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '1.0'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jordan Hamel
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2010-04-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Generate an authentication token to pass to the Sinch Javascript SDK.
|
|
14
|
+
Once authenticated, you can use the Sinch Javascript SDK to make browser-browser
|
|
15
|
+
calls, browser-phone calls, and send instant messages.
|
|
16
|
+
email: jo.mravca@gmail.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- lib/sinch_auth.rb
|
|
22
|
+
homepage: https://www.sinch.com/docs/javascript/user-guide/
|
|
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
|
+
rubyforge_project:
|
|
42
|
+
rubygems_version: 2.4.2
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Generate an authentication token to pass to the Sinch Javascript SDK.
|
|
46
|
+
test_files: []
|