workos 0.3.2 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2dc4e5ea1ade6d908e794c3b639b798c7e108c6d0f4b57b322943dd8f2385fb
4
- data.tar.gz: b7aa22e7dcfe183574eb8db29990ba1427751b746aaf952f74d03be3a0ab1fb4
3
+ metadata.gz: 56cf52cb4a104516de13499b34f7c6f36a102c0c2af1bf6934e963579f27a596
4
+ data.tar.gz: 45dee16f5ed91f99133e7f974d607e76effa73e0d0d3b271fd7e9756e72055c5
5
5
  SHA512:
6
- metadata.gz: 7563e3b8585a1dce014b44b0096b9f9b7cb8716d95b0328e0e26690e8ef4e588464ecf1333d6f18aa6720649be2a4f3b334ec58d0be43b95e466f1cdfece73c3
7
- data.tar.gz: 3a1de478d8e10c8bf78a7c1b880df0ae01858562394c82161dbf36fb9bb2e8de51d0e6166a5556af4a715d8dd26d300b2bde4aadb47a3c06560be88687c532e8
6
+ metadata.gz: 00d537dcaf496aa3b8244f72b04137496fef5613100ec61d32f837f20f42f6f5ed20180d41eb560dd6bfe6491810f07d4f4401d0e0cacc121c991b5c74d80676
7
+ data.tar.gz: 843f4d8558e3412ed6fa3becaf6c7717a301121baa7fd6edb292184518d335b2f616f024fdf13a9adf8659110aae3411744525be76f25f1bf238dd05acf14d99
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.3.2)
4
+ workos (0.5.0)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -10,17 +10,16 @@ GEM
10
10
  addressable (2.7.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
12
  ast (2.4.0)
13
- codecov (0.1.16)
13
+ codecov (0.2.8)
14
14
  json
15
15
  simplecov
16
- url
17
16
  crack (0.4.3)
18
17
  safe_yaml (~> 1.0.0)
19
18
  diff-lcs (1.3)
20
19
  docile (1.3.2)
21
20
  hashdiff (1.0.0)
22
21
  jaro_winkler (1.5.4)
23
- json (2.3.0)
22
+ json (2.3.1)
24
23
  parallel (1.19.1)
25
24
  parser (2.7.0.0)
26
25
  ast (~> 2.4.0)
@@ -49,17 +48,15 @@ GEM
49
48
  unicode-display_width (>= 1.4.0, < 1.7)
50
49
  ruby-progressbar (1.10.1)
51
50
  safe_yaml (1.0.5)
52
- simplecov (0.17.1)
51
+ simplecov (0.19.0)
53
52
  docile (~> 1.1)
54
- json (>= 1.8, < 3)
55
- simplecov-html (~> 0.10.0)
56
- simplecov-html (0.10.2)
53
+ simplecov-html (~> 0.11)
54
+ simplecov-html (0.12.2)
57
55
  sorbet (0.5.5560)
58
56
  sorbet-static (= 0.5.5560)
59
- sorbet-runtime (0.5.5657)
57
+ sorbet-runtime (0.5.5877)
60
58
  sorbet-static (0.5.5560-universal-darwin-14)
61
59
  unicode-display_width (1.6.0)
62
- url (0.3.2)
63
60
  vcr (5.0.0)
64
61
  webmock (3.7.6)
65
62
  addressable (>= 2.3.6)
@@ -72,7 +69,7 @@ PLATFORMS
72
69
 
73
70
  DEPENDENCIES
74
71
  bundler (>= 2.0.1)
75
- codecov (~> 0.1.16)
72
+ codecov (~> 0.2.8)
76
73
  rake
77
74
  rspec (~> 3.9.0)
78
75
  rubocop (~> 0.77)
data/README.md CHANGED
@@ -157,6 +157,13 @@ This method will return an instance of a `WorkOS::Profile` with the following at
157
157
  @connection_type="OktaSAML",
158
158
  @last_name="Demo",
159
159
  @idp_id="00u1klkowm8EGah2H357",
160
+ @raw_attributes={
161
+ :id=>"prof_01DRA1XNSJDZ19A31F183ECQW5",
162
+ :email=>"demo@workos-okta.com",
163
+ :first_name=>"WorkOS",
164
+ :last_name=>"Demo",
165
+ :idp_id=>"00u1klkowm8EGah2H357"
166
+ },
160
167
  >
161
168
  ```
162
169
 
@@ -57,6 +57,54 @@ module WorkOS
57
57
 
58
58
  execute_request(request: request)
59
59
  end
60
+
61
+ # Retrieve Audit Trail events.
62
+ #
63
+ # @param [Hash] options An options hash
64
+ # @option options [String] before Event ID to look before
65
+ # @option options [String] after Event ID to look after
66
+ # @option options [Integer] limit Number of Events to return
67
+ # @option options [Array<String>] group List of Groups to filter for
68
+ # @option options [Array<String>] action List of Actions to filter for
69
+ # @option options [Array<String>] action_type List of Action Types to
70
+ # filter for
71
+ # @option options [Array<String>] actor_name List of Actor Name to filter
72
+ # for
73
+ # @option options [Array<String>] actor_id List of Actor IDs to filter for
74
+ # @option options [Array<String>] target_name List of Target Names to
75
+ # filter for
76
+ # @option options [Array<String>] target_id List of Target IDs to filter
77
+ # for
78
+ # @option options [String] occurred_at ISO-8601 datetime of when an event
79
+ # occurred
80
+ # @option options [String] occurred_at_gt ISO-8601 datetime of when an
81
+ # event occurred after
82
+ # @option options [String] occurred_at_gte ISO-8601 datetime of when an
83
+ # event occurred at or after
84
+ # @option options [String] occurred_at_lt ISO-8601 datetime of when an
85
+ # event occurred before
86
+ # @option options [String] ISO-8601 datetime of when an event occured at
87
+ # or before
88
+ # @option options [String] search Keyword search
89
+ #
90
+ # @return [Array<Hash>]
91
+ sig do
92
+ params(
93
+ options: T::Hash[Symbol, String],
94
+ ).returns(T::Array[T::Hash[String, T.nilable(String)]])
95
+ end
96
+
97
+ def get_events(options = {})
98
+ response = execute_request(
99
+ request: get_request(
100
+ path: '/events',
101
+ auth: true,
102
+ params: options,
103
+ ),
104
+ )
105
+
106
+ JSON.parse(response.body)['data']
107
+ end
60
108
  end
61
109
  end
62
110
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  # typed: true
3
3
 
4
+ require 'net/http'
5
+
4
6
  module WorkOS
5
7
  # The Directory Sync module provides convenience methods for working with the
6
8
  # WorkOS Directory Sync platform. You'll need a valid API key and to have
@@ -14,7 +14,7 @@ module WorkOS
14
14
 
15
15
  sig { returns(String) }
16
16
  attr_accessor :id, :email, :first_name, :last_name,
17
- :connection_type, :idp_id
17
+ :connection_type, :idp_id, :raw_attributes
18
18
 
19
19
  sig { params(profile_json: String).void }
20
20
  def initialize(profile_json)
@@ -22,10 +22,11 @@ module WorkOS
22
22
 
23
23
  @id = T.let(raw.id, String)
24
24
  @email = T.let(raw.email, String)
25
- @first_name = T.let(raw.first_name, String)
26
- @last_name = T.let(raw.last_name, String)
25
+ @first_name = raw.first_name
26
+ @last_name = raw.last_name
27
27
  @connection_type = T.let(raw.connection_type, String)
28
- @idp_id = T.let(raw.idp_id, String)
28
+ @idp_id = raw.idp_id
29
+ @raw_attributes = raw.raw_attributes
29
30
  end
30
31
 
31
32
  sig { returns(String) }
@@ -41,11 +42,13 @@ module WorkOS
41
42
  last_name: last_name,
42
43
  connection_type: connection_type,
43
44
  idp_id: idp_id,
45
+ raw_attributes: raw_attributes,
44
46
  }
45
47
  end
46
48
 
47
49
  private
48
50
 
51
+ # rubocop:disable Metrics/AbcSize
49
52
  sig { params(json_string: String).returns(WorkOS::Types::ProfileStruct) }
50
53
  def parse_json(json_string)
51
54
  hash = JSON.parse(json_string, symbolize_names: true)
@@ -57,7 +60,9 @@ module WorkOS
57
60
  last_name: hash[:profile][:last_name],
58
61
  connection_type: hash[:profile][:connection_type],
59
62
  idp_id: hash[:profile][:idp_id],
63
+ raw_attributes: hash[:profile][:raw_attributes],
60
64
  )
61
65
  end
66
+ # rubocop:enable Metrics/AbcSize
62
67
  end
63
68
  end
@@ -40,7 +40,7 @@ module WorkOS
40
40
  # redirect_uri: 'https://workos.com/callback',
41
41
  # state: {
42
42
  # next_page: '/docs'
43
- # }
43
+ # }.to_s
44
44
  # )
45
45
  #
46
46
  # => "https://api.workos.com/sso/authorize?domain=acme.com" \
@@ -8,10 +8,11 @@ module WorkOS
8
8
  class ProfileStruct < T::Struct
9
9
  const :id, String
10
10
  const :email, String
11
- const :first_name, String
12
- const :last_name, String
11
+ const :first_name, T.nilable(String)
12
+ const :last_name, T.nilable(String)
13
13
  const :connection_type, String
14
- const :idp_id, String
14
+ const :idp_id, T.nilable(String)
15
+ const :raw_attributes, T::Hash[Symbol, Object]
15
16
  end
16
17
  end
17
18
  end
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '0.3.2'
5
+ VERSION = '0.5.0'
6
6
  end
@@ -137,4 +137,16 @@ describe WorkOS::AuditTrail do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ describe '.get_events' do
142
+ context 'with no options' do
143
+ it 'returns events' do
144
+ VCR.use_cassette('audit_trail/get_events') do
145
+ events = described_class.get_events
146
+
147
+ expect(events.size).to eq(2)
148
+ end
149
+ end
150
+ end
151
+ end
140
152
  end
@@ -161,6 +161,24 @@ describe WorkOS::SSO do
161
161
  it 'returns a WorkOS::Profile' do
162
162
  profile = described_class.profile(**args)
163
163
  expect(profile).to be_a(WorkOS::Profile)
164
+
165
+ expectation = {
166
+ connection_type: 'OktaSAML',
167
+ email: 'demo@workos-okta.com',
168
+ first_name: 'WorkOS',
169
+ id: 'prof_01DRA1XNSJDZ19A31F183ECQW5',
170
+ idp_id: '00u1klkowm8EGah2H357',
171
+ last_name: 'Demo',
172
+ raw_attributes: {
173
+ email: 'demo@workos-okta.com',
174
+ first_name: 'WorkOS',
175
+ id: 'prof_01DRA1XNSJDZ19A31F183ECQW5',
176
+ idp_id: '00u1klkowm8EGah2H357',
177
+ last_name: 'Demo',
178
+ },
179
+ }
180
+
181
+ expect(profile.to_json).to eq(expectation)
164
182
  end
165
183
  end
166
184
 
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/events
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - WorkOS; ruby/2.7.1; x86_64-darwin19; v0.4.0
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Vary:
26
+ - Origin, Accept-Encoding
27
+ Access-Control-Allow-Credentials:
28
+ - "true"
29
+ X-Dns-Prefetch-Control:
30
+ - "off"
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ Strict-Transport-Security:
34
+ - max-age=15552000; includeSubDomains
35
+ X-Download-Options:
36
+ - noopen
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ X-Xss-Protection:
40
+ - 1; mode=block
41
+ X-Request-Id:
42
+ - ""
43
+ Content-Type:
44
+ - application/json; charset=utf-8
45
+ Etag:
46
+ - W/"1784-HtVN7X+AT30Dlt9nZrirP0nnyV8"
47
+ Date:
48
+ - Fri, 31 Jul 2020 14:41:12 GMT
49
+ Connection:
50
+ - keep-alive
51
+ Transfer-Encoding:
52
+ - chunked
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string:
56
+ '{"data":[{"object":"event","id":"evt_01EEJM9Q9SMC3W2SZDKA5VJ8XQ","group":"workos.com","location":"::1","latitude":null,"longitude":null,"type":"r","actor_name":"foo@example.com","actor_id":"user_01EEG9P7A1DA9VY9CX7GT47RPF","target_name":"api_key_query","target_id":"key_01EEG9MPHAYX46BBZKGK3BGQXJ","metadata":{"description":"User
57
+ viewed API key.","x_request_id":""},"occurred_at":"2020-07-31T14:27:00.384Z","action":{"object":"event_action","id":"evt_action_01EEGQXWAHB065P5JD0QDAAGDC","name":"user.viewed_api_key","project_id":"project_01DZB0E7HQMA6G85PQNHQJMZD0"}},{"object":"event","id":"evt_01EEJM9Q7GMR1VGT6VXN2N2JJQ","group":"workos.com","location":"::1","latitude":null,"longitude":null,"type":"r","actor_name":"foo@example.com","actor_id":"user_01EEG9P7A1DA9VY9CX7GT47RPF","target_name":"api_key_query","target_id":"key_01EEG9MPGM8KFT9VBQHJMV8YZB","metadata":{"description":"User
58
+ viewed API key.","x_request_id":""},"occurred_at":"2020-07-31T14:27:00.360Z","action":{"object":"event_action","id":"evt_action_01EEGQXWAHB065P5JD0QDAAGDC","name":"user.viewed_api_key","project_id":"project_01DZB0E7HQMA6G85PQNHQJMZD0"}}],"listMetadata":{"before":"evt_01EEJKZDAR6G4JHFQT4R3KSZDQ","after":null}}'
59
+ http_version:
60
+ recorded_at: Fri, 31 Jul 2020 14:41:12 GMT
61
+ recorded_with: VCR 5.0.0
@@ -1 +1 @@
1
- {"profile":{"object":"profile","id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"demo@workos-okta.com","first_name":"WorkOS","connection_type":"OktaSAML","last_name":"Demo","idp_id":"00u1klkowm8EGah2H357"},"access_token":"01DVX6QBS3EG6FHY2ESAA5Q65X"}
1
+ {"profile":{"object":"profile","id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"demo@workos-okta.com","first_name":"WorkOS","connection_type":"OktaSAML","last_name":"Demo","idp_id":"00u1klkowm8EGah2H357","raw_attributes":{"id":"prof_01DRA1XNSJDZ19A31F183ECQW5","email":"demo@workos-okta.com","first_name":"WorkOS","last_name":"Demo","idp_id":"00u1klkowm8EGah2H357"}},"access_token":"01DVX6QBS3EG6FHY2ESAA5Q65X"}
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'sorbet-runtime', '~> 0.5'
26
26
 
27
27
  spec.add_development_dependency 'bundler', '>= 2.0.1'
28
- spec.add_development_dependency 'codecov', '~> 0.1.16'
28
+ spec.add_development_dependency 'codecov', '~> 0.2.8'
29
29
  spec.add_development_dependency 'rake'
30
30
  spec.add_development_dependency 'rspec', '~> 3.9.0'
31
31
  spec.add_development_dependency 'rubocop', '~> 0.77'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.16
47
+ version: 0.2.8
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.16
54
+ version: 0.2.8
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -239,6 +239,7 @@ files:
239
239
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event_invalid.yml
240
240
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
241
241
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
242
+ - spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
242
243
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
243
244
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
244
245
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml
@@ -274,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
275
  - !ruby/object:Gem::Version
275
276
  version: '0'
276
277
  requirements: []
277
- rubygems_version: 3.1.3
278
+ rubygems_version: 3.1.4
278
279
  signing_key:
279
280
  specification_version: 4
280
281
  summary: API client for WorkOS
@@ -289,6 +290,7 @@ test_files:
289
290
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event_invalid.yml
290
291
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
291
292
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
293
+ - spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
292
294
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
293
295
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
294
296
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml