workos 4.7.0 → 4.8.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/workos/user_management.rb +20 -1
- data/lib/workos/version.rb +1 -1
- data/spec/lib/workos/user_management_spec.rb +26 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/find_invitation_by_token/invalid.yml +80 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/find_invitation_by_token/valid.yml +80 -0
- metadata +6 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a59645d5489656e64892044220f777e2e1da74715f38e11f82c8bfad3ed905aa
         | 
| 4 | 
            +
              data.tar.gz: baa9a0fa487c51d3c3adf1f11635fb17bbd22effefc774ca40d1a09e537dfcc8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ebb7b90352a85f433273cafd86e2ceecabd4d20451ce6e6c8122637beb509f55f82f19dc800f4028bdaf35f61a5a3d42dbe7d348db686dda129fff4fa0e034ce
         | 
| 7 | 
            +
              data.tar.gz: 9a6039a67909bfce3a5f42ba854d88da052d5a70d6208f9d60cc3a5d7c20c3ea596f6fba3b1263c6a00e435f772c77a6176d16011f4f3151246dafbd49e142c5
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -603,9 +603,11 @@ module WorkOS | |
| 603 603 | 
             
                  # @param [String] totp_issuer For totp factors. Typically your application
         | 
| 604 604 | 
             
                  #  or company name, this helps users distinguish between factors in authenticator apps.
         | 
| 605 605 | 
             
                  # @param [String] totp_user For totp factors. Used as the account name in authenticator apps.
         | 
| 606 | 
            +
                  # @param [String] totp_secret For totp factors.  The Base32 encdoded secret key for the
         | 
| 607 | 
            +
                  # factor. Generated if not provided. (Optional)
         | 
| 606 608 | 
             
                  #
         | 
| 607 609 | 
             
                  # @return WorkOS::AuthenticationFactorAndChallenge
         | 
| 608 | 
            -
                  def enroll_auth_factor(user_id:, type:, totp_issuer: nil, totp_user: nil)
         | 
| 610 | 
            +
                  def enroll_auth_factor(user_id:, type:, totp_issuer: nil, totp_user: nil, totp_secret: nil)
         | 
| 609 611 | 
             
                    validate_auth_factor_type(
         | 
| 610 612 | 
             
                      type: type,
         | 
| 611 613 | 
             
                    )
         | 
| @@ -617,6 +619,7 @@ module WorkOS | |
| 617 619 | 
             
                          type: type,
         | 
| 618 620 | 
             
                          totp_issuer: totp_issuer,
         | 
| 619 621 | 
             
                          totp_user: totp_user,
         | 
| 622 | 
            +
                          totp_secret: totp_secret,
         | 
| 620 623 | 
             
                        },
         | 
| 621 624 | 
             
                        auth: true,
         | 
| 622 625 | 
             
                      ),
         | 
| @@ -919,6 +922,22 @@ module WorkOS | |
| 919 922 | 
             
                    WorkOS::Invitation.new(response.body)
         | 
| 920 923 | 
             
                  end
         | 
| 921 924 |  | 
| 925 | 
            +
                  # Finds an Invitation by Token
         | 
| 926 | 
            +
                  #
         | 
| 927 | 
            +
                  # @param [String] token The token of the Invitation.
         | 
| 928 | 
            +
                  #
         | 
| 929 | 
            +
                  # @return WorkOS::Invitation
         | 
| 930 | 
            +
                  def find_invitation_by_token(token:)
         | 
| 931 | 
            +
                    response = execute_request(
         | 
| 932 | 
            +
                      request: get_request(
         | 
| 933 | 
            +
                        path: "/user_management/invitations/by_token/#{token}",
         | 
| 934 | 
            +
                        auth: true,
         | 
| 935 | 
            +
                      ),
         | 
| 936 | 
            +
                    )
         | 
| 937 | 
            +
             | 
| 938 | 
            +
                    WorkOS::Invitation.new(response.body)
         | 
| 939 | 
            +
                  end
         | 
| 940 | 
            +
             | 
| 922 941 | 
             
                  # Retrieve a list of invitations.
         | 
| 923 942 | 
             
                  #
         | 
| 924 943 | 
             
                  # @param [Hash] options
         | 
    
        data/lib/workos/version.rb
    CHANGED
    
    
| @@ -677,6 +677,7 @@ describe WorkOS::UserManagement do | |
| 677 677 | 
             
                      authentication_response = WorkOS::UserManagement.enroll_auth_factor(
         | 
| 678 678 | 
             
                        user_id: 'user_01H7TVSKS45SDHN5V9XPSM6H44',
         | 
| 679 679 | 
             
                        type: 'totp',
         | 
| 680 | 
            +
                        totp_secret: 'secret-test',
         | 
| 680 681 | 
             
                      )
         | 
| 681 682 |  | 
| 682 683 | 
             
                      expect(authentication_response.authentication_factor.id).to eq('auth_factor_01H96FETXENNY99ARX0GRC804C')
         | 
| @@ -1155,6 +1156,31 @@ describe WorkOS::UserManagement do | |
| 1155 1156 | 
             
                end
         | 
| 1156 1157 | 
             
              end
         | 
| 1157 1158 |  | 
| 1159 | 
            +
              describe '.find_invitation_by_token' do
         | 
| 1160 | 
            +
                context 'with a valid id' do
         | 
| 1161 | 
            +
                  it 'returns an invitation' do
         | 
| 1162 | 
            +
                    VCR.use_cassette 'user_management/find_invitation_by_token/valid' do
         | 
| 1163 | 
            +
                      invitation = described_class.find_invitation_by_token(
         | 
| 1164 | 
            +
                        token: 'iUV3XbYajpJlbpw1Qt3ZKlaKx',
         | 
| 1165 | 
            +
                      )
         | 
| 1166 | 
            +
             | 
| 1167 | 
            +
                      expect(invitation.id.instance_of?(String))
         | 
| 1168 | 
            +
                      expect(invitation.instance_of?(WorkOS::Invitation))
         | 
| 1169 | 
            +
                    end
         | 
| 1170 | 
            +
                  end
         | 
| 1171 | 
            +
                end
         | 
| 1172 | 
            +
             | 
| 1173 | 
            +
                context 'with an invalid id' do
         | 
| 1174 | 
            +
                  it 'raises an error' do
         | 
| 1175 | 
            +
                    VCR.use_cassette('user_management/find_invitation_by_token/invalid') do
         | 
| 1176 | 
            +
                      expect do
         | 
| 1177 | 
            +
                        WorkOS::UserManagement.find_invitation_by_token(token: 'invalid')
         | 
| 1178 | 
            +
                      end.to raise_error(WorkOS::APIError, /Invitation not found/)
         | 
| 1179 | 
            +
                    end
         | 
| 1180 | 
            +
                  end
         | 
| 1181 | 
            +
                end
         | 
| 1182 | 
            +
              end
         | 
| 1183 | 
            +
             | 
| 1158 1184 | 
             
              describe '.list_invitations' do
         | 
| 1159 1185 | 
             
                context 'with no options' do
         | 
| 1160 1186 | 
             
                  it 'returns invitations and metadata' do
         | 
| @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: get
         | 
| 5 | 
            +
                uri: https://api.workos.com/user_management/invitations/by_token/invalid
         | 
| 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/3.0.2; x86_64-darwin19; v4.7.0
         | 
| 18 | 
            +
                  Authorization:
         | 
| 19 | 
            +
                  - Bearer <API_KEY>
         | 
| 20 | 
            +
              response:
         | 
| 21 | 
            +
                status:
         | 
| 22 | 
            +
                  code: 404
         | 
| 23 | 
            +
                  message: Not Found
         | 
| 24 | 
            +
                headers:
         | 
| 25 | 
            +
                  Date:
         | 
| 26 | 
            +
                  - Mon, 03 Jun 2024 20:16:37 GMT
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json; charset=utf-8
         | 
| 29 | 
            +
                  Transfer-Encoding:
         | 
| 30 | 
            +
                  - chunked
         | 
| 31 | 
            +
                  Connection:
         | 
| 32 | 
            +
                  - keep-alive
         | 
| 33 | 
            +
                  Cf-Ray:
         | 
| 34 | 
            +
                  - 88e25cab2e0c520c-DEN
         | 
| 35 | 
            +
                  Cf-Cache-Status:
         | 
| 36 | 
            +
                  - DYNAMIC
         | 
| 37 | 
            +
                  Etag:
         | 
| 38 | 
            +
                  - W/"5a-PPX6d4bMxLfMyXe/1aUqFNwW/Dc"
         | 
| 39 | 
            +
                  Strict-Transport-Security:
         | 
| 40 | 
            +
                  - max-age=15552000; includeSubDomains
         | 
| 41 | 
            +
                  Vary:
         | 
| 42 | 
            +
                  - Origin, Accept-Encoding
         | 
| 43 | 
            +
                  Access-Control-Allow-Credentials:
         | 
| 44 | 
            +
                  - 'true'
         | 
| 45 | 
            +
                  Content-Security-Policy:
         | 
| 46 | 
            +
                  - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
         | 
| 47 | 
            +
                    https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
         | 
| 48 | 
            +
                    ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
         | 
| 49 | 
            +
                  Expect-Ct:
         | 
| 50 | 
            +
                  - max-age=0
         | 
| 51 | 
            +
                  Referrer-Policy:
         | 
| 52 | 
            +
                  - no-referrer
         | 
| 53 | 
            +
                  X-Content-Type-Options:
         | 
| 54 | 
            +
                  - nosniff
         | 
| 55 | 
            +
                  X-Dns-Prefetch-Control:
         | 
| 56 | 
            +
                  - 'off'
         | 
| 57 | 
            +
                  X-Download-Options:
         | 
| 58 | 
            +
                  - noopen
         | 
| 59 | 
            +
                  X-Frame-Options:
         | 
| 60 | 
            +
                  - SAMEORIGIN
         | 
| 61 | 
            +
                  X-Permitted-Cross-Domain-Policies:
         | 
| 62 | 
            +
                  - none
         | 
| 63 | 
            +
                  X-Request-Id:
         | 
| 64 | 
            +
                  - 7066479f-3c65-4eb0-a5ab-fa371e8747e5
         | 
| 65 | 
            +
                  X-Xss-Protection:
         | 
| 66 | 
            +
                  - '0'
         | 
| 67 | 
            +
                  Set-Cookie:
         | 
| 68 | 
            +
                  - __cf_bm=V3RT_KMrnFyoIbj_1OgapyAtReNBXvdzeYmNZWQQt6Y-1717445797-1.0.1.1-XWQk50226uaRo4S1BTn3wou4.mFaLOC20eA_MhrSil._j0XoCx6I2Q0gmgtBp1j9.dHqkmf4ZwOw1j6RmBLSnQ;
         | 
| 69 | 
            +
                    path=/; expires=Mon, 03-Jun-24 20:46:37 GMT; domain=.workos.com; HttpOnly;
         | 
| 70 | 
            +
                    Secure; SameSite=None
         | 
| 71 | 
            +
                  - __cfruid=cb54bc416259840c8c11ad58469ec2c5d9f88ff3-1717445797; path=/; domain=.workos.com;
         | 
| 72 | 
            +
                    HttpOnly; Secure; SameSite=None
         | 
| 73 | 
            +
                  Server:
         | 
| 74 | 
            +
                  - cloudflare
         | 
| 75 | 
            +
                body:
         | 
| 76 | 
            +
                  encoding: ASCII-8BIT
         | 
| 77 | 
            +
                  string: '{"message":"Invitation not found: ''invalid''.","code":"entity_not_found","entity_id":"invalid"}'
         | 
| 78 | 
            +
                http_version:
         | 
| 79 | 
            +
              recorded_at: Mon, 03 Jun 2024 20:16:37 GMT
         | 
| 80 | 
            +
            recorded_with: VCR 5.0.0
         | 
| @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: get
         | 
| 5 | 
            +
                uri: https://api.workos.com/user_management/invitations/by_token/iUV3XbYajpJlbpw1Qt3ZKlaKx
         | 
| 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/3.0.2; x86_64-darwin19; v4.7.0
         | 
| 18 | 
            +
                  Authorization:
         | 
| 19 | 
            +
                  - Bearer <API_KEY>
         | 
| 20 | 
            +
              response:
         | 
| 21 | 
            +
                status:
         | 
| 22 | 
            +
                  code: 200
         | 
| 23 | 
            +
                  message: OK
         | 
| 24 | 
            +
                headers:
         | 
| 25 | 
            +
                  Date:
         | 
| 26 | 
            +
                  - Mon, 03 Jun 2024 20:16:37 GMT
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json; charset=utf-8
         | 
| 29 | 
            +
                  Transfer-Encoding:
         | 
| 30 | 
            +
                  - chunked
         | 
| 31 | 
            +
                  Connection:
         | 
| 32 | 
            +
                  - keep-alive
         | 
| 33 | 
            +
                  Cf-Ray:
         | 
| 34 | 
            +
                  - 88e25ca97a127b32-DEN
         | 
| 35 | 
            +
                  Cf-Cache-Status:
         | 
| 36 | 
            +
                  - DYNAMIC
         | 
| 37 | 
            +
                  Etag:
         | 
| 38 | 
            +
                  - W/"1e5-ZUKH6e1N8G9JBxE8/nulDIEawKk"
         | 
| 39 | 
            +
                  Strict-Transport-Security:
         | 
| 40 | 
            +
                  - max-age=15552000; includeSubDomains
         | 
| 41 | 
            +
                  Vary:
         | 
| 42 | 
            +
                  - Origin, Accept-Encoding
         | 
| 43 | 
            +
                  Access-Control-Allow-Credentials:
         | 
| 44 | 
            +
                  - 'true'
         | 
| 45 | 
            +
                  Content-Security-Policy:
         | 
| 46 | 
            +
                  - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
         | 
| 47 | 
            +
                    https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
         | 
| 48 | 
            +
                    ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
         | 
| 49 | 
            +
                  Expect-Ct:
         | 
| 50 | 
            +
                  - max-age=0
         | 
| 51 | 
            +
                  Referrer-Policy:
         | 
| 52 | 
            +
                  - no-referrer
         | 
| 53 | 
            +
                  X-Content-Type-Options:
         | 
| 54 | 
            +
                  - nosniff
         | 
| 55 | 
            +
                  X-Dns-Prefetch-Control:
         | 
| 56 | 
            +
                  - 'off'
         | 
| 57 | 
            +
                  X-Download-Options:
         | 
| 58 | 
            +
                  - noopen
         | 
| 59 | 
            +
                  X-Frame-Options:
         | 
| 60 | 
            +
                  - SAMEORIGIN
         | 
| 61 | 
            +
                  X-Permitted-Cross-Domain-Policies:
         | 
| 62 | 
            +
                  - none
         | 
| 63 | 
            +
                  X-Request-Id:
         | 
| 64 | 
            +
                  - 1359e287-00bc-4081-a3d9-6bfcded70273
         | 
| 65 | 
            +
                  X-Xss-Protection:
         | 
| 66 | 
            +
                  - '0'
         | 
| 67 | 
            +
                  Set-Cookie:
         | 
| 68 | 
            +
                  - __cf_bm=WToCUplL1o5i0KSz5l81mSZ5SqsRh0MGwXHPwM7C.Sg-1717445797-1.0.1.1-KXhOU0BqmCe7ZDWcpEJ7V3gLLZpioBrWPxtyB5m2sOmYxj3GWOfjhqRz5d1L0cTOpGoT9OfeqzGa5qfmD0ELZw;
         | 
| 69 | 
            +
                    path=/; expires=Mon, 03-Jun-24 20:46:37 GMT; domain=.workos.com; HttpOnly;
         | 
| 70 | 
            +
                    Secure; SameSite=None
         | 
| 71 | 
            +
                  - __cfruid=cb54bc416259840c8c11ad58469ec2c5d9f88ff3-1717445797; path=/; domain=.workos.com;
         | 
| 72 | 
            +
                    HttpOnly; Secure; SameSite=None
         | 
| 73 | 
            +
                  Server:
         | 
| 74 | 
            +
                  - cloudflare
         | 
| 75 | 
            +
                body:
         | 
| 76 | 
            +
                  encoding: ASCII-8BIT
         | 
| 77 | 
            +
                  string: '{"object":"invitation","id":"invitation_01HZFVRAJ7EV7935K7H8NX2MRH","email":"blairlunceford@gmail.com","state":"pending","accepted_at":null,"revoked_at":null,"expires_at":"2024-06-10T20:13:21.862Z","organization_id":null,"inviter_user_id":null,"token":"iUV3XbYajpJlbpw1Qt3ZKlaKx","accept_invitation_url":"https://manageable-child-63-staging.authkit.app/invite/?invitation_token=iUV3XbYajpJlbpw1Qt3ZKlaKx","created_at":"2024-06-03T20:13:21.820Z","updated_at":"2024-06-03T20:13:21.820Z"}'
         | 
| 78 | 
            +
                http_version:
         | 
| 79 | 
            +
              recorded_at: Mon, 03 Jun 2024 20:16:37 GMT
         | 
| 80 | 
            +
            recorded_with: VCR 5.0.0
         | 
    
        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: 4. | 
| 4 | 
            +
              version: 4.8.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - WorkOS
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-06-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -284,6 +284,8 @@ files: | |
| 284 284 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/delete_user/valid.yml
         | 
| 285 285 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/enroll_auth_factor/invalid.yml
         | 
| 286 286 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/enroll_auth_factor/valid.yml
         | 
| 287 | 
            +
            - spec/support/fixtures/vcr_cassettes/user_management/find_invitation_by_token/invalid.yml
         | 
| 288 | 
            +
            - spec/support/fixtures/vcr_cassettes/user_management/find_invitation_by_token/valid.yml
         | 
| 287 289 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/get_email_verification/invalid.yml
         | 
| 288 290 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/get_email_verification/valid.yml
         | 
| 289 291 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/get_invitation/invalid.yml
         | 
| @@ -489,6 +491,8 @@ test_files: | |
| 489 491 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/delete_user/valid.yml
         | 
| 490 492 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/enroll_auth_factor/invalid.yml
         | 
| 491 493 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/enroll_auth_factor/valid.yml
         | 
| 494 | 
            +
            - spec/support/fixtures/vcr_cassettes/user_management/find_invitation_by_token/invalid.yml
         | 
| 495 | 
            +
            - spec/support/fixtures/vcr_cassettes/user_management/find_invitation_by_token/valid.yml
         | 
| 492 496 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/get_email_verification/invalid.yml
         | 
| 493 497 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/get_email_verification/valid.yml
         | 
| 494 498 | 
             
            - spec/support/fixtures/vcr_cassettes/user_management/get_invitation/invalid.yml
         |