stytch 3.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stytch/sessions.rb +8 -2
- data/lib/stytch/users.rb +24 -0
- data/lib/stytch/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc4550a480f46589fd16edc9445850c3b291a1972a5715a00dccab129df2595f
|
4
|
+
data.tar.gz: b18030ff8be340da133c636ff137fb5b60c727d09b5132a3e76148144d6aadee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bde5b7238e9e3f3e83a341e619ad0fe0b02f5902a7740f42b0fea42a636baaadd559c931b28c9df59d534ee89de0df62e48df44e6627ef4a9a280a16b073dea7
|
7
|
+
data.tar.gz: f713601765602a2376a32cb13a63058e337a0648aa9c28f8d0591d5062e7871a812832620c0607524ae34fc56d6833df75420397ffd66a6b99241cee8b9b9bc5
|
data/lib/stytch/sessions.rb
CHANGED
@@ -88,6 +88,12 @@ module Stytch
|
|
88
88
|
session_duration_minutes: session_duration_minutes,
|
89
89
|
)
|
90
90
|
end
|
91
|
+
rescue StandardError
|
92
|
+
# JWT could not be verified locally. Check with the Stytch API.
|
93
|
+
return authenticate(
|
94
|
+
session_jwt: session_jwt,
|
95
|
+
session_duration_minutes: session_duration_minutes,
|
96
|
+
)
|
91
97
|
end
|
92
98
|
|
93
99
|
# Parse a JWT and verify the signature locally (without calling /authenticate in the API)
|
@@ -97,7 +103,7 @@ module Stytch
|
|
97
103
|
def authenticate_jwt_local(session_jwt)
|
98
104
|
issuer = "stytch.com/" + @project_id
|
99
105
|
begin
|
100
|
-
decoded_token = JWT.decode session_jwt, nil, true,
|
106
|
+
decoded_token = JWT.decode session_jwt, nil, true,
|
101
107
|
{ jwks: @jwks_loader, iss: issuer, verify_iss: true, aud: @project_id, verify_aud: true, algorithms: ["RS256"]}
|
102
108
|
return decoded_token[0]
|
103
109
|
rescue JWT::InvalidIssuerError
|
@@ -114,7 +120,7 @@ module Stytch
|
|
114
120
|
def marshal_jwt_into_session(jwt)
|
115
121
|
stytch_claim = "https://stytch.com/session"
|
116
122
|
return {
|
117
|
-
"session_id" => jwt["
|
123
|
+
"session_id" => jwt[stytch_claim]["id"],
|
118
124
|
"user_id" => jwt["sub"],
|
119
125
|
"started_at" => jwt[stytch_claim]["started_at"],
|
120
126
|
"last_accessed_at" => jwt[stytch_claim]["last_accessed_at"],
|
data/lib/stytch/users.rb
CHANGED
@@ -12,6 +12,30 @@ module Stytch
|
|
12
12
|
@connection = connection
|
13
13
|
end
|
14
14
|
|
15
|
+
def search(query, limit: 100, cursor: nil)
|
16
|
+
request = {
|
17
|
+
query: query,
|
18
|
+
limit: limit
|
19
|
+
}
|
20
|
+
request[:cursor] = cursor if cursor
|
21
|
+
post_request("#{PATH}/search", request)
|
22
|
+
end
|
23
|
+
|
24
|
+
def search_all(query, limit: 100)
|
25
|
+
Enumerator.new do |enum|
|
26
|
+
cursor = nil
|
27
|
+
loop do
|
28
|
+
resp = search(query, limit: limit, cursor: cursor)
|
29
|
+
resp['results'].each do |user|
|
30
|
+
enum << user
|
31
|
+
end
|
32
|
+
|
33
|
+
cursor = resp['results_metadata']['next_cursor']
|
34
|
+
break if cursor.nil?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
15
39
|
def get(user_id:)
|
16
40
|
get_request("#{PATH}/#{user_id}")
|
17
41
|
end
|
data/lib/stytch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stytch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- stytch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: 1.13.0
|
81
|
-
description:
|
81
|
+
description:
|
82
82
|
email:
|
83
83
|
- support@stytch.com
|
84
84
|
executables: []
|
@@ -118,7 +118,7 @@ licenses:
|
|
118
118
|
metadata:
|
119
119
|
homepage_uri: https://stytch.com
|
120
120
|
source_code_uri: https://github.com/stytchauth/stytch-ruby
|
121
|
-
post_install_message:
|
121
|
+
post_install_message:
|
122
122
|
rdoc_options: []
|
123
123
|
require_paths:
|
124
124
|
- lib
|
@@ -133,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
137
|
-
signing_key:
|
136
|
+
rubygems_version: 3.1.6
|
137
|
+
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Stytch Ruby Gem
|
140
140
|
test_files: []
|