Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bsv/wallet-toolbox-client",
"version": "1.7.12",
"version": "1.7.13",
"description": "Client only Wallet Storage",
"main": "./out/src/index.client.js",
"types": "./out/src/index.client.d.ts",
Expand Down
28 changes: 12 additions & 16 deletions docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -4004,17 +4004,16 @@ encryptWalletMetadata?: boolean

###### Property permissionModules

A map of P-basket permission scheme modules.
A map of P-basket/protocol permission scheme modules.

Keys are scheme IDs (e.g., "btms"), values are PermissionsModule instances.

Each module handles basket IDs of the form: `p <schemeID> <rest...>`
Each module handles basket/protocol names of the form: `p <schemeID> <rest...>`

The WalletPermissionManager detects P-prefix baskets and delegates
The WalletPermissionManager detects P-prefix baskets/protocols and delegates
request/response transformation to the corresponding module.

If no module exists for a given schemeID, the wallet MUST reject access
according to the P-Baskets specification.
If no module exists for a given schemeID, the wallet will reject access.

```ts
permissionModules?: Record<string, PermissionsModule>
Expand Down Expand Up @@ -4179,19 +4178,17 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
---
##### Interface: PermissionsModule

A permissions module handles request/response transformation for a specific P-basket scheme.
A permissions module handles request/response transformation for a specific P-protocol or P-basket scheme under BRC-98/99.
Modules are registered in the config mapped by their scheme ID.

```ts
export interface PermissionsModule {
onRequest(req: {
method: string;
args: any[];
args: object;
originator: string;
}): Promise<{
method: string;
args: any[];
originator: string;
args: object;
}>;
onResponse(res: any, context: {
method: string;
Expand All @@ -4203,23 +4200,21 @@ export interface PermissionsModule {
###### Method onRequest

Transforms the request before it's passed to the underlying wallet.
Can modify method name, args, or originator as needed.
Can check and enforce permissions, throw errors, or modify any arguments as needed prior to invocation.

```ts
onRequest(req: {
method: string;
args: any[];
args: object;
originator: string;
}): Promise<{
method: string;
args: any[];
originator: string;
args: object;
}>
```

Returns

Transformed request that will be passed to the underlying wallet
Transformed arguments that will be passed to the underlying wallet

Argument Details

Expand Down Expand Up @@ -9000,6 +8995,7 @@ export class CWIStyleWalletManager implements WalletInterface {
async provideRecoveryKey(recoveryKey: number[]): Promise<void>
saveSnapshot(): number[]
async loadSnapshot(snapshot: number[]): Promise<void>
async syncUMPToken(): Promise<boolean>
destroy(): void
listProfiles(): Array<{
id: number[];
Expand Down
28 changes: 12 additions & 16 deletions docs/wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4003,17 +4003,16 @@ encryptWalletMetadata?: boolean

###### Property permissionModules

A map of P-basket permission scheme modules.
A map of P-basket/protocol permission scheme modules.

Keys are scheme IDs (e.g., "btms"), values are PermissionsModule instances.

Each module handles basket IDs of the form: `p <schemeID> <rest...>`
Each module handles basket/protocol names of the form: `p <schemeID> <rest...>`

The WalletPermissionManager detects P-prefix baskets and delegates
The WalletPermissionManager detects P-prefix baskets/protocols and delegates
request/response transformation to the corresponding module.

If no module exists for a given schemeID, the wallet MUST reject access
according to the P-Baskets specification.
If no module exists for a given schemeID, the wallet will reject access.

```ts
permissionModules?: Record<string, PermissionsModule>
Expand Down Expand Up @@ -4178,19 +4177,17 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
---
##### Interface: PermissionsModule

A permissions module handles request/response transformation for a specific P-basket scheme.
A permissions module handles request/response transformation for a specific P-protocol or P-basket scheme under BRC-98/99.
Modules are registered in the config mapped by their scheme ID.

```ts
export interface PermissionsModule {
onRequest(req: {
method: string;
args: any[];
args: object;
originator: string;
}): Promise<{
method: string;
args: any[];
originator: string;
args: object;
}>;
onResponse(res: any, context: {
method: string;
Expand All @@ -4202,23 +4199,21 @@ export interface PermissionsModule {
###### Method onRequest

Transforms the request before it's passed to the underlying wallet.
Can modify method name, args, or originator as needed.
Can check and enforce permissions, throw errors, or modify any arguments as needed prior to invocation.

```ts
onRequest(req: {
method: string;
args: any[];
args: object;
originator: string;
}): Promise<{
method: string;
args: any[];
originator: string;
args: object;
}>
```

Returns

Transformed request that will be passed to the underlying wallet
Transformed arguments that will be passed to the underlying wallet

Argument Details

Expand Down Expand Up @@ -8999,6 +8994,7 @@ export class CWIStyleWalletManager implements WalletInterface {
async provideRecoveryKey(recoveryKey: number[]): Promise<void>
saveSnapshot(): number[]
async loadSnapshot(snapshot: number[]): Promise<void>
async syncUMPToken(): Promise<boolean>
destroy(): void
listProfiles(): Array<{
id: number[];
Expand Down
4 changes: 2 additions & 2 deletions mobile/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bsv/wallet-toolbox-mobile",
"version": "1.7.12",
"version": "1.7.13",
"description": "Client only Wallet Storage",
"main": "./out/src/index.mobile.js",
"types": "./out/src/index.mobile.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bsv/wallet-toolbox",
"version": "1.7.12",
"version": "1.7.13",
"description": "BRC100 conforming wallet, wallet storage and wallet signer components",
"main": "./out/src/index.js",
"types": "./out/src/index.d.ts",
Expand Down
34 changes: 34 additions & 0 deletions src/CWIStyleWalletManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,40 @@
}
}

async syncUMPToken(): Promise<boolean> {
if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey) {
throw new Error('Wallet not authenticated or missing UMP token.')
}

const currentToken = this.currentUMPToken
let refreshed: UMPToken | undefined

if (currentToken.presentationHash && currentToken.presentationHash.length) {

Check warning on line 1055 in src/CWIStyleWalletManager.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=bsv-blockchain_wallet-toolbox&issues=AZqjWO9uHH4KBv-fkmmN&open=AZqjWO9uHH4KBv-fkmmN&pullRequest=97
refreshed = await this.UMPTokenInteractor.findByPresentationKeyHash(currentToken.presentationHash)
}

if (!refreshed && currentToken.recoveryHash && currentToken.recoveryHash.length) {

Check warning on line 1059 in src/CWIStyleWalletManager.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=bsv-blockchain_wallet-toolbox&issues=AZqjWO9uHH4KBv-fkmmO&open=AZqjWO9uHH4KBv-fkmmO&pullRequest=97
refreshed = await this.UMPTokenInteractor.findByRecoveryKeyHash(currentToken.recoveryHash)
}

if (!refreshed) {
return false
}

if (
refreshed.currentOutpoint &&
currentToken.currentOutpoint &&
refreshed.currentOutpoint === currentToken.currentOutpoint
) {
return false
}

this.currentUMPToken = refreshed
await this.setupRootInfrastructure(this.rootPrimaryKey)
this.saveSnapshot()
return true
}

/**
* Destroys the wallet state, clearing keys, tokens, and profiles.
*/
Expand Down
1 change: 1 addition & 0 deletions src/__tests/CWIStyleWalletManager.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading