mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge branch 'master' of github.com:appwrite/appwrite into preloader
This commit is contained in:
+133
-100
@@ -1,171 +1,204 @@
|
||||
# Version 0.6.2 (PRE-RELEASE)
|
||||
|
||||
## Features
|
||||
|
||||
- New route in Locale API to fetch list of languages
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Fixed custom domain not setting correct domain
|
||||
- Fixed wrong SDK method type in avatars browser route
|
||||
- Fixed bug denied public documents (*) to be accessed by guest users
|
||||
- Fixed cache control issue not allowing collection UI to update properly
|
||||
- Fixed a bug where single permission tag in the console was not being saved
|
||||
- Added missing webhooks events in the console
|
||||
- Added missing option to delete project
|
||||
- Fixed a bug where the session was not set properly when the API used an IP with non-standard port as hostname
|
||||
- Fixed bug where requests number on the dashboard was hidden when the number got too long
|
||||
|
||||
## Security
|
||||
|
||||
- [low severity] Patch for email library (https://github.com/advisories/GHSA-f7hx-fqxw-rvvj)
|
||||
|
||||
# Version 0.6.1 (PRE-RELEASE)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Fix for Google OAuth provider not working properly
|
||||
- Fix for login error when using a remote host with non-default ports
|
||||
- Removed empty activity tab on the document editor
|
||||
- Changed upgrade script name to ‘migrate’ to better reflect what it actually does
|
||||
- Fixed bug where after clicking the cancel option in the confirmation dialog the button got disabled
|
||||
- Fixed a small grammar error in the documents list screen
|
||||
|
||||
# Version 0.6.0 (PRE-RELEASE)
|
||||
|
||||
## Features
|
||||
|
||||
* New collections UI with ability to create and update a collection
|
||||
* New documents UI with ability to create and update a document
|
||||
* Added support for Flutter iOS & Android apps
|
||||
* Added support for default DB document values
|
||||
* Exposed health API to all the server SDKs
|
||||
* New locale for Khmer
|
||||
* Added TypeScript type hinting to the JS SDK (@zevektor)
|
||||
* Added LTR/RTL support for markdown editor
|
||||
* Added cachebuster to version number on footer
|
||||
* New OAuth logos
|
||||
* Minor fixes to the dark mode theme
|
||||
* Added JSON view for a project user
|
||||
* Removed setKey and setMode methods from all client SDKs
|
||||
- New collections UI with ability to create and update a collection
|
||||
- New documents UI with ability to create and update a document
|
||||
- Added support for Flutter iOS & Android apps
|
||||
- Added support for default DB document values
|
||||
- Exposed health API to all the server SDKs
|
||||
- New locale for Khmer
|
||||
- Added TypeScript type hinting to the JS SDK (@zevektor)
|
||||
- Added LTR/RTL support for markdown editor
|
||||
- Added cachebuster to version number on footer
|
||||
- New OAuth logos
|
||||
- Minor fixes to the dark mode theme
|
||||
- Added JSON view for a project user
|
||||
- Removed setKey and setMode methods from all client SDKs
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
* Updated all the REST API query params to be in camelCase
|
||||
* Normalized locale phone codes response body
|
||||
- Updated all the REST API query params to be in camelCase
|
||||
- Normalized locale phone codes response body
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Fixed project users logout button
|
||||
* Fixed wrong target in database back link
|
||||
- Fixed project users logout button
|
||||
- Fixed wrong target in database back link
|
||||
|
||||
# Version 0.5.3 (PRE-RELEASE)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Fixed bug where multiple unique attribute were allowed
|
||||
* Blocked forms from being submitted unlimited times
|
||||
- Fixed bug where multiple unique attribute were allowed
|
||||
- Blocked forms from being submitted unlimited times
|
||||
|
||||
# Version 0.5.2 (PRE-RELEASE)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Fixed missing attributes in user account
|
||||
- Fixed missing attributes in user account
|
||||
|
||||
# Version 0.5.1 (PRE-RELEASE)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Delayed SSL init when server startup for traefik to be ready for HTTP challenge
|
||||
* Enabled easy access to the upgrade tool from the terminal
|
||||
- Delayed SSL init when server startup for traefik to be ready for HTTP challenge
|
||||
- Enabled easy access to the upgrade tool from the terminal
|
||||
|
||||
# Version 0.5.0 (PRE-RELEASE)
|
||||
|
||||
## Features
|
||||
|
||||
* Upgraded core API PHP version to 7.4
|
||||
* New database rule validation options
|
||||
* Allow non-web platform to skip origin header
|
||||
* Limited console dashboard to show max 5 alerts at the same time
|
||||
* Added more webhooks events
|
||||
* Normailized all webhooks event names
|
||||
* Added support for SameSite cookie option with fallback cookie for old clients
|
||||
* Added a new Discord OAuth adapter
|
||||
* Added a new Twitch OAuth adapter
|
||||
* Added a new Spotify OAuth adapter
|
||||
* Added a new Yahoo OAuth adapter
|
||||
* Added a new Salesforce OAuth adapter
|
||||
* Added a new Yandex OAuth adapter
|
||||
* Added a new Paypal OAuth adapter
|
||||
* Added a new Bitly OAuth adapter
|
||||
* Upgraded MariaDB image to version 1.0.2
|
||||
* Upgraded SMTP image to version 1.0.1
|
||||
* File upload route (POST /v1/storage/files) now accept a single file per request
|
||||
* Added ENV vars to change system email sender name and address
|
||||
* Usage for requests made by project admin in the console are not counted as API usage
|
||||
* Added ENV var to change default file upload size limit. New default value is 100MB
|
||||
* Added option to delete file directly from the dashboard
|
||||
* Added option to view file preview from the dashboard
|
||||
* Added option to add custom domains with auto SSL certificate generator
|
||||
- Upgraded core API PHP version to 7.4
|
||||
- New database rule validation options
|
||||
- Allow non-web platform to skip origin header
|
||||
- Limited console dashboard to show max 5 alerts at the same time
|
||||
- Added more webhooks events
|
||||
- Normailized all webhooks event names
|
||||
- Added support for SameSite cookie option with fallback cookie for old clients
|
||||
- Added a new Discord OAuth adapter
|
||||
- Added a new Twitch OAuth adapter
|
||||
- Added a new Spotify OAuth adapter
|
||||
- Added a new Yahoo OAuth adapter
|
||||
- Added a new Salesforce OAuth adapter
|
||||
- Added a new Yandex OAuth adapter
|
||||
- Added a new Paypal OAuth adapter
|
||||
- Added a new Bitly OAuth adapter
|
||||
- Upgraded MariaDB image to version 1.0.2
|
||||
- Upgraded SMTP image to version 1.0.1
|
||||
- File upload route (POST /v1/storage/files) now accept a single file per request
|
||||
- Added ENV vars to change system email sender name and address
|
||||
- Usage for requests made by project admin in the console are not counted as API usage
|
||||
- Added ENV var to change default file upload size limit. New default value is 100MB
|
||||
- Added option to delete file directly from the dashboard
|
||||
- Added option to view file preview from the dashboard
|
||||
- Added option to add custom domains with auto SSL certificate generator
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Fixed bug where user status was saved as a string instead of an integer
|
||||
* Fixed gravatar icons not showing up correctly on the console
|
||||
* Fixed code location of project not found error
|
||||
* Fixed bug where tags element would ignore tab key for parsing new tags
|
||||
* Fixed OAuth login error saying project UID is missing when its not
|
||||
* Fixed wrong input validation for user preferences
|
||||
- Fixed bug where user status was saved as a string instead of an integer
|
||||
- Fixed gravatar icons not showing up correctly on the console
|
||||
- Fixed code location of project not found error
|
||||
- Fixed bug where tags element would ignore tab key for parsing new tags
|
||||
- Fixed OAuth login error saying project UID is missing when its not
|
||||
- Fixed wrong input validation for user preferences
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
* Merged Auth and Account service route to make the API REST compatible
|
||||
- Merged Auth and Account service route to make the API REST compatible
|
||||
|
||||
# Version 0.4.0 (PRE-RELEASE)
|
||||
|
||||
## Features
|
||||
|
||||
* Added 5 new locales for locale service and email templates (is, ml, th, fo, ph, pn)
|
||||
* 2 stage Docker build
|
||||
* Limit HTTP origin check only to browser integrations
|
||||
* Updated new Brexit date to 31-01-2020
|
||||
* Added a version number to sign in and signup pages for easier debugging of issues
|
||||
* Preparation for adding SameSite cookie option support
|
||||
* Using native Docker volumes for setup for better cross-platform support and easier management of read/write permissions
|
||||
* Added support for custom SSL certificates without needing to set a proxy
|
||||
* Added project UID validation check when making an API call. This should help developers to understand our authentication errors better.
|
||||
* Updated ClamAV docker image to version 1.0.7
|
||||
* Updated MariaDB docker image to version 1.0.1
|
||||
* Core Docker image size reduced to 127MB
|
||||
- Added 5 new locales for locale service and email templates (is, ml, th, fo, ph, pn)
|
||||
- 2 stage Docker build
|
||||
- Limit HTTP origin check only to browser integrations
|
||||
- Updated new Brexit date to 31-01-2020
|
||||
- Added a version number to sign in and signup pages for easier debugging of issues
|
||||
- Preparation for adding SameSite cookie option support
|
||||
- Using native Docker volumes for setup for better cross-platform support and easier management of read/write permissions
|
||||
- Added support for custom SSL certificates without needing to set a proxy
|
||||
- Added project UID validation check when making an API call. This should help developers to understand our authentication errors better.
|
||||
- Updated ClamAV docker image to version 1.0.7
|
||||
- Updated MariaDB docker image to version 1.0.1
|
||||
- Core Docker image size reduced to 127MB
|
||||
|
||||
## Security
|
||||
|
||||
* [PHP-FPM security patch fix](https://bugs.php.net/patch-display.php?bug_id=78599&patch=0001-Fix-bug-78599-env_path_info-underflow-can-lead-to-RC.patch&revision=latest) - Upgraded PHP version to 7.3.12 [Major]
|
||||
* Remove executable permission from avatars files [Minor]
|
||||
* Updated SDK Generator Twig dependency with security issue: https://www.exploit-db.com/exploits/44102 [Minor]
|
||||
- [PHP-FPM security patch fix](https://bugs.php.net/patch-display.php?bug_id=78599&patch=0001-Fix-bug-78599-env_path_info-underflow-can-lead-to-RC.patch&revision=latest) - Upgraded PHP version to 7.3.12 [Major]
|
||||
- Remove executable permission from avatars files [Minor]
|
||||
- Updated SDK Generator Twig dependency with security issue: https://www.exploit-db.com/exploits/44102 [Minor]
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* New loading message when creating a new project
|
||||
* Fixed broken redirect URL when creating a new project
|
||||
* Fixed broken modal when a user password is too short
|
||||
* Fixed issue denying the creation of session cookies on localhosts with port other than 80 or 443
|
||||
* Fixed bug that prevented actual file size calculation
|
||||
* Fixed MariaDB SQL abuse table time field-type
|
||||
* Fixed error message not showing up in console failed signup
|
||||
* Fixed cookie session not being appropriately set when accessing the console from IP hostname
|
||||
- New loading message when creating a new project
|
||||
- Fixed broken redirect URL when creating a new project
|
||||
- Fixed broken modal when a user password is too short
|
||||
- Fixed issue denying the creation of session cookies on localhosts with port other than 80 or 443
|
||||
- Fixed bug that prevented actual file size calculation
|
||||
- Fixed MariaDB SQL abuse table time field-type
|
||||
- Fixed error message not showing up in console failed signup
|
||||
- Fixed cookie session not being appropriately set when accessing the console from IP hostname
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
* OAuth path is now /auth/login/oauth instead of /auth/oauth and /auth/oauth/callback is now /auth/login/oauth/callback, this is for better consistency with new login methods we will introduce in the future
|
||||
* Changed file attribute sizeCompressed to sizeActual to better reflect server logic
|
||||
- OAuth path is now /auth/login/oauth instead of /auth/oauth and /auth/oauth/callback is now /auth/login/oauth/callback, this is for better consistency with new login methods we will introduce in the future
|
||||
- Changed file attribute sizeCompressed to sizeActual to better reflect server logic
|
||||
|
||||
# Version 0.3.0 (PRE-RELEASE)
|
||||
|
||||
## Features
|
||||
|
||||
* Added 19 new locales for locale service and email templates (af, ar, bn, cz, hu, hy, jv, ko, lt, ml, no, ru, si, sq, sv, ta, vi, zh-cn, zh-tw)
|
||||
* New users service routes to allow updates pref and name update
|
||||
* New OAuth adapters (Amazon, Dropbox, Microsoft, Slack, VK)
|
||||
* Added support for ES6 require statements in JS SDK
|
||||
* New Locale API route for fetching a list of continents
|
||||
- Added 19 new locales for locale service and email templates (af, ar, bn, cz, hu, hy, jv, ko, lt, ml, no, ru, si, sq, sv, ta, vi, zh-cn, zh-tw)
|
||||
- New users service routes to allow updates pref and name update
|
||||
- New OAuth adapters (Amazon, Dropbox, Microsoft, Slack, VK)
|
||||
- Added support for ES6 require statements in JS SDK
|
||||
- New Locale API route for fetching a list of continents
|
||||
|
||||
## Bug Fixes
|
||||
* Fix for typos in PT-BR translations
|
||||
* Fix for UI crash when project user was missing a name
|
||||
* Fix for it locale including the en templates by mistake
|
||||
* Fix for UI not showing user's prefs properly
|
||||
* Fixed 401 unexpected error when no permission passed in creation of a new resource
|
||||
- Fix for typos in PT-BR translations
|
||||
- Fix for UI crash when project user was missing a name
|
||||
- Fix for it locale including the en templates by mistake
|
||||
- Fix for UI not showing user's prefs properly
|
||||
- Fixed 401 unexpected error when no permission passed in creation of a new resource
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
* users/deleteUsersSession method name changed to users/deleteUserSession in all SDKs for better consistency
|
||||
- users/deleteUsersSession method name changed to users/deleteUserSession in all SDKs for better consistency
|
||||
|
||||
# Version 0.2.0 (PRE-RELEASE)
|
||||
|
||||
## Features
|
||||
|
||||
* Added option to limit access to the Appwrite console
|
||||
* Added option to disable abuse check and rate limits
|
||||
* Added input field with the server API endpoint for easy access
|
||||
* Added new OAuth providers for Google, Bitbucket, and GitLab
|
||||
* Added 15 new locales for locale service and email templates (cat, de, es, fi, fr, gr, hi, id, it, nl, pt-br, pt-pt, ro, tr, ua)
|
||||
* Improved test coverage for the project and synced DEV & CI environments settings
|
||||
- Added option to limit access to the Appwrite console
|
||||
- Added option to disable abuse check and rate limits
|
||||
- Added input field with the server API endpoint for easy access
|
||||
- Added new OAuth providers for Google, Bitbucket, and GitLab
|
||||
- Added 15 new locales for locale service and email templates (cat, de, es, fi, fr, gr, hi, id, it, nl, pt-br, pt-pt, ro, tr, ua)
|
||||
- Improved test coverage for the project and synced DEV & CI environments settings
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Fixed bug not allowing to update OAuth providers settings
|
||||
* Fixed some broken API examples in docs
|
||||
* Fixed bug that caused the Appwrite container to change DB directory file permissions.
|
||||
- Fixed bug not allowing to update OAuth providers settings
|
||||
- Fixed some broken API examples in docs
|
||||
- Fixed bug that caused the Appwrite container to change DB directory file permissions.
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
* Changed auth service 'redirect' param to 'confirm' for better clarity
|
||||
* Updated all SDKs to sync with API changes
|
||||
- Changed auth service 'redirect' param to 'confirm' for better clarity
|
||||
- Updated all SDKs to sync with API changes
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ Before running the command, make sure you have proper write permissions to the A
|
||||
To run tests manually, run phpunit from your command line:
|
||||
|
||||
```bash
|
||||
docker exec appwrite /bin/bash -c '/usr/share/nginx/html/vendor/bin/phpunit'
|
||||
docker exec appwrite test
|
||||
```
|
||||
|
||||
## Tutorials
|
||||
|
||||
+7
-9
@@ -53,6 +53,7 @@ ENV TZ=Asia/Tel_Aviv \
|
||||
_APP_OPTIONS_ABUSE=enabled \
|
||||
_APP_OPENSSL_KEY_V1=your-secret-key \
|
||||
_APP_STORAGE_LIMIT=104857600 \
|
||||
_APP_STORAGE_ANTIVIRUS=enabled \
|
||||
_APP_REDIS_HOST=redis \
|
||||
_APP_REDIS_PORT=6379 \
|
||||
_APP_DB_HOST=mariadb \
|
||||
@@ -111,6 +112,7 @@ COPY ./docker/www.conf /etc/php/$PHP_VERSION/fpm/pool.d/www.conf
|
||||
|
||||
# Add PHP Source Code
|
||||
COPY ./app /usr/share/nginx/html/app
|
||||
COPY ./bin /usr/local/bin
|
||||
COPY ./docs /usr/share/nginx/html/docs
|
||||
COPY ./public /usr/share/nginx/html/public
|
||||
COPY ./src /usr/share/nginx/html/src
|
||||
@@ -131,7 +133,6 @@ COPY ./docker/supervisord.conf /etc/supervisord.conf
|
||||
# Set Upload Limit (default to 100MB)
|
||||
RUN echo "upload_max_filesize = ${_APP_STORAGE_LIMIT}" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
RUN echo "post_max_size = ${_APP_STORAGE_LIMIT}" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
RUN echo "env[TESTME] = your-secret-key" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
RUN echo "opcache.preload_user=www-data" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
RUN echo "opcache.preload=/usr/share/nginx/html/app/preload.php" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
RUN echo "opcache.preload_user=www-data" >> /etc/php/$PHP_VERSION/cli/conf.d/appwrite.ini
|
||||
@@ -140,13 +141,10 @@ RUN echo "opcache.preload=/usr/share/nginx/html/app/preload.php" >> /etc/php/$PH
|
||||
# Add logs file
|
||||
RUN echo "" >> /var/log/appwrite.log
|
||||
|
||||
# Start
|
||||
COPY ./docker/bin/start /start
|
||||
RUN chmod 775 /start
|
||||
|
||||
# Upgrade
|
||||
COPY ./docker/bin/upgrade /upgrade
|
||||
RUN chmod 775 /upgrade
|
||||
# Executables
|
||||
RUN chmod +x /usr/local/bin/start
|
||||
RUN chmod +x /usr/local/bin/migrate
|
||||
RUN chmod +x /usr/local/bin/test
|
||||
|
||||
# Letsencrypt Permissions
|
||||
RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/
|
||||
@@ -155,4 +153,4 @@ EXPOSE 80
|
||||
|
||||
WORKDIR /usr/share/nginx/html
|
||||
|
||||
CMD ["/bin/bash", "/start"]
|
||||
CMD ["/bin/bash", "/usr/local/bin/start"]
|
||||
@@ -2,7 +2,7 @@
|
||||
<a href="https://appwrite.io" target="_blank"><img width="260" height="39" src="https://appwrite.io/images/github-logo.png" alt="Appwrite Logo"></a>
|
||||
<br />
|
||||
<br />
|
||||
<b>Simple Backend Server for your [Vue / Angular / React / iOS / Android / Flutter / *ANY OTHER*] Frontend App</b>
|
||||
<b>A complete backend solution for your [Flutter / Vue / Angular / React / iOS / Android / *ANY OTHER*] client app</b>
|
||||
<br />
|
||||
<br />
|
||||
</p>
|
||||
@@ -14,14 +14,9 @@
|
||||
[](https://twitter.com/appwrite_io)
|
||||
[](https://stackshare.io/appwrite)
|
||||
|
||||
Appwrite is an end-to-end backend server for Web, Mobile, Native, or Backend apps packaged as a set of Docker microservices. Appwrite abstract the complexity and repetitiveness required to build a modern backend API from scratch to allow you to build secure apps faster.
|
||||
|
||||
Appwrite is a simple self-hosted backend server for web and mobile developers with a shiny dashboard and a very easy-to-use REST API.
|
||||
|
||||
Appwrite API services aim to make developer's life a lot easier by hiding the complexity of common and repetitive software development tasks.
|
||||
|
||||
Using Appwrite, you can easily manage user authentication with multiple sign-in methods, a database for storing and querying user and team data, storage and file management, image manipulation and cropping, schedule cron tasks and many other features to help you get more results in faster times and with a lot less code.
|
||||
|
||||
Appwrite can also integrate really well with your backend. Appwrite can word behind your own proxy facing your internal network, or alongside your own custom backend. You can use Appwrite server SDK to integrate your backend with Appwrite's APIs and webhooks.
|
||||
Using Appwrite, you can easily integrate your app with user authentication & multiple sign-in methods, a database for storing and querying users and team data, storage and file management, image manipulation, schedule CRON tasks, and [more services](https://appwrite.io/docs).
|
||||
|
||||
[https://appwrite.io](https://appwrite.io)
|
||||
|
||||
@@ -30,10 +25,15 @@ Appwrite can also integrate really well with your backend. Appwrite can word beh
|
||||
Table of Contents:
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Changing Port Number](#changing-port-number)
|
||||
- [Unix](#unix)
|
||||
- [Windows](#windows)
|
||||
- [CMD](#cmd)
|
||||
- [PowerShell](#powershell)
|
||||
- [Getting Started](#getting-started)
|
||||
- [Services](#services)
|
||||
- [SDKs](#sdks)
|
||||
- [Client](#client)
|
||||
- [Server](#server)
|
||||
- [Security](#security)
|
||||
- [Follow Us](#follow-us)
|
||||
- [Contributing](#contributing)
|
||||
@@ -45,58 +45,82 @@ Appwrite backend server is designed to run in a container environment. Running y
|
||||
|
||||
The easiest way to start running your Appwrite server is by running our docker-compose file. Before running the installation command make sure you have [Docker](https://www.docker.com/products/docker-desktop) installed on your machine:
|
||||
|
||||
### Unix
|
||||
|
||||
```bash
|
||||
docker run -it --rm \
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock \
|
||||
--volume "$(pwd)"/appwrite:/install/appwrite:rw \
|
||||
-e version=0.5.3 \
|
||||
-e version=0.6.1 \
|
||||
appwrite/install
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
#### CMD
|
||||
|
||||
```cmd
|
||||
docker run -it --rm ^
|
||||
--volume //var/run/docker.sock:/var/run/docker.sock ^
|
||||
--volume "%cd%"/appwrite:/install/appwrite:rw ^
|
||||
-e version=0.6.1 ^
|
||||
appwrite/install
|
||||
```
|
||||
|
||||
#### PowerShell
|
||||
|
||||
```powershell
|
||||
docker run -it --rm ,
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock ,
|
||||
--volume ${pwd}/appwrite:/install/appwrite:rw ,
|
||||
-e version=0.6.1 ,
|
||||
appwrite/install
|
||||
```
|
||||
|
||||
Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-linux native hosts, the server might take a few minutes to start after installation completes.
|
||||
|
||||
|
||||
For advanced production and custom installation, check out our Docker [environment variables](docs/tutorials/environment-variables.md) docs.
|
||||
|
||||
### Changing Port Number
|
||||
|
||||
In case your port 80 is already taken, change the port number in the command above. Make sure to set the correct endpoint in your selected SDK, including your new port number.
|
||||
For advanced production and custom installation, check out our Docker [environment variables](docs/tutorials/environment-variables.md) docs. You can also use our public [docker-compose.yml](https://appwrite.io/docker-compose.yml) file to manually set up and environment.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Getting started with Appwrite is as easy as creating a new project, choosing your platform and integrating its SDK in your code. You can easily get started with your platform of choice by reading one of our Getting Started tutorials.
|
||||
|
||||
* [Getting Started for Web](https://appwrite.io/docs/getting-started-for-web)
|
||||
* [Getting Started for Flutter](https://appwrite.io/docs/getting-started-for-flutter)
|
||||
* [Getting Started for Server](https://appwrite.io/docs/getting-started-for-server)
|
||||
* Getting Started for Android (soon...)
|
||||
* Getting Started for iOS (soon...)
|
||||
|
||||
### Services
|
||||
|
||||
* [**Account**](https://appwrite.io/docs/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sign-in methods, and security logs.
|
||||
* [**Users**](https://appwrite.io/docs/users) - Manage and list all project users when in admin mode.
|
||||
* [**Teams**](https://appwrite.io/docs/teams) - Manage and group users in teams. Manage memberships, invites, and user roles within a team.
|
||||
* [**Database**](https://appwrite.io/docs/database) - Manage database collections and documents. Read, create, update, and delete documents and filter lists of documents collections using an advanced filter with graph-like capabilities.
|
||||
* [**Storage**](https://appwrite.io/docs/storage) - Manage storage files. Read, create, delete, and preview files. Manipulate the preview of your files to fit your app perfectly. All files are scanned by ClamAV and stored in a secure and encrypted way.
|
||||
* [**Locale**](https://appwrite.io/docs/locale) - Track your user's location, and manage your app locale-based data.
|
||||
* [**Avatars**](https://appwrite.io/docs/avatars) - Manage your users' avatars, countries' flags, browser icons, credit card symbols, and generate QR codes.
|
||||
* [**Account**](https://appwrite.io/docs/client/account) - Manage current user authentication and account. Track and manage the user sessions, devices, sign-in methods, and security logs.
|
||||
* [**Users**](https://appwrite.io/docs/server/users) - Manage and list all project users when in admin mode.
|
||||
* [**Teams**](https://appwrite.io/docs/client/teams) - Manage and group users in teams. Manage memberships, invites, and user roles within a team.
|
||||
* [**Database**](https://appwrite.io/docs/client/database) - Manage database collections and documents. Read, create, update, and delete documents and filter lists of documents collections using an advanced filter with graph-like capabilities.
|
||||
* [**Storage**](https://appwrite.io/docs/client/storage) - Manage storage files. Read, create, delete, and preview files. Manipulate the preview of your files to fit your app perfectly. All files are scanned by ClamAV and stored in a secure and encrypted way.
|
||||
* [**Locale**](https://appwrite.io/docs/client/locale) - Track your user's location, and manage your app locale-based data.
|
||||
* [**Avatars**](https://appwrite.io/docs/client/avatars) - Manage your users' avatars, countries' flags, browser icons, credit card symbols, and generate QR codes.
|
||||
|
||||
For the complete API documentation, visit [https://appwrite.io/docs](https://appwrite.io/docs). For more tutorials, news and announcements check out our [blog](https://medium.com/appwrite-io).
|
||||
For the complete API documentation, visit [https://appwrite.io/docs](https://appwrite.io/docs). For more tutorials, news and announcements check out our [blog](https://medium.com/appwrite-io) and [Discord Server](https://discord.gg/GSeTUeA).
|
||||
|
||||
### SDKs
|
||||
|
||||
Currently, we support only a few SDK libraries and are constantly working on including new ones.
|
||||
|
||||
Below is a list of currently supported platforms and languages. If you wish to help us add support to your platform of choice, you can go over to our [SDK Generator](https://github.com/appwrite/sdk-generator) project and view our [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md).
|
||||
|
||||
* ✅ [JS](https://github.com/appwrite/sdk-for-js) (Maintained by the Appwrite Team)
|
||||
#### Client
|
||||
* ✅ [Web](https://github.com/appwrite/sdk-for-js) (Maintained by the Appwrite Team)
|
||||
* ✅ [Flutter](https://github.com/appwrite/sdk-for-flutter) (Maintained by the Appwrite Team)
|
||||
|
||||
#### Server
|
||||
* ✅ [NodeJS](https://github.com/appwrite/sdk-for-node) (Maintained by the Appwrite Team)
|
||||
* ✅ [PHP](https://github.com/appwrite/sdk-for-php) (Maintained by the Appwrite Team)
|
||||
* ✅ [Ruby](https://github.com/appwrite/sdk-for-ruby) - **Beta** (Maintained by the Appwrite Team)
|
||||
* ✅ [Python](https://github.com/appwrite/sdk-for-python) - **Beta** (Maintained by the Appwrite Team)
|
||||
* ✅ [Go](https://github.com/appwrite/sdk-for-go) **Work in progress** (Maintained by the Appwrite Team)
|
||||
* ✅ [Dart](https://github.com/appwrite/sdk-for-dart) **Work in progress** (Maintained by the Appwrite Team)
|
||||
* ✅ [Ruby](https://github.com/appwrite/sdk-for-ruby) - **Work in progress** (Maintained by the Appwrite Team)
|
||||
* ✅ [Python](https://github.com/appwrite/sdk-for-python) - **Work in progress** (Maintained by the Appwrite Team)
|
||||
* ✳️ Looking for more SDKs? - Help us by contributing a pull request to our [SDK Generator](https://github.com/appwrite/sdk-generator)!
|
||||
|
||||
Looking for more SDKs? - Help us by contributing a pull request to our [SDK Generator](https://github.com/appwrite/sdk-generator)!
|
||||
|
||||
## Security
|
||||
|
||||
|
||||
+12
-6
@@ -27,6 +27,7 @@ $services = include __DIR__.'/config/services.php'; // List of services
|
||||
$webhook = new Event('v1-webhooks', 'WebhooksV1');
|
||||
$audit = new Event('v1-audits', 'AuditsV1');
|
||||
$usage = new Event('v1-usage', 'UsageV1');
|
||||
$deletes = new Event('v1-deletes', 'DeletesV1');
|
||||
|
||||
/**
|
||||
* Get All verified client URLs for both console and current projects
|
||||
@@ -68,11 +69,12 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
||||
$refDomain = $protocol.'://'.((in_array($origin, $clients))
|
||||
? $origin : 'localhost') . (!empty($port) ? ':'.$port : '');
|
||||
|
||||
$selfDomain = new Domain(Config::getParam('domain'));
|
||||
$selfDomain = new Domain(Config::getParam('hostname'));
|
||||
$endDomain = new Domain($origin);
|
||||
|
||||
Config::setParam('domainVerification',
|
||||
($selfDomain->getRegisterable() === $endDomain->getRegisterable()));
|
||||
($selfDomain->getRegisterable() === $endDomain->getRegisterable()) &&
|
||||
$endDomain->getRegisterable() !== '');
|
||||
|
||||
/*
|
||||
* Security Headers
|
||||
@@ -86,7 +88,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
||||
//->addHeader('X-Frame-Options', ($refDomain == 'http://localhost') ? 'SAMEORIGIN' : 'ALLOW-FROM ' . $refDomain)
|
||||
->addHeader('X-Content-Type-Options', 'nosniff')
|
||||
->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE')
|
||||
->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version')
|
||||
->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version, Cache-Control, Expires, Pragma')
|
||||
->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies')
|
||||
->addHeader('Access-Control-Allow-Origin', $refDomain)
|
||||
->addHeader('Access-Control-Allow-Credentials', 'true')
|
||||
@@ -215,10 +217,10 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
||||
;
|
||||
});
|
||||
|
||||
$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage, $mode, $project, $utopia) {
|
||||
$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage, $deletes, $mode, $project, $utopia) {
|
||||
|
||||
/*
|
||||
* Trigger Events for background jobs
|
||||
* Trigger events for background workers
|
||||
*/
|
||||
if (!empty($webhook->getParam('event'))) {
|
||||
$webhook->trigger();
|
||||
@@ -228,6 +230,10 @@ $utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage
|
||||
$audit->trigger();
|
||||
}
|
||||
|
||||
if (!empty($deletes->getParam('document'))) {
|
||||
$deletes->trigger();
|
||||
}
|
||||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
if($project->getId()
|
||||
@@ -246,7 +252,7 @@ $utopia->options(function () use ($request, $response) {
|
||||
|
||||
$response
|
||||
->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE')
|
||||
->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version, X-Fallback-Cookies')
|
||||
->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version, Cache-Control, Expires, Pragma, X-Fallback-Cookies')
|
||||
->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies')
|
||||
->addHeader('Access-Control-Allow-Origin', $origin)
|
||||
->addHeader('Access-Control-Allow-Credentials', 'true')
|
||||
|
||||
@@ -41,7 +41,7 @@ $collections = [
|
||||
'$collection' => Database::SYSTEM_COLLECTION_PLATFORMS,
|
||||
'name' => 'Current Host',
|
||||
'type' => 'web',
|
||||
'hostname' => $request->getServer('HTTP_HOST'),
|
||||
'hostname' => parse_url('https://'.$request->getServer('HTTP_HOST'), PHP_URL_HOST),
|
||||
],
|
||||
],
|
||||
'legalName' => '',
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* List of publicly accessiable system events
|
||||
*/
|
||||
return [
|
||||
'account.create' => [
|
||||
'description' => 'This event triggers when the account is created.',
|
||||
],
|
||||
'account.update.email' => [
|
||||
'description' => 'This event triggers when the account email address is updated.',
|
||||
],
|
||||
'account.update.name' => [
|
||||
'description' => 'This event triggers when the account name is updated.',
|
||||
],
|
||||
'account.update.password' => [
|
||||
'description' => 'This event triggers when the account password is updated.',
|
||||
],
|
||||
'account.update.prefs' => [
|
||||
'description' => 'This event triggers when the account preferences are updated.',
|
||||
],
|
||||
'account.delete' => [
|
||||
'description' => 'This event triggers when the account is deleted.',
|
||||
],
|
||||
'account.sessions.create' => [
|
||||
'description' => 'This event triggers when the account session is created.',
|
||||
],
|
||||
'account.sessions.delete' => [
|
||||
'description' => 'This event triggers when the account session is deleted.',
|
||||
],
|
||||
'database.collections.create' => [
|
||||
'description' => 'This event triggers when a database collection is created.',
|
||||
],
|
||||
'database.collections.update' => [
|
||||
'description' => 'This event triggers when a database collection is updated.',
|
||||
],
|
||||
'database.collections.delete' => [
|
||||
'description' => 'This event triggers when a database collection is deleted.',
|
||||
],
|
||||
'database.documents.create' => [
|
||||
'description' => 'This event triggers when a database document is created.',
|
||||
],
|
||||
'database.documents.patch' => [
|
||||
'description' => 'This event triggers when a database document is patched.',
|
||||
],
|
||||
'database.documents.delete' => [
|
||||
'description' => 'This event triggers when a database document is deleted.',
|
||||
],
|
||||
'storage.files.create' => [
|
||||
'description' => 'This event triggers when a storage file is created.',
|
||||
],
|
||||
'storage.files.update' => [
|
||||
'description' => 'This event triggers when a storage file is updated.',
|
||||
],
|
||||
'storage.files.delete' => [
|
||||
'description' => 'This event triggers when a storage file is deleted.',
|
||||
],
|
||||
];
|
||||
+73
-95
@@ -1,60 +1,45 @@
|
||||
<?php
|
||||
|
||||
const APP_PLATFORM_WEB = 'web';
|
||||
const APP_PLATFORM_IOS = 'ios';
|
||||
const APP_PLATFORM_ANDROID = 'android';
|
||||
const APP_PLATFORM_UNITY = 'unity';
|
||||
const APP_PLATFORM_FLUTTER = 'flutter';
|
||||
|
||||
const APP_PLATFORM_SERVER = 'server';
|
||||
const APP_PLATFORM_CLIENT = 'client';
|
||||
const APP_PLATFORM_CONSOLE = 'console';
|
||||
|
||||
return [
|
||||
APP_PLATFORM_WEB => [
|
||||
'key' => APP_PLATFORM_WEB,
|
||||
'name' => 'Web',
|
||||
'description' => 'Client libraries for integrating with '.APP_NAME.' to build web-based applications and websites. Read the [getting started for web](/docs/getting-started-for-web) tutorial to start building your first web application.',
|
||||
APP_PLATFORM_CLIENT => [
|
||||
'key' => APP_PLATFORM_CLIENT,
|
||||
'name' => 'Client',
|
||||
'description' => 'Client libraries for integrating with '.APP_NAME.' to build client-based applications and websites. Read the [getting started for web](/docs/getting-started-for-web) or [getting started for Flutter](/docs/getting-started-for-flutter) tutorials to start building your first application.',
|
||||
'enabled' => true,
|
||||
'beta' => false,
|
||||
'languages' => [
|
||||
'languages' => [ // TODO change key to 'sdks'
|
||||
[
|
||||
'key' => 'javascript',
|
||||
'name' => 'JavaScript',
|
||||
'version' => '1.0.29',
|
||||
'key' => 'web',
|
||||
'name' => 'Web',
|
||||
'version' => '1.1.0',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-js',
|
||||
'enabled' => true,
|
||||
'beta' => false,
|
||||
'family' => APP_PLATFORM_CLIENT,
|
||||
'prism' => 'javascript',
|
||||
'source' => realpath(__DIR__ . '/../sdks/web-javascript'),
|
||||
'source' => realpath(__DIR__ . '/../sdks/client-web'),
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-js.git',
|
||||
'gitRepoName' => 'sdk-for-js',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
[
|
||||
'key' => 'typescript',
|
||||
'name' => 'TypeScript',
|
||||
'url' => '',
|
||||
'enabled' => false,
|
||||
'key' => 'flutter',
|
||||
'name' => 'Flutter',
|
||||
'version' => '0.2.2',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-flutter',
|
||||
'enabled' => true,
|
||||
'beta' => true,
|
||||
'family' => APP_PLATFORM_CLIENT,
|
||||
'prism' => 'typescript',
|
||||
'source' => false,
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-typescript.git',
|
||||
'gitRepoName' => 'sdk-for-typescript',
|
||||
'prism' => 'dart',
|
||||
'source' => realpath(__DIR__ . '/../sdks/client-flutter'),
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-flutter.git',
|
||||
'gitRepoName' => 'sdk-for-flutter',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
APP_PLATFORM_IOS => [
|
||||
'key' => APP_PLATFORM_IOS,
|
||||
'name' => 'iOS',
|
||||
'description' => 'Client libraries for integrating with '.APP_NAME.' to build iOS applications. Read the [getting started for iOS](/docs/getting-started-for-ios) tutorial to start building your first iOS application.',
|
||||
'enabled' => false,
|
||||
'beta' => false,
|
||||
'languages' => [
|
||||
[
|
||||
'key' => 'swift',
|
||||
'name' => 'Swift',
|
||||
@@ -81,16 +66,6 @@ return [
|
||||
'gitRepoName' => 'sdk-for-objective-c',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
APP_PLATFORM_ANDROID => [
|
||||
'key' => APP_PLATFORM_ANDROID,
|
||||
'name' => 'Android',
|
||||
'description' => 'Client libraries for integrating with '.APP_NAME.' to build Android applications. Read the [getting started for Android](/docs/getting-started-for-android) tutorial to start building your first Android application.',
|
||||
'enabled' => false,
|
||||
'beta' => false,
|
||||
'languages' => [
|
||||
[
|
||||
'key' => 'kotlin',
|
||||
'name' => 'Kotlin',
|
||||
@@ -104,62 +79,38 @@ return [
|
||||
'gitRepoName' => 'sdk-for-kotlin',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
[
|
||||
'key' => 'java',
|
||||
'name' => 'Java',
|
||||
'url' => '',
|
||||
'enabled' => false,
|
||||
'beta' => false,
|
||||
'family' => APP_PLATFORM_CLIENT,
|
||||
'prism' => 'java',
|
||||
'source' => false,
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-java.git',
|
||||
'gitRepoName' => 'sdk-for-java',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
// [
|
||||
// 'key' => 'java',
|
||||
// 'name' => 'Java',
|
||||
// 'url' => '',
|
||||
// 'enabled' => false,
|
||||
// 'beta' => false,
|
||||
// 'family' => APP_PLATFORM_CLIENT,
|
||||
// 'prism' => 'java',
|
||||
// 'source' => false,
|
||||
// 'gitUrl' => 'git@github.com:appwrite/sdk-for-java.git',
|
||||
// 'gitRepoName' => 'sdk-for-java',
|
||||
// 'gitUserName' => 'appwrite',
|
||||
// ],
|
||||
],
|
||||
],
|
||||
|
||||
APP_PLATFORM_FLUTTER => [
|
||||
'key' => APP_PLATFORM_FLUTTER,
|
||||
'name' => 'Flutter',
|
||||
'description' => 'Client libraries for integrating with '.APP_NAME.' to build cross-platform Flutter applications. Read the [getting started for Flutter](/docs/getting-started-for-flutter) tutorial to start building your first Flutter application.',
|
||||
'enabled' => true,
|
||||
'beta' => true,
|
||||
'languages' => [
|
||||
[
|
||||
'key' => 'dart',
|
||||
'name' => 'Dart',
|
||||
'version' => '0.1.1',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-dart',
|
||||
'enabled' => true,
|
||||
'beta' => true,
|
||||
'family' => APP_PLATFORM_CLIENT,
|
||||
'prism' => 'dart',
|
||||
'source' => realpath(__DIR__ . '/../sdks/flutter-dart'),
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-dart.git',
|
||||
'gitRepoName' => 'sdk-for-dart',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
APP_PLATFORM_CONSOLE => [
|
||||
'key' => APP_PLATFORM_CONSOLE,
|
||||
'name' => 'Console',
|
||||
'enabled' => false,
|
||||
'beta' => false,
|
||||
'languages' => [
|
||||
'languages' => [ // TODO change key to 'sdks'
|
||||
[
|
||||
'key' => 'javascript',
|
||||
'name' => 'JS',
|
||||
'key' => 'web',
|
||||
'name' => 'Console',
|
||||
'version' => '1.0.0',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-console',
|
||||
'enabled' => true,
|
||||
'beta' => false,
|
||||
'family' => APP_PLATFORM_CONSOLE,
|
||||
'prism' => 'console',
|
||||
'source' => realpath(__DIR__ . '/../sdks/console-javascript'),
|
||||
'source' => realpath(__DIR__ . '/../sdks/console-web'),
|
||||
'gitUrl' => null,
|
||||
'gitRepoName' => 'sdk-for-console',
|
||||
'gitUserName' => 'appwrite',
|
||||
@@ -173,11 +124,11 @@ return [
|
||||
'description' => 'Libraries for integrating with '.APP_NAME.' to build server side integrations. Read the [getting started for server](/docs/getting-started-for-server) tutorial to start building your first server integration.',
|
||||
'enabled' => true,
|
||||
'beta' => false,
|
||||
'languages' => [
|
||||
'languages' => [ // TODO change key to 'sdks'
|
||||
[
|
||||
'key' => 'nodejs',
|
||||
'name' => 'Node.js',
|
||||
'version' => '1.0.32',
|
||||
'version' => '1.1.0',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-node',
|
||||
'enabled' => true,
|
||||
'beta' => false,
|
||||
@@ -188,10 +139,24 @@ return [
|
||||
'gitRepoName' => 'sdk-for-node',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
[
|
||||
'key' => 'deno',
|
||||
'name' => 'Deno',
|
||||
'version' => '0.0.1',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-deno',
|
||||
'enabled' => false,
|
||||
'beta' => true,
|
||||
'family' => APP_PLATFORM_SERVER,
|
||||
'prism' => 'typescript',
|
||||
'source' => realpath(__DIR__ . '/../sdks/server-deno'),
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-deno.git',
|
||||
'gitRepoName' => 'sdk-for-deno',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
[
|
||||
'key' => 'php',
|
||||
'name' => 'PHP',
|
||||
'version' => '1.0.17',
|
||||
'version' => '1.1.0',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-php',
|
||||
'enabled' => true,
|
||||
'beta' => false,
|
||||
@@ -205,7 +170,7 @@ return [
|
||||
[
|
||||
'key' => 'python',
|
||||
'name' => 'Python',
|
||||
'version' => '0.0.4',
|
||||
'version' => '0.0.5',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-python',
|
||||
'enabled' => true,
|
||||
'beta' => true,
|
||||
@@ -219,7 +184,7 @@ return [
|
||||
[
|
||||
'key' => 'ruby',
|
||||
'name' => 'Ruby',
|
||||
'version' => '1.0.9',
|
||||
'version' => '1.0.10',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-ruby',
|
||||
'enabled' => true,
|
||||
'beta' => true,
|
||||
@@ -233,9 +198,9 @@ return [
|
||||
[
|
||||
'key' => 'go',
|
||||
'name' => 'Go',
|
||||
'version' => '0.0.6',
|
||||
'version' => '0.0.7',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-go',
|
||||
'enabled' => true,
|
||||
'enabled' => false,
|
||||
'beta' => true,
|
||||
'family' => APP_PLATFORM_SERVER,
|
||||
'prism' => 'go',
|
||||
@@ -247,9 +212,9 @@ return [
|
||||
[
|
||||
'key' => 'java',
|
||||
'name' => 'Java',
|
||||
'version' => '0.0.1',
|
||||
'version' => '0.0.2',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-java',
|
||||
'enabled' => true,
|
||||
'enabled' => false,
|
||||
'beta' => true,
|
||||
'family' => APP_PLATFORM_SERVER,
|
||||
'prism' => 'java',
|
||||
@@ -258,7 +223,20 @@ return [
|
||||
'gitRepoName' => 'sdk-for-java',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
[
|
||||
'key' => 'dart',
|
||||
'name' => 'Dart',
|
||||
'version' => '0.0.1',
|
||||
'url' => 'https://github.com/appwrite/sdk-for-dart',
|
||||
'enabled' => false,
|
||||
'beta' => true,
|
||||
'family' => APP_PLATFORM_SERVER,
|
||||
'prism' => 'java',
|
||||
'source' => realpath(__DIR__ . '/../sdks/server-dart'),
|
||||
'gitUrl' => 'git@github.com:appwrite/sdk-for-dart.git',
|
||||
'gitRepoName' => 'sdk-for-dart',
|
||||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -58,6 +58,7 @@ return [
|
||||
'public',
|
||||
'home',
|
||||
'console',
|
||||
'documents.read',
|
||||
'files.read',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
|
||||
@@ -21,4 +21,5 @@ return [ // List of publicly visible scopes
|
||||
// 'webhooks.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
];;
|
||||
@@ -30,8 +30,8 @@ use GeoIp2\Database\Reader;
|
||||
|
||||
include_once __DIR__ . '/../shared/api.php';
|
||||
|
||||
$oauthDefaultSuccess = Config::getParam('protocol').'://'.Config::getParam('domain').'/auth/oauth2/success';
|
||||
$oauthDefaultFailure = Config::getParam('protocol').'://'.Config::getParam('domain').'/auth/oauth2/failure';
|
||||
$oauthDefaultSuccess = $request->getServer('_APP_HOME').'/auth/oauth2/success';
|
||||
$oauthDefaultFailure = $request->getServer('_APP_HOME').'/auth/oauth2/failure';
|
||||
|
||||
$oauth2Keys = [];
|
||||
|
||||
@@ -251,8 +251,8 @@ $utopia->get('/v1/account/sessions/oauth2/:provider')
|
||||
->label('abuse-limit', 50)
|
||||
->label('abuse-key', 'ip:{ip}')
|
||||
->param('provider', '', function () { return new WhiteList(array_keys(Config::getParam('providers'))); }, 'OAuth2 Provider. Currently, supported providers are: ' . implode(', ', array_keys(array_filter(Config::getParam('providers'), function($node) {return (!$node['mock']);}))).'.')
|
||||
->param('success', $oauthDefaultSuccess, function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt.', true)
|
||||
->param('failure', $oauthDefaultFailure, function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.', true)
|
||||
->param('success', $oauthDefaultSuccess, function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt. 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.', true)
|
||||
->param('failure', $oauthDefaultFailure, function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt. 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.', true)
|
||||
->action(
|
||||
function ($provider, $success, $failure) use ($response, $request, $project) {
|
||||
$protocol = Config::getParam('protocol');
|
||||
@@ -483,6 +483,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||
if($state['success'] === $oauthDefaultSuccess) { // Add keys for non-web platforms
|
||||
$state['success'] = URLParser::parse($state['success']);
|
||||
$query = URLParser::parseQuery($state['success']['query']);
|
||||
$query['project'] = $project->getId();
|
||||
$query['domain'] = COOKIE_DOMAIN;
|
||||
$query['key'] = Auth::$cookieName;
|
||||
$query['secret'] = Auth::encodeSession($user->getId(), $secret);
|
||||
@@ -1026,7 +1027,7 @@ $utopia->post('/v1/account/recovery')
|
||||
->label('abuse-limit', 10)
|
||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
||||
->param('email', '', function () { return new Email(); }, 'User email.')
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email.')
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email. 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.')
|
||||
->action(
|
||||
function ($email, $url) use ($request, $response, $projectDB, $register, $audit, $project) {
|
||||
$profile = $projectDB->getCollection([ // Get user by email address
|
||||
@@ -1187,7 +1188,7 @@ $utopia->post('/v1/account/verification')
|
||||
->label('sdk.description', '/docs/references/account/create-verification.md')
|
||||
->label('abuse-limit', 10)
|
||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email.') // TODO add built-in confirm page
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email. 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.') // TODO add built-in confirm page
|
||||
->action(
|
||||
function ($url) use ($request, $response, $register, $user, $project, $projectDB, $audit) {
|
||||
$verificationSecret = Auth::tokenGenerator();
|
||||
|
||||
@@ -99,6 +99,7 @@ $utopia->get('/v1/avatars/credit-cards/:code')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
->label('sdk.method', 'getCreditCard')
|
||||
->label('sdk.methodType', 'location')
|
||||
->label('sdk.description', '/docs/references/avatars/get-credit-card.md')
|
||||
->action(function ($code, $width, $height, $quality) use ($avatarCallback) { return $avatarCallback('credit-cards', $code, $width, $height, $quality);
|
||||
});
|
||||
@@ -113,6 +114,7 @@ $utopia->get('/v1/avatars/browsers/:code')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
->label('sdk.method', 'getBrowser')
|
||||
->label('sdk.methodType', 'location')
|
||||
->label('sdk.description', '/docs/references/avatars/get-browser.md')
|
||||
->action(function ($code, $width, $height, $quality) use ($avatarCallback) { return $avatarCallback('browsers', $code, $width, $height, $quality);
|
||||
});
|
||||
@@ -127,6 +129,7 @@ $utopia->get('/v1/avatars/flags/:code')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
->label('sdk.method', 'getFlag')
|
||||
->label('sdk.methodType', 'location')
|
||||
->label('sdk.description', '/docs/references/avatars/get-flag.md')
|
||||
->action(function ($code, $width, $height, $quality) use ($avatarCallback) { return $avatarCallback('flags', $code, $width, $height, $quality);
|
||||
});
|
||||
@@ -140,6 +143,7 @@ $utopia->get('/v1/avatars/image')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
->label('sdk.method', 'getImage')
|
||||
->label('sdk.methodType', 'location')
|
||||
->label('sdk.description', '/docs/references/avatars/get-image.md')
|
||||
->action(
|
||||
function ($url, $width, $height) use ($response) {
|
||||
@@ -206,6 +210,7 @@ $utopia->get('/v1/avatars/favicon')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
->label('sdk.method', 'getFavicon')
|
||||
->label('sdk.methodType', 'location')
|
||||
->label('sdk.description', '/docs/references/avatars/get-favicon.md')
|
||||
->action(
|
||||
function ($url) use ($response, $request) {
|
||||
@@ -362,6 +367,7 @@ $utopia->get('/v1/avatars/qr')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'avatars')
|
||||
->label('sdk.method', 'getQR')
|
||||
->label('sdk.methodType', 'location')
|
||||
->label('sdk.description', '/docs/references/avatars/get-qr.md')
|
||||
->action(
|
||||
function ($text, $size, $margin, $download) use ($response) {
|
||||
|
||||
@@ -8,8 +8,8 @@ use Appwrite\Storage\Storage;
|
||||
use Appwrite\ClamAV\Network;
|
||||
|
||||
$utopia->get('/v1/health')
|
||||
->desc('Check API HTTP Health')
|
||||
->label('scope', 'public')
|
||||
->desc('Get HTTP')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'get')
|
||||
@@ -21,8 +21,8 @@ $utopia->get('/v1/health')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/db')
|
||||
->desc('Check DB Health')
|
||||
->label('scope', 'public')
|
||||
->desc('Get DB')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getDB')
|
||||
@@ -36,8 +36,8 @@ $utopia->get('/v1/health/db')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/cache')
|
||||
->desc('Check Cache Health')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Cache')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getCache')
|
||||
@@ -51,8 +51,8 @@ $utopia->get('/v1/health/cache')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/time')
|
||||
->desc('Check Time Health')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Time')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getTime')
|
||||
@@ -98,8 +98,8 @@ $utopia->get('/v1/health/time')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/queue/webhooks')
|
||||
->desc('Check number of pending webhook messages')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Webhooks Queue')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueWebhooks')
|
||||
@@ -111,8 +111,8 @@ $utopia->get('/v1/health/queue/webhooks')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/queue/tasks')
|
||||
->desc('Check the number of pending task messages')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Tasks Queue')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueTasks')
|
||||
@@ -124,8 +124,8 @@ $utopia->get('/v1/health/queue/tasks')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/queue/logs')
|
||||
->desc('Check the number of pending log messages')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Logs Queue')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueLogs')
|
||||
@@ -137,8 +137,8 @@ $utopia->get('/v1/health/queue/logs')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/queue/usage')
|
||||
->desc('Check the number of pending usage messages')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Usage Queue')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueUsage')
|
||||
@@ -150,8 +150,8 @@ $utopia->get('/v1/health/queue/usage')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/queue/certificates')
|
||||
->desc('Check the number of pending certificate messages')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Certificate Queue')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueCertificates')
|
||||
@@ -162,9 +162,22 @@ $utopia->get('/v1/health/queue/certificates')
|
||||
}
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/queue/functions')
|
||||
->desc('Get Functions Queue')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueFunctions')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-functions.md')
|
||||
->action(
|
||||
function () use ($response) {
|
||||
$response->json(['size' => Resque::size('v1-functions')]);
|
||||
}
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/storage/local')
|
||||
->desc('Check File System Health')
|
||||
->label('scope', 'public')
|
||||
->desc('Get Local Storage')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getStorageLocal')
|
||||
@@ -197,15 +210,19 @@ $utopia->get('/v1/health/storage/local')
|
||||
}
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/storage/anti-virus')
|
||||
->desc('Check Anti virus Health')
|
||||
->label('scope', 'public')
|
||||
$utopia->get('/v1/health/anti-virus')
|
||||
->desc('Get Anti virus')
|
||||
->label('scope', 'health.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getStorageAntiVirus')
|
||||
->label('sdk.method', 'getAntiVirus')
|
||||
->label('sdk.description', '/docs/references/health/get-storage-anti-virus.md')
|
||||
->action(
|
||||
function () use ($response) {
|
||||
function () use ($request, $response) {
|
||||
if($request->getServer('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled
|
||||
throw new Exception('Anitvirus is disabled');
|
||||
}
|
||||
|
||||
$antiVirus = new Network('clamav', 3310);
|
||||
|
||||
$response->json([
|
||||
@@ -216,7 +233,7 @@ $utopia->get('/v1/health/storage/anti-virus')
|
||||
);
|
||||
|
||||
$utopia->get('/v1/health/stats') // Currently only used internally
|
||||
->desc('System Stats')
|
||||
->desc('Get System Stats')
|
||||
->label('scope', 'god')
|
||||
// ->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
// ->label('sdk.namespace', 'health')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB;
|
||||
global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB, $deletes;
|
||||
|
||||
use Utopia\Exception;
|
||||
use Utopia\Response;
|
||||
@@ -175,7 +175,7 @@ $utopia->get('/v1/projects/:projectId/usage')
|
||||
],
|
||||
'last30' => [
|
||||
'start' => DateTime::createFromFormat('U', strtotime('-30 days')),
|
||||
'end' => DateTime::createFromFormat('U', strtotime('today')),
|
||||
'end' => DateTime::createFromFormat('U', strtotime('tomorrow')),
|
||||
'group' => '1d',
|
||||
],
|
||||
'last90' => [
|
||||
@@ -402,7 +402,7 @@ $utopia->delete('/v1/projects/:projectId')
|
||||
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
|
||||
->param('password', '', function () { return new UID(); }, 'Your user password for confirmation.')
|
||||
->action(
|
||||
function ($projectId, $password) use ($response, $consoleDB, $user) {
|
||||
function ($projectId, $password) use ($response, $consoleDB, $user, $deletes) {
|
||||
if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password
|
||||
throw new Exception('Invalid credentials', 401);
|
||||
}
|
||||
@@ -413,20 +413,22 @@ $utopia->delete('/v1/projects/:projectId')
|
||||
throw new Exception('Project not found', 404);
|
||||
}
|
||||
|
||||
// Delete all children (keys, webhooks, tasks [stop tasks?], platforms)
|
||||
$deletes->setParam('document', $project->getArrayCopy());
|
||||
|
||||
foreach(['keys', 'webhooks', 'tasks', 'platforms', 'domains'] as $key) { // Delete all children (keys, webhooks, tasks [stop tasks?], platforms)
|
||||
$list = $project->getAttribute('webhooks', []);
|
||||
|
||||
foreach ($list as $document) { /* @var $document Document */
|
||||
if (!$consoleDB->deleteDocument($projectId)) {
|
||||
throw new Exception('Failed to remove project document ('.$key.')] from DB', 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$consoleDB->deleteDocument($projectId)) {
|
||||
throw new Exception('Failed to remove project from DB', 500);
|
||||
}
|
||||
|
||||
// Delete all DBs
|
||||
// $consoleDB->deleteNamespace($project->getId());
|
||||
|
||||
// Optimize DB?
|
||||
|
||||
// Delete all storage files
|
||||
// Delete all storage cache
|
||||
|
||||
$response->noContent();
|
||||
}
|
||||
);
|
||||
@@ -1229,9 +1231,8 @@ $utopia->post('/v1/projects/:projectId/domains')
|
||||
->param('projectId', null, function () { return new UID(); }, 'Project unique ID.')
|
||||
->param('domain', null, function () { return new DomainValidator(); }, 'Domain name.')
|
||||
->action(
|
||||
function ($projectId) use ($request, $response, $consoleDB) {
|
||||
function ($projectId, $domain) use ($request, $response, $consoleDB) {
|
||||
$project = $consoleDB->getDocument($projectId);
|
||||
$domain = Config::getParam('domain');
|
||||
|
||||
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
||||
throw new Exception('Project not found', 404);
|
||||
|
||||
@@ -179,8 +179,6 @@ $utopia->post('/v1/storage/files')
|
||||
throw new Exception('File size not allowed', 400);
|
||||
}
|
||||
|
||||
$antiVirus = new Network('clamav', 3310);
|
||||
|
||||
/*
|
||||
* Models
|
||||
*/
|
||||
@@ -200,10 +198,14 @@ $utopia->post('/v1/storage/files')
|
||||
|
||||
$mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption
|
||||
|
||||
// Check if file size is exceeding allowed limit
|
||||
if (!$antiVirus->fileScan($path)) {
|
||||
$device->delete($path);
|
||||
throw new Exception('Invalid file', 403);
|
||||
if($request->getServer('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled
|
||||
$antiVirus = new Network('clamav', 3310);
|
||||
|
||||
// Check if file size is exceeding allowed limit
|
||||
if (!$antiVirus->fileScan($path)) {
|
||||
$device->delete($path);
|
||||
throw new Exception('Invalid file', 403);
|
||||
}
|
||||
}
|
||||
|
||||
// Compression
|
||||
@@ -654,53 +656,53 @@ $utopia->delete('/v1/storage/files/:fileId')
|
||||
}
|
||||
);
|
||||
|
||||
$utopia->get('/v1/storage/files/:fileId/scan')
|
||||
->desc('Scan Storage')
|
||||
->label('scope', 'god')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'storage')
|
||||
->label('sdk.method', 'getFileScan')
|
||||
->label('sdk.hide', true)
|
||||
->param('fileId', '', function () { return new UID(); }, 'File unique ID.')
|
||||
->param('storage', 'local', function () { return new WhiteList(['local']);})
|
||||
->action(
|
||||
function ($fileId, $storage) use ($response, $request, $projectDB) {
|
||||
$file = $projectDB->getDocument($fileId);
|
||||
// $utopia->get('/v1/storage/files/:fileId/scan')
|
||||
// ->desc('Scan Storage')
|
||||
// ->label('scope', 'god')
|
||||
// ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
// ->label('sdk.namespace', 'storage')
|
||||
// ->label('sdk.method', 'getFileScan')
|
||||
// ->label('sdk.hide', true)
|
||||
// ->param('fileId', '', function () { return new UID(); }, 'File unique ID.')
|
||||
// ->param('storage', 'local', function () { return new WhiteList(['local']);})
|
||||
// ->action(
|
||||
// function ($fileId, $storage) use ($response, $request, $projectDB) {
|
||||
// $file = $projectDB->getDocument($fileId);
|
||||
|
||||
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
|
||||
throw new Exception('File not found', 404);
|
||||
}
|
||||
// if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
|
||||
// throw new Exception('File not found', 404);
|
||||
// }
|
||||
|
||||
$path = $file->getAttribute('path', '');
|
||||
// $path = $file->getAttribute('path', '');
|
||||
|
||||
if (!file_exists($path)) {
|
||||
throw new Exception('File not found in '.$path, 404);
|
||||
}
|
||||
// if (!file_exists($path)) {
|
||||
// throw new Exception('File not found in '.$path, 404);
|
||||
// }
|
||||
|
||||
$compressor = new GZIP();
|
||||
$device = Storage::getDevice($storage);
|
||||
// $compressor = new GZIP();
|
||||
// $device = Storage::getDevice($storage);
|
||||
|
||||
$source = $device->read($path);
|
||||
// $source = $device->read($path);
|
||||
|
||||
if (!empty($file->getAttribute('fileOpenSSLCipher'))) { // Decrypt
|
||||
$source = OpenSSL::decrypt(
|
||||
$source,
|
||||
$file->getAttribute('fileOpenSSLCipher'),
|
||||
$request->getServer('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')),
|
||||
0,
|
||||
hex2bin($file->getAttribute('fileOpenSSLIV')),
|
||||
hex2bin($file->getAttribute('fileOpenSSLTag'))
|
||||
);
|
||||
}
|
||||
// if (!empty($file->getAttribute('fileOpenSSLCipher'))) { // Decrypt
|
||||
// $source = OpenSSL::decrypt(
|
||||
// $source,
|
||||
// $file->getAttribute('fileOpenSSLCipher'),
|
||||
// $request->getServer('_APP_OPENSSL_KEY_V'.$file->getAttribute('fileOpenSSLVersion')),
|
||||
// 0,
|
||||
// hex2bin($file->getAttribute('fileOpenSSLIV')),
|
||||
// hex2bin($file->getAttribute('fileOpenSSLTag'))
|
||||
// );
|
||||
// }
|
||||
|
||||
$source = $compressor->decompress($source);
|
||||
// $source = $compressor->decompress($source);
|
||||
|
||||
$antiVirus = new Network('clamav', 3310);
|
||||
// $antiVirus = new Network('clamav', 3310);
|
||||
|
||||
//var_dump($antiVirus->ping());
|
||||
//var_dump($antiVirus->version());
|
||||
//var_dump($antiVirus->fileScan('/storage/uploads/app-1/5/9/f/e/59fecaed49645.pdf'));
|
||||
// //var_dump($antiVirus->ping());
|
||||
// //var_dump($antiVirus->version());
|
||||
// //var_dump($antiVirus->fileScan('/storage/uploads/app-1/5/9/f/e/59fecaed49645.pdf'));
|
||||
|
||||
//$response->json($antiVirus->continueScan($device->getRoot()));
|
||||
}
|
||||
);
|
||||
// //$response->json($antiVirus->continueScan($device->getRoot()));
|
||||
// }
|
||||
// );
|
||||
|
||||
@@ -213,7 +213,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
|
||||
->param('email', '', function () { return new Email(); }, 'New team member email.')
|
||||
->param('name', '', function () { return new Text(100); }, 'New team member name.', true)
|
||||
->param('roles', [], function () { return new ArrayList(new Text(128)); }, 'Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions).')
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the invitation email.') // TODO add our own built-in confirm page
|
||||
->param('url', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the invitation email. 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.') // TODO add our own built-in confirm page
|
||||
->action(
|
||||
function ($teamId, $email, $name, $roles, $url) use ($response, $register, $project, $user, $audit, $projectDB) {
|
||||
$name = (empty($name)) ? $email : $name;
|
||||
|
||||
@@ -31,7 +31,7 @@ $layout
|
||||
->setParam('env', $utopia->getEnv())
|
||||
;
|
||||
|
||||
$utopia->shutdown(function () use ($utopia, $response, $request, $layout) {
|
||||
$utopia->init(function () use ($utopia, $response, $request, $layout) {
|
||||
$time = (60 * 60 * 24 * 45); // 45 days cache
|
||||
$isDev = (\Utopia\App::ENV_TYPE_DEVELOPMENT == Config::getParam('env'));
|
||||
|
||||
|
||||
@@ -133,7 +133,11 @@ $utopia->get('/console/webhooks')
|
||||
->label('scope', 'console')
|
||||
->action(function () use ($layout) {
|
||||
$page = new View(__DIR__.'/../../views/console/webhooks/index.phtml');
|
||||
|
||||
|
||||
$page
|
||||
->setParam('events', Config::getParam('events', []))
|
||||
;
|
||||
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Webhooks')
|
||||
->setParam('body', $page);
|
||||
@@ -183,7 +187,7 @@ $utopia->get('/console/database/collection')
|
||||
->label('permission', 'public')
|
||||
->label('scope', 'console')
|
||||
->param('id', '', function () { return new UID(); }, 'Collection unique ID.')
|
||||
->action(function ($id) use ($layout, $projectDB) {
|
||||
->action(function ($id) use ($response, $layout, $projectDB) {
|
||||
Authorization::disable();
|
||||
$collection = $projectDB->getDocument($id, false);
|
||||
Authorization::reset();
|
||||
@@ -197,10 +201,18 @@ $utopia->get('/console/database/collection')
|
||||
$page
|
||||
->setParam('collection', $collection)
|
||||
;
|
||||
|
||||
|
||||
$layout
|
||||
->setParam('title', APP_NAME.' - Database Collection')
|
||||
->setParam('body', $page);
|
||||
->setParam('body', $page)
|
||||
;
|
||||
|
||||
$response
|
||||
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
|
||||
->addHeader('Expires', 0)
|
||||
->addHeader('Pragma', 'no-cache')
|
||||
;
|
||||
|
||||
});
|
||||
|
||||
$utopia->get('/console/database/document')
|
||||
|
||||
@@ -6,6 +6,8 @@ global $utopia, $response, $request, $layout;
|
||||
|
||||
use Utopia\View;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Validator\WhiteList;
|
||||
use Utopia\Validator\Range;
|
||||
|
||||
$header = new View(__DIR__.'/../../views/home/comps/header.phtml');
|
||||
$footer = new View(__DIR__.'/../../views/home/comps/footer.phtml');
|
||||
@@ -155,3 +157,401 @@ $utopia->get('/error/:code')
|
||||
->setParam('title', 'Error'.' - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
});
|
||||
|
||||
$utopia->get('/open-api-2.json')
|
||||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->param('platform', APP_PLATFORM_CLIENT, function () {return new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE]);}, 'Choose target platform.', true)
|
||||
->param('extensions', 0, function () {return new Range(0, 1);}, 'Show extra data.', true)
|
||||
->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true)
|
||||
->action(
|
||||
function ($platform, $extensions, $tests) use ($response, $request, $utopia, $services) {
|
||||
function fromCamelCase($input)
|
||||
{
|
||||
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
|
||||
$ret = $matches[0];
|
||||
foreach ($ret as &$match) {
|
||||
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||
}
|
||||
|
||||
return implode('_', $ret);
|
||||
}
|
||||
|
||||
function fromCamelCaseToDash($input)
|
||||
{
|
||||
return str_replace([' ', '_'], '-', strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $input)));
|
||||
}
|
||||
|
||||
foreach ($services as $service) { /* @noinspection PhpIncludeInspection */
|
||||
if($tests && !isset($service['tests'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($tests && !$service['tests']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$tests && !$service['sdk']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include_once realpath(__DIR__.'/../../'.$service['controller']);
|
||||
}
|
||||
|
||||
$security = [
|
||||
APP_PLATFORM_CLIENT => ['Project' => []],
|
||||
APP_PLATFORM_SERVER => ['Project' => [], 'Key' => []],
|
||||
APP_PLATFORM_CONSOLE => ['Project' => [], 'Key' => []],
|
||||
];
|
||||
|
||||
$platforms = [
|
||||
'client' => APP_PLATFORM_CLIENT,
|
||||
'server' => APP_PLATFORM_SERVER,
|
||||
'all' => APP_PLATFORM_CONSOLE,
|
||||
];
|
||||
|
||||
$keys = [
|
||||
APP_PLATFORM_CLIENT => [
|
||||
'Project' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Project',
|
||||
'description' => 'Your project ID',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Locale' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Locale',
|
||||
'description' => '',
|
||||
'in' => 'header',
|
||||
],
|
||||
],
|
||||
APP_PLATFORM_SERVER => [
|
||||
'Project' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Project',
|
||||
'description' => 'Your project ID',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Key' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Key',
|
||||
'description' => 'Your secret API key',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Locale' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Locale',
|
||||
'description' => '',
|
||||
'in' => 'header',
|
||||
],
|
||||
],
|
||||
APP_PLATFORM_CONSOLE => [
|
||||
'Project' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Project',
|
||||
'description' => 'Your project ID',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Key' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Key',
|
||||
'description' => 'Your secret API key',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Locale' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Locale',
|
||||
'description' => '',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Mode' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Mode',
|
||||
'description' => '',
|
||||
'in' => 'header',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/*
|
||||
* Specifications (v3.0.0):
|
||||
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md
|
||||
*/
|
||||
$output = [
|
||||
'swagger' => '2.0',
|
||||
'info' => [
|
||||
'version' => APP_VERSION_STABLE,
|
||||
'title' => APP_NAME,
|
||||
'description' => 'Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)',
|
||||
'termsOfService' => 'https://appwrite.io/policy/terms',
|
||||
'contact' => [
|
||||
'name' => 'Appwrite Team',
|
||||
'url' => 'https://appwrite.io/support',
|
||||
'email' => $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM),
|
||||
],
|
||||
'license' => [
|
||||
'name' => 'BSD-3-Clause',
|
||||
'url' => 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE',
|
||||
],
|
||||
],
|
||||
'host' => parse_url($request->getServer('_APP_HOME', Config::getParam('domain')), PHP_URL_HOST),
|
||||
'basePath' => '/v1',
|
||||
'schemes' => ['https'],
|
||||
'consumes' => ['application/json', 'multipart/form-data'],
|
||||
'produces' => ['application/json'],
|
||||
'securityDefinitions' => $keys[$platform],
|
||||
'paths' => [],
|
||||
'definitions' => [
|
||||
// 'Pet' => [
|
||||
// 'required' => ['id', 'name'],
|
||||
// 'properties' => [
|
||||
// 'id' => [
|
||||
// 'type' => 'integer',
|
||||
// 'format' => 'int64',
|
||||
// ],
|
||||
// 'name' => [
|
||||
// 'type' => 'string',
|
||||
// ],
|
||||
// 'tag' => [
|
||||
// 'type' => 'string',
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
// 'Pets' => array(
|
||||
// 'type' => 'array',
|
||||
// 'items' => array(
|
||||
// '$ref' => '#/definitions/Pet',
|
||||
// ),
|
||||
// ),
|
||||
'Error' => array(
|
||||
'required' => array(
|
||||
0 => 'code',
|
||||
1 => 'message',
|
||||
),
|
||||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'integer',
|
||||
'format' => 'int32',
|
||||
),
|
||||
'message' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
'externalDocs' => [
|
||||
'description' => 'Full API docs, specs and tutorials',
|
||||
'url' => Config::getParam('protocol').'://'.Config::getParam('domain').'/docs',
|
||||
],
|
||||
];
|
||||
|
||||
if ($extensions) {
|
||||
if(isset($output['securityDefinitions']['Project'])) {
|
||||
$output['securityDefinitions']['Project']['extensions'] = ['demo' => '5df5acd0d48c2'];
|
||||
}
|
||||
|
||||
if(isset($output['securityDefinitions']['Key'])) {
|
||||
$output['securityDefinitions']['Key']['extensions'] = ['demo' => '919c2d18fb5d4...a2ae413da83346ad2'];
|
||||
}
|
||||
|
||||
if(isset($output['securityDefinitions']['Locale'])) {
|
||||
$output['securityDefinitions']['Locale']['extensions'] = ['demo' => 'en'];
|
||||
}
|
||||
|
||||
if(isset($output['securityDefinitions']['Mode'])) {
|
||||
$output['securityDefinitions']['Mode']['extensions'] = ['demo' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($utopia->getRoutes() as $key => $method) {
|
||||
foreach ($method as $route) { /* @var $route \Utopia\Route */
|
||||
if (!$route->getLabel('docs', true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($route->getLabel('sdk.namespace', null))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($platform !== APP_PLATFORM_CONSOLE && !in_array($platforms[$platform], $route->getLabel('sdk.platform', []))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$url = str_replace('/v1', '', $route->getURL());
|
||||
$scope = $route->getLabel('scope', '');
|
||||
$hide = $route->getLabel('sdk.hide', false);
|
||||
$consumes = ['application/json'];
|
||||
|
||||
if ($hide) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$desc = (!empty($route->getLabel('sdk.description', ''))) ? realpath('../'.$route->getLabel('sdk.description', '')) : null;
|
||||
|
||||
$temp = [
|
||||
'summary' => $route->getDesc(),
|
||||
'operationId' => $route->getLabel('sdk.method', uniqid()),
|
||||
'consumes' => [],
|
||||
'tags' => [$route->getLabel('sdk.namespace', 'default')],
|
||||
'description' => ($desc) ? file_get_contents($desc) : '',
|
||||
|
||||
// 'responses' => [
|
||||
// 200 => [
|
||||
// 'description' => 'An paged array of pets',
|
||||
// 'schema' => [
|
||||
// '$ref' => '#/definitions/Pet',
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
];
|
||||
|
||||
if ($extensions) {
|
||||
$platformList = $route->getLabel('sdk.platform', []);
|
||||
|
||||
$temp['extensions'] = [
|
||||
'weight' => $route->getOrder(),
|
||||
'cookies' => $route->getLabel('sdk.cookies', false),
|
||||
'type' => $route->getLabel('sdk.methodType', ''),
|
||||
'demo' => 'docs/examples/'.fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')).'/'.fromCamelCaseToDash($temp['operationId']).'.md',
|
||||
'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''),
|
||||
'rate-limit' => $route->getLabel('abuse-limit', 0),
|
||||
'rate-time' => $route->getLabel('abuse-time', 3600),
|
||||
'scope' => $route->getLabel('scope', ''),
|
||||
'platforms' => $platformList,
|
||||
];
|
||||
}
|
||||
|
||||
if ((!empty($scope))) { // && 'public' != $scope
|
||||
$temp['security'][] = $route->getLabel('sdk.security', $security[$platform]);
|
||||
}
|
||||
|
||||
$requestBody = [
|
||||
'content' => [
|
||||
'application/x-www-form-urlencoded' => [
|
||||
'schema' => [
|
||||
'type' => 'object',
|
||||
'properties' => [],
|
||||
],
|
||||
'required' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($route->getParams() as $name => $param) {
|
||||
$validator = (is_callable($param['validator'])) ? $param['validator']() : $param['validator']; /* @var $validator \Utopia\Validator */
|
||||
|
||||
$node = [
|
||||
'name' => $name,
|
||||
'description' => $param['description'],
|
||||
'required' => !$param['optional'],
|
||||
];
|
||||
|
||||
switch ((!empty($validator)) ? get_class($validator) : '') {
|
||||
case 'Utopia\Validator\Text':
|
||||
$node['type'] = 'string';
|
||||
$node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']';
|
||||
break;
|
||||
case 'Appwrite\Database\Validator\UID':
|
||||
$node['type'] = 'string';
|
||||
$node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']';
|
||||
break;
|
||||
case 'Utopia\Validator\Email':
|
||||
$node['type'] = 'string';
|
||||
$node['format'] = 'email';
|
||||
$node['x-example'] = 'email@example.com';
|
||||
break;
|
||||
case 'Utopia\Validator\URL':
|
||||
$node['type'] = 'string';
|
||||
$node['format'] = 'url';
|
||||
$node['x-example'] = 'https://example.com';
|
||||
break;
|
||||
case 'Utopia\Validator\JSON':
|
||||
case 'Utopia\Validator\Mock':
|
||||
case 'Utopia\Validator\Assoc':
|
||||
$node['type'] = 'object';
|
||||
$node['type'] = 'object';
|
||||
$node['x-example'] = '{}';
|
||||
//$node['format'] = 'json';
|
||||
break;
|
||||
case 'Appwrite\Storage\Validators\File':
|
||||
$consumes = ['multipart/form-data'];
|
||||
$node['type'] = 'file';
|
||||
break;
|
||||
case 'Utopia\Validator\ArrayList':
|
||||
$node['type'] = 'array';
|
||||
$node['collectionFormat'] = 'multi';
|
||||
$node['items'] = [
|
||||
'type' => 'string',
|
||||
];
|
||||
break;
|
||||
case 'Appwrite\Auth\Validator\Password':
|
||||
$node['type'] = 'string';
|
||||
$node['format'] = 'format';
|
||||
$node['x-example'] = 'password';
|
||||
break;
|
||||
case 'Utopia\Validator\Range': /* @var $validator \Utopia\Validator\Range */
|
||||
$node['type'] = 'integer';
|
||||
$node['format'] = 'int32';
|
||||
$node['x-example'] = $validator->getMin();
|
||||
break;
|
||||
case 'Utopia\Validator\Numeric':
|
||||
$node['type'] = 'integer';
|
||||
$node['format'] = 'int32';
|
||||
break;
|
||||
case 'Utopia\Validator\Length':
|
||||
$node['type'] = 'string';
|
||||
break;
|
||||
case 'Utopia\Validator\Host':
|
||||
$node['type'] = 'string';
|
||||
$node['format'] = 'url';
|
||||
$node['x-example'] = 'https://example.com';
|
||||
break;
|
||||
case 'Utopia\Validator\WhiteList': /* @var $validator \Utopia\Validator\WhiteList */
|
||||
$node['type'] = 'string';
|
||||
$node['x-example'] = $validator->getList()[0];
|
||||
break;
|
||||
default:
|
||||
$node['type'] = 'string';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($param['optional'] && !is_null($param['default'])) { // Param has default value
|
||||
$node['default'] = $param['default'];
|
||||
}
|
||||
|
||||
if (false !== strpos($url, ':'.$name)) { // Param is in URL path
|
||||
$node['in'] = 'path';
|
||||
$temp['parameters'][] = $node;
|
||||
} elseif ($key == 'GET') { // Param is in query
|
||||
$node['in'] = 'query';
|
||||
$temp['parameters'][] = $node;
|
||||
} else { // Param is in payload
|
||||
$node['in'] = 'formData';
|
||||
$temp['parameters'][] = $node;
|
||||
$requestBody['content']['application/x-www-form-urlencoded']['schema']['properties'][] = $node;
|
||||
|
||||
if (!$param['optional']) {
|
||||
$requestBody['content']['application/x-www-form-urlencoded']['required'][] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$url = str_replace(':'.$name, '{'.$name.'}', $url);
|
||||
}
|
||||
|
||||
$temp['consumes'] = $consumes;
|
||||
|
||||
$output['paths'][$url][strtolower($route->getMethod())] = $temp;
|
||||
}
|
||||
}
|
||||
|
||||
/*foreach ($consoleDB->getMocks() as $mock) {
|
||||
var_dump($mock['name']);
|
||||
}*/
|
||||
|
||||
ksort($output['paths']);
|
||||
|
||||
$response
|
||||
->json($output);
|
||||
}
|
||||
);
|
||||
+8
-4
@@ -33,7 +33,7 @@ const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s';
|
||||
const APP_MODE_ADMIN = 'admin';
|
||||
const APP_PAGING_LIMIT = 15;
|
||||
const APP_CACHE_BUSTER = 125;
|
||||
const APP_VERSION_STABLE = '0.5.3';
|
||||
const APP_VERSION_STABLE = '0.6.1';
|
||||
const APP_STORAGE_UPLOADS = '/storage/uploads';
|
||||
const APP_STORAGE_CACHE = '/storage/cache';
|
||||
const APP_STORAGE_CERTIFICATES = '/storage/certificates';
|
||||
@@ -45,6 +45,7 @@ const APP_SOCIAL_LINKEDIN = 'https://www.linkedin.com/company/appwrite';
|
||||
const APP_SOCIAL_INSTAGRAM = 'https://www.instagram.com/appwrite.io';
|
||||
const APP_SOCIAL_GITHUB = 'https://github.com/appwrite';
|
||||
const APP_SOCIAL_DISCORD = 'https://discord.gg/GSeTUeA';
|
||||
const APP_SOCIAL_DEV = 'https://dev.to/appwrite';
|
||||
|
||||
$register = new Registry();
|
||||
$request = new Request();
|
||||
@@ -53,6 +54,7 @@ $response = new Response();
|
||||
/*
|
||||
* ENV vars
|
||||
*/
|
||||
Config::load('events', __DIR__.'/../app/config/events.php');
|
||||
Config::load('providers', __DIR__.'/../app/config/providers.php');
|
||||
Config::load('platforms', __DIR__.'/../app/config/platforms.php');
|
||||
Config::load('locales', __DIR__.'/../app/config/locales.php');
|
||||
@@ -64,6 +66,7 @@ Config::setParam('domainVerification', false);
|
||||
Config::setParam('version', $request->getServer('_APP_VERSION', 'UNKNOWN'));
|
||||
Config::setParam('protocol', $request->getServer('HTTP_X_FORWARDED_PROTO', $request->getServer('REQUEST_SCHEME', 'https')));
|
||||
Config::setParam('port', (string) parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_PORT));
|
||||
Config::setParam('hostname', parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', null), PHP_URL_HOST));
|
||||
|
||||
$utopia = new App('Asia/Tel_Aviv', Config::getParam('env'));
|
||||
|
||||
@@ -74,10 +77,11 @@ define('COOKIE_DOMAIN',
|
||||
(
|
||||
$request->getServer('HTTP_HOST', null) === 'localhost' ||
|
||||
$request->getServer('HTTP_HOST', null) === 'localhost:'.Config::getParam('port') ||
|
||||
(filter_var($request->getServer('HTTP_HOST', null), FILTER_VALIDATE_IP) !== false)
|
||||
(filter_var(Config::getParam('hostname'), FILTER_VALIDATE_IP) !== false)
|
||||
)
|
||||
? null
|
||||
: '.'.parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_HOST));
|
||||
: '.'.Config::getParam('hostname')
|
||||
);
|
||||
define('COOKIE_SAMESITE', Response::COOKIE_SAMESITE_NONE);
|
||||
|
||||
/*
|
||||
@@ -254,7 +258,7 @@ if (APP_MODE_ADMIN === $mode) {
|
||||
$session = Auth::decodeSession(
|
||||
$request->getCookie(Auth::$cookieName, // Get sessions
|
||||
$request->getCookie(Auth::$cookieName.'_legacy', // Get fallback session from old clients (no SameSite support)
|
||||
$request->getHeader('X-Appwrite-Key', '')))); // Get API Key
|
||||
$request->getHeader('X-Appwrite-Key', '')))); // Get API Key
|
||||
|
||||
// Get fallback session from clients who block 3rd-party cookies
|
||||
$response->addHeader('X-Debug-Fallback', 'false');
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
## 0.2.2
|
||||
|
||||
- Fixed an error that happend when the OAuth session creation request was sent before any other API call
|
||||
- Fixed a bug in the Avatars service where location URL generation had syntax error
|
||||
|
||||
## 0.2.1
|
||||
|
||||
- Fixed callback scheme
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Updated flutter_web_auth plugin to version 0.2.4
|
||||
- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects
|
||||
|
||||
## 0.1.1
|
||||
|
||||
- Updated flutter_web_auth version
|
||||
@@ -1,13 +1,13 @@
|
||||
# Appwrite SDK for Dart
|
||||
# Appwrite Flutter SDK
|
||||
|
||||
[](https://pub.dartlang.org/packages/appwrite)
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.**
|
||||
**This SDK is compatible with Appwrite server version 0.6.1. For older versions, please check previous releases.**
|
||||
|
||||
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 Dart SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
|
||||
Use the Flutter 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)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Add this to your package's `pubspec.yaml` file:
|
||||
|
||||
```yml
|
||||
dependencies:
|
||||
appwrite: ^0.1.1
|
||||
appwrite: ^0.2.2
|
||||
```
|
||||
|
||||
You can install packages from the command line:
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createOAuth2Session(
|
||||
provider: 'bitbucket',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createRecovery(
|
||||
email: 'email@example.com',
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createSession(
|
||||
email: 'email@example.com',
|
||||
password: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createVerification(
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.create(
|
||||
email: 'email@example.com',
|
||||
password: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.deleteSession(
|
||||
sessionId: '[SESSION_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.deleteSessions( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.delete( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getLogs( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getPrefs( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getSessions( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.get( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateEmail(
|
||||
email: 'email@example.com',
|
||||
password: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateName(
|
||||
name: '[NAME]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updatePassword(
|
||||
password: 'password',
|
||||
oldPassword: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updatePrefs(
|
||||
prefs: {},
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateRecovery(
|
||||
userId: '[USER_ID]',
|
||||
secret: '[SECRET]',
|
||||
password: 'password',
|
||||
passwordAgain: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateVerification(
|
||||
userId: '[USER_ID]',
|
||||
secret: '[SECRET]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = avatars.getBrowser(
|
||||
code: 'aa',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = avatars.getCreditCard(
|
||||
code: 'amex',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = avatars.getFavicon(
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = avatars.getFlag(
|
||||
code: 'af',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = avatars.getImage(
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = avatars.getQR(
|
||||
text: '[TEXT]',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.createDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
data: {},
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.deleteDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
documentId: '[DOCUMENT_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.getDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
documentId: '[DOCUMENT_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.listDocuments(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.updateDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
documentId: '[DOCUMENT_ID]',
|
||||
data: {},
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getContinents( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountriesEU( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountriesPhones( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountries( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCurrencies( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.get( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'dart:io';
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.createFile(
|
||||
file: await MultipartFile.fromFile('./path-to-files/image.jpg', 'image.jpg'),
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.deleteFile(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = storage.getFileDownload(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = storage.getFilePreview(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
String result = storage.getFileView(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.getFile(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.listFiles(
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.updateFile(
|
||||
fileId: '[FILE_ID]',
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.createMembership(
|
||||
teamId: '[TEAM_ID]',
|
||||
email: 'email@example.com',
|
||||
roles: [],
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.create(
|
||||
name: '[NAME]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.deleteMembership(
|
||||
teamId: '[TEAM_ID]',
|
||||
inviteId: '[INVITE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.delete(
|
||||
teamId: '[TEAM_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.getMemberships(
|
||||
teamId: '[TEAM_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.get(
|
||||
teamId: '[TEAM_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.list(
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.updateMembershipStatus(
|
||||
teamId: '[TEAM_ID]',
|
||||
inviteId: '[INVITE_ID]',
|
||||
userId: '[USER_ID]',
|
||||
secret: '[SECRET]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
void main() { // Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.update(
|
||||
teamId: '[TEAM_ID]',
|
||||
name: '[NAME]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class Client {
|
||||
Map<String, String> headers;
|
||||
Map<String, String> config;
|
||||
bool selfSigned;
|
||||
bool init = false;
|
||||
bool initialized = false;
|
||||
Dio http;
|
||||
PersistCookieJar cookieJar;
|
||||
|
||||
@@ -30,7 +30,7 @@ class Client {
|
||||
|
||||
this.headers = {
|
||||
'content-type': 'application/json',
|
||||
'x-sdk-version': 'appwrite:dart:0.1.1',
|
||||
'x-sdk-version': 'appwrite:dart:0.2.2',
|
||||
};
|
||||
|
||||
this.config = {};
|
||||
@@ -76,6 +76,22 @@ class Client {
|
||||
return this;
|
||||
}
|
||||
|
||||
Future init() async {
|
||||
if(!initialized) {
|
||||
final Directory cookieDir = await _getCookiePath();
|
||||
|
||||
cookieJar = new PersistCookieJar(dir:cookieDir.path);
|
||||
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
this.http.options.validateStatus = (status) => status < 400;
|
||||
this.http.interceptors.add(CookieManager(cookieJar));
|
||||
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) async {
|
||||
if(selfSigned) {
|
||||
// Allow self signed requests
|
||||
@@ -85,21 +101,7 @@ class Client {
|
||||
};
|
||||
}
|
||||
|
||||
if(!init) {
|
||||
final Directory cookieDir = await _getCookiePath();
|
||||
|
||||
cookieJar = new PersistCookieJar(dir:cookieDir.path);
|
||||
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
this.http.options.validateStatus = (status) => status < 400;
|
||||
this.http.interceptors.add(CookieManager(cookieJar));
|
||||
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
|
||||
|
||||
init = true;
|
||||
}
|
||||
await this.init();
|
||||
|
||||
// Origin is hardcoded for testing
|
||||
Options options = Options(
|
||||
+4
-3
@@ -305,7 +305,7 @@ class Account extends Service {
|
||||
/// first. Use the success and failure arguments to provide a redirect URL's
|
||||
/// back to your app when login is completed.
|
||||
///
|
||||
Future createOAuth2Session({@required String provider, String success = 'https://localhost:2444/auth/oauth2/success', String failure = 'https://localhost:2444/auth/oauth2/failure'}) {
|
||||
Future createOAuth2Session({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure'}) {
|
||||
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
@@ -324,10 +324,11 @@ class Account extends Service {
|
||||
|
||||
return FlutterWebAuth.authenticate(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: "appwrite-callback"
|
||||
).then((value) {
|
||||
callbackUrlScheme: "appwrite-callback-" + client.config['project']
|
||||
).then((value) async {
|
||||
Uri url = Uri.parse(value);
|
||||
List<Cookie> cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])];
|
||||
await client.init();
|
||||
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
|
||||
});
|
||||
}
|
||||
+60
-30
@@ -17,20 +17,25 @@ class Avatars extends Service {
|
||||
/// /account/sessions endpoint. Use width, height and quality arguments to
|
||||
/// change the output settings.
|
||||
///
|
||||
Future<Response> getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
String getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get Credit Card Icon
|
||||
@@ -40,20 +45,25 @@ class Avatars extends Service {
|
||||
/// card provider you need. Use width, height and quality arguments to change
|
||||
/// the output settings.
|
||||
///
|
||||
Future<Response> getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
String getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get Favicon
|
||||
@@ -61,18 +71,23 @@ class Avatars extends Service {
|
||||
/// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
|
||||
/// website URL.
|
||||
///
|
||||
Future<Response> getFavicon({@required String url}) {
|
||||
String getFavicon({@required String url}) {
|
||||
final String path = '/avatars/favicon';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get Country Flag
|
||||
@@ -81,20 +96,25 @@ class Avatars extends Service {
|
||||
/// users. The code argument receives the 2 letter country code. Use width,
|
||||
/// height and quality arguments to change the output settings.
|
||||
///
|
||||
Future<Response> getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
String getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) {
|
||||
final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get Image from URL
|
||||
@@ -104,20 +124,25 @@ class Avatars extends Service {
|
||||
/// remote images in your app or in case you want to make sure a 3rd party
|
||||
/// image is properly served using a TLS protocol.
|
||||
///
|
||||
Future<Response> getImage({@required String url, int width = 400, int height = 400}) {
|
||||
String getImage({@required String url, int width = 400, int height = 400}) {
|
||||
final String path = '/avatars/image';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get QR Code
|
||||
@@ -125,7 +150,7 @@ class Avatars extends Service {
|
||||
/// Converts a given plain text to a QR code image. You can use the query
|
||||
/// parameters to change the size and style of the resulting image.
|
||||
///
|
||||
Future<Response> getQR({@required String text, int size = 400, int margin = 1, int download = 0}) {
|
||||
String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) {
|
||||
final String path = '/avatars/qr';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
@@ -133,12 +158,17 @@ class Avatars extends Service {
|
||||
'size': size,
|
||||
'margin': margin,
|
||||
'download': download,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
return location.toString();
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -125,14 +125,14 @@ class Storage extends Service {
|
||||
};
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return url.toString();
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get File Preview
|
||||
@@ -155,14 +155,14 @@ class Storage extends Service {
|
||||
};
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return url.toString();
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get File for View
|
||||
@@ -179,13 +179,13 @@ class Storage extends Service {
|
||||
};
|
||||
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
Uri location = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return url.toString();
|
||||
return location.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
name: appwrite
|
||||
version: 0.1.1
|
||||
version: 0.2.2
|
||||
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
|
||||
homepage: https://appwrite.io
|
||||
repository: https://github.com/appwrite/sdk-for-dart
|
||||
repository: https://github.com/appwrite/sdk-for-flutter
|
||||
issue_tracker: https://github.com/appwrite/sdk-generator/issues
|
||||
documentation: https://appwrite.io/support
|
||||
environment:
|
||||
@@ -14,7 +14,7 @@ dependencies:
|
||||
dio: ^3.0.0
|
||||
cookie_jar: ^1.0.0
|
||||
dio_cookie_manager: ^1.0.0
|
||||
flutter_web_auth: ^0.2.0
|
||||
flutter_web_auth: ^0.2.4
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Appwrite SDK for JavaScript
|
||||
# Appwrite Web SDK
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
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 JavaScript SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
|
||||
Use the Web 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)
|
||||
|
||||

|
||||
@@ -30,24 +30,9 @@ import * as Appwrite from "appwrite";
|
||||
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/appwrite@1.0.29"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/appwrite@1.1.0"></script>
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Initialise the Appwrite SDK in your code, and setup your API credentials:
|
||||
|
||||
```js
|
||||
|
||||
// Init your JS SDK
|
||||
var appwrite = new Appwrite();
|
||||
|
||||
appwrite
|
||||
.setEndpoint('http://localhost/v1') // Set only when using self-hosted solution
|
||||
.setProject('455x34dfkj') // Your Appwrite Project UID
|
||||
;
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Contribution
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user