@bsv/expo-wallet-toolbox 0.11.2 → 0.11.4
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.4
|
|
4
|
+
|
|
5
|
+
### dApp results the SDK rejected: noSend actions and identity discovery
|
|
6
|
+
|
|
7
|
+
Three wallet responses from `@bsv/wallet-toolbox-mobile` 2.14.3 fail
|
|
8
|
+
`@bsv/sdk` 2.8.8+ result validation in every dApp. `conformWalletResults`
|
|
9
|
+
(`core/services/conformWalletResults.ts`) wraps the permissions manager and
|
|
10
|
+
corrects them until the library ships the same fixes (bsv-blockchain/ts-stack#673):
|
|
11
|
+
|
|
12
|
+
- A `createAction` with `noSend` returned `noSendChange` outpoints on the
|
|
13
|
+
unsigned txid next to the signed `txid` (`noSendChange[0]: expected an
|
|
14
|
+
outpoint of the returned transaction`). They now name the signed transaction.
|
|
15
|
+
- That no-send action could not be released: the caller only has its `txid`,
|
|
16
|
+
and the permissions manager refused `abortAction` by txid from any non-admin
|
|
17
|
+
origin, so its inputs stayed locked until no-send expiry. The origin that
|
|
18
|
+
created it in this session may now abort it; another origin still cannot, and
|
|
19
|
+
a broadcast action is never abortable this way.
|
|
20
|
+
- `discoverByIdentityKey` and `discoverByAttributes` ignored `limit`/`offset`
|
|
21
|
+
(`certificates: expected at most the requested limit`). They now return the
|
|
22
|
+
requested page (10 when no limit is given); `totalCertificates` still counts
|
|
23
|
+
every match.
|
|
24
|
+
|
|
25
|
+
## 0.11.3
|
|
26
|
+
|
|
27
|
+
### Identity lookups: default certifier descriptions fit BRC-100
|
|
28
|
+
|
|
29
|
+
`IdentityClient.resolveByAttributes` and `resolveByIdentityKey` failed in dApps
|
|
30
|
+
using `@bsv/sdk` 2.8.8 or later with `Invalid discoverByAttributes result
|
|
31
|
+
certificates[n].certifierInfo.description: expected 5–50 UTF-8 bytes`. The
|
|
32
|
+
wallet copies each trusted certifier's description into `certifierInfo`, and
|
|
33
|
+
the library's default SocialCert and Metanet Trust Services descriptions are 56
|
|
34
|
+
and 55 bytes. `DEFAULT_SETTINGS` now carries shorter descriptions for those two
|
|
35
|
+
(same wording as bsv-blockchain/ts-stack#665, which fixes the library), so
|
|
36
|
+
their certificates pass the SDK's result validation. Nothing else about either
|
|
37
|
+
certifier changes. `DEFAULT_SETTINGS` moves to `core/context/defaultWalletSettings.ts`.
|
|
38
|
+
|
|
3
39
|
## 0.11.2
|
|
4
40
|
|
|
5
41
|
0.11.1 was tagged but never reached npm: its publish run failed on a test-only
|
|
@@ -10,11 +10,12 @@ import {
|
|
|
10
10
|
PermissionRequest,
|
|
11
11
|
SimpleWalletManager,
|
|
12
12
|
Monitor,
|
|
13
|
-
DEFAULT_SETTINGS as LIB_DEFAULT_SETTINGS,
|
|
14
13
|
WalletSettings,
|
|
15
14
|
WalletSettingsManager
|
|
16
15
|
} from '@bsv/wallet-toolbox-mobile'
|
|
17
16
|
import { KeyDeriver, PrivateKey, MerklePath, Transaction, Utils } from '@bsv/sdk'
|
|
17
|
+
import { DEFAULT_SETTINGS } from './defaultWalletSettings'
|
|
18
|
+
import { conformWalletResults } from '../services/conformWalletResults'
|
|
18
19
|
import { VAULT_RETENTION_MS, ceremony as vaultCeremony } from '../services/vault/ceremonyHost'
|
|
19
20
|
import { getVaultDriver } from '../services/vault/driver'
|
|
20
21
|
import { backupAttestation } from '../services/vault/backupAttestation'
|
|
@@ -133,34 +134,6 @@ async function resolveMandalaAssetMetadata(assetId: string): Promise<MandalaAsse
|
|
|
133
134
|
const MANDALA_OUTPOINT_LIST_PAGE = 1000
|
|
134
135
|
const MANDALA_OUTPOINT_LIST_MAX_PAGES = 1000
|
|
135
136
|
|
|
136
|
-
const DEFAULT_SETTINGS: WalletSettings = {
|
|
137
|
-
...LIB_DEFAULT_SETTINGS,
|
|
138
|
-
trustSettings: {
|
|
139
|
-
...LIB_DEFAULT_SETTINGS.trustSettings,
|
|
140
|
-
trustedCertifiers: [
|
|
141
|
-
...LIB_DEFAULT_SETTINGS.trustSettings.trustedCertifiers,
|
|
142
|
-
{
|
|
143
|
-
name: 'Who I Am',
|
|
144
|
-
description: 'Certifies email, phone, and X account ownership',
|
|
145
|
-
iconUrl: 'https://whoiam.bsvblockchain.tech/whoiam.png',
|
|
146
|
-
identityKey: '02e7eeb3986273db6843b790a1595ed0ff1b2ae8f43ae2e7f1a0c9db4dd3fb9441',
|
|
147
|
-
trust: 5
|
|
148
|
-
},
|
|
149
|
-
// Values as published in https://auth.sigmaidentity.com/manifest.json
|
|
150
|
-
// (babbage.trust). Lowest trust of the shipped set: it is the newest
|
|
151
|
-
// certifier here and the list is ordered by trust on the Trust screen.
|
|
152
|
-
// The icon is an SVG; the Trust screen draws those with react-native-svg
|
|
153
|
-
// rather than the platform decoder, which mispositions its <text> glyph.
|
|
154
|
-
{
|
|
155
|
-
name: 'Sigma Identity',
|
|
156
|
-
description: 'Certifies verified identity claims',
|
|
157
|
-
iconUrl: 'https://auth.sigmaidentity.com/sigma-mark.svg',
|
|
158
|
-
identityKey: '02250905f0383085b53409876aefbf01fc8e7fd841922dc4ce55ae035b31341e6d',
|
|
159
|
-
trust: 2
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
137
|
import type { AppChain } from '../config'
|
|
165
138
|
import { DEFAULT_STORAGE_URL, DEFAULT_CHAIN, ADMIN_ORIGINATOR, toWalletChain } from '../config'
|
|
166
139
|
import { getBackupUrl, getMandalaEndpoints } from '../toolboxConfig'
|
|
@@ -1796,7 +1769,11 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
1796
1769
|
// rows unreadable rather than absent.
|
|
1797
1770
|
newManagers.permissionsManager = guardVaultAccess(
|
|
1798
1771
|
wrapAbortActionForSettlements(
|
|
1799
|
-
wrapCreateActionForTokenInputs(
|
|
1772
|
+
wrapCreateActionForTokenInputs(
|
|
1773
|
+
conformWalletResults(adminOriginator, permissionsManager),
|
|
1774
|
+
listMandalaTokenOutpoints,
|
|
1775
|
+
adminOriginator
|
|
1776
|
+
),
|
|
1800
1777
|
() => mandalaRef.current?.store,
|
|
1801
1778
|
() => mandalaEndpoints !== undefined
|
|
1802
1779
|
),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DEFAULT_SETTINGS as LIB_DEFAULT_SETTINGS, WalletSettings } from '@bsv/wallet-toolbox-mobile'
|
|
2
|
+
|
|
3
|
+
// BRC-100 bounds certifierInfo.description to 5-50 UTF-8 bytes, and @bsv/sdk
|
|
4
|
+
// 2.8.8+ rejects a discovery result outside it. The wallet copies these
|
|
5
|
+
// descriptions into certifierInfo, and the library ships Metanet Trust Services
|
|
6
|
+
// and SocialCert at 55 and 56 bytes, so every identity lookup returning one of
|
|
7
|
+
// their certificates threw in the dApp. Same wording as ts-stack#665, which
|
|
8
|
+
// fixes the library; drop this once @bsv/wallet-toolbox-mobile ships it.
|
|
9
|
+
const LIB_CERTIFIER_DESCRIPTIONS: Record<string, string> = {
|
|
10
|
+
'03daf815fe38f83da0ad83b5bedc520aa488aef5cbc93a93c67a7fe60406cbffe8': 'Registry of protocols, baskets, certificate types',
|
|
11
|
+
'02cf6cdf466951d8dfc9e7c9367511d0007ed6fba35ed42d425cc412fd6cfd4a17': 'Certifies social media handles, phones and emails'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const DEFAULT_SETTINGS: WalletSettings = {
|
|
15
|
+
...LIB_DEFAULT_SETTINGS,
|
|
16
|
+
trustSettings: {
|
|
17
|
+
...LIB_DEFAULT_SETTINGS.trustSettings,
|
|
18
|
+
trustedCertifiers: [
|
|
19
|
+
...LIB_DEFAULT_SETTINGS.trustSettings.trustedCertifiers.map(certifier => ({
|
|
20
|
+
...certifier,
|
|
21
|
+
description: LIB_CERTIFIER_DESCRIPTIONS[certifier.identityKey] ?? certifier.description
|
|
22
|
+
})),
|
|
23
|
+
{
|
|
24
|
+
name: 'Who I Am',
|
|
25
|
+
description: 'Certifies email, phone, and X account ownership',
|
|
26
|
+
iconUrl: 'https://whoiam.bsvblockchain.tech/whoiam.png',
|
|
27
|
+
identityKey: '02e7eeb3986273db6843b790a1595ed0ff1b2ae8f43ae2e7f1a0c9db4dd3fb9441',
|
|
28
|
+
trust: 5
|
|
29
|
+
},
|
|
30
|
+
// Values as published in https://auth.sigmaidentity.com/manifest.json
|
|
31
|
+
// (babbage.trust). Lowest trust of the shipped set: it is the newest
|
|
32
|
+
// certifier here and the list is ordered by trust on the Trust screen.
|
|
33
|
+
// The icon is an SVG; the Trust screen draws those with react-native-svg
|
|
34
|
+
// rather than the platform decoder, which mispositions its <text> glyph.
|
|
35
|
+
{
|
|
36
|
+
name: 'Sigma Identity',
|
|
37
|
+
description: 'Certifies verified identity claims',
|
|
38
|
+
iconUrl: 'https://auth.sigmaidentity.com/sigma-mark.svg',
|
|
39
|
+
identityKey: '02250905f0383085b53409876aefbf01fc8e7fd841922dc4ce55ae035b31341e6d',
|
|
40
|
+
trust: 2
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brings two @bsv/wallet-toolbox-mobile 2.14.3 results in line with what
|
|
3
|
+
* @bsv/sdk 2.8.8+ accepts. Without this, every dApp using the SDK sees them as
|
|
4
|
+
* invalid wallet responses:
|
|
5
|
+
*
|
|
6
|
+
* - createAction: when the permissions manager signs a non-admin action
|
|
7
|
+
* itself, `noSendChange` still names the unsigned txid next to the signed
|
|
8
|
+
* `txid` ("noSendChange[0]: expected an outpoint of the returned
|
|
9
|
+
* transaction"). Signing never moves outputs, so only the txid changes.
|
|
10
|
+
* - discoverByIdentityKey / discoverByAttributes: every trusted match comes
|
|
11
|
+
* back regardless of `limit`/`offset` ("expected at most the requested
|
|
12
|
+
* limit"). `totalCertificates` keeps counting every match.
|
|
13
|
+
* - abortAction: that signed no-send action can only be released by its txid,
|
|
14
|
+
* which the manager refuses from any non-admin originator. The origin that
|
|
15
|
+
* created it in this session may abort it; the wrapper forwards that one
|
|
16
|
+
* abort as the admin. Any other reference goes through the manager's own
|
|
17
|
+
* check unchanged, and a broadcast action is never recorded.
|
|
18
|
+
*
|
|
19
|
+
* bsv-blockchain/ts-stack fixes all three in @bsv/wallet-toolbox 2.14.4; drop this
|
|
20
|
+
* wrapper once @bsv/wallet-toolbox-mobile ships that.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const DEFAULT_DISCOVERY_LIMIT = 10
|
|
24
|
+
|
|
25
|
+
interface CreateActionResultLike {
|
|
26
|
+
txid?: string
|
|
27
|
+
noSendChange?: string[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface DiscoveryResultLike {
|
|
31
|
+
totalCertificates: number
|
|
32
|
+
certificates: unknown[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function noSendChangeOnTxid<R>(result: R): R {
|
|
36
|
+
const r = result as CreateActionResultLike | undefined
|
|
37
|
+
if (!r?.txid || !Array.isArray(r.noSendChange)) return result
|
|
38
|
+
const txid = r.txid
|
|
39
|
+
return {
|
|
40
|
+
...r,
|
|
41
|
+
noSendChange: r.noSendChange.map(outpoint => `${txid}.${outpoint.slice(outpoint.lastIndexOf('.') + 1)}`)
|
|
42
|
+
} as R
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function discoveryPage<R>(result: R, args: { limit?: number; offset?: number } | undefined): R {
|
|
46
|
+
const r = result as DiscoveryResultLike | undefined
|
|
47
|
+
if (!r || !Array.isArray(r.certificates)) return result
|
|
48
|
+
const offset = args?.offset ?? 0
|
|
49
|
+
const limit = args?.limit ?? DEFAULT_DISCOVERY_LIMIT
|
|
50
|
+
return { ...r, certificates: r.certificates.slice(offset, offset + limit) } as R
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function noSendKey(reference: unknown): string {
|
|
54
|
+
return typeof reference === 'string' ? reference.toLowerCase() : ''
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function conformWalletResults<T extends object>(adminOriginator: string, manager: T): T {
|
|
58
|
+
// txid of each signed no-send action → the originator that created it.
|
|
59
|
+
const noSendOriginators = new Map<string, string>()
|
|
60
|
+
return new Proxy(manager, {
|
|
61
|
+
get(target, prop, receiver) {
|
|
62
|
+
const value = Reflect.get(target, prop, receiver)
|
|
63
|
+
if (typeof value !== 'function') return value
|
|
64
|
+
if (prop === 'createAction') {
|
|
65
|
+
return async (args: { options?: { noSend?: boolean } } | undefined, originator?: string) => {
|
|
66
|
+
const result = noSendChangeOnTxid(await value.call(target, args, originator)) as CreateActionResultLike
|
|
67
|
+
if (args?.options?.noSend === true && result?.txid && originator !== adminOriginator) {
|
|
68
|
+
noSendOriginators.set(noSendKey(result.txid), originator ?? '')
|
|
69
|
+
}
|
|
70
|
+
return result
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (prop === 'abortAction') {
|
|
74
|
+
return async (args: { reference?: string } | undefined, originator?: string) => {
|
|
75
|
+
const key = noSendKey(args?.reference)
|
|
76
|
+
const owner = noSendOriginators.get(key)
|
|
77
|
+
if (owner === undefined || originator === adminOriginator) return await value.call(target, args, originator)
|
|
78
|
+
if (owner !== (originator ?? '')) throw new Error('The action reference belongs to a different originator.')
|
|
79
|
+
const result = await value.call(target, args, adminOriginator)
|
|
80
|
+
if ((result as { aborted?: boolean } | undefined)?.aborted === true) noSendOriginators.delete(key)
|
|
81
|
+
return result
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (prop === 'discoverByIdentityKey' || prop === 'discoverByAttributes') {
|
|
85
|
+
return async (...args: unknown[]) =>
|
|
86
|
+
discoveryPage(await value.apply(target, args), args[0] as { limit?: number; offset?: number })
|
|
87
|
+
}
|
|
88
|
+
return value.bind(target)
|
|
89
|
+
}
|
|
90
|
+
}) as T
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/expo-wallet-toolbox",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Wallet screens and P2P local-payment backend for Expo/React Native apps, extracted from BSV Wallet.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|