@1sat/connect 0.0.54 → 0.0.55
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/dist/index.js +5 -53
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -100373,8 +100373,7 @@ class LocalWalletPermissionsManager extends import_index_client.WalletPermission
|
|
|
100373
100373
|
return super.dismissGroupedPermission(requestID);
|
|
100374
100374
|
}
|
|
100375
100375
|
async listProtocolPermissions(filter = {}) {
|
|
100376
|
-
|
|
100377
|
-
const idb = await this.idbTokensFor("protocol", filter.originator, (g) => {
|
|
100376
|
+
return this.idbTokensFor("protocol", filter.originator, (g) => {
|
|
100378
100377
|
if (g.key.type !== "protocol")
|
|
100379
100378
|
return false;
|
|
100380
100379
|
if (filter.privileged !== undefined && g.key.privileged !== filter.privileged) {
|
|
@@ -100391,11 +100390,9 @@ class LocalWalletPermissionsManager extends import_index_client.WalletPermission
|
|
|
100391
100390
|
}
|
|
100392
100391
|
return true;
|
|
100393
100392
|
});
|
|
100394
|
-
return mergeTokens(onchain, idb);
|
|
100395
100393
|
}
|
|
100396
100394
|
async listBasketAccess(params = {}) {
|
|
100397
|
-
|
|
100398
|
-
const idb = await this.idbTokensFor("basket", params.originator, (g) => {
|
|
100395
|
+
return this.idbTokensFor("basket", params.originator, (g) => {
|
|
100399
100396
|
if (g.key.type !== "basket")
|
|
100400
100397
|
return false;
|
|
100401
100398
|
if (params.basket !== undefined && g.key.basket !== params.basket) {
|
|
@@ -100403,16 +100400,12 @@ class LocalWalletPermissionsManager extends import_index_client.WalletPermission
|
|
|
100403
100400
|
}
|
|
100404
100401
|
return true;
|
|
100405
100402
|
});
|
|
100406
|
-
return mergeTokens(onchain, idb);
|
|
100407
100403
|
}
|
|
100408
100404
|
async listSpendingAuthorizations(params) {
|
|
100409
|
-
|
|
100410
|
-
const idb = await this.idbTokensFor("spending", params.originator, (g) => g.key.type === "spending");
|
|
100411
|
-
return mergeTokens(onchain, idb);
|
|
100405
|
+
return this.idbTokensFor("spending", params.originator, (g) => g.key.type === "spending");
|
|
100412
100406
|
}
|
|
100413
100407
|
async listCertificateAccess(params = {}) {
|
|
100414
|
-
|
|
100415
|
-
const idb = await this.idbTokensFor("certificate", params.originator, (g) => {
|
|
100408
|
+
return this.idbTokensFor("certificate", params.originator, (g) => {
|
|
100416
100409
|
if (g.key.type !== "certificate")
|
|
100417
100410
|
return false;
|
|
100418
100411
|
if (params.privileged !== undefined && g.key.privileged !== params.privileged) {
|
|
@@ -100426,7 +100419,6 @@ class LocalWalletPermissionsManager extends import_index_client.WalletPermission
|
|
|
100426
100419
|
}
|
|
100427
100420
|
return true;
|
|
100428
100421
|
});
|
|
100429
|
-
return mergeTokens(onchain, idb);
|
|
100430
100422
|
}
|
|
100431
100423
|
async idbTokensFor(type, originator, predicate) {
|
|
100432
100424
|
const filter = { type };
|
|
@@ -100439,7 +100431,7 @@ class LocalWalletPermissionsManager extends import_index_client.WalletPermission
|
|
|
100439
100431
|
const normalized = normalizeOriginator(originator);
|
|
100440
100432
|
await this.permissionStore.deleteAllForOriginator(normalized);
|
|
100441
100433
|
this.clearPermissionCache();
|
|
100442
|
-
return
|
|
100434
|
+
return [];
|
|
100443
100435
|
}
|
|
100444
100436
|
async revokePermission(oldToken) {
|
|
100445
100437
|
const idbKey = idbKeyFromToken(oldToken);
|
|
@@ -100447,10 +100439,6 @@ class LocalWalletPermissionsManager extends import_index_client.WalletPermission
|
|
|
100447
100439
|
await this.permissionStore.deleteGrant(idbKey);
|
|
100448
100440
|
}
|
|
100449
100441
|
this.clearPermissionCache();
|
|
100450
|
-
if (oldToken.txid.startsWith(IDB_TXID_PREFIX)) {
|
|
100451
|
-
return;
|
|
100452
|
-
}
|
|
100453
|
-
return super.revokePermission(oldToken);
|
|
100454
100442
|
}
|
|
100455
100443
|
clearPermissionCache() {
|
|
100456
100444
|
const cache = this.permissionCache;
|
|
@@ -100580,42 +100568,6 @@ function parseIdbKey(serialized) {
|
|
|
100580
100568
|
}
|
|
100581
100569
|
return null;
|
|
100582
100570
|
}
|
|
100583
|
-
function mergeTokens(onchain, idb) {
|
|
100584
|
-
const seen = new Set;
|
|
100585
|
-
const out = [];
|
|
100586
|
-
for (const t of onchain) {
|
|
100587
|
-
const k = onchainSignature(t);
|
|
100588
|
-
if (k)
|
|
100589
|
-
seen.add(k);
|
|
100590
|
-
out.push(t);
|
|
100591
|
-
}
|
|
100592
|
-
for (const t of idb) {
|
|
100593
|
-
const k = idbSignature(t);
|
|
100594
|
-
if (k && seen.has(k))
|
|
100595
|
-
continue;
|
|
100596
|
-
out.push(t);
|
|
100597
|
-
}
|
|
100598
|
-
return out;
|
|
100599
|
-
}
|
|
100600
|
-
function onchainSignature(t) {
|
|
100601
|
-
const originator = normalizeOriginator(t.originator);
|
|
100602
|
-
if (t.basketName)
|
|
100603
|
-
return `basket:${originator}:${t.basketName}`;
|
|
100604
|
-
if (t.protocol && t.securityLevel !== undefined) {
|
|
100605
|
-
return `proto:${originator}:${!!t.privileged}:${t.securityLevel},${t.protocol}:${t.counterparty ?? "self"}`;
|
|
100606
|
-
}
|
|
100607
|
-
if (t.certType && t.verifier && t.certFields) {
|
|
100608
|
-
return `cert:${originator}:${!!t.privileged}:${t.verifier}:${t.certType}:${[...t.certFields].sort().join("|")}`;
|
|
100609
|
-
}
|
|
100610
|
-
if (t.authorizedAmount !== undefined)
|
|
100611
|
-
return `spend:${originator}`;
|
|
100612
|
-
return null;
|
|
100613
|
-
}
|
|
100614
|
-
function idbSignature(t) {
|
|
100615
|
-
if (!t.txid.startsWith(IDB_TXID_PREFIX))
|
|
100616
|
-
return null;
|
|
100617
|
-
return t.txid.slice(IDB_TXID_PREFIX.length);
|
|
100618
|
-
}
|
|
100619
100571
|
// src/connectWallet.ts
|
|
100620
100572
|
var LAST_PROVIDER_KEY = "cwi_last_provider";
|
|
100621
100573
|
function saveLastProvider(providerType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/connect",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
4
4
|
"description": "Connection layer for 1Sat wallet - popup flow, events, session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@1sat/wallet": "0.0.
|
|
31
|
+
"@1sat/wallet": "0.0.72",
|
|
32
32
|
"@sigma-auth/better-auth-plugin": "^0.0.84",
|
|
33
33
|
"better-auth": "^1.5.4",
|
|
34
34
|
"eventemitter3": "^5.0.1"
|