memorio 5.0.0 → 5.1.0

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.
Files changed (60) hide show
  1. package/README.md +80 -449
  2. package/SECURITY.md +152 -42
  3. package/SUMMARY.md +1 -1
  4. package/adr/001-state-proxy-model.md +95 -96
  5. package/adr/002-observer-semantics.md +179 -180
  6. package/adr/003-deep-mutation-semantics.md +7 -8
  7. package/adr/004-array-mutation-semantics.md +127 -128
  8. package/adr/005-scheduler-contract.md +148 -149
  9. package/adr/006-context-isolation.md +91 -92
  10. package/adr/007-mutation-records.md +5 -6
  11. package/adr/008-transactions.md +6 -7
  12. package/adr/009-history-model.md +6 -7
  13. package/adr/README.md +46 -46
  14. package/adr/template.md +48 -49
  15. package/bin/cli.js +68 -0
  16. package/global.cjs +1462 -323
  17. package/global.js +1459 -324
  18. package/index.cjs +1462 -323
  19. package/index.d.ts +1 -0
  20. package/index.js +1459 -324
  21. package/llms.txt +42 -5
  22. package/markdown/AUDIT-REPORT.md +7 -8
  23. package/markdown/CACHE.md +190 -99
  24. package/markdown/DEVTOOLS.md +0 -1
  25. package/markdown/DISPATCH.md +0 -1
  26. package/markdown/HISTORY.md +0 -1
  27. package/markdown/IDB.md +0 -1
  28. package/markdown/IMPORT.md +0 -1
  29. package/markdown/INSPECT.md +0 -1
  30. package/markdown/LOGGER.md +0 -1
  31. package/markdown/MEMORY-ATTACHMENT.md +0 -1
  32. package/markdown/MEMORY.md +0 -1
  33. package/markdown/OBSERVER.md +0 -1
  34. package/markdown/PLATFORM.md +277 -271
  35. package/markdown/REDUX.md +54 -0
  36. package/markdown/SCHEMA.md +0 -1
  37. package/markdown/SESSION.md +0 -1
  38. package/markdown/SQLITE.md +0 -1
  39. package/markdown/STATE.md +0 -1
  40. package/markdown/STORE.md +0 -1
  41. package/markdown/SYNC.md +0 -1
  42. package/markdown/TYPED.md +0 -1
  43. package/markdown/USEOBSERVER.md +0 -1
  44. package/modules/redux.cjs +381 -10
  45. package/modules/redux.cjs.map +1 -1
  46. package/modules/redux.js +381 -10
  47. package/modules/redux.js.map +1 -1
  48. package/package.json +14 -2
  49. package/types/broadcast.d.ts +61 -0
  50. package/types/computed.d.ts +96 -0
  51. package/types/encryption.d.ts +129 -0
  52. package/types/exports.d.ts +9 -0
  53. package/types/memorio.d.ts +19 -12
  54. package/types/security.d.ts +67 -0
  55. package/types/session.d.ts +23 -5
  56. package/types/store.d.ts +19 -3
  57. package/vsix/memorio.vsix +0 -0
  58. package/markdown/CHANGELOG.md +0 -243
  59. package/markdown/PROJECT.md +0 -311
  60. package/markdown/SECURITY.md +0 -330
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "memorio",
3
3
  "codeName": "memorio",
4
- "version": "5.0.0",
4
+ "version": "5.1.0",
5
5
  "description": "Memorio, State + Observer, Store and iDB for an easy life - Cross-platform compatible",
6
6
  "main": "./index.cjs",
7
7
  "browser": {
@@ -25,6 +25,13 @@
25
25
  "email": "valeriacalascaglitta@gmail.com"
26
26
  }
27
27
  ],
28
+ "bin": {
29
+ "memorio": "./bin/cli.js"
30
+ },
31
+ "workspaces": [
32
+ "tests",
33
+ "extension/vscode"
34
+ ],
28
35
  "keywords": [
29
36
  "memorio",
30
37
  "state",
@@ -40,6 +47,8 @@
40
47
  "sqlite",
41
48
  "sql.js",
42
49
  "wasm",
50
+ "bun",
51
+ "cross-runtime",
43
52
  "browser",
44
53
  "frontend"
45
54
  ],
@@ -50,9 +59,12 @@
50
59
  }
51
60
  ],
52
61
  "engines": {
53
- "node": ">=18.0.0"
62
+ "node": ">=18.0.0",
63
+ "bun": ">=1.4.0"
54
64
  },
55
65
  "files": [
66
+ "bin",
67
+ "vsix",
56
68
  "markdown/**/*",
57
69
  "types/**/*",
58
70
  "examples/**/*",
@@ -0,0 +1,61 @@
1
+ /*!
2
+ memorio
3
+ Copyright (c) 2025 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under MIT License, see
5
+ dario.passariello.ca
6
+ */
7
+
8
+ type SyncTarget = 'store' | 'session' | 'state' | 'all'
9
+
10
+ interface BroadcastConfig {
11
+ channelName?: string
12
+ targets?: SyncTarget
13
+ }
14
+
15
+ interface BroadcastMessage {
16
+ __memorio_sync: true
17
+ target: SyncTarget
18
+ action: 'set' | 'remove' | 'delete' | 'clearAll'
19
+ path: string
20
+ value?: any
21
+ oldValue?: any
22
+ timestamp: number
23
+ }
24
+
25
+ interface _broadcast {
26
+ /**
27
+ * Install cross-tab synchronization.
28
+ *
29
+ * @param channelName Name for the BroadcastChannel (default: `memorio_sync`).
30
+ * @param opts Optional configuration.
31
+ * @param opts.targets Which layers to sync: `store`, `session`, `state`, or `all` (default).
32
+ *
33
+ * @since memorio 5.1
34
+ */
35
+ install: (channelName?: string, opts?: BroadcastConfig) => void
36
+
37
+ /**
38
+ * Uninstall cross-tab synchronization and close the channel.
39
+ * @since memorio 5.1
40
+ */
41
+ uninstall: () => void
42
+
43
+ /**
44
+ * Whether cross-tab sync is currently installed.
45
+ * @since memorio 5.1
46
+ */
47
+ isInstalled: () => boolean
48
+
49
+ /**
50
+ * Broadcast a message to all other tabs (internal / advanced use).
51
+ * @since memorio 5.1
52
+ */
53
+ broadcast: (msg: Omit<BroadcastMessage, 'timestamp'>) => void
54
+ }
55
+
56
+ declare var broadcast: _broadcast | undefined
57
+ type broadcast = _broadcast
58
+
59
+ declare global {
60
+ var broadcast: _broadcast | undefined
61
+ }
@@ -0,0 +1,96 @@
1
+ /*!
2
+ memorio
3
+ Copyright (c) 2025 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under MIT License, see
5
+ dario.passariello.ca
6
+ */
7
+
8
+ type ComputeGetter = (path: string) => any
9
+ type ComputeSelector = (get: ComputeGetter) => any
10
+ type EqualityFn = (prev: any, next: any) => boolean
11
+
12
+ interface ComputedEntry {
13
+ selector: ComputeSelector
14
+ lastValue: any
15
+ deps: Set<string>
16
+ equality: EqualityFn
17
+ subscribers: Set<(value: any) => void>
18
+ }
19
+
20
+ interface ComputeOptions {
21
+ /**
22
+ * Custom equality function to determine if the computed value changed.
23
+ * Defaults to deep equality (JSON.stringify comparison).
24
+ */
25
+ equality?: EqualityFn
26
+ /**
27
+ * Custom cache key (for multiple computations of the same path
28
+ * with different selectors).
29
+ */
30
+ equalityKey?: string
31
+ }
32
+
33
+ interface _computed {
34
+ /**
35
+ * Register a computed/derived value.
36
+ *
37
+ * @example
38
+ * memorio.computed.compute('state.user.fullName', (get) => {
39
+ * const first = get('state.user.firstName')
40
+ * const last = get('state.user.lastName')
41
+ * return `${first} ${last}`
42
+ * })
43
+ *
44
+ * @since memorio 5.1
45
+ */
46
+ compute: (
47
+ key: string,
48
+ selector: ComputeSelector,
49
+ opts?: ComputeOptions
50
+ ) => any
51
+
52
+ /**
53
+ * Retrieve the cached value of a computed key.
54
+ * Recomputes lazily if dependencies have changed.
55
+ *
56
+ * @since memorio 5.1
57
+ */
58
+ getValue: (key: string) => any
59
+
60
+ /**
61
+ * Subscribe to changes on a computed key.
62
+ *
63
+ * @param key The state path of the computed value.
64
+ * @param cb Callback invoked with the new value when it changes.
65
+ * @returns Unsubscribe function.
66
+ *
67
+ * @since memorio 5.1
68
+ */
69
+ subscribe: (key: string, cb: (value: any) => void) => (() => void)
70
+
71
+ /**
72
+ * Remove a computed value registration and clean up its dependency listeners.
73
+ *
74
+ * @since memorio 5.1
75
+ */
76
+ remove: (key: string) => boolean
77
+
78
+ /**
79
+ * List all registered computed keys.
80
+ * @since memorio 5.1
81
+ */
82
+ list: () => string[]
83
+
84
+ /**
85
+ * Clear all computed registrations and their dependency listeners.
86
+ * @since memorio 5.1
87
+ */
88
+ clear: () => void
89
+ }
90
+
91
+ declare var computed: _computed
92
+ type computed = _computed
93
+
94
+ declare global {
95
+ var computed: _computed | undefined
96
+ }
@@ -0,0 +1,129 @@
1
+ /*!
2
+ memorio
3
+ Copyright (c) 2025 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under MIT License, see
5
+ dario.passariello.ca
6
+ */
7
+
8
+ interface EncryptedEnvelope {
9
+ __memorio_encrypted: true
10
+ v: number
11
+ alg: 'AES-GCM'
12
+ iv: string
13
+ data: string
14
+ keyId?: string
15
+ }
16
+
17
+ interface _encryption {
18
+ /** Check whether the Web Crypto API is available in this environment. */
19
+ isAvailable: () => boolean
20
+
21
+ /**
22
+ * Derive a CryptoKey from a password using PBKDF2.
23
+ * @param password The password to derive the key from.
24
+ * @param salt Optional salt (string or Uint8Array).
25
+ * @param alg Key algorithm: `'AES-GCM'` (default) or `'AES-CBC'`.
26
+ * @param iterations PBKDF2 iteration count (default 600000, NIST SP 800-132).
27
+ * @returns A Promise that resolves to a CryptoKey.
28
+ */
29
+ deriveKey: (
30
+ password: string,
31
+ salt?: string | Uint8Array,
32
+ alg?: 'AES-GCM' | 'AES-CBC'
33
+ iterations?: number
34
+ ) => Promise<CryptoKey>
35
+
36
+ /**
37
+ * Generate a fresh random CryptoKey (AES-GCM, 256-bit).
38
+ * @param alg `'AES-GCM'` (default) or `'AES-CBC'`.
39
+ */
40
+ generateKey: (alg?: 'AES-GCM' | 'AES-CBC') => Promise<CryptoKey>
41
+
42
+ /**
43
+ * Generate a random salt string (base64-encoded).
44
+ * @param bytes Number of random bytes (default 16).
45
+ */
46
+ generateSalt: (bytes?: number) => string
47
+
48
+ /**
49
+ * Export a CryptoKey to portable base64 strings for secure storage.
50
+ * @param cryptoKey A raw CryptoKey (not a password string).
51
+ * @returns { key, iv } base64-encoded key material and IV (if any).
52
+ */
53
+ exportKey: (cryptoKey: CryptoKey) => Promise<{ key: string; iv: string }>
54
+
55
+ /**
56
+ * Import a CryptoKey from base64 strings produced by exportKey().
57
+ * @param keyData Base64-encoded raw key bytes.
58
+ * @param _ivData Ignored (kept for API compatibility).
59
+ * @returns A Promise that resolves to a CryptoKey.
60
+ */
61
+ importKey: (keyData: string, _ivData?: string) => Promise<CryptoKey>
62
+
63
+ /**
64
+ * Encrypt a value with AES-GCM.
65
+ * @param value Any JSON-serializable value.
66
+ * @param key A CryptoKey or a password string (derived via PBKDF2).
67
+ * @param keyId Optional label for key rotation.
68
+ * @returns An EncryptedEnvelope object.
69
+ */
70
+ encrypt: (value: any, key: CryptoKey | string, keyId?: string) => Promise<EncryptedEnvelope>
71
+
72
+ /**
73
+ * Decrypt an EncryptedEnvelope.
74
+ * @param envelope The envelope returned by encrypt().
75
+ * @param key A CryptoKey or a password string.
76
+ * @returns The original decrypted value.
77
+ */
78
+ decrypt: (envelope: EncryptedEnvelope, key: CryptoKey | string) => Promise<any>
79
+
80
+ /**
81
+ * Encrypt with a password and return a JSON string (for direct persistence).
82
+ * @param value The value to encrypt.
83
+ * @param password The password to derive the key from.
84
+ * @param salt Optional salt string.
85
+ * @param keyId Optional key label.
86
+ */
87
+ encryptWithPassword: (
88
+ value: any,
89
+ password: string,
90
+ salt?: string,
91
+ keyId?: string
92
+ ) => Promise<string>
93
+
94
+ /**
95
+ * Decrypt a JSON envelope string with a password.
96
+ * @param envelopeJson The JSON string from encryptWithPassword().
97
+ * @param password The password to derive the key from.
98
+ * @param salt Optional salt (must match the one used for encryption).
99
+ */
100
+ decryptWithPassword: (
101
+ envelopeJson: string,
102
+ password: string,
103
+ salt?: string
104
+ ) => Promise<any>
105
+
106
+ /**
107
+ * Type guard: check whether a value is an encrypted envelope.
108
+ */
109
+ isEncrypted: (value: any) => boolean
110
+
111
+ /**
112
+ * Configure a default encryption key for auto-encrypt mode.
113
+ * When a default key is set, store/session operations automatically
114
+ * encrypt on write and attempt decryption on read.
115
+ */
116
+ config: (opts: { key?: CryptoKey | string; keyId?: string }) => _encryption
117
+
118
+ /** Internal: the configured default key. */
119
+ _key?: CryptoKey | string | null
120
+ /** Internal: the configured default key ID. */
121
+ _keyId?: string
122
+ }
123
+
124
+ declare var encryption: _encryption
125
+ type encryption = _encryption
126
+
127
+ declare global {
128
+ var encryption: _encryption | null | undefined
129
+ }
@@ -21,6 +21,10 @@
21
21
  /// <reference path="./sqlite.d.ts" />
22
22
  /// <reference path="./observer.d.ts" />
23
23
  /// <reference path="./useObserver.d.ts" />
24
+ /// <reference path="./encryption.d.ts" />
25
+ /// <reference path="./computed.d.ts" />
26
+ /// <reference path="./broadcast.d.ts" />
27
+ /// <reference path="./security.d.ts" />
24
28
 
25
29
  export const memorio: _memorio
26
30
  export const state: _state
@@ -31,6 +35,10 @@ export const idb: _idb
31
35
  export const sqlite: _sqlite
32
36
  export const observer: _observer
33
37
  export const useObserver: _useObserver
38
+ export const encryption: _encryption
39
+ export const computed: _computed
40
+ export const broadcast: _broadcast
41
+ export const security: _security
34
42
  export const dispatch: _dispatch
35
43
  export const events: Record<string, any>
36
44
 
@@ -59,6 +67,7 @@ export const fractional: {
59
67
  export const isBrowser: () => boolean
60
68
  export const isNode: () => boolean
61
69
  export const isDeno: () => boolean
70
+ export const isBun: () => boolean
62
71
  export const isEdge: () => boolean
63
72
  export const getCapabilities: (...args: unknown[]) => any
64
73
  export const createContext: _memorio['createContext']
@@ -47,6 +47,7 @@ interface _memorio {
47
47
  isBrowser: () => boolean
48
48
  isNode: () => boolean
49
49
  isDeno: () => boolean
50
+ isBun: () => boolean
50
51
  isEdge: () => boolean
51
52
  getCapabilities: (...args: unknown[]) => any
52
53
  // Platform properties
@@ -55,21 +56,23 @@ interface _memorio {
55
56
  _sessionId?: string
56
57
  _currentContext?: string
57
58
  // Context management (for server-side isolation)
58
- createContext?: (name?: string) => {
59
+ createContext?: (name?: string, opts?: { encryptionKey?: any }) => {
59
60
  id: string
60
61
  state: any
61
62
  store: any
62
63
  session: any
63
64
  cache: any
65
+ encryptionKey?: any
64
66
  }
65
67
  listContexts?: () => string[]
66
68
  deleteContext?: (id: string) => boolean
67
- isolate?: (name?: string) => {
69
+ isolate?: (name?: string, opts?: { encryptionKey?: any }) => {
68
70
  id: string
69
71
  state: any
70
72
  store: any
71
73
  session: any
72
74
  cache: any
75
+ encryptionKey?: any
73
76
  }
74
77
  help?: () => void
75
78
  global?: () => void
@@ -92,16 +95,16 @@ interface _memorio {
92
95
  trace?: () => _mutationRecord[]
93
96
  enableHistory?: (enabled?: boolean) => void
94
97
  clearHistory?: () => void
95
- clearRedo?: () => void
96
- // Mutation Engine (Memorio 5)
97
- mutate?: (path: string, value: any, opts?: { source?: string; transactionId?: string }) => _mutation
98
- createMutation?: (path: string, operation: _operation, before: any, after: any, opts?: { context?: string; source?: string; transactionId?: string }) => _mutation
99
- recordMutation?: (mutation: _mutation) => void
100
- toPatch?: (mutation: _mutation) => _patch | null
101
- transaction?: (source?: string, message?: string, metadata?: Record<string, any>) => _transaction
102
- commitTransaction?: () => _transaction | null
103
- abortTransaction?: () => _transaction | null
104
- currentTransaction?: () => _transaction | null
98
+ clearRedo?: () => void
99
+ // Mutation Engine (Memorio 5)
100
+ mutate?: (path: string, value: any, opts?: { source?: string; transactionId?: string }) => _mutation
101
+ createMutation?: (path: string, operation: _operation, before: any, after: any, opts?: { context?: string; source?: string; transactionId?: string }) => _mutation
102
+ recordMutation?: (mutation: _mutation) => void
103
+ toPatch?: (mutation: _mutation) => _patch | null
104
+ transaction?: (source?: string, message?: string, metadata?: Record<string, any>) => _transaction
105
+ commitTransaction?: () => _transaction | null
106
+ abortTransaction?: () => _transaction | null
107
+ currentTransaction?: () => _transaction | null
105
108
  // Introspection
106
109
  stateKeys?: () => string[]
107
110
  pathExists?: (path: string) => boolean
@@ -109,6 +112,10 @@ interface _memorio {
109
112
  stateGet?: (path: string) => any
110
113
  stateSchema?: () => Array<{ path: string; type: string; defined: boolean }>
111
114
  memory?: MemoryAPI
115
+ encryption?: _encryption
116
+ computed?: _computed
117
+ broadcast?: _broadcast
118
+ security?: _security
112
119
  // Development-only surfaces (excluded from production builds via `if (DEV)`).
113
120
  // Not a security boundary on its own - rely on your backend for auth.
114
121
  devtools?: any
@@ -0,0 +1,67 @@
1
+ /*!
2
+ memorio
3
+ Copyright (c) 2025 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under MIT License, see
5
+ dario.passariello.ca
6
+ */
7
+
8
+ type Permission = 'read' | 'write' | 'delete' | 'admin'
9
+
10
+ interface AccessRule {
11
+ pattern: string | ((key: string, userId?: string) => boolean)
12
+ permissions: Permission[]
13
+ }
14
+
15
+ type AccessRulesMap = Map<string | ((key: string, userId?: string) => boolean), Permission[]>
16
+
17
+ interface AuditEntry {
18
+ timestamp: number
19
+ action: 'set' | 'get' | 'delete' | 'hydrate' | 'remove' | 'clearAll'
20
+ key: string
21
+ userId?: string
22
+ success: boolean
23
+ error?: string
24
+ }
25
+
26
+ interface ConsentRecord {
27
+ id: string
28
+ purpose: string
29
+ granted: boolean
30
+ timestamp: number
31
+ }
32
+
33
+ type ConsentsMap = Map<string, ConsentRecord[]>
34
+
35
+ interface _security {
36
+ safeRandomUUID: () => string
37
+ safeRegexTest: (pattern: string, key: string) => boolean
38
+
39
+ addAccessRule: (rules: AccessRulesMap, pattern: string | ((key: string, userId?: string) => boolean), perms: Permission[]) => AccessRulesMap
40
+ hasPermission: (rules: AccessRulesMap, key: string, action: Permission, userId?: string) => boolean
41
+
42
+ isAuditActive: () => boolean
43
+ setAuditLogger: (logger: (entry: AuditEntry) => void) => void
44
+ logAudit: (entry: Partial<AuditEntry>) => void
45
+
46
+ sanitizeValue: (value: unknown) => unknown
47
+ validateKey: (key: string) => boolean
48
+
49
+ recordConsent: (consents: ConsentsMap, userId: string, purpose: string, granted: boolean) => ConsentRecord
50
+ hasConsent: (consents: ConsentsMap, userId: string, purpose: string) => boolean
51
+ revokeConsent: (consents: ConsentsMap, userId: string, purpose: string) => ConsentRecord | null
52
+ getConsents: (consents: ConsentsMap, userId: string) => ConsentRecord[]
53
+ exportUserData: (consents: ConsentsMap, userId: string) => { userId: string; exportedAt: number; consents: ConsentRecord[] }
54
+ deleteUserData: (consents: ConsentsMap, userId: string) => { success: boolean; deletedConsents: number }
55
+ }
56
+
57
+ declare var security: _security
58
+ type security = _security
59
+
60
+ export {
61
+ Permission,
62
+ AccessRule,
63
+ AccessRulesMap,
64
+ AuditEntry,
65
+ ConsentRecord,
66
+ ConsentsMap
67
+ }
@@ -10,24 +10,42 @@ interface _session {
10
10
  *
11
11
  * @example
12
12
  * session.set("test","example") // or Array, Object, Number, Functions...
13
+ * session.set("test", value, { encrypt: key }) // encrypt at rest
13
14
  *
14
15
  * @since memorio 0.0.1
15
16
  * @param name The String as name to define the session.
16
17
  * @param param The information taht you want to session (Any).
17
- * @return boolean
18
- */
19
- set: (name: string, value: any) => void
18
+ * @param opts Optional { encrypt: key } to encrypt before storage.
19
+ * @return boolean | Promise<boolean>
20
+ */
21
+ set: (name: string, value: any, opts?: { encrypt?: any }) => boolean | Promise<boolean>
22
+
23
+ /**
24
+ * Configure session-wide behavior.
25
+ *
26
+ * @example
27
+ * session.config({ encryptionKey: derivedKey })
28
+ * session.config({ onError: (err, ctx) => console.error(err, ctx) })
29
+ * session.config({ maxObjectSize: 5 * 1024 * 1024 })
30
+ * session.config({ maxTotalSize: 50 * 1024 * 1024 })
31
+ *
32
+ * @since memorio 5.0
33
+ * @param opts { encryptionKey, onError, maxObjectSize, maxTotalSize }
34
+ */
35
+ config: (opts: { encryptionKey?: any; onError?: (err: unknown, ctx: { operation: string }) => void; maxObjectSize?: number; maxTotalSize?: number }) => void
20
36
 
21
37
  /**
22
38
  * Have back the data from a session.
23
39
  *
24
40
  * @example
25
41
  * session.get("test")
42
+ * session.get("test", { decrypt: key }) // decrypt an encrypted envelope
26
43
  *
27
44
  * @since memorio 0.0.1
28
45
  * @param name The String as name to define the session.
29
- */
30
- get: (name: string) => any
46
+ * @param opts Optional { decrypt: key } to decrypt an encrypted envelope.
47
+ */
48
+ get: (name: string, opts?: { decrypt?: any }) => any
31
49
 
32
50
  /**
33
51
  * Delete an existing session:
package/types/store.d.ts CHANGED
@@ -14,18 +14,34 @@ interface _store {
14
14
  * @param value The information you want to store. Functions are blocked for security.
15
15
  * @return void
16
16
  */
17
- set: (name: string, value: any) => void
17
+ set: (name: string, value: any, opts?: { encrypt?: any }) => boolean | Promise<boolean>
18
+
19
+ /**
20
+ * Configure store-wide behavior.
21
+ *
22
+ * @example
23
+ * store.config({ encryptionKey: derivedKey })
24
+ * store.config({ onError: (err, ctx) => console.error(err, ctx) })
25
+ * store.config({ maxObjectSize: 5 * 1024 * 1024 })
26
+ * store.config({ maxTotalSize: 50 * 1024 * 1024 })
27
+ *
28
+ * @since memorio 5.0
29
+ * @param opts { encryptionKey, onError, maxObjectSize, maxTotalSize }
30
+ */
31
+ config: (opts: { encryptionKey?: any; onError?: (err: unknown, ctx: { operation: string }) => void; maxObjectSize?: number; maxTotalSize?: number }) => void
18
32
 
19
33
  /**
20
- * Have back the data from a store.
34
+ * Gets a value from storage.
21
35
  *
22
36
  * @example
23
37
  * store.get("test")
38
+ * store.get("test", { decrypt: key }) // decrypt an encrypted envelope
24
39
  *
25
40
  * @since memorio 0.0.1
26
41
  * @param name The String as name to define the store.
42
+ * @param opts Optional { decrypt: key } to decrypt an encrypted envelope.
27
43
  */
28
- get: (name: string) => any
44
+ get: (name: string, opts?: { decrypt?: any }) => any
29
45
 
30
46
  /**
31
47
  * Delete an existing store:
Binary file