phibac developer docs

Users, sign-in and consent

This page explains how users sign in to your app (the web app you build), what they are asked to approve, and what they can see and undo later. The words in quotes are the words the server shows them. In the examples the app is called "Notes" and is served from https://notes.example.com.

Signing in

A user is the person whose data it is. Users sign up on the server (https://phibac.com) with their email address: they confirm it from a link the server emails them, then choose how to sign in: they create a passkey or set a password. They can add the other way later.

A passkey is a key kept on the user's device and unlocked with the device's screen lock, fingerprint or face. There is nothing to type, and it cannot be guessed. A user can have several passkeys, for example one per device.

A password works on any device: the user types their email address and password on the server's sign-in page. In a browser the user has not signed in from before, the server also sends a short code to their email address, which they type to finish. A user who ticks "Remember this browser" is not asked for a code there again; without the tick, as on a borrowed device, the sign-in to the server ends when the browser closes.

Sign-in always happens on the server, never in your page:

  1. Your app calls connect() when the user presses a button. Browsers allow a popup only from a click, so call it from one.
  2. The SDK (the JavaScript library your page uses) opens a sign-in popup on https://phibac.com. If the user is not signed in to the server in this browser, the popup first asks them to sign in, with their passkey or their password.
  3. The popup asks the user to approve your app (see the next section), then closes.
  4. The SDK keeps the sign-in in the browser, tied to a key kept in the browser, so it only works there. The next time the app calls connect() in this browser, the user is not asked again and no network is needed.

If the user closes the popup before finishing, connect() fails with sign_in_cancelled; if the browser blocks the popup, with popup_blocked.

Your app never sees a password or a passkey: both are used only on the server's own page. Your app is not given the user's email address either.

The first connection

Consent is the user's approval for an app to use their data. The first time a user signs in to your app, the popup shows a page titled "Connect Notes" with this sentence and two buttons, Allow and Cancel:

Notes (https://notes.example.com) will store data in your backend.

The page names your app as you registered it and the web address (the origin) the request came from. If the user presses Allow, the popup closes and connect() returns. If they press Cancel, connect() fails with access_denied.

This one approval lets your app read and write its own data in the user's database: the collections your app published (a collection is one kind of data, such as notes, described by your app) and its own sandbox collections (collections named sandbox.<name> that only your app can use). Collections and records explains both. Your app needs no further approval for them.

After that, the connect page is not shown again, in any browser, until the user disconnects your app. When the user signs in to your app again, the popup closes by itself; in a browser where they are not signed in to the server, it first asks them to sign in. One exception: a page on http://localhost that is not one of your app's registered origins is asked about at every sign-in, because any program on the user's computer can serve a page from localhost.

Reading another app's data

An app may also read data owned by another app, but only with the user's permission, and only read: it can never create, change or delete another app's records (the saved items in its collections), even with permission.

To ask, your app calls requestAccess() on the other app's collection from a click. A popup titled "Allow Notes to read your data?" names your app and its origin, describes the collection in the words its owner wrote, and names the app that owns it. It then says that, if the user allows it, your app can read every record in that collection, in every version, including fields the owner adds later. It lists the fields the collection includes now, marking sensitive ones "(sensitive)", and ends:

This app could keep a copy of what it reads.

The user presses Allow or Deny. requestAccess() resolves to true when the user allows and false when they deny or close the popup. A permission covers the whole collection: every record, not a chosen few.

Every read of another app's data is shown in the user's activity log, and when one app reads more than 1,000 records of another app's data in a day, the user is emailed.

What the user can see and undo

The user's account area on the server (https://phibac.com/account) shows them everything apps do with their data:

  • Apps lists every connected app, when it was connected and when it was last used. Disconnect signs the app out on every device and removes its connection; the next time the user opens it, the app asks to connect again. The records the app saved stay in the user's database.
  • Access to other apps' data, on the same page, lists each permission to read another app's collection. Revoke removes it. The app loses access from its next request, its live updates for that collection (the messages that tell the app when data changes) stop, and its reads then fail with consent_required. Disconnecting an app does not remove these permissions: the user revokes them here.
  • Your data lists every collection that has records, grouped by the app that owns it. The user can open each record's history and restore an earlier version, including a deleted record's, for as long as its history is kept.
  • Activity shows reads of one app's data by another app, unusually large reads, deleted files, and every time an operator of the server opened the user's data.
  • Sign-in lists the user's passkeys and lets them remove one, for example from a lost device, and lets them set, change or remove their password. One way to sign in always remains.
  • Export downloads a zip file of everything the user has stored: their database, their files and the schemas (the descriptions of each collection's fields) their data uses.
  • Delete account signs every app out at once and deletes the user's data and files after a grace period, during which the user can cancel.

The connected apps list and the consent page also have a Report this app link.

What an app can never do

  • See the user's password or passkey: both are used only on the server's pages.
  • Learn the user's email address.
  • Read or change another user's data.
  • Create, change or delete records in a collection another app owns. That fails with forbidden, whatever the user allowed.
  • Read another app's collection without the user's permission. That fails with consent_required until the user allows it.
  • Read another app's sandbox collection. Sandbox collections can never be shared.
  • Be used from a web address that is not registered for it (except http://localhost while you develop, where the user is asked at every sign-in).

Your developer token (the secret key the CLI, the command-line tool, uses to create and change your apps) cannot do these things either: it can manage your apps and their collections, but it can never read, write, export or delete any user's data.