Origo Account OAuth 2.0 / OIDC & Portable Data Formats
Integration guide for Origo Account OAuth 2.0 / OpenID Connect (PKCE S256, JWKS, scopes, and immutable sub rules) plus specifications for Backup Archive v5 ZIP, ReplaceRule JSON, and Markdown export formats.
На этой странице
This specification documents two core interoperability layers of the Origo ecosystem: integrating with Origo Account (https://account.origo.xin) over standard OAuth 2.0 / OpenID Connect (OIDC), and parsing or producing Origo X's open portable local data formats (Backup Archive v5, Canonical UTF-16 Locators, Replace Rules JSON, and Reading Notes Markdown exports). For read-only site APIs and developer toolkits, see Open Ecosystem Toolkits & Public HTTP API Reference.
Part 1: Origo Account OAuth 2.0 / OIDC Integration
Origo's unified account center operates as an OpenID Connect Provider (iss: https://account.origo.xin), issuing short-lived opaque Bearer access tokens and RS256-signed JWT ID tokens via the Authorization Code flow.
1. Discovery & JWKS
- OpenID Connect Discovery:
GET https://account.origo.xin/.well-known/openid-configuration
| Discovery Member | Value |
|---|---|
issuer |
https://account.origo.xin |
authorization_endpoint |
https://account.origo.xin/api/v1/identity/authorize |
token_endpoint |
https://account.origo.xin/api/v1/identity/token |
userinfo_endpoint |
https://account.origo.xin/api/v1/identity/userinfo |
third_party_entitlements_endpoint |
https://account.origo.xin/api/v1/identity/third-party/entitlements |
jwks_uri |
https://account.origo.xin/api/v1/identity/jwks |
response_types_supported |
["code"] |
grant_types_supported |
["authorization_code"] |
subject_types_supported |
["public", "pairwise"] |
id_token_signing_alg_values_supported |
["RS256"] |
token_endpoint_auth_methods_supported |
["client_secret_post", "client_secret_basic"] |
scopes_supported |
["openid", "email", "profile", "entitlements"] |
code_challenge_methods_supported |
["S256"] |
- JWKS Endpoint:
GET https://account.origo.xin/api/v1/identity/jwksserves the active RS256 public signing keys (alg: "RS256",use: "sig",kid) used to verifyid_tokensignatures.
2. Authorization Request (Mandatory PKCE S256 & nonce)
Redirect the user-agent to:
GET https://account.origo.xin/api/v1/identity/authorize
| Parameter | Required | Rules & Description |
|---|---|---|
response_type |
Yes | Must be code |
client_id |
Yes | Registered OAuth client identifier |
redirect_uri |
Yes | Must match an exact pre-registered callback URI |
scope |
Yes | Space-delimited scopes; must include openid |
state |
Yes | CSRF protection token (16–512 characters) |
nonce |
Yes (third-party) | Replay protection token (16–256 characters), echoed in the signed id_token |
code_challenge |
Yes (third-party) | BASE64URL(SHA256(code_verifier)) |
code_challenge_method |
Yes | Must be S256 (plain is rejected) |
prompt |
No | Optional UX hint: none, login, create, or add_account |
screen_hint |
No | Optional reset to open the password-reset flow |
login_hint |
No | Optional account UUID to select a signed-in account in the active browser session |
Authorization query strings are bounded at 8 KiB and rate-limited at 30 requests per 15 minutes per IP (
1200global per 15 minutes).
3. Token Exchange
After verifying state on the callback, exchange code server-to-server:
POST https://account.origo.xin/api/v1/identity/token
Content-Type: application/x-www-form-urlencoded
- Single-Use 60-Second Code: Authorization codes are strictly bound to the issuing
client_idand exactredirect_uri, are single-use, and expire after 60 seconds. - Client Authentication: Authenticate via either
client_secret_basic(Authorization: Basic ...) orclient_secret_post(client_idandclient_secretin the form body). Never mix both methods in the same request. - PKCE Verification: Supply
code_verifier(43–128characters) matching theS256challenge sent during authorization. - Token Response (request form body capped at 8 KiB):
{
"access_token": "<opaque-bearer-token>",
"token_type": "Bearer",
"expires_in": 300,
"id_token": "<rs256-jwt>",
"scope": "openid profile email"
}
- ID Token Validation Checklist: Verify the RS256 signature against
/api/v1/identity/jwks, confirmiss == "https://account.origo.xin", confirmaud == client_id, matchnonceagainst the transaction session, and verifyiatandexp(5-minute token lifetime).
4. UserInfo, Scopes & Immutable sub Identity Rules
Call GET https://account.origo.xin/api/v1/identity/userinfo with Authorization: Bearer <access_token>:
openid: Always returns the immutable subject claimsub.- Immutable
subRule: First-party (public) clients receive the canonical account UUID, while third-party (pairwise) clients receive a stable, client-scoped opaque identifier prefixed withopw_. Never key users by mutableemailorpreferred_username, and never merge accounts by email. Always bind identity to(issuer, sub).
- Immutable
profile: Returnspreferred_username(when unset, clients may receive anorigo_<14-hex>creation hint, which is never an identity key),name(display name), andpicture(avatar URL when set).email: Returnsemailandemail_verified.entitlements: Returns read-only membership and service entitlement status. Third-party apps with active user consent may also refresh entitlements server-to-server viaPOST https://account.origo.xin/api/v1/identity/third-party/entitlementsusing client credentials andsub; revoked grants return403 grant_revoked. Disabled or deleted accounts cannot authorize, redeem codes, or query UserInfo.
5. Cross-Origin Passkeys via WebAuthn Related Origin Requests
origox.site serves a WebAuthn Related Origin Requests manifest at https://origox.site/.well-known/webauthn:
{
"origins": ["https://account.origo.xin"]
}
Modern browsers supporting Related Origin Requests (Chromium 129+, Safari 18+, Firefox 152+) allow passkeys registered under RP ID origox.site to authenticate seamlessly on https://account.origo.xin without re-registration.
Part 2: Open Portable Data Formats
Origo X stores user libraries locally first and exports data using documented, inspectable, platform-independent formats.
1. Backup Archive v5 (.zip + .complete Marker)
Both local and WebDAV backups produce origo-x-<UTC ms>-<UUID>.zip paired with a origo-x-<UTC ms>-<UUID>.zip.complete marker whose content is the lowercase 64-character SHA-256 hex digest of the complete ZIP archive.
Archive Layout
origo-x-1795852800000-<uuid>.zip
├── manifest.json # Archive metadata, scope, and per-file SHA-256 map
├── records.jsonl # UTF-8 JSON Lines of PortableRecord v2 envelopes
├── assets/<sha256> # Content-addressed book files, covers, and sidecars (STORE)
└── credentials.jsonl # Optional local-only credentials (never exported to WebDAV)
manifest.json Schema
{
"format": "origo-x-backup",
"version": 5,
"createdAt": "2026-11-28T08:00:00.000Z",
"platform": "macos",
"scope": {
"reading": true,
"statistics": true,
"sources": true,
"settings": true
},
"recordCount": 128,
"files": {
"records.jsonl": "<64-hex-sha256>",
"assets/<sha256>": "<64-hex-sha256>",
"manifest.json": "<64-hex-sha256>"
}
}
records.jsonl & PortableRecord v2 Envelope
Each line in records.jsonl is a strict 7-key JSON envelope using flat camelCase domain maps—never leaking SQLite integer row IDs or host-specific absolute filesystem paths:
{
"key": "note:9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"kind": "note",
"uid": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"rev": 0,
"modifiedMs": 1795852800000,
"device": "backup",
"value": {
"bookUid": "book-uuid",
"content": "Highlighted excerpt",
"type": "highlight",
"readerNote": "Margin note",
"canonicalLocator": "{...}",
"createdMs": 1795852000000,
"updatedMs": 1795852800000
}
}
Supported PortableRecord v2 kind values include: book, asset (uid = sha256(bookUid + "\0" + role) with role in file, cover, sidecar), binding, position, bookmark, note, session, folder, membership, sourceDefinition, source, sourceGroup, preference, legacyDaily, and bookVersionRecord (plus bookMerge for official cloud sync only, and credential for local encrypted backups only).
Canonical UTF-16 Locator (CanonicalLocator v1)
Reading positions, bookmarks, and notes persist a layout-independent CanonicalLocator JSON payload so anchors survive font, screen, and pagination changes:
- Locator Fields:
version(1),format(epub,txt,pdf, etc.),href(text://chapter/{id}/offset/{n}/excerpt/{text}),chapterId,resourceHref,progression(0.0–1.0),positionHint,totalPositionsHint,fragments, andcontentSignature. textAnchorObject:quote,prefix,suffix,chapterId,resourceHref,startOffsetUtf16(UTF-16 code-unit offset),lengthUtf16, andoffsetHint.
Size Caps & Integrity Verification
- Maximum 2 GiB per decompressed file, 8 GiB total decompressed archive size, 64 MiB each for
manifest.jsonandrecords.jsonl, and 20,000 archive entries. - Before touching any user database or preference, the importer preflights the ZIP central directory to reject encrypted entries, Unix symlinks, path traversal (
..), and case-insensitive collisions, then streams each entry while verifying exact declared byte counts andmanifest.jsonSHA-256 digests. Archives missing a valid.completemarker are rejected.
2. Reading Purification Replace Rules JSON Schema (ReplaceRule)
Purification rules import and export as a UTF-8 JSON array (max 8 MiB import file, 5,000 rules total, 20,000 characters per pattern):
| Field | Type | Description & Legacy Aliases |
|---|---|---|
id |
integer / string |
Unique rule identifier |
name |
string |
Rule display name (legacy alias replaceSummary) |
pattern |
string |
Match string or regular expression (required; legacy alias regex) |
replacement |
string |
Replacement template (supports capture groups such as $1) |
group |
string |
Group name |
scope |
string |
Included book titles or sources (legacy alias useTo) |
excludeScope |
string |
Excluded scope |
isEnabled |
boolean |
Enabled flag (legacy aliases enabled, enable) |
isRegex |
boolean |
Regex vs. literal match mode |
scopeTitle |
boolean |
Apply rule to chapter titles |
scopeContent |
boolean |
Apply rule to chapter body text |
scopeSource |
boolean |
Match scope against source |
previewText |
string? |
Optional sample input for testing |
order |
integer |
Sort order (legacy aliases sortOrder, serialNumber) |
timeoutMillisecond |
integer |
Per-rule regex timeout in milliseconds, default 3000 (legacy alias timeout) |
[
{
"id": 101,
"name": "Strip trailing chapter promo",
"pattern": "\\n*\\(End of chapter.*?\\)",
"replacement": "",
"group": "Cleanup",
"scope": "",
"excludeScope": "",
"isEnabled": true,
"isRegex": true,
"scopeTitle": false,
"scopeSource": false,
"scopeContent": true,
"order": 1,
"timeoutMillisecond": 3000
}
]
Validation rejects empty pattern values, invalid regex syntax, and rules where both scopeTitle and scopeContent are false.
3. Reading Notes Markdown Export & Preferences Portability
- Reading Notes Markdown Export (
ReadingDataMarkdownRenderer): Emits YAML frontmatter (title,author,exported_atUTC ISO 8601,annotation_count), a top-level book heading, a summary metadata blockquote, and entries grouped by chapter (## <Chapter>) and annotation type (### Highlight/Underline/Note) with blockquoted excerpts,**My note**commentary, and inline code page labels:
---
title: "Example Book"
author: "Example Author"
exported_at: "2026-11-28T08:00:00.000Z"
annotation_count: 1
---
# 《Example Book》
> **Author**: Example Author
> **Whole book** · 1 Highlight · 0 Underline · 0 Note
> **Exported**: 2026-11-28T16:00:00.000
---
## Chapter 1
### Highlight
> Excerpted passage text.
**My note**
Personal annotation text.
`Page 12`
- Portable Preferences Format:
PreferencesRegistryseparates portable appearance and reading settings from device-local paths, secure credentials, and rebuildable caches. Portable preferences are serialized askind: "preference"PortableRecordentries (uidandkeyequal the preference key,valueholds the JSON value) inside Backup Archive v5 alongside appearance asset manifests (custom fonts, reader backgrounds, custom SVGs, and theme packages).
See also: Open Ecosystem Toolkits & Public HTTP API Reference, Account & Sign-In, Backup & Restore, Notes & Highlights, and Purification & Replace Rules.
Нашли проблему в руководстве? Предложить правку