Skip to content

Commit 9c317a4

Browse files
committed
Release candidate for 1.5.x
1 parent d044fd9 commit 9c317a4

File tree

192 files changed

+15055
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+15055
-181
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
1+
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Appwrite PHP SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1)
4-
![Version](https://img.shields.io/badge/api%20version-1.4.12-blue.svg?style=flat-square&v=1)
4+
![Version](https://img.shields.io/badge/api%20version-1.4.13-blue.svg?style=flat-square&v=1)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

9-
**This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).**
9+
**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).**
1010

1111
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1212

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"ext-json": "*"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "3.7.35"
21+
"phpunit/phpunit": "^10",
22+
"mockery/mockery": "^1.6.6"
2223
},
2324
"minimum-stability": "dev"
2425
}

docs/account.md

Lines changed: 246 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ GET https://HOSTNAME/v1/account
88

99
** Get the currently logged in user. **
1010

11+
## Create account
12+
13+
```http request
14+
POST https://HOSTNAME/v1/account
15+
```
16+
17+
** Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). **
18+
19+
### Parameters
20+
21+
| Field Name | Type | Description | Default |
22+
| --- | --- | --- | --- |
23+
| userId | string | 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. | |
24+
| email | string | User email. | |
25+
| password | string | New user password. Must be between 8 and 256 chars. | |
26+
| name | string | User name. Max length: 128 chars. | |
27+
1128
## Update email
1229

1330
```http request
@@ -37,9 +54,9 @@ GET https://HOSTNAME/v1/account/identities
3754

3855
| Field Name | Type | Description | Default |
3956
| --- | --- | --- | --- |
40-
| queries | string | 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 | [] |
57+
| queries | array | 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 | [] |
4158

42-
## Delete Identity
59+
## Delete identity
4360

4461
```http request
4562
DELETE https://HOSTNAME/v1/account/identities/{identityId}
@@ -53,6 +70,14 @@ DELETE https://HOSTNAME/v1/account/identities/{identityId}
5370
| --- | --- | --- | --- |
5471
| identityId | string | **Required** Identity ID. | |
5572

73+
## Create JWT
74+
75+
```http request
76+
POST https://HOSTNAME/v1/account/jwt
77+
```
78+
79+
** Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. **
80+
5681
## List logs
5782

5883
```http request
@@ -67,6 +92,89 @@ GET https://HOSTNAME/v1/account/logs
6792
| --- | --- | --- | --- |
6893
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset | [] |
6994

95+
## Update MFA
96+
97+
```http request
98+
PATCH https://HOSTNAME/v1/account/mfa
99+
```
100+
101+
### Parameters
102+
103+
| Field Name | Type | Description | Default |
104+
| --- | --- | --- | --- |
105+
| mfa | boolean | Enable or disable MFA. | |
106+
107+
## Create MFA Challenge
108+
109+
```http request
110+
POST https://HOSTNAME/v1/account/mfa/challenge
111+
```
112+
113+
### Parameters
114+
115+
| Field Name | Type | Description | Default |
116+
| --- | --- | --- | --- |
117+
| provider | string | provider. | |
118+
119+
## Create MFA Challenge (confirmation)
120+
121+
```http request
122+
PUT https://HOSTNAME/v1/account/mfa/challenge
123+
```
124+
125+
### Parameters
126+
127+
| Field Name | Type | Description | Default |
128+
| --- | --- | --- | --- |
129+
| challengeId | string | Valid verification token. | |
130+
| otp | string | Valid verification token. | |
131+
132+
## List Factors
133+
134+
```http request
135+
GET https://HOSTNAME/v1/account/mfa/factors
136+
```
137+
138+
** Get the currently logged in user. **
139+
140+
## Add Authenticator
141+
142+
```http request
143+
POST https://HOSTNAME/v1/account/mfa/{factor}
144+
```
145+
146+
### Parameters
147+
148+
| Field Name | Type | Description | Default |
149+
| --- | --- | --- | --- |
150+
| factor | string | **Required** Factor. | |
151+
152+
## Verify Authenticator
153+
154+
```http request
155+
PUT https://HOSTNAME/v1/account/mfa/{factor}
156+
```
157+
158+
### Parameters
159+
160+
| Field Name | Type | Description | Default |
161+
| --- | --- | --- | --- |
162+
| factor | string | **Required** Factor. | |
163+
| otp | string | Valid verification token. | |
164+
165+
## Delete Authenticator
166+
167+
```http request
168+
DELETE https://HOSTNAME/v1/account/mfa/{provider}
169+
```
170+
171+
### Parameters
172+
173+
| Field Name | Type | Description | Default |
174+
| --- | --- | --- | --- |
175+
| provider | string | **Required** Provider. | |
176+
| otp | string | Valid verification token. | |
177+
70178
## Update name
71179

72180
```http request
@@ -164,8 +272,7 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/
164272
| --- | --- | --- | --- |
165273
| userId | string | User ID. | |
166274
| secret | string | Valid reset token. | |
167-
| password | string | New user password. Must be at least 8 chars. | |
168-
| passwordAgain | string | Repeat new user password. Must be at least 8 chars. | |
275+
| password | string | New user password. Must be between 8 and 256 chars. | |
169276

170277
## List sessions
171278

@@ -183,6 +290,84 @@ DELETE https://HOSTNAME/v1/account/sessions
183290

184291
** Delete all sessions from the user account and remove any sessions cookies from the end client. **
185292

293+
## Create anonymous session
294+
295+
```http request
296+
POST https://HOSTNAME/v1/account/sessions/anonymous
297+
```
298+
299+
** Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). **
300+
301+
## Create email password session
302+
303+
```http request
304+
POST https://HOSTNAME/v1/account/sessions/email
305+
```
306+
307+
** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.
308+
309+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). **
310+
311+
### Parameters
312+
313+
| Field Name | Type | Description | Default |
314+
| --- | --- | --- | --- |
315+
| email | string | User email. | |
316+
| password | string | User password. Must be at least 8 chars. | |
317+
318+
## Create session (deprecated)
319+
320+
```http request
321+
PUT https://HOSTNAME/v1/account/sessions/magic-url
322+
```
323+
324+
** Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. **
325+
326+
### Parameters
327+
328+
| Field Name | Type | Description | Default |
329+
| --- | --- | --- | --- |
330+
| userId | string | 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. | |
331+
| secret | string | Valid verification token. | |
332+
333+
## Create OAuth2 session
334+
335+
```http request
336+
GET https://HOSTNAME/v1/account/sessions/oauth2/{provider}
337+
```
338+
339+
** Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
340+
341+
If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.
342+
343+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
344+
**
345+
346+
### Parameters
347+
348+
| Field Name | Type | Description | Default |
349+
| --- | --- | --- | --- |
350+
| provider | string | **Required** 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. | |
351+
| success | string | 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. | |
352+
| failure | string | 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. | |
353+
| token | boolean | Include token credentials in the final redirect, useful for server-side integrations, or when cookies are not available. | |
354+
| scopes | array | 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. | [] |
355+
356+
## Create session
357+
358+
```http request
359+
POST https://HOSTNAME/v1/account/sessions/token
360+
```
361+
362+
** Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. **
363+
364+
### Parameters
365+
366+
| Field Name | Type | Description | Default |
367+
| --- | --- | --- | --- |
368+
| userId | string | 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. | |
369+
| secret | string | Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. | |
370+
186371
## Get session
187372

188373
```http request
@@ -197,13 +382,13 @@ GET https://HOSTNAME/v1/account/sessions/{sessionId}
197382
| --- | --- | --- | --- |
198383
| sessionId | string | **Required** Session ID. Use the string 'current' to get the current device session. | |
199384

200-
## Update OAuth session (refresh tokens)
385+
## Update (or renew) a session
201386

202387
```http request
203388
PATCH https://HOSTNAME/v1/account/sessions/{sessionId}
204389
```
205390

206-
** Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token. **
391+
** Extend session's expiry to increase it's lifespan. Extending a session is useful when session length is short such as 5 minutes. **
207392

208393
### Parameters
209394

@@ -233,6 +418,61 @@ PATCH https://HOSTNAME/v1/account/status
233418

234419
** Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. **
235420

421+
## Create email token (OTP)
422+
423+
```http request
424+
POST https://HOSTNAME/v1/account/tokens/email
425+
```
426+
427+
** Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.
428+
429+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). **
430+
431+
### Parameters
432+
433+
| Field Name | Type | Description | Default |
434+
| --- | --- | --- | --- |
435+
| userId | string | 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. | |
436+
| email | string | User email. | |
437+
| phrase | boolean | 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. | |
438+
439+
## Create magic URL token
440+
441+
```http request
442+
POST https://HOSTNAME/v1/account/tokens/magic-url
443+
```
444+
445+
** Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.
446+
447+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
448+
**
449+
450+
### Parameters
451+
452+
| Field Name | Type | Description | Default |
453+
| --- | --- | --- | --- |
454+
| userId | string | 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. | |
455+
| email | string | User email. | |
456+
| url | string | 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. | |
457+
| phrase | boolean | 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. | |
458+
459+
## Create phone token
460+
461+
```http request
462+
POST https://HOSTNAME/v1/account/tokens/phone
463+
```
464+
465+
** Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.
466+
467+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). **
468+
469+
### Parameters
470+
471+
| Field Name | Type | Description | Default |
472+
| --- | --- | --- | --- |
473+
| userId | string | 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. | |
474+
| phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | |
475+
236476
## Create email verification
237477

238478
```http request

0 commit comments

Comments
 (0)