Capability first · transport second

AppDataScope.js

Reconciles declared and native application identity and scopes OPFS/localStorage ownership fail-closed.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Reconciles declared and native application identity and scopes OPFS/localStorage ownership fail-closed.

  • Artifact
    AppDataScope.js · esm
  • Classification
    public first party
  • Availability
    Browser / native WebView hybrid
  • Normalization
    Strict normalized identifiers and coded mismatch failures.

Import and lifecycle

JavaScript
import * as module from '/arcane/modules/AppDataScope.js';

Identity helpers are pure; openApplicationDataDirectory() opens and, by default, creates OPFS apps/<application-id>.

Application-facing behavior: Identity constants and canonicalApplicationId(), resolveApplicationId(), resolveApplicationLocalStorageKey(), openApplicationDataDirectory().

Protocol and host implementation

Arcane.app.current, DOM declaration, OPFS This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
canonicalApplicationIdfunctionfunction canonicalApplicationId(value,label='applicationId')value,label='applicationId'
declaredApplicationIdfunctionfunction declaredApplicationId(documentObject=globalThis.document)documentObject=globalThis.document
resolveBrowserApplicationIdfunctionfunction resolveBrowserApplicationId({ applicationId=null, documentObject=globalThis.document }={}){ applicationId=null, documentObject=globalThis.document }={}
resolveApplicationLocalStorageKeyfunctionfunction resolveApplicationLocalStorageKey(logicalKey='',options={})logicalKey='',options={}
resolveApplicationIdfunctionasync function resolveApplicationId({ applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane }={}){ applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane }={}
openApplicationDataDirectoryfunctionasync function openApplicationDataDirectory({ storage=globalThis.navigator?.storage, applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane, create=true }={}){ storage=globalThis.navigator?.storage, applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane, create=true }={}
APPLICATION_ID_MAX_LENGTHvariable · valuevariable APPLICATION_ID_MAX_LENGTH
APPLICATION_ID_PATTERNvariable · valuevariable APPLICATION_ID_PATTERN
APP_DATA_DIRECTORYvariable · valuevariable APP_DATA_DIRECTORY
APP_LOCAL_STORAGE_PREFIXvariable · valuevariable APP_LOCAL_STORAGE_PREFIX
CallableKindExact public signatureParameter syntax
canonicalApplicationIdexported-functionfunction canonicalApplicationId(value,label='applicationId')value,label='applicationId'
resolveApplicationIdexported-functionasync function resolveApplicationId({ applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane }={}){ applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane }={}
resolveApplicationLocalStorageKeyexported-functionfunction resolveApplicationLocalStorageKey(logicalKey='',options={})logicalKey='',options={}
openApplicationDataDirectoryexported-functionasync function openApplicationDataDirectory({ storage=globalThis.navigator?.storage, applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane, create=true }={}){ storage=globalThis.navigator?.storage, applicationId=null, documentObject=globalThis.document, arcane=globalThis.Arcane, create=true }={}

Parameter meanings and results

Canonical IDs are lowercase hyphenated strings up to 64 characters. resolveApplicationId(options) reconciles explicit, document, and native identity; resolveApplicationLocalStorageKey(logicalKey, options) scopes a key; openApplicationDataDirectory(options) returns {applicationId, directory, path}.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

This artifact has no additional documented lifecycle event flow.

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • APP_DATA_SCOPE_INVALID
  • APP_DATA_SCOPE_MISMATCH
  • APP_DATA_SCOPE_REQUIRED
  • APP_DATA_STORAGE_UNAVAILABLE

Availability and capabilities

Browser / native WebView hybrid. Strict normalized identifiers and coded mismatch failures.

Normalizes browser declarations with authoritative Arcane.app.current when native; browser-only OPFS isolation is organizational, while native profiles add host isolation.

Contract example

JavaScript
import {resolveApplicationLocalStorageKey} from '/arcane/modules/AppDataScope.js';

const key=resolveApplicationLocalStorageKey('draft',{
    applicationId:'notes-app',
    documentObject:null
});
console.log(key);