@phantom/browser-sdk 1.0.0-beta.20 → 1.0.0-beta.22
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 +121 -105
- package/dist/index.d.ts +19 -35
- package/dist/index.js +121 -59
- package/dist/index.mjs +123 -59
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -282,8 +282,9 @@ var InjectedEthereumChain = class {
|
|
|
282
282
|
return await this.phantom.ethereum.sendTransaction(transaction);
|
|
283
283
|
}
|
|
284
284
|
async switchChain(chainId) {
|
|
285
|
-
|
|
286
|
-
this.
|
|
285
|
+
const hexChainId = typeof chainId === "string" ? chainId.toLowerCase().startsWith("0x") ? chainId : `0x${parseInt(chainId, 10).toString(16)}` : `0x${chainId.toString(16)}`;
|
|
286
|
+
await this.phantom.ethereum.switchChain(hexChainId);
|
|
287
|
+
this._chainId = hexChainId;
|
|
287
288
|
this.eventEmitter.emit("chainChanged", this._chainId);
|
|
288
289
|
}
|
|
289
290
|
async getChainId() {
|
|
@@ -347,8 +348,8 @@ var InjectedEthereumChain = class {
|
|
|
347
348
|
};
|
|
348
349
|
|
|
349
350
|
// src/providers/injected/index.ts
|
|
350
|
-
var
|
|
351
|
-
var
|
|
351
|
+
var WAS_CONNECTED_KEY = "phantom-injected-was-connected";
|
|
352
|
+
var WAS_CONNECTED_VALUE = "true";
|
|
352
353
|
var InjectedProvider = class {
|
|
353
354
|
constructor(config) {
|
|
354
355
|
this.connected = false;
|
|
@@ -384,9 +385,6 @@ var InjectedProvider = class {
|
|
|
384
385
|
}
|
|
385
386
|
debug.info(DebugCategory.INJECTED_PROVIDER, "InjectedProvider initialized");
|
|
386
387
|
}
|
|
387
|
-
/**
|
|
388
|
-
* Access to Solana chain operations
|
|
389
|
-
*/
|
|
390
388
|
get solana() {
|
|
391
389
|
if (!this.addressTypes.includes(AddressType4.solana)) {
|
|
392
390
|
throw new Error("Solana not enabled for this provider");
|
|
@@ -485,10 +483,10 @@ var InjectedProvider = class {
|
|
|
485
483
|
this.connected = true;
|
|
486
484
|
const authUserId = await this.getAuthUserId("manual-connect");
|
|
487
485
|
try {
|
|
488
|
-
localStorage.
|
|
489
|
-
debug.log(DebugCategory.INJECTED_PROVIDER, "
|
|
486
|
+
localStorage.setItem(WAS_CONNECTED_KEY, WAS_CONNECTED_VALUE);
|
|
487
|
+
debug.log(DebugCategory.INJECTED_PROVIDER, "Set was-connected flag - auto-reconnect enabled");
|
|
490
488
|
} catch (error) {
|
|
491
|
-
debug.warn(DebugCategory.INJECTED_PROVIDER, "Failed to
|
|
489
|
+
debug.warn(DebugCategory.INJECTED_PROVIDER, "Failed to set was-connected flag", { error });
|
|
492
490
|
}
|
|
493
491
|
const result = {
|
|
494
492
|
addresses: this.addresses,
|
|
@@ -521,18 +519,15 @@ var InjectedProvider = class {
|
|
|
521
519
|
debug.warn(DebugCategory.INJECTED_PROVIDER, "Failed to disconnect Solana", { error: err });
|
|
522
520
|
}
|
|
523
521
|
}
|
|
524
|
-
if (this.addressTypes.includes(AddressType4.ethereum)) {
|
|
525
|
-
debug.log(DebugCategory.INJECTED_PROVIDER, "Ethereum disconnected (no-op)");
|
|
526
|
-
}
|
|
527
522
|
this.browserInjectedCleanupFunctions.forEach((cleanup) => cleanup());
|
|
528
523
|
this.browserInjectedCleanupFunctions = [];
|
|
529
524
|
this.connected = false;
|
|
530
525
|
this.addresses = [];
|
|
531
526
|
try {
|
|
532
|
-
localStorage.
|
|
533
|
-
debug.log(DebugCategory.INJECTED_PROVIDER, "
|
|
527
|
+
localStorage.removeItem(WAS_CONNECTED_KEY);
|
|
528
|
+
debug.log(DebugCategory.INJECTED_PROVIDER, "Cleared was connected flag to prevent auto-reconnect");
|
|
534
529
|
} catch (error) {
|
|
535
|
-
debug.warn(DebugCategory.INJECTED_PROVIDER, "Failed to
|
|
530
|
+
debug.warn(DebugCategory.INJECTED_PROVIDER, "Failed to clear was-connected flag", { error });
|
|
536
531
|
}
|
|
537
532
|
this.emit("disconnect", {
|
|
538
533
|
source: "manual-disconnect"
|
|
@@ -540,20 +535,22 @@ var InjectedProvider = class {
|
|
|
540
535
|
debug.info(DebugCategory.INJECTED_PROVIDER, "Injected provider disconnected successfully");
|
|
541
536
|
}
|
|
542
537
|
/**
|
|
543
|
-
* Attempt auto-connection
|
|
544
|
-
*
|
|
538
|
+
* Attempt auto-connection if user was previously connected
|
|
539
|
+
* Only reconnects if the user connected before and didn't explicitly disconnect
|
|
545
540
|
* Should be called after setting up event listeners
|
|
546
541
|
*/
|
|
547
542
|
async autoConnect() {
|
|
548
|
-
debug.log(DebugCategory.INJECTED_PROVIDER, "Attempting auto-connect
|
|
543
|
+
debug.log(DebugCategory.INJECTED_PROVIDER, "Attempting auto-connect");
|
|
549
544
|
try {
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
552
|
-
debug.log(DebugCategory.INJECTED_PROVIDER, "Skipping auto-connect: user previously
|
|
545
|
+
const wasConnected = localStorage.getItem(WAS_CONNECTED_KEY);
|
|
546
|
+
if (wasConnected !== WAS_CONNECTED_VALUE) {
|
|
547
|
+
debug.log(DebugCategory.INJECTED_PROVIDER, "Skipping auto-connect: user was not previously connected");
|
|
553
548
|
return;
|
|
554
549
|
}
|
|
550
|
+
debug.log(DebugCategory.INJECTED_PROVIDER, "User was previously connected, attempting auto-connect");
|
|
555
551
|
} catch (error) {
|
|
556
|
-
debug.warn(DebugCategory.INJECTED_PROVIDER, "Failed to check
|
|
552
|
+
debug.warn(DebugCategory.INJECTED_PROVIDER, "Failed to check was-connected flag", { error });
|
|
553
|
+
return;
|
|
557
554
|
}
|
|
558
555
|
this.emit("connect_start", {
|
|
559
556
|
source: "auto-connect",
|
|
@@ -581,7 +578,10 @@ var InjectedProvider = class {
|
|
|
581
578
|
debug.info(DebugCategory.INJECTED_PROVIDER, "Solana auto-connected successfully", { address: publicKey });
|
|
582
579
|
}
|
|
583
580
|
} catch (err) {
|
|
584
|
-
debug.log(DebugCategory.INJECTED_PROVIDER, "Solana auto-connect failed (expected if not trusted)", {
|
|
581
|
+
debug.log(DebugCategory.INJECTED_PROVIDER, "Solana auto-connect failed (expected if not trusted)", {
|
|
582
|
+
error: err
|
|
583
|
+
});
|
|
584
|
+
throw err;
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
if (this.addressTypes.includes(AddressType4.ethereum)) {
|
|
@@ -595,10 +595,14 @@ var InjectedProvider = class {
|
|
|
595
595
|
address
|
|
596
596
|
}))
|
|
597
597
|
);
|
|
598
|
-
debug.info(DebugCategory.INJECTED_PROVIDER, "Ethereum auto-connected successfully", {
|
|
598
|
+
debug.info(DebugCategory.INJECTED_PROVIDER, "Ethereum auto-connected successfully", {
|
|
599
|
+
addresses: accounts
|
|
600
|
+
});
|
|
599
601
|
}
|
|
600
602
|
} catch (err) {
|
|
601
|
-
debug.log(DebugCategory.INJECTED_PROVIDER, "Ethereum auto-connect failed (expected if not trusted)", {
|
|
603
|
+
debug.log(DebugCategory.INJECTED_PROVIDER, "Ethereum auto-connect failed (expected if not trusted)", {
|
|
604
|
+
error: err
|
|
605
|
+
});
|
|
602
606
|
}
|
|
603
607
|
}
|
|
604
608
|
if (connectedAddresses.length === 0) {
|
|
@@ -619,7 +623,10 @@ var InjectedProvider = class {
|
|
|
619
623
|
});
|
|
620
624
|
debug.info(DebugCategory.INJECTED_PROVIDER, "Auto-connect successful", {
|
|
621
625
|
addressCount: connectedAddresses.length,
|
|
622
|
-
addresses: connectedAddresses.map((addr) => ({
|
|
626
|
+
addresses: connectedAddresses.map((addr) => ({
|
|
627
|
+
type: addr.addressType,
|
|
628
|
+
address: addr.address.substring(0, 8) + "..."
|
|
629
|
+
})),
|
|
623
630
|
authUserId
|
|
624
631
|
});
|
|
625
632
|
} catch (error) {
|
|
@@ -665,14 +672,22 @@ var InjectedProvider = class {
|
|
|
665
672
|
const userInfo = await window.phantom.app.getUser();
|
|
666
673
|
const authUserId = userInfo?.authUserId;
|
|
667
674
|
if (authUserId) {
|
|
668
|
-
debug.log(
|
|
669
|
-
|
|
670
|
-
|
|
675
|
+
debug.log(
|
|
676
|
+
DebugCategory.INJECTED_PROVIDER,
|
|
677
|
+
`Retrieved authUserId from window.phantom.app.getUser() during ${context}`,
|
|
678
|
+
{
|
|
679
|
+
authUserId
|
|
680
|
+
}
|
|
681
|
+
);
|
|
671
682
|
}
|
|
672
683
|
return authUserId;
|
|
673
684
|
}
|
|
674
685
|
} catch (error) {
|
|
675
|
-
debug.log(
|
|
686
|
+
debug.log(
|
|
687
|
+
DebugCategory.INJECTED_PROVIDER,
|
|
688
|
+
`Failed to get user info during ${context} (method may not be supported)`,
|
|
689
|
+
{ error }
|
|
690
|
+
);
|
|
676
691
|
}
|
|
677
692
|
return void 0;
|
|
678
693
|
}
|
|
@@ -1163,7 +1178,7 @@ var BrowserAuthProvider = class {
|
|
|
1163
1178
|
// OAuth session management - defaults to allow refresh unless explicitly clearing after logout
|
|
1164
1179
|
clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
|
|
1165
1180
|
allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
|
|
1166
|
-
sdk_version: "1.0.0-beta.
|
|
1181
|
+
sdk_version: "1.0.0-beta.22",
|
|
1167
1182
|
sdk_type: "browser",
|
|
1168
1183
|
platform: detectBrowser().name
|
|
1169
1184
|
});
|
|
@@ -1193,7 +1208,7 @@ var BrowserAuthProvider = class {
|
|
|
1193
1208
|
resolve();
|
|
1194
1209
|
});
|
|
1195
1210
|
}
|
|
1196
|
-
resumeAuthFromRedirect() {
|
|
1211
|
+
resumeAuthFromRedirect(provider) {
|
|
1197
1212
|
try {
|
|
1198
1213
|
const walletId = this.urlParamsAccessor.getParam("wallet_id");
|
|
1199
1214
|
const sessionId = this.urlParamsAccessor.getParam("session_id");
|
|
@@ -1260,16 +1275,21 @@ var BrowserAuthProvider = class {
|
|
|
1260
1275
|
throw new Error("Missing organization_id in auth response");
|
|
1261
1276
|
}
|
|
1262
1277
|
if (organizationId.startsWith("temp-")) {
|
|
1263
|
-
debug.warn(
|
|
1264
|
-
|
|
1265
|
-
|
|
1278
|
+
debug.warn(
|
|
1279
|
+
DebugCategory.PHANTOM_CONNECT_AUTH,
|
|
1280
|
+
"Received temporary organization_id, server may not be configured properly",
|
|
1281
|
+
{
|
|
1282
|
+
organizationId
|
|
1283
|
+
}
|
|
1284
|
+
);
|
|
1266
1285
|
}
|
|
1267
1286
|
return {
|
|
1268
1287
|
walletId,
|
|
1269
1288
|
organizationId,
|
|
1270
1289
|
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) : 0,
|
|
1271
1290
|
expiresInMs: expiresInMs ? parseInt(expiresInMs) : 0,
|
|
1272
|
-
authUserId: authUserId || void 0
|
|
1291
|
+
authUserId: authUserId || void 0,
|
|
1292
|
+
provider
|
|
1273
1293
|
};
|
|
1274
1294
|
} catch (error) {
|
|
1275
1295
|
sessionStorage.removeItem("phantom-auth-context");
|
|
@@ -1422,7 +1442,7 @@ var EmbeddedProvider = class extends CoreEmbeddedProvider {
|
|
|
1422
1442
|
// Full user agent for more detailed info
|
|
1423
1443
|
[ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
1424
1444
|
[ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
1425
|
-
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.
|
|
1445
|
+
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.22"
|
|
1426
1446
|
// Replaced at build time
|
|
1427
1447
|
}
|
|
1428
1448
|
};
|
|
@@ -1434,6 +1454,9 @@ var EmbeddedProvider = class extends CoreEmbeddedProvider {
|
|
|
1434
1454
|
};
|
|
1435
1455
|
|
|
1436
1456
|
// src/ProviderManager.ts
|
|
1457
|
+
import {
|
|
1458
|
+
EMBEDDED_PROVIDER_AUTH_TYPES
|
|
1459
|
+
} from "@phantom/embedded-provider-core";
|
|
1437
1460
|
import { DEFAULT_WALLET_API_URL, DEFAULT_EMBEDDED_WALLET_TYPE, DEFAULT_AUTH_URL as DEFAULT_AUTH_URL2 } from "@phantom/constants";
|
|
1438
1461
|
|
|
1439
1462
|
// src/utils/auth-callback.ts
|
|
@@ -1517,6 +1540,12 @@ var ProviderManager = class {
|
|
|
1517
1540
|
embeddedWalletType
|
|
1518
1541
|
};
|
|
1519
1542
|
}
|
|
1543
|
+
/**
|
|
1544
|
+
* Check if a provider is allowed by the config
|
|
1545
|
+
*/
|
|
1546
|
+
isProviderAllowed(provider) {
|
|
1547
|
+
return this.config.providers.includes(provider);
|
|
1548
|
+
}
|
|
1520
1549
|
/**
|
|
1521
1550
|
* Connect using the current provider
|
|
1522
1551
|
* Automatically switches provider based on authOptions.provider
|
|
@@ -1524,13 +1553,18 @@ var ProviderManager = class {
|
|
|
1524
1553
|
async connect(authOptions) {
|
|
1525
1554
|
debug.info(DebugCategory.PROVIDER_MANAGER, "Starting connection", {
|
|
1526
1555
|
currentProviderKey: this.currentProviderKey,
|
|
1527
|
-
authOptions: { provider: authOptions.provider
|
|
1556
|
+
authOptions: { provider: authOptions.provider }
|
|
1528
1557
|
});
|
|
1558
|
+
if (!this.isProviderAllowed(authOptions.provider)) {
|
|
1559
|
+
const error = `Provider "${authOptions.provider}" is not in the allowed providers list: ${JSON.stringify(this.config.providers)}`;
|
|
1560
|
+
debug.error(DebugCategory.PROVIDER_MANAGER, error);
|
|
1561
|
+
throw new Error(error);
|
|
1562
|
+
}
|
|
1529
1563
|
const requestedProvider = authOptions.provider;
|
|
1530
1564
|
let targetProviderType = null;
|
|
1531
1565
|
if (requestedProvider === "injected") {
|
|
1532
1566
|
targetProviderType = "injected";
|
|
1533
|
-
} else if (
|
|
1567
|
+
} else if (EMBEDDED_PROVIDER_AUTH_TYPES.includes(requestedProvider)) {
|
|
1534
1568
|
targetProviderType = "embedded";
|
|
1535
1569
|
}
|
|
1536
1570
|
if (targetProviderType) {
|
|
@@ -1554,16 +1588,14 @@ var ProviderManager = class {
|
|
|
1554
1588
|
}
|
|
1555
1589
|
debug.log(DebugCategory.PROVIDER_MANAGER, "Delegating to provider connect method");
|
|
1556
1590
|
const result = await this.currentProvider.connect(authOptions);
|
|
1557
|
-
const providerInfo = this.getCurrentProviderInfo();
|
|
1558
|
-
result.providerType = providerInfo?.type;
|
|
1559
1591
|
debug.log(DebugCategory.PROVIDER_MANAGER, "Connection successful, saving preferences", {
|
|
1560
1592
|
addressCount: result.addresses?.length || 0,
|
|
1561
|
-
|
|
1593
|
+
provider: authOptions.provider
|
|
1562
1594
|
});
|
|
1563
1595
|
this.saveProviderPreference();
|
|
1564
1596
|
debug.info(DebugCategory.PROVIDER_MANAGER, "Connect completed", {
|
|
1565
1597
|
addresses: result.addresses,
|
|
1566
|
-
|
|
1598
|
+
provider: authOptions.provider
|
|
1567
1599
|
});
|
|
1568
1600
|
return result;
|
|
1569
1601
|
}
|
|
@@ -1592,7 +1624,7 @@ var ProviderManager = class {
|
|
|
1592
1624
|
}
|
|
1593
1625
|
/**
|
|
1594
1626
|
* Attempt auto-connect with fallback strategy
|
|
1595
|
-
* Tries embedded provider first if it exists, then injected provider
|
|
1627
|
+
* Tries embedded provider first if it exists and is allowed, then injected provider if allowed
|
|
1596
1628
|
* Returns true if any provider successfully connected
|
|
1597
1629
|
*/
|
|
1598
1630
|
async autoConnect() {
|
|
@@ -1603,7 +1635,8 @@ var ProviderManager = class {
|
|
|
1603
1635
|
}
|
|
1604
1636
|
const embeddedWalletType = this.config.embeddedWalletType || "user-wallet";
|
|
1605
1637
|
const embeddedKey = this.getProviderKey("embedded", embeddedWalletType);
|
|
1606
|
-
|
|
1638
|
+
const embeddedAllowed = this.config.providers.some((p) => p !== "injected");
|
|
1639
|
+
if (embeddedAllowed && this.providers.has(embeddedKey)) {
|
|
1607
1640
|
debug.log(DebugCategory.PROVIDER_MANAGER, "Trying auto-connect with existing embedded provider");
|
|
1608
1641
|
const embeddedProvider = this.providers.get(embeddedKey);
|
|
1609
1642
|
try {
|
|
@@ -1632,8 +1665,9 @@ var ProviderManager = class {
|
|
|
1632
1665
|
}
|
|
1633
1666
|
}
|
|
1634
1667
|
}
|
|
1668
|
+
const injectedAllowed = this.config.providers.includes("injected");
|
|
1635
1669
|
const injectedKey = this.getProviderKey("injected");
|
|
1636
|
-
if (this.providers.has(injectedKey)) {
|
|
1670
|
+
if (injectedAllowed && this.providers.has(injectedKey)) {
|
|
1637
1671
|
debug.log(DebugCategory.PROVIDER_MANAGER, "Trying auto-connect with existing injected provider");
|
|
1638
1672
|
const injectedProvider = this.providers.get(injectedKey);
|
|
1639
1673
|
try {
|
|
@@ -1652,7 +1686,7 @@ var ProviderManager = class {
|
|
|
1652
1686
|
});
|
|
1653
1687
|
}
|
|
1654
1688
|
}
|
|
1655
|
-
debug.log(DebugCategory.PROVIDER_MANAGER, "Auto-connect failed for all
|
|
1689
|
+
debug.log(DebugCategory.PROVIDER_MANAGER, "Auto-connect failed for all allowed providers");
|
|
1656
1690
|
return false;
|
|
1657
1691
|
}
|
|
1658
1692
|
/**
|
|
@@ -1736,17 +1770,28 @@ var ProviderManager = class {
|
|
|
1736
1770
|
}
|
|
1737
1771
|
/**
|
|
1738
1772
|
* Set default provider based on initial config
|
|
1739
|
-
* Creates
|
|
1773
|
+
* Creates providers based on the allowed providers array
|
|
1740
1774
|
*/
|
|
1741
1775
|
setDefaultProvider() {
|
|
1742
|
-
const defaultType = this.config.providerType || "embedded";
|
|
1743
1776
|
const defaultEmbeddedType = this.config.embeddedWalletType || "user-wallet";
|
|
1744
|
-
|
|
1745
|
-
|
|
1777
|
+
const hasInjected = this.config.providers.includes("injected");
|
|
1778
|
+
const hasEmbedded = this.config.providers.some((p) => p !== "injected");
|
|
1779
|
+
if (hasInjected) {
|
|
1780
|
+
debug.log(DebugCategory.PROVIDER_MANAGER, "Creating injected provider (allowed by providers array)");
|
|
1781
|
+
this.createProvider("injected");
|
|
1782
|
+
}
|
|
1783
|
+
if (hasEmbedded) {
|
|
1784
|
+
debug.log(DebugCategory.PROVIDER_MANAGER, "Creating embedded provider (allowed by providers array)");
|
|
1746
1785
|
this.createProvider("embedded", defaultEmbeddedType);
|
|
1747
1786
|
}
|
|
1748
|
-
|
|
1749
|
-
this.
|
|
1787
|
+
let defaultType;
|
|
1788
|
+
if (hasEmbedded && this.providers.has(`embedded-${defaultEmbeddedType}`)) {
|
|
1789
|
+
defaultType = "embedded";
|
|
1790
|
+
} else if (hasInjected && this.providers.has("injected")) {
|
|
1791
|
+
defaultType = "injected";
|
|
1792
|
+
} else {
|
|
1793
|
+
throw new Error("No valid providers could be created from the providers array");
|
|
1794
|
+
}
|
|
1750
1795
|
const switchOptions = {};
|
|
1751
1796
|
if (defaultType === "embedded") {
|
|
1752
1797
|
switchOptions.embeddedWalletType = defaultEmbeddedType;
|
|
@@ -1839,20 +1884,39 @@ async function waitForPhantomExtension(timeoutMs = 3e3) {
|
|
|
1839
1884
|
}
|
|
1840
1885
|
|
|
1841
1886
|
// src/BrowserSDK.ts
|
|
1887
|
+
import { EMBEDDED_PROVIDER_AUTH_TYPES as EMBEDDED_PROVIDER_AUTH_TYPES2 } from "@phantom/embedded-provider-core";
|
|
1842
1888
|
import { DEFAULT_EMBEDDED_WALLET_TYPE as DEFAULT_EMBEDDED_WALLET_TYPE2 } from "@phantom/constants";
|
|
1889
|
+
var BROWSER_SDK_PROVIDER_TYPES = [...EMBEDDED_PROVIDER_AUTH_TYPES2, "injected"];
|
|
1843
1890
|
var BrowserSDK = class {
|
|
1844
1891
|
constructor(config) {
|
|
1845
1892
|
debug.info(DebugCategory.BROWSER_SDK, "Initializing BrowserSDK", {
|
|
1846
|
-
|
|
1893
|
+
providers: config.providers,
|
|
1847
1894
|
embeddedWalletType: config.embeddedWalletType,
|
|
1848
1895
|
addressTypes: config.addressTypes
|
|
1849
1896
|
});
|
|
1850
|
-
if (!
|
|
1851
|
-
debug.error(DebugCategory.BROWSER_SDK, "Invalid
|
|
1852
|
-
throw new Error(
|
|
1897
|
+
if (!Array.isArray(config.providers) || config.providers.length === 0) {
|
|
1898
|
+
debug.error(DebugCategory.BROWSER_SDK, "Invalid providers array", { providers: config.providers });
|
|
1899
|
+
throw new Error("providers must be a non-empty array of AuthProviderType");
|
|
1900
|
+
}
|
|
1901
|
+
const invalidProviders = config.providers.filter((p) => !BROWSER_SDK_PROVIDER_TYPES.includes(p));
|
|
1902
|
+
if (invalidProviders.length > 0) {
|
|
1903
|
+
debug.error(DebugCategory.BROWSER_SDK, "Invalid provider types", {
|
|
1904
|
+
invalidProviders,
|
|
1905
|
+
validProviders: BROWSER_SDK_PROVIDER_TYPES
|
|
1906
|
+
});
|
|
1907
|
+
throw new Error(
|
|
1908
|
+
`Invalid provider type(s): ${invalidProviders.join(", ")}. Valid providers are: ${BROWSER_SDK_PROVIDER_TYPES.join(", ")}`
|
|
1909
|
+
);
|
|
1910
|
+
}
|
|
1911
|
+
const hasEmbeddedProviders = config.providers.some((p) => p !== "injected");
|
|
1912
|
+
if (hasEmbeddedProviders && !config.appId) {
|
|
1913
|
+
debug.error(DebugCategory.BROWSER_SDK, "appId required for embedded providers", {
|
|
1914
|
+
providers: config.providers
|
|
1915
|
+
});
|
|
1916
|
+
throw new Error("appId is required when using embedded providers (google, apple, phantom, etc.)");
|
|
1853
1917
|
}
|
|
1854
1918
|
const embeddedWalletType = config.embeddedWalletType || DEFAULT_EMBEDDED_WALLET_TYPE2;
|
|
1855
|
-
if (
|
|
1919
|
+
if (!["app-wallet", "user-wallet"].includes(embeddedWalletType)) {
|
|
1856
1920
|
debug.error(DebugCategory.BROWSER_SDK, "Invalid embeddedWalletType", {
|
|
1857
1921
|
embeddedWalletType: config.embeddedWalletType
|
|
1858
1922
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/browser-sdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.22",
|
|
4
4
|
"description": "Browser SDK for Phantom Wallet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\""
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@phantom/base64url": "^1.0.0-beta.
|
|
32
|
-
"@phantom/browser-injected-sdk": "^1.0.0-beta.
|
|
33
|
-
"@phantom/chain-interfaces": "^1.0.0-beta.
|
|
34
|
-
"@phantom/client": "^1.0.0-beta.
|
|
35
|
-
"@phantom/constants": "^1.0.0-beta.
|
|
36
|
-
"@phantom/embedded-provider-core": "^1.0.0-beta.
|
|
37
|
-
"@phantom/indexed-db-stamper": "^1.0.0-beta.
|
|
38
|
-
"@phantom/parsers": "^1.0.0-beta.
|
|
39
|
-
"@phantom/sdk-types": "^1.0.0-beta.
|
|
31
|
+
"@phantom/base64url": "^1.0.0-beta.10",
|
|
32
|
+
"@phantom/browser-injected-sdk": "^1.0.0-beta.7",
|
|
33
|
+
"@phantom/chain-interfaces": "^1.0.0-beta.10",
|
|
34
|
+
"@phantom/client": "^1.0.0-beta.22",
|
|
35
|
+
"@phantom/constants": "^1.0.0-beta.10",
|
|
36
|
+
"@phantom/embedded-provider-core": "^1.0.0-beta.22",
|
|
37
|
+
"@phantom/indexed-db-stamper": "^1.0.0-beta.3",
|
|
38
|
+
"@phantom/parsers": "^1.0.0-beta.10",
|
|
39
|
+
"@phantom/sdk-types": "^1.0.0-beta.10",
|
|
40
40
|
"axios": "^1.10.0",
|
|
41
41
|
"bs58": "^6.0.0",
|
|
42
42
|
"buffer": "^6.0.3",
|