@unicitylabs/sphere-sdk 0.15.0 → 0.16.0-dev.1
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.
- package/README.md +15 -5
- package/dist/connect/index.cjs +14 -23
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.cts +4 -0
- package/dist/connect/index.d.ts +4 -0
- package/dist/connect/index.js +14 -23
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +726 -225
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +172 -21
- package/dist/core/index.d.ts +172 -21
- package/dist/core/index.js +726 -224
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +14 -23
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +14 -23
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +331 -504
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +331 -504
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/connect/index.cjs +13 -22
- package/dist/impl/nodejs/connect/index.cjs.map +1 -1
- package/dist/impl/nodejs/connect/index.js +13 -22
- package/dist/impl/nodejs/connect/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +298 -569
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +90 -13
- package/dist/impl/nodejs/index.d.ts +90 -13
- package/dist/impl/nodejs/index.js +298 -569
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/impl/shared/wallet-api/index.d.cts +54 -2
- package/dist/impl/shared/wallet-api/index.d.ts +54 -2
- package/dist/index.cjs +728 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -108
- package/dist/index.d.ts +227 -108
- package/dist/index.js +728 -224
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +11 -7
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.d.cts +56 -3
- package/dist/modules/payments-v2/index.d.ts +56 -3
- package/dist/modules/payments-v2/index.js +11 -7
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs +46 -0
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.js +46 -0
- package/dist/token-engine/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -58,6 +58,25 @@ interface TrackedAddressEntry {
|
|
|
58
58
|
* All operations are async for platform flexibility
|
|
59
59
|
*/
|
|
60
60
|
interface StorageProvider extends BaseProvider {
|
|
61
|
+
/**
|
|
62
|
+
* Stable identity of the BACKING STORE this provider addresses — not of this
|
|
63
|
+
* object, and not of the class (`id` is a class constant like `'file-storage'`,
|
|
64
|
+
* which is exactly the wrong granularity).
|
|
65
|
+
*
|
|
66
|
+
* Two providers that return the SAME value address the same data, so erasing
|
|
67
|
+
* through one erases through the other: `Sphere.clear({ storage })` tears down
|
|
68
|
+
* the live Spheres of every provider sharing this value, not merely those built
|
|
69
|
+
* on this object. Compose it from everything that selects the store (file path,
|
|
70
|
+
* database name, key prefix) behind a scheme prefix, so two kinds of store can
|
|
71
|
+
* never collide on one string.
|
|
72
|
+
*
|
|
73
|
+
* It must not change over the provider's lifetime — it is read again on teardown,
|
|
74
|
+
* and a value that moved would strand the entry it was registered under.
|
|
75
|
+
*
|
|
76
|
+
* Optional: omit it and liveness falls back to per-object identity, i.e. a
|
|
77
|
+
* second provider over the same data is treated as unrelated.
|
|
78
|
+
*/
|
|
79
|
+
readonly backingStoreId?: string;
|
|
61
80
|
/**
|
|
62
81
|
* Set identity for scoped storage
|
|
63
82
|
*/
|
|
@@ -87,11 +106,44 @@ interface StorageProvider extends BaseProvider {
|
|
|
87
106
|
*/
|
|
88
107
|
clear(prefix?: string): Promise<void>;
|
|
89
108
|
/**
|
|
90
|
-
* Save tracked addresses (only user state: index, hidden, timestamps)
|
|
109
|
+
* Save tracked addresses (only user state: index, hidden, timestamps).
|
|
110
|
+
*
|
|
111
|
+
* MUST MERGE, NEVER REPLACE (#766 item 5). `entries` is ONE writer's snapshot,
|
|
112
|
+
* not the whole truth: every Sphere sharing this storage keeps its own copy of
|
|
113
|
+
* the registry and persists all of it, so writing the argument verbatim is a
|
|
114
|
+
* lost update — A activates index 1, B (whose snapshot predates that) activates
|
|
115
|
+
* index 2, and B's write erases index 1 while A still reports it. This happens
|
|
116
|
+
* on a single network with a single provider; do NOT "fix" it by renaming or
|
|
117
|
+
* network-scoping the key.
|
|
118
|
+
*
|
|
119
|
+
* The contract, implemented by `storage/tracked-addresses.ts` — reuse those
|
|
120
|
+
* helpers rather than re-deriving this:
|
|
121
|
+
* - read the stored registry, union it with `entries` BY `index`;
|
|
122
|
+
* - on a conflicting index, the entry with the greater `updatedAt` supplies
|
|
123
|
+
* `hidden`, and `createdAt` keeps the earlier value;
|
|
124
|
+
* - serialize concurrent calls on the provider instance, so one call's read
|
|
125
|
+
* cannot interleave with another's write;
|
|
126
|
+
* - a failed write must not brick later writes, and must still reject to its
|
|
127
|
+
* own caller.
|
|
128
|
+
*
|
|
129
|
+
* An `index` must be a UINT32 — a BIP32 child number. `deriveKeyAtPath` parseInt()s
|
|
130
|
+
* that path segment, so `1.5` derives index 1's keys and the row aliases a real
|
|
131
|
+
* address. The ceiling matters too: `deriveChildKey` pads the child number to 8 hex
|
|
132
|
+
* digits, so anything above `0xffffffff` emits extra bytes and derives off-standard.
|
|
133
|
+
* An `entries` row that is not one must REJECT the whole call (`mergeTrackedAddresses`
|
|
134
|
+
* throws `VALIDATION_ERROR`); dropping it silently on a write reports a save that
|
|
135
|
+
* never happened. Already-stored rows are dropped on READ instead, so one bad row
|
|
136
|
+
* cannot brick every later write. Validate before opening the write transaction if
|
|
137
|
+
* your platform would otherwise replace the reason with a generic abort.
|
|
138
|
+
*
|
|
139
|
+
* A union is safe because there is no delete path: entries are only ever added,
|
|
140
|
+
* and wiping the wallet removes the key itself (`Sphere.clear()`). Adding a
|
|
141
|
+
* per-entry delete would require revisiting this contract.
|
|
91
142
|
*/
|
|
92
143
|
saveTrackedAddresses(entries: TrackedAddressEntry[]): Promise<void>;
|
|
93
144
|
/**
|
|
94
|
-
* Load tracked addresses
|
|
145
|
+
* Load tracked addresses. Tolerant: unusable/corrupt storage reads as `[]`
|
|
146
|
+
* (see `parseTrackedAddresses` in `storage/tracked-addresses.ts`).
|
|
95
147
|
*/
|
|
96
148
|
loadTrackedAddresses(): Promise<TrackedAddressEntry[]>;
|
|
97
149
|
}
|
|
@@ -58,6 +58,25 @@ interface TrackedAddressEntry {
|
|
|
58
58
|
* All operations are async for platform flexibility
|
|
59
59
|
*/
|
|
60
60
|
interface StorageProvider extends BaseProvider {
|
|
61
|
+
/**
|
|
62
|
+
* Stable identity of the BACKING STORE this provider addresses — not of this
|
|
63
|
+
* object, and not of the class (`id` is a class constant like `'file-storage'`,
|
|
64
|
+
* which is exactly the wrong granularity).
|
|
65
|
+
*
|
|
66
|
+
* Two providers that return the SAME value address the same data, so erasing
|
|
67
|
+
* through one erases through the other: `Sphere.clear({ storage })` tears down
|
|
68
|
+
* the live Spheres of every provider sharing this value, not merely those built
|
|
69
|
+
* on this object. Compose it from everything that selects the store (file path,
|
|
70
|
+
* database name, key prefix) behind a scheme prefix, so two kinds of store can
|
|
71
|
+
* never collide on one string.
|
|
72
|
+
*
|
|
73
|
+
* It must not change over the provider's lifetime — it is read again on teardown,
|
|
74
|
+
* and a value that moved would strand the entry it was registered under.
|
|
75
|
+
*
|
|
76
|
+
* Optional: omit it and liveness falls back to per-object identity, i.e. a
|
|
77
|
+
* second provider over the same data is treated as unrelated.
|
|
78
|
+
*/
|
|
79
|
+
readonly backingStoreId?: string;
|
|
61
80
|
/**
|
|
62
81
|
* Set identity for scoped storage
|
|
63
82
|
*/
|
|
@@ -87,11 +106,44 @@ interface StorageProvider extends BaseProvider {
|
|
|
87
106
|
*/
|
|
88
107
|
clear(prefix?: string): Promise<void>;
|
|
89
108
|
/**
|
|
90
|
-
* Save tracked addresses (only user state: index, hidden, timestamps)
|
|
109
|
+
* Save tracked addresses (only user state: index, hidden, timestamps).
|
|
110
|
+
*
|
|
111
|
+
* MUST MERGE, NEVER REPLACE (#766 item 5). `entries` is ONE writer's snapshot,
|
|
112
|
+
* not the whole truth: every Sphere sharing this storage keeps its own copy of
|
|
113
|
+
* the registry and persists all of it, so writing the argument verbatim is a
|
|
114
|
+
* lost update — A activates index 1, B (whose snapshot predates that) activates
|
|
115
|
+
* index 2, and B's write erases index 1 while A still reports it. This happens
|
|
116
|
+
* on a single network with a single provider; do NOT "fix" it by renaming or
|
|
117
|
+
* network-scoping the key.
|
|
118
|
+
*
|
|
119
|
+
* The contract, implemented by `storage/tracked-addresses.ts` — reuse those
|
|
120
|
+
* helpers rather than re-deriving this:
|
|
121
|
+
* - read the stored registry, union it with `entries` BY `index`;
|
|
122
|
+
* - on a conflicting index, the entry with the greater `updatedAt` supplies
|
|
123
|
+
* `hidden`, and `createdAt` keeps the earlier value;
|
|
124
|
+
* - serialize concurrent calls on the provider instance, so one call's read
|
|
125
|
+
* cannot interleave with another's write;
|
|
126
|
+
* - a failed write must not brick later writes, and must still reject to its
|
|
127
|
+
* own caller.
|
|
128
|
+
*
|
|
129
|
+
* An `index` must be a UINT32 — a BIP32 child number. `deriveKeyAtPath` parseInt()s
|
|
130
|
+
* that path segment, so `1.5` derives index 1's keys and the row aliases a real
|
|
131
|
+
* address. The ceiling matters too: `deriveChildKey` pads the child number to 8 hex
|
|
132
|
+
* digits, so anything above `0xffffffff` emits extra bytes and derives off-standard.
|
|
133
|
+
* An `entries` row that is not one must REJECT the whole call (`mergeTrackedAddresses`
|
|
134
|
+
* throws `VALIDATION_ERROR`); dropping it silently on a write reports a save that
|
|
135
|
+
* never happened. Already-stored rows are dropped on READ instead, so one bad row
|
|
136
|
+
* cannot brick every later write. Validate before opening the write transaction if
|
|
137
|
+
* your platform would otherwise replace the reason with a generic abort.
|
|
138
|
+
*
|
|
139
|
+
* A union is safe because there is no delete path: entries are only ever added,
|
|
140
|
+
* and wiping the wallet removes the key itself (`Sphere.clear()`). Adding a
|
|
141
|
+
* per-entry delete would require revisiting this contract.
|
|
91
142
|
*/
|
|
92
143
|
saveTrackedAddresses(entries: TrackedAddressEntry[]): Promise<void>;
|
|
93
144
|
/**
|
|
94
|
-
* Load tracked addresses
|
|
145
|
+
* Load tracked addresses. Tolerant: unusable/corrupt storage reads as `[]`
|
|
146
|
+
* (see `parseTrackedAddresses` in `storage/tracked-addresses.ts`).
|
|
95
147
|
*/
|
|
96
148
|
loadTrackedAddresses(): Promise<TrackedAddressEntry[]>;
|
|
97
149
|
}
|