Skip to content

Commit d686c10

Browse files
Merge branch 'main' into dependabot/bundler/rexml-3.3.3
2 parents 5977b50 + 3289d78 commit d686c10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2068
-134
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ jobs:
1717
strategy:
1818
matrix:
1919
ruby:
20-
- '2.7'
21-
- '3.0'
2220
- '3.1'
2321
- '3.2'
2422
steps:
2523
- uses: actions/checkout@v4
26-
- uses: ruby/setup-ruby@v1
24+
- uses: ruby/setup-ruby@1a615958ad9d422dd932dc1d5823942ee002799f # v1.227.0
2725
with:
2826
ruby-version: ${{ matrix.ruby }}
2927
bundler-cache: true

.rubocop.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
# Disabling due to conflict with Ruby 2.7/3.1
2-
Layout/BlockAlignment:
3-
Enabled: false
1+
inherit_from: .rubocop_todo.yml
2+
43
Layout/DotPosition:
54
EnforcedStyle: trailing
65
Layout/EmptyLineAfterMagicComment:
76
Enabled: false
87
Layout/EmptyLines:
98
Enabled: false
109
Layout/LineLength:
11-
IgnoredPatterns:
10+
AllowedPatterns:
1211
- 'VCR\.use_cassette'
1312
- '(\A|\s)/.*?/'
1413
Metrics/BlockLength:
15-
ExcludedMethods: ['describe', 'context', 'before']
14+
AllowedMethods: ['describe', 'context', 'before', 'it']
1615
Metrics/MethodLength:
1716
Max: 30
1817
Metrics/ModuleLength:
@@ -28,4 +27,4 @@ Style/TrailingCommaInArguments:
2827
Style/TrailingCommaInHashLiteral:
2928
EnforcedStyleForMultiline: 'consistent_comma'
3029
AllCops:
31-
TargetRubyVersion: 2.7
30+
TargetRubyVersion: 3.1

.rubocop_todo.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2025-01-22 21:38:20 UTC using RuboCop version 1.71.0.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# This cop supports safe autocorrection (--autocorrect).
11+
# Configuration parameters: EnforcedStyleAlignWith.
12+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
13+
Layout/BlockAlignment:
14+
Exclude:
15+
- 'spec/lib/workos/session_spec.rb'
16+
17+
# Offense count: 2
18+
# This cop supports safe autocorrection (--autocorrect).
19+
Layout/EmptyLinesAroundMethodBody:
20+
Exclude:
21+
- 'lib/workos/mfa.rb'
22+
- 'lib/workos/user_management.rb'
23+
24+
# Offense count: 1
25+
# This cop supports safe autocorrection (--autocorrect).
26+
Layout/SpaceAroundMethodCallOperator:
27+
Exclude:
28+
- 'spec/lib/workos/directory_sync_spec.rb'
29+
30+
# Offense count: 1
31+
# This cop supports unsafe autocorrection (--autocorrect-all).
32+
Lint/DuplicateRequire:
33+
Exclude:
34+
- 'lib/workos/session.rb'
35+
36+
# Offense count: 3
37+
# Configuration parameters: AllowedParentClasses.
38+
Lint/MissingSuper:
39+
Exclude:
40+
- 'lib/workos/directory_group.rb'
41+
- 'lib/workos/directory_user.rb'
42+
- 'lib/workos/errors.rb'
43+
44+
# Offense count: 5
45+
# Configuration parameters: CountComments, CountAsOne.
46+
Metrics/ClassLength:
47+
Max: 624
48+
49+
# Offense count: 8
50+
# This cop supports safe autocorrection (--autocorrect).
51+
# Configuration parameters: EnforcedStyle.
52+
# SupportedStyles: separated, grouped
53+
Style/AccessorGrouping:
54+
Exclude:
55+
- 'lib/workos/errors.rb'
56+
57+
# Offense count: 34
58+
# This cop supports safe autocorrection (--autocorrect).
59+
# Configuration parameters: EnforcedStyle.
60+
# SupportedStyles: braces, no_braces
61+
Style/HashAsLastArrayItem:
62+
Exclude:
63+
- 'spec/lib/workos/directory_sync_spec.rb'
64+
- 'spec/lib/workos/event_spec.rb'
65+
- 'spec/lib/workos/organizations_spec.rb'
66+
- 'spec/lib/workos/sso_spec.rb'
67+
- 'spec/lib/workos/user_management_spec.rb'
68+
69+
# Offense count: 2
70+
# This cop supports safe autocorrection (--autocorrect).
71+
Style/KeywordParametersOrder:
72+
Exclude:
73+
- 'lib/workos/organizations.rb'
74+
75+
# Offense count: 3
76+
# This cop supports unsafe autocorrection (--autocorrect-all).
77+
# Configuration parameters: SafeForConstants.
78+
Style/RedundantFetchBlock:
79+
Exclude:
80+
- 'spec/lib/workos/cache_spec.rb'
81+
82+
# Offense count: 1
83+
# This cop supports safe autocorrection (--autocorrect).
84+
# Configuration parameters: AllowMultipleReturnValues.
85+
Style/RedundantReturn:
86+
Exclude:
87+
- 'lib/workos/directory_user.rb'
88+
89+
# Offense count: 2
90+
# This cop supports unsafe autocorrection (--autocorrect-all).
91+
Style/SlicingWithRange:
92+
Exclude:
93+
- 'lib/workos/deprecated_hash_wrapper.rb'
94+
- 'lib/workos/session.rb'

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2
1+
3.1.4

Gemfile.lock

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
PATH
22
remote: .
33
specs:
4-
workos (5.3.0)
4+
workos (5.16.0)
5+
encryptor (~> 3.0)
6+
jwt (~> 2.8)
57

68
GEM
79
remote: https://rubygems.org/
810
specs:
911
addressable (2.8.6)
1012
public_suffix (>= 2.0.2, < 6.0)
1113
ast (2.4.2)
14+
base64 (0.2.0)
1215
bigdecimal (3.1.7)
1316
crack (1.0.0)
1417
bigdecimal
1518
rexml
1619
diff-lcs (1.5.1)
20+
encryptor (3.0.0)
1721
hashdiff (1.1.0)
18-
parallel (1.24.0)
19-
parser (3.3.0.5)
22+
json (2.9.1)
23+
jwt (2.10.1)
24+
base64
25+
language_server-protocol (3.17.0.3)
26+
parallel (1.26.3)
27+
parser (3.3.7.0)
2028
ast (~> 2.4.1)
2129
racc
2230
public_suffix (5.0.4)
23-
racc (1.7.3)
31+
racc (1.8.1)
2432
rainbow (3.1.1)
25-
regexp_parser (2.9.0)
33+
regexp_parser (2.10.0)
2634
rexml (3.3.3)
2735
strscan
2836
rspec (3.9.0)
@@ -38,20 +46,23 @@ GEM
3846
diff-lcs (>= 1.2.0, < 2.0)
3947
rspec-support (~> 3.9.0)
4048
rspec-support (3.9.4)
41-
rubocop (0.93.1)
49+
rubocop (1.71.0)
50+
json (~> 2.3)
51+
language_server-protocol (>= 3.17.0)
4252
parallel (~> 1.10)
43-
parser (>= 2.7.1.5)
53+
parser (>= 3.3.0.2)
4454
rainbow (>= 2.2.2, < 4.0)
45-
regexp_parser (>= 1.8)
46-
rexml
47-
rubocop-ast (>= 0.6.0)
55+
regexp_parser (>= 2.9.3, < 3.0)
56+
rubocop-ast (>= 1.36.2, < 2.0)
4857
ruby-progressbar (~> 1.7)
49-
unicode-display_width (>= 1.4.0, < 2.0)
50-
rubocop-ast (1.31.2)
51-
parser (>= 3.3.0.4)
58+
unicode-display_width (>= 2.4.0, < 4.0)
59+
rubocop-ast (1.37.0)
60+
parser (>= 3.3.1.0)
5261
ruby-progressbar (1.13.0)
5362
strscan (3.1.0)
54-
unicode-display_width (1.8.0)
63+
unicode-display_width (3.1.4)
64+
unicode-emoji (~> 4.0, >= 4.0.4)
65+
unicode-emoji (4.0.4)
5566
vcr (5.0.0)
5667
webmock (3.23.0)
5768
addressable (>= 2.8.0)
@@ -64,7 +75,7 @@ PLATFORMS
6475
DEPENDENCIES
6576
bundler (>= 2.0.1)
6677
rspec (~> 3.9.0)
67-
rubocop (~> 0.77)
78+
rubocop (~> 1.71)
6879
vcr (~> 5.0.0)
6980
webmock
7081
workos!

lib/workos.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def self.key
4545
autoload :AuthenticationFactorAndChallenge, 'workos/authentication_factor_and_challenge'
4646
autoload :AuthenticationResponse, 'workos/authentication_response'
4747
autoload :AuditLogs, 'workos/audit_logs'
48+
autoload :Cache, 'workos/cache'
4849
autoload :Challenge, 'workos/challenge'
4950
autoload :Client, 'workos/client'
5051
autoload :Connection, 'workos/connection'
@@ -71,6 +72,8 @@ def self.key
7172
autoload :Profile, 'workos/profile'
7273
autoload :ProfileAndToken, 'workos/profile_and_token'
7374
autoload :RefreshAuthenticationResponse, 'workos/refresh_authentication_response'
75+
autoload :Role, 'workos/role'
76+
autoload :Session, 'workos/session'
7477
autoload :SSO, 'workos/sso'
7578
autoload :Types, 'workos/types'
7679
autoload :User, 'workos/user'
@@ -80,11 +83,13 @@ def self.key
8083
autoload :VerifyChallenge, 'workos/verify_challenge'
8184
autoload :Webhook, 'workos/webhook'
8285
autoload :Webhooks, 'workos/webhooks'
86+
autoload :Widgets, 'workos/widgets'
8387

8488
# Errors
8589
autoload :APIError, 'workos/errors'
8690
autoload :AuthenticationError, 'workos/errors'
8791
autoload :InvalidRequestError, 'workos/errors'
92+
autoload :ForbiddenRequestError, 'workos/errors'
8893
autoload :SignatureVerificationError, 'workos/errors'
8994
autoload :TimeoutError, 'workos/errors'
9095
autoload :NotFoundError, 'workos/errors'

lib/workos/authentication_response.rb

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,39 @@ module WorkOS
66
class AuthenticationResponse
77
include HashProvider
88

9-
attr_accessor :user, :organization_id, :impersonator, :access_token, :refresh_token
9+
attr_accessor :user,
10+
:organization_id,
11+
:impersonator,
12+
:access_token,
13+
:refresh_token,
14+
:authentication_method,
15+
:sealed_session
1016

11-
def initialize(authentication_response_json)
17+
# rubocop:disable Metrics/AbcSize
18+
def initialize(authentication_response_json, session = nil)
1219
json = JSON.parse(authentication_response_json, symbolize_names: true)
20+
@access_token = json[:access_token]
21+
@refresh_token = json[:refresh_token]
1322
@user = WorkOS::User.new(json[:user].to_json)
1423
@organization_id = json[:organization_id]
1524
@impersonator =
1625
if (impersonator_json = json[:impersonator])
1726
Impersonator.new(email: impersonator_json[:email],
1827
reason: impersonator_json[:reason],)
1928
end
20-
@access_token = json[:access_token]
21-
@refresh_token = json[:refresh_token]
29+
@authentication_method = json[:authentication_method]
30+
@sealed_session =
31+
if session && session[:seal_session]
32+
WorkOS::Session.seal_data({
33+
access_token: access_token,
34+
refresh_token: refresh_token,
35+
user: user.to_json,
36+
organization_id: organization_id,
37+
impersonator: impersonator.to_json,
38+
}, session[:cookie_password],)
39+
end
2240
end
41+
# rubocop:enable Metrics/AbcSize
2342

2443
def to_json(*)
2544
{
@@ -28,6 +47,8 @@ def to_json(*)
2847
impersonator: impersonator.to_json,
2948
access_token: access_token,
3049
refresh_token: refresh_token,
50+
authentication_method: authentication_method,
51+
sealed_session: sealed_session,
3152
}
3253
end
3354
end

0 commit comments

Comments
 (0)