mnfst 0.5.254 → 0.5.256

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,11 @@ function manifestNativePlugin(name) {
15
15
  const cap = window.Capacitor;
16
16
  return (cap && cap.Plugins && cap.Plugins[name]) || null;
17
17
  }
18
+ // Whether a plugin is in the native header list (no list: assume installed)
19
+ function manifestNativeInstalled(name) {
20
+ const headers = window.Capacitor && window.Capacitor.PluginHeaders;
21
+ return !Array.isArray(headers) || headers.some(h => h && h.name === name);
22
+ }
18
23
  // Whether a plugin exposes a native method. Bundled apps get a registerPlugin
19
24
  // Proxy where every property is a function, so prefer the native header; a
20
25
  // header list without this plugin means it isn't installed natively.
@@ -158,6 +163,7 @@ function initManifestNativeNetwork() {
158
163
  // namespaced localStorage fallback on the web. Intended for session tokens etc.
159
164
  // Native: a plugin registered as SecureStorage (@aparajita/capacitor-secure-storage,
160
165
  // or any getItem/setItem or get/set shape); $secure.use(adapter) overrides.
166
+ // Native without a plugin rejects; never localStorage.
161
167
  // The web fallback is NOT encrypted — it degrades honestly, not securely.
162
168
 
163
169
  const MANIFEST_SECURE_NS = 'mnfst:';
@@ -228,25 +234,32 @@ function manifestSecureNativeBackend(plugin, name) {
228
234
  };
229
235
  }
230
236
 
231
- // Registered in JS but absent from the native header list
232
- function manifestSecureInstalled(name) {
233
- const headers = window.Capacitor && window.Capacitor.PluginHeaders;
234
- return !Array.isArray(headers) || headers.some(h => h && h.name === name);
235
- }
237
+ const MANIFEST_SECURE_NONE = 'No secure-storage plugin is installed; install @aparajita/capacitor-secure-storage and run npx cap sync, or provide one with $secure.use(adapter)';
238
+ const MANIFEST_SECURE_UNSYNCED = 'SecureStorage plugin is not installed natively; run npx cap sync';
236
239
 
237
- // Rejects every call; never falls back to unencrypted web storage
238
- function manifestSecureMissingBackend(name) {
239
- const fail = (op) => async () => manifestSecureFail(op, new Error(name + ' plugin is not installed natively; run npx cap sync'));
240
+ // Rejects every call, logs once; never falls back to unencrypted web storage
241
+ let _manifestSecureMissingLogged = false;
242
+ function manifestSecureMissingBackend(msg) {
243
+ const fail = (op) => async () => {
244
+ const e = new Error(msg);
245
+ if (!_manifestSecureMissingLogged) {
246
+ _manifestSecureMissingLogged = true;
247
+ try { console.error('[Manifest] $secure.' + op + ' failed', e); } catch (_) {}
248
+ }
249
+ throw e;
250
+ };
240
251
  return { get: fail('get'), set: fail('set'), remove: fail('remove'), keys: fail('keys'), clear: fail('clear') };
241
252
  }
242
253
 
254
+ // Missing backends aren't cached, so a later-registered plugin is picked up
243
255
  let _manifestSecureBackend = null;
244
256
  function manifestSecureBackend() {
245
257
  if (_manifestSecureBackend) return _manifestSecureBackend;
246
- const plugin = manifestNativeIsNative() ? manifestNativePlugin('SecureStorage') : null;
247
- if (plugin && !manifestSecureInstalled('SecureStorage')) return manifestSecureMissingBackend('SecureStorage');
248
- _manifestSecureBackend = plugin ? manifestSecureNativeBackend(plugin, 'SecureStorage') : manifestSecureWebBackend();
249
- return _manifestSecureBackend;
258
+ if (!manifestNativeIsNative()) return (_manifestSecureBackend = manifestSecureWebBackend());
259
+ const plugin = manifestNativePlugin('SecureStorage');
260
+ if (!plugin) return manifestSecureMissingBackend(MANIFEST_SECURE_NONE);
261
+ if (!manifestNativeInstalled('SecureStorage')) return manifestSecureMissingBackend(MANIFEST_SECURE_UNSYNCED);
262
+ return (_manifestSecureBackend = manifestSecureNativeBackend(plugin, 'SecureStorage'));
250
263
  }
251
264
 
252
265
  function initManifestSecure() {
@@ -396,6 +396,23 @@
396
396
  "type": "string",
397
397
  "description": "May reference an env var via ${VAR_NAME}."
398
398
  },
399
+ "presences": {
400
+ "description": "Enable the $presence plugin (Appwrite Presences): true, or an options object.",
401
+ "oneOf": [
402
+ {
403
+ "type": "boolean"
404
+ },
405
+ {
406
+ "type": "object",
407
+ "properties": {
408
+ "scope": {
409
+ "type": "string",
410
+ "description": "Roster scope: 'auto'/'team' (current team when one is active, default), 'global', or an explicit team id. May reference an env var via ${VAR_NAME}."
411
+ }
412
+ }
413
+ }
414
+ ]
415
+ },
399
416
  "auth": {
400
417
  "type": "object",
401
418
  "properties": {
@@ -16,7 +16,7 @@
16
16
 
17
17
  // Build stamps the published version here; unstamped (dev) falls back to the
18
18
  // registration URL's `v`, then 'dev'.
19
- const BUILD_VERSION = '0.5.254';
19
+ const BUILD_VERSION = '0.5.256';
20
20
  const CACHE_PREFIX = 'mnfst-sw:';
21
21
  const META_CACHE = CACHE_PREFIX + 'meta';
22
22
  // Sized to hold a full precache.json warm-up (PRECACHE_MAX_ENTRIES server-side)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.254",
3
+ "version": "0.5.256",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",