appwrite 11.0.0.pre.rc.4 → 11.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/appwrite/client.rb +7 -17
- data/lib/appwrite/enums/authentication_factor.rb +3 -2
- data/lib/appwrite/enums/flag.rb +2 -2
- data/lib/appwrite/enums/index_type.rb +0 -1
- data/lib/appwrite/enums/name.rb +1 -0
- data/lib/appwrite/enums/password_hash.rb +2 -2
- data/lib/appwrite/enums/runtime.rb +42 -34
- data/lib/appwrite/enums/{encryption.rb → smtp_encryption.rb} +1 -1
- data/lib/appwrite/id.rb +20 -4
- data/lib/appwrite/models/mfa_recovery_codes.rb +27 -0
- data/lib/appwrite/models/mfa_type.rb +0 -5
- data/lib/appwrite/models/session.rb +8 -3
- data/lib/appwrite/models/user.rb +0 -5
- data/lib/appwrite/services/account.rb +219 -90
- data/lib/appwrite/services/databases.rb +16 -10
- data/lib/appwrite/services/health.rb +80 -1
- data/lib/appwrite/services/messaging.rb +42 -35
- data/lib/appwrite/services/users.rb +115 -22
- data/lib/appwrite.rb +3 -3
- metadata +6 -6
- data/lib/appwrite/enums/message_status.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bca03eb7af675e72f241faee81443dd471831f3e7835c9f7bb32f83979a9266
|
4
|
+
data.tar.gz: 14612cd69df877ead2f82c0e0e9c9eaf423b1f059d6221570a9a285bd2f91189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5afccd0969e11345fb06bf9f6857624f98a852d1359a685fe659245d490ff7a03351747b37173a9cb9030a326ee0b275c1ccee911c9cbc9509878c7c7479ac2
|
7
|
+
data.tar.gz: 8083c9e4416972961fc58af0b7a5328b72fb7e3e67f792bef5c7b8a4e04fc3600ae2e6c007e2bdf7093f4418ca34321f00b82428ed4a5514ff8096a06588a90f
|
data/lib/appwrite/client.rb
CHANGED
@@ -15,7 +15,7 @@ module Appwrite
|
|
15
15
|
'x-sdk-name'=> 'Ruby',
|
16
16
|
'x-sdk-platform'=> 'server',
|
17
17
|
'x-sdk-language'=> 'ruby',
|
18
|
-
'x-sdk-version'=> '11.0.
|
18
|
+
'x-sdk-version'=> '11.0.1',
|
19
19
|
'X-Appwrite-Response-Format' => '1.5.0'
|
20
20
|
}
|
21
21
|
@endpoint = 'https://cloud.appwrite.io/v1'
|
@@ -84,19 +84,6 @@ module Appwrite
|
|
84
84
|
self
|
85
85
|
end
|
86
86
|
|
87
|
-
# Set ForwardedFor
|
88
|
-
#
|
89
|
-
# The IP address of the client that made the request
|
90
|
-
#
|
91
|
-
# @param [String] value The value to set for the ForwardedFor header
|
92
|
-
#
|
93
|
-
# @return [self]
|
94
|
-
def set_forwarded_for(value)
|
95
|
-
add_header('x-forwarded-for', value)
|
96
|
-
|
97
|
-
self
|
98
|
-
end
|
99
|
-
|
100
87
|
# Set ForwardedUserAgent
|
101
88
|
#
|
102
89
|
# The user agent string of the client that made the request
|
@@ -293,12 +280,15 @@ module Appwrite
|
|
293
280
|
rescue => error
|
294
281
|
raise Appwrite::Exception.new(error.message)
|
295
282
|
end
|
283
|
+
|
284
|
+
location = response['location']
|
285
|
+
if response_type == "location"
|
286
|
+
return location
|
287
|
+
end
|
296
288
|
|
297
289
|
# Handle Redirects
|
298
|
-
if response.class == Net::HTTPRedirection || response.class == Net::HTTPMovedPermanently
|
299
|
-
location = response['location']
|
290
|
+
if (response.class == Net::HTTPRedirection || response.class == Net::HTTPMovedPermanently)
|
300
291
|
uri = URI.parse(uri.scheme + "://" + uri.host + "" + location)
|
301
|
-
|
302
292
|
return fetch(method, uri, headers, {}, response_type, limit - 1)
|
303
293
|
end
|
304
294
|
|
data/lib/appwrite/enums/flag.rb
CHANGED
@@ -34,7 +34,7 @@ module Appwrite
|
|
34
34
|
SWITZERLAND = 'ch'
|
35
35
|
CHILE = 'cl'
|
36
36
|
CHINA = 'cn'
|
37
|
-
|
37
|
+
COTE_DIVOIRE = 'ci'
|
38
38
|
CAMEROON = 'cm'
|
39
39
|
DEMOCRATIC_REPUBLIC_OF_THE_CONGO = 'cd'
|
40
40
|
REPUBLIC_OF_THE_CONGO = 'cg'
|
@@ -96,7 +96,7 @@ module Appwrite
|
|
96
96
|
SAINT_KITTS_AND_NEVIS = 'kn'
|
97
97
|
SOUTH_KOREA = 'kr'
|
98
98
|
KUWAIT = 'kw'
|
99
|
-
|
99
|
+
LAO_PEOPLES_DEMOCRATIC_REPUBLIC = 'la'
|
100
100
|
LEBANON = 'lb'
|
101
101
|
LIBERIA = 'lr'
|
102
102
|
LIBYA = 'ly'
|
data/lib/appwrite/enums/name.rb
CHANGED
@@ -1,42 +1,50 @@
|
|
1
1
|
module Appwrite
|
2
2
|
module Enums
|
3
3
|
module Runtime
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
4
|
+
NODE_14_5 = 'node-14.5'
|
5
|
+
NODE_16_0 = 'node-16.0'
|
6
|
+
NODE_18_0 = 'node-18.0'
|
7
|
+
NODE_19_0 = 'node-19.0'
|
8
|
+
NODE_20_0 = 'node-20.0'
|
9
|
+
NODE_21_0 = 'node-21.0'
|
10
|
+
PHP_8_0 = 'php-8.0'
|
11
|
+
PHP_8_1 = 'php-8.1'
|
12
|
+
PHP_8_2 = 'php-8.2'
|
13
|
+
PHP_8_3 = 'php-8.3'
|
14
|
+
RUBY_3_0 = 'ruby-3.0'
|
15
|
+
RUBY_3_1 = 'ruby-3.1'
|
16
|
+
RUBY_3_2 = 'ruby-3.2'
|
17
|
+
RUBY_3_3 = 'ruby-3.3'
|
18
|
+
PYTHON_3_8 = 'python-3.8'
|
19
|
+
PYTHON_3_9 = 'python-3.9'
|
20
|
+
PYTHON_3_10 = 'python-3.10'
|
21
|
+
PYTHON_3_11 = 'python-3.11'
|
22
|
+
PYTHON_3_12 = 'python-3.12'
|
23
|
+
DENO_1_40 = 'deno-1.40'
|
24
|
+
DART_2_15 = 'dart-2.15'
|
25
|
+
DART_2_16 = 'dart-2.16'
|
26
|
+
DART_2_17 = 'dart-2.17'
|
27
|
+
DART_2_18 = 'dart-2.18'
|
28
|
+
DART_3_0 = 'dart-3.0'
|
29
|
+
DART_3_1 = 'dart-3.1'
|
30
|
+
DART_3_3 = 'dart-3.3'
|
31
|
+
DOTNET_3_1 = 'dotnet-3.1'
|
32
|
+
DOTNET_6_0 = 'dotnet-6.0'
|
33
|
+
DOTNET_7_0 = 'dotnet-7.0'
|
34
|
+
JAVA_8_0 = 'java-8.0'
|
35
|
+
JAVA_11_0 = 'java-11.0'
|
36
|
+
JAVA_17_0 = 'java-17.0'
|
37
|
+
JAVA_18_0 = 'java-18.0'
|
38
|
+
JAVA_21_0 = 'java-21.0'
|
39
|
+
SWIFT_5_5 = 'swift-5.5'
|
40
|
+
SWIFT_5_8 = 'swift-5.8'
|
41
|
+
SWIFT_5_9 = 'swift-5.9'
|
42
|
+
KOTLIN_1_6 = 'kotlin-1.6'
|
43
|
+
KOTLIN_1_8 = 'kotlin-1.8'
|
44
|
+
KOTLIN_1_9 = 'kotlin-1.9'
|
37
45
|
CPP_17 = 'cpp-17'
|
38
46
|
CPP_20 = 'cpp-20'
|
39
|
-
|
47
|
+
BUN_1_0 = 'bun-1.0'
|
40
48
|
end
|
41
49
|
end
|
42
50
|
end
|
data/lib/appwrite/id.rb
CHANGED
@@ -1,11 +1,27 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
module Appwrite
|
2
4
|
class ID
|
3
5
|
def self.custom(id)
|
4
6
|
id
|
5
7
|
end
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
|
9
|
+
# Generate a unique ID with padding to have a longer ID
|
10
|
+
def self.unique(padding=7)
|
11
|
+
base_id = self.hex_timestamp
|
12
|
+
random_padding = SecureRandom.hex(padding)
|
13
|
+
random_padding = random_padding[0...padding]
|
14
|
+
base_id + random_padding
|
15
|
+
end
|
16
|
+
|
17
|
+
#Generate an hex ID based on timestamp
|
18
|
+
#Recreated from https://www.php.net/manual/en/function.uniqid.php
|
19
|
+
private_class_method def self.hex_timestamp
|
20
|
+
now = Time.now
|
21
|
+
sec = now.to_i
|
22
|
+
usec = now.usec
|
23
|
+
hex_timestamp = "%08x%05x" % [sec, usec]
|
24
|
+
hex_timestamp
|
9
25
|
end
|
10
26
|
end
|
11
|
-
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appwrite
|
4
|
+
module Models
|
5
|
+
class MfaRecoveryCodes
|
6
|
+
attr_reader :recovery_codes
|
7
|
+
|
8
|
+
def initialize(
|
9
|
+
recovery_codes:
|
10
|
+
)
|
11
|
+
@recovery_codes = recovery_codes
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.from(map:)
|
15
|
+
MfaRecoveryCodes.new(
|
16
|
+
recovery_codes: map["recoveryCodes"]
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_map
|
21
|
+
{
|
22
|
+
"recoveryCodes": @recovery_codes
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,23 +3,19 @@
|
|
3
3
|
module Appwrite
|
4
4
|
module Models
|
5
5
|
class MfaType
|
6
|
-
attr_reader :backups
|
7
6
|
attr_reader :secret
|
8
7
|
attr_reader :uri
|
9
8
|
|
10
9
|
def initialize(
|
11
|
-
backups:,
|
12
10
|
secret:,
|
13
11
|
uri:
|
14
12
|
)
|
15
|
-
@backups = backups
|
16
13
|
@secret = secret
|
17
14
|
@uri = uri
|
18
15
|
end
|
19
16
|
|
20
17
|
def self.from(map:)
|
21
18
|
MfaType.new(
|
22
|
-
backups: map["backups"],
|
23
19
|
secret: map["secret"],
|
24
20
|
uri: map["uri"]
|
25
21
|
)
|
@@ -27,7 +23,6 @@ module Appwrite
|
|
27
23
|
|
28
24
|
def to_map
|
29
25
|
{
|
30
|
-
"backups": @backups,
|
31
26
|
"secret": @secret,
|
32
27
|
"uri": @uri
|
33
28
|
}
|
@@ -30,6 +30,7 @@ module Appwrite
|
|
30
30
|
attr_reader :current
|
31
31
|
attr_reader :factors
|
32
32
|
attr_reader :secret
|
33
|
+
attr_reader :mfa_updated_at
|
33
34
|
|
34
35
|
def initialize(
|
35
36
|
id:,
|
@@ -58,7 +59,8 @@ module Appwrite
|
|
58
59
|
country_name:,
|
59
60
|
current:,
|
60
61
|
factors:,
|
61
|
-
secret
|
62
|
+
secret:,
|
63
|
+
mfa_updated_at:
|
62
64
|
)
|
63
65
|
@id = id
|
64
66
|
@created_at = created_at
|
@@ -87,6 +89,7 @@ module Appwrite
|
|
87
89
|
@current = current
|
88
90
|
@factors = factors
|
89
91
|
@secret = secret
|
92
|
+
@mfa_updated_at = mfa_updated_at
|
90
93
|
end
|
91
94
|
|
92
95
|
def self.from(map:)
|
@@ -117,7 +120,8 @@ module Appwrite
|
|
117
120
|
country_name: map["countryName"],
|
118
121
|
current: map["current"],
|
119
122
|
factors: map["factors"],
|
120
|
-
secret: map["secret"]
|
123
|
+
secret: map["secret"],
|
124
|
+
mfa_updated_at: map["mfaUpdatedAt"]
|
121
125
|
)
|
122
126
|
end
|
123
127
|
|
@@ -149,7 +153,8 @@ module Appwrite
|
|
149
153
|
"countryName": @country_name,
|
150
154
|
"current": @current,
|
151
155
|
"factors": @factors,
|
152
|
-
"secret": @secret
|
156
|
+
"secret": @secret,
|
157
|
+
"mfaUpdatedAt": @mfa_updated_at
|
153
158
|
}
|
154
159
|
end
|
155
160
|
end
|
data/lib/appwrite/models/user.rb
CHANGED
@@ -19,7 +19,6 @@ module Appwrite
|
|
19
19
|
attr_reader :email_verification
|
20
20
|
attr_reader :phone_verification
|
21
21
|
attr_reader :mfa
|
22
|
-
attr_reader :totp
|
23
22
|
attr_reader :prefs
|
24
23
|
attr_reader :targets
|
25
24
|
attr_reader :accessed_at
|
@@ -41,7 +40,6 @@ module Appwrite
|
|
41
40
|
email_verification:,
|
42
41
|
phone_verification:,
|
43
42
|
mfa:,
|
44
|
-
totp:,
|
45
43
|
prefs:,
|
46
44
|
targets:,
|
47
45
|
accessed_at:
|
@@ -62,7 +60,6 @@ module Appwrite
|
|
62
60
|
@email_verification = email_verification
|
63
61
|
@phone_verification = phone_verification
|
64
62
|
@mfa = mfa
|
65
|
-
@totp = totp
|
66
63
|
@prefs = prefs
|
67
64
|
@targets = targets
|
68
65
|
@accessed_at = accessed_at
|
@@ -86,7 +83,6 @@ module Appwrite
|
|
86
83
|
email_verification: map["emailVerification"],
|
87
84
|
phone_verification: map["phoneVerification"],
|
88
85
|
mfa: map["mfa"],
|
89
|
-
totp: map["totp"],
|
90
86
|
prefs: Preferences.from(map: map["prefs"]),
|
91
87
|
targets: map["targets"].map { |it| Target.from(map: it) },
|
92
88
|
accessed_at: map["accessedAt"]
|
@@ -111,7 +107,6 @@ module Appwrite
|
|
111
107
|
"emailVerification": @email_verification,
|
112
108
|
"phoneVerification": @phone_verification,
|
113
109
|
"mfa": @mfa,
|
114
|
-
"totp": @totp,
|
115
110
|
"prefs": @prefs.to_map,
|
116
111
|
"targets": @targets.map { |it| it.to_map },
|
117
112
|
"accessedAt": @accessed_at
|