comet_backup_ruby_sdk 1.8.0 → 1.12.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.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +31 -0
  4. data/Gemfile.lock +3 -3
  5. data/README.md +1 -1
  6. data/RELEASING.md +1 -0
  7. data/comet_backup_ruby_sdk.gemspec +2 -2
  8. data/lib/comet/api_response_error.rb +1 -1
  9. data/lib/comet/comet_server.rb +197 -4
  10. data/lib/comet/definitions.rb +52 -13
  11. data/lib/comet/models/add_bucket_response_message.rb +1 -1
  12. data/lib/comet/models/admin_account_properties_response.rb +1 -1
  13. data/lib/comet/models/admin_email_options.rb +1 -1
  14. data/lib/comet/models/admin_resource_response.rb +1 -1
  15. data/lib/comet/models/admin_security_options.rb +26 -1
  16. data/lib/comet/models/admin_u2fregistration.rb +2 -1
  17. data/lib/comet/models/admin_user_permissions.rb +1 -1
  18. data/lib/comet/models/admin_web_authn_registration.rb +121 -0
  19. data/lib/comet/models/allowed_admin_user.rb +214 -0
  20. data/lib/comet/models/available_download.rb +1 -1
  21. data/lib/comet/models/azure_destination_location.rb +1 -1
  22. data/lib/comet/models/b2destination_location.rb +10 -1
  23. data/lib/comet/models/b2storage_extra_info.rb +1 -1
  24. data/lib/comet/models/b2transaction_totals.rb +1 -1
  25. data/lib/comet/models/b2virtual_storage_role_settings.rb +7 -1
  26. data/lib/comet/models/backup_job_advanced_options.rb +1 -1
  27. data/lib/comet/models/backup_job_detail.rb +43 -1
  28. data/lib/comet/models/backup_job_progress.rb +1 -1
  29. data/lib/comet/models/backup_rule_config.rb +1 -1
  30. data/lib/comet/models/backup_rule_event_triggers.rb +1 -1
  31. data/lib/comet/models/branding_options.rb +1 -1
  32. data/lib/comet/models/branding_properties.rb +1 -1
  33. data/lib/comet/models/browse_disk_drives_response.rb +1 -1
  34. data/lib/comet/models/browse_edbresponse.rb +1 -1
  35. data/lib/comet/models/browse_hvresponse.rb +1 -1
  36. data/lib/comet/models/browse_office_365list_virtual_accounts_response.rb +99 -0
  37. data/lib/comet/models/browse_office_365objects_response.rb +1 -1
  38. data/lib/comet/models/browse_sqlserver_response.rb +1 -1
  39. data/lib/comet/models/browse_vssresponse.rb +1 -1
  40. data/lib/comet/models/bucket_properties.rb +1 -1
  41. data/lib/comet/models/bucket_usage_info.rb +1 -1
  42. data/lib/comet/models/comet_apiresponse_message.rb +1 -1
  43. data/lib/comet/models/comet_destination_location.rb +1 -1
  44. data/lib/comet/models/constellation_check_report.rb +1 -1
  45. data/lib/comet/models/constellation_stats.rb +1 -1
  46. data/lib/comet/models/constellation_status_apiresponse.rb +1 -1
  47. data/lib/comet/models/content_measurement.rb +1 -1
  48. data/lib/comet/models/content_measurement_component.rb +1 -1
  49. data/lib/comet/models/create_group_policy_response.rb +1 -1
  50. data/lib/comet/models/custom_remote_bucket_settings.rb +1 -1
  51. data/lib/comet/models/default_email_report_policy.rb +1 -1
  52. data/lib/comet/models/default_source_with_osrestriction.rb +1 -1
  53. data/lib/comet/models/destination_config.rb +1 -1
  54. data/lib/comet/models/destination_location.rb +1 -1
  55. data/lib/comet/models/destination_statistics.rb +1 -1
  56. data/lib/comet/models/device_config.rb +12 -1
  57. data/lib/comet/models/disk_drive.rb +1 -1
  58. data/lib/comet/models/dispatcher_admin_sources_response.rb +1 -1
  59. data/lib/comet/models/dispatcher_stored_objects_response.rb +1 -1
  60. data/lib/comet/models/dispatcher_vault_snapshots_response.rb +1 -1
  61. data/lib/comet/models/dispatcher_windisk_snapshot_response.rb +99 -0
  62. data/lib/comet/models/edbfile_info.rb +1 -1
  63. data/lib/comet/models/email_options.rb +1 -1
  64. data/lib/comet/models/email_report_config.rb +1 -1
  65. data/lib/comet/models/email_report_generated_preview.rb +26 -1
  66. data/lib/comet/models/external_ldapauthentication_source_settings.rb +1 -1
  67. data/lib/comet/models/extra_file_exclusion.rb +1 -1
  68. data/lib/comet/models/ftpdestination_location.rb +1 -1
  69. data/lib/comet/models/get_group_policy_response.rb +1 -1
  70. data/lib/comet/models/get_profile_and_hash_response_message.rb +1 -1
  71. data/lib/comet/models/get_profile_hash_response_message.rb +1 -1
  72. data/lib/comet/models/group_policy.rb +1 -1
  73. data/lib/comet/models/hyper_vmachine_info.rb +1 -1
  74. data/lib/comet/models/install_creds.rb +1 -1
  75. data/lib/comet/models/install_token.rb +1 -1
  76. data/lib/comet/models/install_token_response.rb +1 -1
  77. data/lib/comet/models/job_entry.rb +1 -1
  78. data/lib/comet/models/live_user_connection.rb +1 -1
  79. data/lib/comet/models/local_destination_location.rb +1 -1
  80. data/lib/comet/models/mac_oscode_sign_properties.rb +1 -1
  81. data/lib/comet/models/mongo_dbconnection.rb +1 -1
  82. data/lib/comet/models/mssqlconnection.rb +1 -1
  83. data/lib/comet/models/my_sqlconnection.rb +40 -1
  84. data/lib/comet/models/new_bucket_detail.rb +1 -1
  85. data/lib/comet/models/news_entry.rb +1 -1
  86. data/lib/comet/models/office_365connection.rb +9 -1
  87. data/lib/comet/models/office_365credential.rb +1 -1
  88. data/lib/comet/models/office_365custom_setting.rb +2 -1
  89. data/lib/comet/models/office_365custom_setting_v2.rb +108 -0
  90. data/lib/comet/models/office_365mixed_virtual_account.rb +211 -0
  91. data/lib/comet/models/office_365object_info.rb +1 -1
  92. data/lib/comet/models/organization.rb +1 -1
  93. data/lib/comet/models/organization_response.rb +1 -1
  94. data/lib/comet/models/osinfo.rb +1 -1
  95. data/lib/comet/models/partition.rb +1 -1
  96. data/lib/comet/models/private_branding_properties.rb +1 -1
  97. data/lib/comet/models/protected_item_engine_type_policy.rb +1 -1
  98. data/lib/comet/models/public_branding_properties.rb +1 -1
  99. data/lib/comet/models/register_office_application_begin_response.rb +1 -1
  100. data/lib/comet/models/register_office_application_check_response.rb +1 -1
  101. data/lib/comet/models/remote_server_address.rb +1 -1
  102. data/lib/comet/models/remote_storage_option.rb +1 -1
  103. data/lib/comet/models/replicator_state_apiresponse.rb +1 -1
  104. data/lib/comet/models/request_storage_vault_response_message.rb +1 -1
  105. data/lib/comet/models/restore_job_advanced_options.rb +1 -1
  106. data/lib/comet/models/retention_policy.rb +1 -1
  107. data/lib/comet/models/retention_range.rb +1 -1
  108. data/lib/comet/models/s3destination_location.rb +1 -1
  109. data/lib/comet/models/schedule_config.rb +1 -1
  110. data/lib/comet/models/search_clause.rb +1 -1
  111. data/lib/comet/models/self_backup_statistics.rb +1 -1
  112. data/lib/comet/models/server_config_options_branding_fragment.rb +1 -1
  113. data/lib/comet/models/server_config_options_software_build_role_fragment.rb +1 -1
  114. data/lib/comet/models/server_meta_branding_properties.rb +10 -1
  115. data/lib/comet/models/server_meta_version_info.rb +1 -1
  116. data/lib/comet/models/session_key_regenerated_response.rb +1 -1
  117. data/lib/comet/models/sftpdestination_location.rb +1 -1
  118. data/lib/comet/models/size_measurement.rb +1 -1
  119. data/lib/comet/models/software_build_role_options.rb +1 -1
  120. data/lib/comet/models/software_update_news_response.rb +1 -1
  121. data/lib/comet/models/source_basic_info.rb +1 -1
  122. data/lib/comet/models/source_config.rb +1 -1
  123. data/lib/comet/models/source_include_pattern.rb +1 -1
  124. data/lib/comet/models/source_statistics.rb +1 -1
  125. data/lib/comet/models/spanned_destination_location.rb +1 -1
  126. data/lib/comet/models/spanned_storage_extra_info.rb +1 -1
  127. data/lib/comet/models/sshconnection.rb +1 -1
  128. data/lib/comet/models/stat_result.rb +10 -1
  129. data/lib/comet/models/storage_free_space_info.rb +1 -1
  130. data/lib/comet/models/storage_vault_provider_policy.rb +1 -1
  131. data/lib/comet/models/stored_object.rb +1 -1
  132. data/lib/comet/models/streamable_event.rb +1 -1
  133. data/lib/comet/models/swift_destination_location.rb +1 -1
  134. data/lib/comet/models/test_response.rb +1 -1
  135. data/lib/comet/models/totp_regenerated_response.rb +1 -1
  136. data/lib/comet/models/u2fregister_request.rb +2 -1
  137. data/lib/comet/models/u2fregistered_key.rb +2 -1
  138. data/lib/comet/models/u2fregistration_challenge_response.rb +2 -1
  139. data/lib/comet/models/u2fsign_request.rb +2 -1
  140. data/lib/comet/models/u2fsign_response.rb +2 -1
  141. data/lib/comet/models/uninstall_config.rb +1 -1
  142. data/lib/comet/models/update_campaign_device_status.rb +1 -1
  143. data/lib/comet/models/update_campaign_options.rb +1 -1
  144. data/lib/comet/models/update_campaign_properties.rb +1 -1
  145. data/lib/comet/models/update_campaign_status.rb +1 -1
  146. data/lib/comet/models/update_campaign_status_device_entry.rb +1 -1
  147. data/lib/comet/models/user_custom_email_settings.rb +1 -1
  148. data/lib/comet/models/user_on_server.rb +1 -1
  149. data/lib/comet/models/user_policy.rb +1 -1
  150. data/lib/comet/models/user_profile_config.rb +1 -1
  151. data/lib/comet/models/user_profile_fragment.rb +1 -1
  152. data/lib/comet/models/vault_snapshot.rb +1 -1
  153. data/lib/comet/models/vsscomponent.rb +1 -1
  154. data/lib/comet/models/vsswriter_info.rb +1 -1
  155. data/lib/comet/models/wasabi_virtual_storage_role_settings.rb +1 -1
  156. data/lib/comet/models/web_authn_authenticator_selection.rb +96 -0
  157. data/lib/comet/models/web_authn_credential.rb +105 -0
  158. data/lib/comet/models/web_authn_credential_assertion.rb +74 -0
  159. data/lib/comet/models/web_authn_credential_descriptor.rb +101 -0
  160. data/lib/comet/models/web_authn_credential_entity.rb +86 -0
  161. data/lib/comet/models/web_authn_credential_parameter.rb +84 -0
  162. data/lib/comet/models/web_authn_public_key_credential_creation_options.rb +172 -0
  163. data/lib/comet/models/web_authn_public_key_credential_request_options.rb +140 -0
  164. data/lib/comet/models/web_authn_registration_challenge_response.rb +101 -0
  165. data/lib/comet/models/web_authn_relying_party_entity.rb +95 -0
  166. data/lib/comet/models/web_authn_sign_request.rb +83 -0
  167. data/lib/comet/models/web_authn_sign_response.rb +84 -0
  168. data/lib/comet/models/web_authn_user_entity.rb +105 -0
  169. data/lib/comet/models/web_interface_branding_properties.rb +1 -1
  170. data/lib/comet/models/webhook_option.rb +1 -1
  171. data/lib/comet/models/win_smbauth.rb +1 -1
  172. data/lib/comet/models/windows_code_sign_properties.rb +1 -1
  173. data/lib/comet_backup_ruby_sdk.rb +20 -1
  174. metadata +24 -4
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2022 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+ #
8
+ # frozen_string_literal: true
9
+
10
+ require 'base64'
11
+ require 'json'
12
+
13
+ module Comet
14
+
15
+ # WebAuthnCredential is a typed class wrapper around the underlying Comet Server API data structure.
16
+ class WebAuthnCredential
17
+
18
+ # @type [Array<Object>] public_key
19
+ attr_accessor :public_key
20
+
21
+ # @type [String] attestation_type
22
+ attr_accessor :attestation_type
23
+
24
+ # @type [Array<Object>] aaguid
25
+ attr_accessor :aaguid
26
+
27
+ # @type [Number] sign_count
28
+ attr_accessor :sign_count
29
+
30
+ # @type [Boolean] clone_warning
31
+ attr_accessor :clone_warning
32
+
33
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
34
+ attr_accessor :unknown_json_fields
35
+
36
+ def initialize
37
+ clear
38
+ end
39
+
40
+ def clear
41
+ @public_key = []
42
+ @attestation_type = ''
43
+ @aaguid = []
44
+ @sign_count = 0
45
+ @unknown_json_fields = {}
46
+ end
47
+
48
+ # @param [String] json_string The complete object in JSON format
49
+ def from_json(json_string)
50
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
51
+
52
+ from_hash(JSON.parse(json_string))
53
+ end
54
+
55
+ # @param [Hash] obj The complete object as a Ruby hash
56
+ def from_hash(obj)
57
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
58
+
59
+ obj.each do |k, v|
60
+ case k
61
+ when 'PublicKey'
62
+ @public_key = Base64.decode64(v)
63
+ when 'AttestationType'
64
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
65
+
66
+ @attestation_type = v
67
+ when 'AAGUID'
68
+ @aaguid = Base64.decode64(v)
69
+ when 'SignCount'
70
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
71
+
72
+ @sign_count = v
73
+ when 'CloneWarning'
74
+ @clone_warning = v
75
+ else
76
+ @unknown_json_fields[k] = v
77
+ end
78
+ end
79
+ end
80
+
81
+ # @return [Hash] The complete object as a Ruby hash
82
+ def to_hash
83
+ ret = {}
84
+ ret['PublicKey'] = Base64.strict_encode64(@public_key)
85
+ ret['AttestationType'] = @attestation_type
86
+ ret['AAGUID'] = Base64.strict_encode64(@aaguid)
87
+ ret['SignCount'] = @sign_count
88
+ ret['CloneWarning'] = @clone_warning
89
+ @unknown_json_fields.each do |k, v|
90
+ ret[k] = v
91
+ end
92
+ ret
93
+ end
94
+
95
+ # @return [Hash] The complete object as a Ruby hash
96
+ def to_h
97
+ to_hash
98
+ end
99
+
100
+ # @return [String] The complete object as a JSON string
101
+ def to_json(options = {})
102
+ to_hash.to_json(options)
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2022 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+ #
8
+ # frozen_string_literal: true
9
+
10
+ require 'json'
11
+
12
+ module Comet
13
+
14
+ # WebAuthnCredentialAssertion is a typed class wrapper around the underlying Comet Server API data structure.
15
+ class WebAuthnCredentialAssertion
16
+
17
+ # @type [Comet::WebAuthnPublicKeyCredentialRequestOptions] response
18
+ attr_accessor :response
19
+
20
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
21
+ attr_accessor :unknown_json_fields
22
+
23
+ def initialize
24
+ clear
25
+ end
26
+
27
+ def clear
28
+ @response = Comet::WebAuthnPublicKeyCredentialRequestOptions.new
29
+ @unknown_json_fields = {}
30
+ end
31
+
32
+ # @param [String] json_string The complete object in JSON format
33
+ def from_json(json_string)
34
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
35
+
36
+ from_hash(JSON.parse(json_string))
37
+ end
38
+
39
+ # @param [Hash] obj The complete object as a Ruby hash
40
+ def from_hash(obj)
41
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
42
+
43
+ obj.each do |k, v|
44
+ case k
45
+ when 'publicKey'
46
+ @response = Comet::WebAuthnPublicKeyCredentialRequestOptions.new
47
+ @response.from_hash(v)
48
+ else
49
+ @unknown_json_fields[k] = v
50
+ end
51
+ end
52
+ end
53
+
54
+ # @return [Hash] The complete object as a Ruby hash
55
+ def to_hash
56
+ ret = {}
57
+ ret['publicKey'] = @response
58
+ @unknown_json_fields.each do |k, v|
59
+ ret[k] = v
60
+ end
61
+ ret
62
+ end
63
+
64
+ # @return [Hash] The complete object as a Ruby hash
65
+ def to_h
66
+ to_hash
67
+ end
68
+
69
+ # @return [String] The complete object as a JSON string
70
+ def to_json(options = {})
71
+ to_hash.to_json(options)
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2022 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+ #
8
+ # frozen_string_literal: true
9
+
10
+ require 'base64'
11
+ require 'json'
12
+
13
+ module Comet
14
+
15
+ # WebAuthnCredentialDescriptor is a typed class wrapper around the underlying Comet Server API data structure.
16
+ class WebAuthnCredentialDescriptor
17
+
18
+ # @type [String] type
19
+ attr_accessor :type
20
+
21
+ # @type [Array<Object>] credential_id
22
+ attr_accessor :credential_id
23
+
24
+ # @type [Array<String>] transport
25
+ attr_accessor :transport
26
+
27
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
28
+ attr_accessor :unknown_json_fields
29
+
30
+ def initialize
31
+ clear
32
+ end
33
+
34
+ def clear
35
+ @type = ''
36
+ @credential_id = []
37
+ @transport = []
38
+ @unknown_json_fields = {}
39
+ end
40
+
41
+ # @param [String] json_string The complete object in JSON format
42
+ def from_json(json_string)
43
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
44
+
45
+ from_hash(JSON.parse(json_string))
46
+ end
47
+
48
+ # @param [Hash] obj The complete object as a Ruby hash
49
+ def from_hash(obj)
50
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
51
+
52
+ obj.each do |k, v|
53
+ case k
54
+ when 'type'
55
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
56
+
57
+ @type = v
58
+ when 'id'
59
+ @credential_id = Base64.decode64(v)
60
+ when 'transports'
61
+ if v.nil?
62
+ @transport = []
63
+ else
64
+ @transport = Array.new(v.length)
65
+ v.each_with_index do |v1, i1|
66
+ raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String
67
+
68
+ @transport[i1] = v1
69
+ end
70
+ end
71
+ else
72
+ @unknown_json_fields[k] = v
73
+ end
74
+ end
75
+ end
76
+
77
+ # @return [Hash] The complete object as a Ruby hash
78
+ def to_hash
79
+ ret = {}
80
+ ret['type'] = @type
81
+ ret['id'] = Base64.strict_encode64(@credential_id)
82
+ unless @transport.nil?
83
+ ret['transports'] = @transport
84
+ end
85
+ @unknown_json_fields.each do |k, v|
86
+ ret[k] = v
87
+ end
88
+ ret
89
+ end
90
+
91
+ # @return [Hash] The complete object as a Ruby hash
92
+ def to_h
93
+ to_hash
94
+ end
95
+
96
+ # @return [String] The complete object as a JSON string
97
+ def to_json(options = {})
98
+ to_hash.to_json(options)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2022 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+ #
8
+ # frozen_string_literal: true
9
+
10
+ require 'json'
11
+
12
+ module Comet
13
+
14
+ # WebAuthnCredentialEntity is a typed class wrapper around the underlying Comet Server API data structure.
15
+ class WebAuthnCredentialEntity
16
+
17
+ # @type [String] name
18
+ attr_accessor :name
19
+
20
+ # @type [String] icon
21
+ attr_accessor :icon
22
+
23
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
24
+ attr_accessor :unknown_json_fields
25
+
26
+ def initialize
27
+ clear
28
+ end
29
+
30
+ def clear
31
+ @name = ''
32
+ @icon = ''
33
+ @unknown_json_fields = {}
34
+ end
35
+
36
+ # @param [String] json_string The complete object in JSON format
37
+ def from_json(json_string)
38
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
39
+
40
+ from_hash(JSON.parse(json_string))
41
+ end
42
+
43
+ # @param [Hash] obj The complete object as a Ruby hash
44
+ def from_hash(obj)
45
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
46
+
47
+ obj.each do |k, v|
48
+ case k
49
+ when 'name'
50
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
51
+
52
+ @name = v
53
+ when 'icon'
54
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
55
+
56
+ @icon = v
57
+ else
58
+ @unknown_json_fields[k] = v
59
+ end
60
+ end
61
+ end
62
+
63
+ # @return [Hash] The complete object as a Ruby hash
64
+ def to_hash
65
+ ret = {}
66
+ ret['name'] = @name
67
+ unless @icon.nil?
68
+ ret['icon'] = @icon
69
+ end
70
+ @unknown_json_fields.each do |k, v|
71
+ ret[k] = v
72
+ end
73
+ ret
74
+ end
75
+
76
+ # @return [Hash] The complete object as a Ruby hash
77
+ def to_h
78
+ to_hash
79
+ end
80
+
81
+ # @return [String] The complete object as a JSON string
82
+ def to_json(options = {})
83
+ to_hash.to_json(options)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2022 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+ #
8
+ # frozen_string_literal: true
9
+
10
+ require 'json'
11
+
12
+ module Comet
13
+
14
+ # WebAuthnCredentialParameter is a typed class wrapper around the underlying Comet Server API data structure.
15
+ class WebAuthnCredentialParameter
16
+
17
+ # @type [String] type
18
+ attr_accessor :type
19
+
20
+ # @type [Number] algorithm
21
+ attr_accessor :algorithm
22
+
23
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
24
+ attr_accessor :unknown_json_fields
25
+
26
+ def initialize
27
+ clear
28
+ end
29
+
30
+ def clear
31
+ @type = ''
32
+ @algorithm = 0
33
+ @unknown_json_fields = {}
34
+ end
35
+
36
+ # @param [String] json_string The complete object in JSON format
37
+ def from_json(json_string)
38
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
39
+
40
+ from_hash(JSON.parse(json_string))
41
+ end
42
+
43
+ # @param [Hash] obj The complete object as a Ruby hash
44
+ def from_hash(obj)
45
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
46
+
47
+ obj.each do |k, v|
48
+ case k
49
+ when 'type'
50
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
51
+
52
+ @type = v
53
+ when 'alg'
54
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
55
+
56
+ @algorithm = v
57
+ else
58
+ @unknown_json_fields[k] = v
59
+ end
60
+ end
61
+ end
62
+
63
+ # @return [Hash] The complete object as a Ruby hash
64
+ def to_hash
65
+ ret = {}
66
+ ret['type'] = @type
67
+ ret['alg'] = @algorithm
68
+ @unknown_json_fields.each do |k, v|
69
+ ret[k] = v
70
+ end
71
+ ret
72
+ end
73
+
74
+ # @return [Hash] The complete object as a Ruby hash
75
+ def to_h
76
+ to_hash
77
+ end
78
+
79
+ # @return [String] The complete object as a JSON string
80
+ def to_json(options = {})
81
+ to_hash.to_json(options)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env ruby --enable-frozen-string-literal
2
+ #
3
+ # Copyright (c) 2020-2022 Comet Licensing Ltd.
4
+ # Please see the LICENSE file for usage information.
5
+ #
6
+ # SPDX-License-Identifier: MIT
7
+ #
8
+ # frozen_string_literal: true
9
+
10
+ require 'base64'
11
+ require 'json'
12
+
13
+ module Comet
14
+
15
+ # WebAuthnPublicKeyCredentialCreationOptions is a typed class wrapper around the underlying Comet Server API data structure.
16
+ class WebAuthnPublicKeyCredentialCreationOptions
17
+
18
+ # @type [Array<Object>] challenge
19
+ attr_accessor :challenge
20
+
21
+ # @type [Comet::WebAuthnRelyingPartyEntity] relying_party
22
+ attr_accessor :relying_party
23
+
24
+ # @type [Comet::WebAuthnUserEntity] user
25
+ attr_accessor :user
26
+
27
+ # @type [Array<Comet::WebAuthnCredentialParameter>] parameters
28
+ attr_accessor :parameters
29
+
30
+ # @type [Comet::WebAuthnAuthenticatorSelection] authenticator_selection
31
+ attr_accessor :authenticator_selection
32
+
33
+ # @type [Number] timeout
34
+ attr_accessor :timeout
35
+
36
+ # @type [Array<Comet::WebAuthnCredentialDescriptor>] credential_exclude_list
37
+ attr_accessor :credential_exclude_list
38
+
39
+ # @type [Hash{String => Object}] extensions
40
+ attr_accessor :extensions
41
+
42
+ # @type [String] attestation
43
+ attr_accessor :attestation
44
+
45
+ # @type [Hash] Hidden storage to preserve future properties for non-destructive roundtrip operations
46
+ attr_accessor :unknown_json_fields
47
+
48
+ def initialize
49
+ clear
50
+ end
51
+
52
+ def clear
53
+ @challenge = []
54
+ @relying_party = Comet::WebAuthnRelyingPartyEntity.new
55
+ @user = Comet::WebAuthnUserEntity.new
56
+ @parameters = []
57
+ @authenticator_selection = Comet::WebAuthnAuthenticatorSelection.new
58
+ @timeout = 0
59
+ @credential_exclude_list = []
60
+ @extensions = {}
61
+ @attestation = ''
62
+ @unknown_json_fields = {}
63
+ end
64
+
65
+ # @param [String] json_string The complete object in JSON format
66
+ def from_json(json_string)
67
+ raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String
68
+
69
+ from_hash(JSON.parse(json_string))
70
+ end
71
+
72
+ # @param [Hash] obj The complete object as a Ruby hash
73
+ def from_hash(obj)
74
+ raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash
75
+
76
+ obj.each do |k, v|
77
+ case k
78
+ when 'challenge'
79
+ @challenge = Base64.decode64(v)
80
+ when 'rp'
81
+ @relying_party = Comet::WebAuthnRelyingPartyEntity.new
82
+ @relying_party.from_hash(v)
83
+ when 'user'
84
+ @user = Comet::WebAuthnUserEntity.new
85
+ @user.from_hash(v)
86
+ when 'pubKeyCredParams'
87
+ if v.nil?
88
+ @parameters = []
89
+ else
90
+ @parameters = Array.new(v.length)
91
+ v.each_with_index do |v1, i1|
92
+ @parameters[i1] = Comet::WebAuthnCredentialParameter.new
93
+ @parameters[i1].from_hash(v1)
94
+ end
95
+ end
96
+ when 'authenticatorSelection'
97
+ @authenticator_selection = Comet::WebAuthnAuthenticatorSelection.new
98
+ @authenticator_selection.from_hash(v)
99
+ when 'timeout'
100
+ raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
101
+
102
+ @timeout = v
103
+ when 'excludeCredentials'
104
+ if v.nil?
105
+ @credential_exclude_list = []
106
+ else
107
+ @credential_exclude_list = Array.new(v.length)
108
+ v.each_with_index do |v1, i1|
109
+ @credential_exclude_list[i1] = Comet::WebAuthnCredentialDescriptor.new
110
+ @credential_exclude_list[i1].from_hash(v1)
111
+ end
112
+ end
113
+ when 'extensions'
114
+ @extensions = {}
115
+ if v.nil?
116
+ @extensions = {}
117
+ else
118
+ v.each do |k1, v1|
119
+ @extensions[k1] = v1
120
+ end
121
+ end
122
+ when 'attestation'
123
+ raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
124
+
125
+ @attestation = v
126
+ else
127
+ @unknown_json_fields[k] = v
128
+ end
129
+ end
130
+ end
131
+
132
+ # @return [Hash] The complete object as a Ruby hash
133
+ def to_hash
134
+ ret = {}
135
+ ret['challenge'] = Base64.strict_encode64(@challenge)
136
+ ret['rp'] = @relying_party
137
+ ret['user'] = @user
138
+ unless @parameters.nil?
139
+ ret['pubKeyCredParams'] = @parameters
140
+ end
141
+ unless @authenticator_selection.nil?
142
+ ret['authenticatorSelection'] = @authenticator_selection
143
+ end
144
+ unless @timeout.nil?
145
+ ret['timeout'] = @timeout
146
+ end
147
+ unless @credential_exclude_list.nil?
148
+ ret['excludeCredentials'] = @credential_exclude_list
149
+ end
150
+ unless @extensions.nil?
151
+ ret['extensions'] = @extensions
152
+ end
153
+ unless @attestation.nil?
154
+ ret['attestation'] = @attestation
155
+ end
156
+ @unknown_json_fields.each do |k, v|
157
+ ret[k] = v
158
+ end
159
+ ret
160
+ end
161
+
162
+ # @return [Hash] The complete object as a Ruby hash
163
+ def to_h
164
+ to_hash
165
+ end
166
+
167
+ # @return [String] The complete object as a JSON string
168
+ def to_json(options = {})
169
+ to_hash.to_json(options)
170
+ end
171
+ end
172
+ end