appwrite 10.1.2 → 11.0.0.pre.rc.4
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 +43 -4
- data/lib/appwrite/enums/authentication_factor.rb +9 -0
- data/lib/appwrite/enums/authenticator_type.rb +7 -0
- data/lib/appwrite/enums/browser.rb +20 -0
- data/lib/appwrite/enums/compression.rb +9 -0
- data/lib/appwrite/enums/credit_card.rb +22 -0
- data/lib/appwrite/enums/encryption.rb +9 -0
- data/lib/appwrite/enums/execution_method.rb +12 -0
- data/lib/appwrite/enums/flag.rb +200 -0
- data/lib/appwrite/enums/image_format.rb +11 -0
- data/lib/appwrite/enums/image_gravity.rb +15 -0
- data/lib/appwrite/enums/index_type.rb +10 -0
- data/lib/appwrite/enums/message_status.rb +9 -0
- data/lib/appwrite/enums/messaging_provider_type.rb +9 -0
- data/lib/appwrite/enums/name.rb +18 -0
- data/lib/appwrite/enums/o_auth_provider.rb +45 -0
- data/lib/appwrite/enums/password_hash.rb +17 -0
- data/lib/appwrite/enums/relation_mutate.rb +9 -0
- data/lib/appwrite/enums/relationship_type.rb +10 -0
- data/lib/appwrite/enums/runtime.rb +42 -0
- data/lib/appwrite/models/health_certificate.rb +52 -0
- data/lib/appwrite/models/jwt.rb +27 -0
- data/lib/appwrite/models/membership.rb +5 -0
- data/lib/appwrite/models/message.rb +87 -0
- data/lib/appwrite/models/message_list.rb +32 -0
- data/lib/appwrite/models/mfa_challenge.rb +42 -0
- data/lib/appwrite/models/mfa_factors.rb +37 -0
- data/lib/appwrite/models/mfa_type.rb +37 -0
- data/lib/appwrite/models/provider.rb +67 -0
- data/lib/appwrite/models/provider_list.rb +32 -0
- data/lib/appwrite/models/session.rb +13 -3
- data/lib/appwrite/models/subscriber.rb +67 -0
- data/lib/appwrite/models/subscriber_list.rb +32 -0
- data/lib/appwrite/models/target.rb +62 -0
- data/lib/appwrite/models/target_list.rb +32 -0
- data/lib/appwrite/models/token.rb +8 -3
- data/lib/appwrite/models/topic.rb +62 -0
- data/lib/appwrite/models/topic_list.rb +32 -0
- data/lib/appwrite/models/user.rb +15 -0
- data/lib/appwrite/query.rb +53 -28
- data/lib/appwrite/services/account.rb +650 -12
- data/lib/appwrite/services/avatars.rb +3 -3
- data/lib/appwrite/services/databases.rb +6 -6
- data/lib/appwrite/services/functions.rb +3 -3
- data/lib/appwrite/services/health.rb +59 -0
- data/lib/appwrite/services/messaging.rb +1879 -0
- data/lib/appwrite/services/storage.rb +4 -4
- data/lib/appwrite/services/teams.rb +1 -1
- data/lib/appwrite/services/users.rb +382 -4
- data/lib/appwrite.rb +36 -0
- metadata +39 -4
@@ -31,6 +31,56 @@ module Appwrite
|
|
31
31
|
end
|
32
32
|
|
33
33
|
|
34
|
+
# Use this endpoint to allow a new user to register a new account in your
|
35
|
+
# project. After the user registration completes successfully, you can use
|
36
|
+
# the
|
37
|
+
# [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification)
|
38
|
+
# route to start verifying the user email address. To allow the new user to
|
39
|
+
# login to their new account, you need to create a new [account
|
40
|
+
# session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
|
41
|
+
#
|
42
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
43
|
+
# @param [String] email User email.
|
44
|
+
# @param [String] password New user password. Must be between 8 and 256 chars.
|
45
|
+
# @param [String] name User name. Max length: 128 chars.
|
46
|
+
#
|
47
|
+
# @return [User]
|
48
|
+
def create(user_id:, email:, password:, name: nil)
|
49
|
+
api_path = '/account'
|
50
|
+
|
51
|
+
if user_id.nil?
|
52
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
53
|
+
end
|
54
|
+
|
55
|
+
if email.nil?
|
56
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
57
|
+
end
|
58
|
+
|
59
|
+
if password.nil?
|
60
|
+
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
61
|
+
end
|
62
|
+
|
63
|
+
api_params = {
|
64
|
+
userId: user_id,
|
65
|
+
email: email,
|
66
|
+
password: password,
|
67
|
+
name: name,
|
68
|
+
}
|
69
|
+
|
70
|
+
api_headers = {
|
71
|
+
"content-type": 'application/json',
|
72
|
+
}
|
73
|
+
|
74
|
+
@client.call(
|
75
|
+
method: 'POST',
|
76
|
+
path: api_path,
|
77
|
+
headers: api_headers,
|
78
|
+
params: api_params,
|
79
|
+
response_type: Models::User
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
34
84
|
# Update currently logged in user account email address. After changing user
|
35
85
|
# address, the user confirmation status will get reset. A new confirmation
|
36
86
|
# email is not sent automatically however you can use the send confirmation
|
@@ -76,7 +126,7 @@ module Appwrite
|
|
76
126
|
|
77
127
|
# Get the list of identities for the currently logged in user.
|
78
128
|
#
|
79
|
-
# @param [
|
129
|
+
# @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry
|
80
130
|
#
|
81
131
|
# @return [IdentityList]
|
82
132
|
def list_identities(queries: nil)
|
@@ -129,6 +179,34 @@ module Appwrite
|
|
129
179
|
end
|
130
180
|
|
131
181
|
|
182
|
+
# Use this endpoint to create a JSON Web Token. You can use the resulting JWT
|
183
|
+
# to authenticate on behalf of the current user when working with the
|
184
|
+
# Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
|
185
|
+
# from its creation and will be invalid if the user will logout in that time
|
186
|
+
# frame.
|
187
|
+
#
|
188
|
+
#
|
189
|
+
# @return [Jwt]
|
190
|
+
def create_jwt()
|
191
|
+
api_path = '/account/jwt'
|
192
|
+
|
193
|
+
api_params = {
|
194
|
+
}
|
195
|
+
|
196
|
+
api_headers = {
|
197
|
+
"content-type": 'application/json',
|
198
|
+
}
|
199
|
+
|
200
|
+
@client.call(
|
201
|
+
method: 'POST',
|
202
|
+
path: api_path,
|
203
|
+
headers: api_headers,
|
204
|
+
params: api_params,
|
205
|
+
response_type: Models::Jwt
|
206
|
+
)
|
207
|
+
end
|
208
|
+
|
209
|
+
|
132
210
|
# Get the list of latest security activity logs for the currently logged in
|
133
211
|
# user. Each log returns user IP address, location and date and time of log.
|
134
212
|
#
|
@@ -156,6 +234,227 @@ module Appwrite
|
|
156
234
|
end
|
157
235
|
|
158
236
|
|
237
|
+
#
|
238
|
+
#
|
239
|
+
# @param [] mfa Enable or disable MFA.
|
240
|
+
#
|
241
|
+
# @return [User]
|
242
|
+
def update_mfa(mfa:)
|
243
|
+
api_path = '/account/mfa'
|
244
|
+
|
245
|
+
if mfa.nil?
|
246
|
+
raise Appwrite::Exception.new('Missing required parameter: "mfa"')
|
247
|
+
end
|
248
|
+
|
249
|
+
api_params = {
|
250
|
+
mfa: mfa,
|
251
|
+
}
|
252
|
+
|
253
|
+
api_headers = {
|
254
|
+
"content-type": 'application/json',
|
255
|
+
}
|
256
|
+
|
257
|
+
@client.call(
|
258
|
+
method: 'PATCH',
|
259
|
+
path: api_path,
|
260
|
+
headers: api_headers,
|
261
|
+
params: api_params,
|
262
|
+
response_type: Models::User
|
263
|
+
)
|
264
|
+
end
|
265
|
+
|
266
|
+
|
267
|
+
#
|
268
|
+
#
|
269
|
+
# @param [AuthenticationFactor] factor Factor used for verification.
|
270
|
+
#
|
271
|
+
# @return [MfaChallenge]
|
272
|
+
def create2_fa_challenge(factor:)
|
273
|
+
api_path = '/account/mfa/challenge'
|
274
|
+
|
275
|
+
if factor.nil?
|
276
|
+
raise Appwrite::Exception.new('Missing required parameter: "factor"')
|
277
|
+
end
|
278
|
+
|
279
|
+
api_params = {
|
280
|
+
factor: factor,
|
281
|
+
}
|
282
|
+
|
283
|
+
api_headers = {
|
284
|
+
"content-type": 'application/json',
|
285
|
+
}
|
286
|
+
|
287
|
+
@client.call(
|
288
|
+
method: 'POST',
|
289
|
+
path: api_path,
|
290
|
+
headers: api_headers,
|
291
|
+
params: api_params,
|
292
|
+
response_type: Models::MfaChallenge
|
293
|
+
)
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
#
|
298
|
+
#
|
299
|
+
# @param [String] challenge_id ID of the challenge.
|
300
|
+
# @param [String] otp Valid verification token.
|
301
|
+
#
|
302
|
+
# @return []
|
303
|
+
def update_challenge(challenge_id:, otp:)
|
304
|
+
api_path = '/account/mfa/challenge'
|
305
|
+
|
306
|
+
if challenge_id.nil?
|
307
|
+
raise Appwrite::Exception.new('Missing required parameter: "challengeId"')
|
308
|
+
end
|
309
|
+
|
310
|
+
if otp.nil?
|
311
|
+
raise Appwrite::Exception.new('Missing required parameter: "otp"')
|
312
|
+
end
|
313
|
+
|
314
|
+
api_params = {
|
315
|
+
challengeId: challenge_id,
|
316
|
+
otp: otp,
|
317
|
+
}
|
318
|
+
|
319
|
+
api_headers = {
|
320
|
+
"content-type": 'application/json',
|
321
|
+
}
|
322
|
+
|
323
|
+
@client.call(
|
324
|
+
method: 'PUT',
|
325
|
+
path: api_path,
|
326
|
+
headers: api_headers,
|
327
|
+
params: api_params,
|
328
|
+
)
|
329
|
+
end
|
330
|
+
|
331
|
+
|
332
|
+
#
|
333
|
+
#
|
334
|
+
#
|
335
|
+
# @return [MfaFactors]
|
336
|
+
def list_factors()
|
337
|
+
api_path = '/account/mfa/factors'
|
338
|
+
|
339
|
+
api_params = {
|
340
|
+
}
|
341
|
+
|
342
|
+
api_headers = {
|
343
|
+
"content-type": 'application/json',
|
344
|
+
}
|
345
|
+
|
346
|
+
@client.call(
|
347
|
+
method: 'GET',
|
348
|
+
path: api_path,
|
349
|
+
headers: api_headers,
|
350
|
+
params: api_params,
|
351
|
+
response_type: Models::MfaFactors
|
352
|
+
)
|
353
|
+
end
|
354
|
+
|
355
|
+
|
356
|
+
#
|
357
|
+
#
|
358
|
+
# @param [AuthenticatorType] type Type of authenticator.
|
359
|
+
#
|
360
|
+
# @return [MfaType]
|
361
|
+
def add_authenticator(type:)
|
362
|
+
api_path = '/account/mfa/{type}'
|
363
|
+
.gsub('{type}', type)
|
364
|
+
|
365
|
+
if type.nil?
|
366
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
367
|
+
end
|
368
|
+
|
369
|
+
api_params = {
|
370
|
+
}
|
371
|
+
|
372
|
+
api_headers = {
|
373
|
+
"content-type": 'application/json',
|
374
|
+
}
|
375
|
+
|
376
|
+
@client.call(
|
377
|
+
method: 'POST',
|
378
|
+
path: api_path,
|
379
|
+
headers: api_headers,
|
380
|
+
params: api_params,
|
381
|
+
response_type: Models::MfaType
|
382
|
+
)
|
383
|
+
end
|
384
|
+
|
385
|
+
|
386
|
+
#
|
387
|
+
#
|
388
|
+
# @param [AuthenticatorType] type Type of authenticator.
|
389
|
+
# @param [String] otp Valid verification token.
|
390
|
+
#
|
391
|
+
# @return [User]
|
392
|
+
def verify_authenticator(type:, otp:)
|
393
|
+
api_path = '/account/mfa/{type}'
|
394
|
+
.gsub('{type}', type)
|
395
|
+
|
396
|
+
if type.nil?
|
397
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
398
|
+
end
|
399
|
+
|
400
|
+
if otp.nil?
|
401
|
+
raise Appwrite::Exception.new('Missing required parameter: "otp"')
|
402
|
+
end
|
403
|
+
|
404
|
+
api_params = {
|
405
|
+
otp: otp,
|
406
|
+
}
|
407
|
+
|
408
|
+
api_headers = {
|
409
|
+
"content-type": 'application/json',
|
410
|
+
}
|
411
|
+
|
412
|
+
@client.call(
|
413
|
+
method: 'PUT',
|
414
|
+
path: api_path,
|
415
|
+
headers: api_headers,
|
416
|
+
params: api_params,
|
417
|
+
response_type: Models::User
|
418
|
+
)
|
419
|
+
end
|
420
|
+
|
421
|
+
|
422
|
+
#
|
423
|
+
#
|
424
|
+
# @param [AuthenticatorType] type Type of authenticator.
|
425
|
+
# @param [String] otp Valid verification token.
|
426
|
+
#
|
427
|
+
# @return [User]
|
428
|
+
def delete_authenticator(type:, otp:)
|
429
|
+
api_path = '/account/mfa/{type}'
|
430
|
+
.gsub('{type}', type)
|
431
|
+
|
432
|
+
if type.nil?
|
433
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
434
|
+
end
|
435
|
+
|
436
|
+
if otp.nil?
|
437
|
+
raise Appwrite::Exception.new('Missing required parameter: "otp"')
|
438
|
+
end
|
439
|
+
|
440
|
+
api_params = {
|
441
|
+
otp: otp,
|
442
|
+
}
|
443
|
+
|
444
|
+
api_headers = {
|
445
|
+
"content-type": 'application/json',
|
446
|
+
}
|
447
|
+
|
448
|
+
@client.call(
|
449
|
+
method: 'DELETE',
|
450
|
+
path: api_path,
|
451
|
+
headers: api_headers,
|
452
|
+
params: api_params,
|
453
|
+
response_type: Models::User
|
454
|
+
)
|
455
|
+
end
|
456
|
+
|
457
|
+
|
159
458
|
# Update currently logged in user account name.
|
160
459
|
#
|
161
460
|
# @param [String] name User name. Max length: 128 chars.
|
@@ -372,11 +671,10 @@ module Appwrite
|
|
372
671
|
#
|
373
672
|
# @param [String] user_id User ID.
|
374
673
|
# @param [String] secret Valid reset token.
|
375
|
-
# @param [String] password New user password. Must be
|
376
|
-
# @param [String] password_again Repeat new user password. Must be at least 8 chars.
|
674
|
+
# @param [String] password New user password. Must be between 8 and 256 chars.
|
377
675
|
#
|
378
676
|
# @return [Token]
|
379
|
-
def update_recovery(user_id:, secret:, password
|
677
|
+
def update_recovery(user_id:, secret:, password:)
|
380
678
|
api_path = '/account/recovery'
|
381
679
|
|
382
680
|
if user_id.nil?
|
@@ -391,15 +689,10 @@ module Appwrite
|
|
391
689
|
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
392
690
|
end
|
393
691
|
|
394
|
-
if password_again.nil?
|
395
|
-
raise Appwrite::Exception.new('Missing required parameter: "passwordAgain"')
|
396
|
-
end
|
397
|
-
|
398
692
|
api_params = {
|
399
693
|
userId: user_id,
|
400
694
|
secret: secret,
|
401
695
|
password: password,
|
402
|
-
passwordAgain: password_again,
|
403
696
|
}
|
404
697
|
|
405
698
|
api_headers = {
|
@@ -465,6 +758,205 @@ module Appwrite
|
|
465
758
|
end
|
466
759
|
|
467
760
|
|
761
|
+
# Use this endpoint to allow a new user to register an anonymous account in
|
762
|
+
# your project. This route will also create a new session for the user. To
|
763
|
+
# allow the new user to convert an anonymous account to a normal account, you
|
764
|
+
# need to update its [email and
|
765
|
+
# password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail)
|
766
|
+
# or create an [OAuth2
|
767
|
+
# session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).
|
768
|
+
#
|
769
|
+
#
|
770
|
+
# @return [Session]
|
771
|
+
def create_anonymous_session()
|
772
|
+
api_path = '/account/sessions/anonymous'
|
773
|
+
|
774
|
+
api_params = {
|
775
|
+
}
|
776
|
+
|
777
|
+
api_headers = {
|
778
|
+
"content-type": 'application/json',
|
779
|
+
}
|
780
|
+
|
781
|
+
@client.call(
|
782
|
+
method: 'POST',
|
783
|
+
path: api_path,
|
784
|
+
headers: api_headers,
|
785
|
+
params: api_params,
|
786
|
+
response_type: Models::Session
|
787
|
+
)
|
788
|
+
end
|
789
|
+
|
790
|
+
|
791
|
+
# Allow the user to login into their account by providing a valid email and
|
792
|
+
# password combination. This route will create a new session for the user.
|
793
|
+
#
|
794
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
795
|
+
# about session
|
796
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
797
|
+
#
|
798
|
+
# @param [String] email User email.
|
799
|
+
# @param [String] password User password. Must be at least 8 chars.
|
800
|
+
#
|
801
|
+
# @return [Session]
|
802
|
+
def create_email_password_session(email:, password:)
|
803
|
+
api_path = '/account/sessions/email'
|
804
|
+
|
805
|
+
if email.nil?
|
806
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
807
|
+
end
|
808
|
+
|
809
|
+
if password.nil?
|
810
|
+
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
811
|
+
end
|
812
|
+
|
813
|
+
api_params = {
|
814
|
+
email: email,
|
815
|
+
password: password,
|
816
|
+
}
|
817
|
+
|
818
|
+
api_headers = {
|
819
|
+
"content-type": 'application/json',
|
820
|
+
}
|
821
|
+
|
822
|
+
@client.call(
|
823
|
+
method: 'POST',
|
824
|
+
path: api_path,
|
825
|
+
headers: api_headers,
|
826
|
+
params: api_params,
|
827
|
+
response_type: Models::Session
|
828
|
+
)
|
829
|
+
end
|
830
|
+
|
831
|
+
|
832
|
+
# Use this endpoint to create a session from token. Provide the **userId**
|
833
|
+
# and **secret** parameters from the successful response of authentication
|
834
|
+
# flows initiated by token creation. For example, magic URL and phone login.
|
835
|
+
#
|
836
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
837
|
+
# @param [String] secret Valid verification token.
|
838
|
+
#
|
839
|
+
# @return [Session]
|
840
|
+
def update_magic_url_session(user_id:, secret:)
|
841
|
+
api_path = '/account/sessions/magic-url'
|
842
|
+
|
843
|
+
if user_id.nil?
|
844
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
845
|
+
end
|
846
|
+
|
847
|
+
if secret.nil?
|
848
|
+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
|
849
|
+
end
|
850
|
+
|
851
|
+
api_params = {
|
852
|
+
userId: user_id,
|
853
|
+
secret: secret,
|
854
|
+
}
|
855
|
+
|
856
|
+
api_headers = {
|
857
|
+
"content-type": 'application/json',
|
858
|
+
}
|
859
|
+
|
860
|
+
@client.call(
|
861
|
+
method: 'PUT',
|
862
|
+
path: api_path,
|
863
|
+
headers: api_headers,
|
864
|
+
params: api_params,
|
865
|
+
response_type: Models::Session
|
866
|
+
)
|
867
|
+
end
|
868
|
+
|
869
|
+
|
870
|
+
# Allow the user to login to their account using the OAuth2 provider of their
|
871
|
+
# choice. Each OAuth2 provider should be enabled from the Appwrite console
|
872
|
+
# first. Use the success and failure arguments to provide a redirect URL's
|
873
|
+
# back to your app when login is completed.
|
874
|
+
#
|
875
|
+
# If there is already an active session, the new session will be attached to
|
876
|
+
# the logged-in account. If there are no active sessions, the server will
|
877
|
+
# attempt to look for a user with the same email address as the email
|
878
|
+
# received from the OAuth2 provider and attach the new session to the
|
879
|
+
# existing user. If no matching user is found - the server will create a new
|
880
|
+
# user.
|
881
|
+
#
|
882
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
883
|
+
# about session
|
884
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
885
|
+
#
|
886
|
+
#
|
887
|
+
# @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.
|
888
|
+
# @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
889
|
+
# @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
890
|
+
# @param [] token Include token credentials in the final redirect, useful for server-side integrations, or when cookies are not available.
|
891
|
+
# @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
|
892
|
+
#
|
893
|
+
# @return []
|
894
|
+
def create_o_auth2_session(provider:, success: nil, failure: nil, token: nil, scopes: nil)
|
895
|
+
api_path = '/account/sessions/oauth2/{provider}'
|
896
|
+
.gsub('{provider}', provider)
|
897
|
+
|
898
|
+
if provider.nil?
|
899
|
+
raise Appwrite::Exception.new('Missing required parameter: "provider"')
|
900
|
+
end
|
901
|
+
|
902
|
+
api_params = {
|
903
|
+
success: success,
|
904
|
+
failure: failure,
|
905
|
+
token: token,
|
906
|
+
scopes: scopes,
|
907
|
+
}
|
908
|
+
|
909
|
+
api_headers = {
|
910
|
+
"content-type": 'application/json',
|
911
|
+
}
|
912
|
+
|
913
|
+
@client.call(
|
914
|
+
method: 'GET',
|
915
|
+
path: api_path,
|
916
|
+
headers: api_headers,
|
917
|
+
params: api_params,
|
918
|
+
)
|
919
|
+
end
|
920
|
+
|
921
|
+
|
922
|
+
# Use this endpoint to create a session from token. Provide the **userId**
|
923
|
+
# and **secret** parameters from the successful response of authentication
|
924
|
+
# flows initiated by token creation. For example, magic URL and phone login.
|
925
|
+
#
|
926
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
927
|
+
# @param [String] secret Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods.
|
928
|
+
#
|
929
|
+
# @return [Session]
|
930
|
+
def create_session(user_id:, secret:)
|
931
|
+
api_path = '/account/sessions/token'
|
932
|
+
|
933
|
+
if user_id.nil?
|
934
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
935
|
+
end
|
936
|
+
|
937
|
+
if secret.nil?
|
938
|
+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
|
939
|
+
end
|
940
|
+
|
941
|
+
api_params = {
|
942
|
+
userId: user_id,
|
943
|
+
secret: secret,
|
944
|
+
}
|
945
|
+
|
946
|
+
api_headers = {
|
947
|
+
"content-type": 'application/json',
|
948
|
+
}
|
949
|
+
|
950
|
+
@client.call(
|
951
|
+
method: 'POST',
|
952
|
+
path: api_path,
|
953
|
+
headers: api_headers,
|
954
|
+
params: api_params,
|
955
|
+
response_type: Models::Session
|
956
|
+
)
|
957
|
+
end
|
958
|
+
|
959
|
+
|
468
960
|
# Use this endpoint to get a logged in user's session using a Session ID.
|
469
961
|
# Inputting 'current' will return the current session being used.
|
470
962
|
#
|
@@ -496,9 +988,8 @@ module Appwrite
|
|
496
988
|
end
|
497
989
|
|
498
990
|
|
499
|
-
#
|
500
|
-
#
|
501
|
-
# "refresh" the access token.
|
991
|
+
# Extend session's expiry to increase it's lifespan. Extending a session is
|
992
|
+
# useful when session length is short such as 5 minutes.
|
502
993
|
#
|
503
994
|
# @param [String] session_id Session ID. Use the string 'current' to update the current device session.
|
504
995
|
#
|
@@ -587,6 +1078,153 @@ module Appwrite
|
|
587
1078
|
end
|
588
1079
|
|
589
1080
|
|
1081
|
+
# Sends the user an email with a secret key for creating a session. If the
|
1082
|
+
# provided user ID has not be registered, a new user will be created. Use the
|
1083
|
+
# returned user ID and secret and submit a request to the [POST
|
1084
|
+
# /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
1085
|
+
# endpoint to complete the login process. The secret sent to the user's email
|
1086
|
+
# is valid for 15 minutes.
|
1087
|
+
#
|
1088
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
1089
|
+
# about session
|
1090
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
1091
|
+
#
|
1092
|
+
# @param [String] user_id User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
1093
|
+
# @param [String] email User email.
|
1094
|
+
# @param [] phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.
|
1095
|
+
#
|
1096
|
+
# @return [Token]
|
1097
|
+
def create_email_token(user_id:, email:, phrase: nil)
|
1098
|
+
api_path = '/account/tokens/email'
|
1099
|
+
|
1100
|
+
if user_id.nil?
|
1101
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
1102
|
+
end
|
1103
|
+
|
1104
|
+
if email.nil?
|
1105
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
api_params = {
|
1109
|
+
userId: user_id,
|
1110
|
+
email: email,
|
1111
|
+
phrase: phrase,
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
api_headers = {
|
1115
|
+
"content-type": 'application/json',
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
@client.call(
|
1119
|
+
method: 'POST',
|
1120
|
+
path: api_path,
|
1121
|
+
headers: api_headers,
|
1122
|
+
params: api_params,
|
1123
|
+
response_type: Models::Token
|
1124
|
+
)
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
|
1128
|
+
# Sends the user an email with a secret key for creating a session. If the
|
1129
|
+
# provided user ID has not been registered, a new user will be created. When
|
1130
|
+
# the user clicks the link in the email, the user is redirected back to the
|
1131
|
+
# URL you provided with the secret key and userId values attached to the URL
|
1132
|
+
# query string. Use the query string parameters to submit a request to the
|
1133
|
+
# [POST
|
1134
|
+
# /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
1135
|
+
# endpoint to complete the login process. The link sent to the user's email
|
1136
|
+
# address is valid for 1 hour. If you are on a mobile device you can leave
|
1137
|
+
# the URL parameter empty, so that the login completion will be handled by
|
1138
|
+
# your Appwrite instance by default.
|
1139
|
+
#
|
1140
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
1141
|
+
# about session
|
1142
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
1143
|
+
#
|
1144
|
+
#
|
1145
|
+
# @param [String] user_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
1146
|
+
# @param [String] email User email.
|
1147
|
+
# @param [String] url URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
1148
|
+
# @param [] phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.
|
1149
|
+
#
|
1150
|
+
# @return [Token]
|
1151
|
+
def create_magic_url_token(user_id:, email:, url: nil, phrase: nil)
|
1152
|
+
api_path = '/account/tokens/magic-url'
|
1153
|
+
|
1154
|
+
if user_id.nil?
|
1155
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
if email.nil?
|
1159
|
+
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
api_params = {
|
1163
|
+
userId: user_id,
|
1164
|
+
email: email,
|
1165
|
+
url: url,
|
1166
|
+
phrase: phrase,
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
api_headers = {
|
1170
|
+
"content-type": 'application/json',
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
@client.call(
|
1174
|
+
method: 'POST',
|
1175
|
+
path: api_path,
|
1176
|
+
headers: api_headers,
|
1177
|
+
params: api_params,
|
1178
|
+
response_type: Models::Token
|
1179
|
+
)
|
1180
|
+
end
|
1181
|
+
|
1182
|
+
|
1183
|
+
# Sends the user an SMS with a secret key for creating a session. If the
|
1184
|
+
# provided user ID has not be registered, a new user will be created. Use the
|
1185
|
+
# returned user ID and secret and submit a request to the [POST
|
1186
|
+
# /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
1187
|
+
# endpoint to complete the login process. The secret sent to the user's phone
|
1188
|
+
# is valid for 15 minutes.
|
1189
|
+
#
|
1190
|
+
# A user is limited to 10 active sessions at a time by default. [Learn more
|
1191
|
+
# about session
|
1192
|
+
# limits](https://appwrite.io/docs/authentication-security#limits).
|
1193
|
+
#
|
1194
|
+
# @param [String] user_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
1195
|
+
# @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
|
1196
|
+
#
|
1197
|
+
# @return [Token]
|
1198
|
+
def create_phone_token(user_id:, phone:)
|
1199
|
+
api_path = '/account/tokens/phone'
|
1200
|
+
|
1201
|
+
if user_id.nil?
|
1202
|
+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
if phone.nil?
|
1206
|
+
raise Appwrite::Exception.new('Missing required parameter: "phone"')
|
1207
|
+
end
|
1208
|
+
|
1209
|
+
api_params = {
|
1210
|
+
userId: user_id,
|
1211
|
+
phone: phone,
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
api_headers = {
|
1215
|
+
"content-type": 'application/json',
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
@client.call(
|
1219
|
+
method: 'POST',
|
1220
|
+
path: api_path,
|
1221
|
+
headers: api_headers,
|
1222
|
+
params: api_params,
|
1223
|
+
response_type: Models::Token
|
1224
|
+
)
|
1225
|
+
end
|
1226
|
+
|
1227
|
+
|
590
1228
|
# Use this endpoint to send a verification message to your user email address
|
591
1229
|
# to confirm they are the valid owners of that address. Both the **userId**
|
592
1230
|
# and **secret** arguments will be passed as query parameters to the URL you
|