@phantom/browser-sdk 1.0.0-beta.16 → 1.0.0-beta.17

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.d.ts CHANGED
@@ -68,7 +68,9 @@ interface PhantomAppLoginResult {
68
68
  }
69
69
  interface PhantomApp {
70
70
  login(options: PhantomAppLoginOptions): Promise<PhantomAppLoginResult>;
71
- features(): Promise<string[]>;
71
+ features(): Promise<{
72
+ features: string[];
73
+ }>;
72
74
  }
73
75
  declare global {
74
76
  interface Window {
package/dist/index.js CHANGED
@@ -1140,7 +1140,7 @@ var BrowserAuthProvider = class {
1140
1140
  // OAuth session management - defaults to allow refresh unless explicitly clearing after logout
1141
1141
  clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
1142
1142
  allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
1143
- sdk_version: "1.0.0-beta.16",
1143
+ sdk_version: "1.0.0-beta.17",
1144
1144
  sdk_type: "browser",
1145
1145
  platform: detectBrowser().name
1146
1146
  });
@@ -1256,13 +1256,59 @@ var BrowserAuthProvider = class {
1256
1256
  };
1257
1257
 
1258
1258
  // src/providers/embedded/adapters/phantom-app.ts
1259
+ var import_browser_injected_sdk3 = require("@phantom/browser-injected-sdk");
1260
+
1261
+ // src/isPhantomLoginAvailable.ts
1259
1262
  var import_browser_injected_sdk2 = require("@phantom/browser-injected-sdk");
1263
+ async function isPhantomLoginAvailable(timeoutMs = 3e3) {
1264
+ const extensionInstalled = await waitForExtension(timeoutMs);
1265
+ if (!extensionInstalled) {
1266
+ return false;
1267
+ }
1268
+ try {
1269
+ if (!window.phantom?.app?.features || typeof window.phantom.app.features !== "function") {
1270
+ return false;
1271
+ }
1272
+ const response = await window.phantom.app.features();
1273
+ if (!Array.isArray(response.features)) {
1274
+ return false;
1275
+ }
1276
+ return response.features.includes("phantom_login");
1277
+ } catch (error) {
1278
+ console.error("Error checking Phantom extension features", error);
1279
+ return false;
1280
+ }
1281
+ }
1282
+ async function waitForExtension(timeoutMs) {
1283
+ return new Promise((resolve) => {
1284
+ const startTime = Date.now();
1285
+ const checkInterval = 100;
1286
+ const checkForExtension = () => {
1287
+ try {
1288
+ if ((0, import_browser_injected_sdk2.isPhantomExtensionInstalled)()) {
1289
+ resolve(true);
1290
+ return;
1291
+ }
1292
+ } catch (error) {
1293
+ }
1294
+ const elapsed = Date.now() - startTime;
1295
+ if (elapsed >= timeoutMs) {
1296
+ resolve(false);
1297
+ return;
1298
+ }
1299
+ setTimeout(checkForExtension, checkInterval);
1300
+ };
1301
+ checkForExtension();
1302
+ });
1303
+ }
1304
+
1305
+ // src/providers/embedded/adapters/phantom-app.ts
1260
1306
  var BrowserPhantomAppProvider = class {
1261
1307
  /**
1262
1308
  * Check if the Phantom extension is installed in the browser
1263
1309
  */
1264
1310
  isAvailable() {
1265
- return (0, import_browser_injected_sdk2.isPhantomExtensionInstalled)();
1311
+ return (0, import_browser_injected_sdk3.isPhantomExtensionInstalled)();
1266
1312
  }
1267
1313
  /**
1268
1314
  * Authenticate using the Phantom browser extension
@@ -1273,32 +1319,16 @@ var BrowserPhantomAppProvider = class {
1273
1319
  "Phantom extension is not installed. Please install the Phantom browser extension to use this authentication method."
1274
1320
  );
1275
1321
  }
1276
- if (!window.phantom?.app?.login || typeof window.phantom.app.login !== "function") {
1322
+ const loginAvailable = await isPhantomLoginAvailable();
1323
+ if (!loginAvailable) {
1277
1324
  throw new Error(
1278
- "Phantom extension authentication is not yet implemented. The extension needs to expose an app.login API (window.phantom.app.login)."
1325
+ "Phantom Login is not available. Please update your Phantom extension to use this authentication method."
1279
1326
  );
1280
1327
  }
1281
1328
  try {
1282
- if (!window.phantom?.app?.features || typeof window.phantom.app.features !== "function") {
1283
- throw new Error(
1284
- "Phantom Login is not available. The extension does not support the features API."
1285
- );
1286
- }
1287
- const features = await window.phantom.app.features();
1288
- if (!Array.isArray(features) || !features.includes("phantom_login")) {
1289
- throw new Error(
1290
- "Phantom Login is not available. Please update your Phantom extension to use this authentication method."
1291
- );
1292
- }
1293
- } catch (error) {
1294
- if (error instanceof Error) {
1295
- throw error;
1329
+ if (!window.phantom?.app?.login) {
1330
+ throw new Error("Phantom extension login method not found");
1296
1331
  }
1297
- throw new Error(
1298
- "Failed to check Phantom Login availability. Please ensure you have the latest version of the Phantom extension."
1299
- );
1300
- }
1301
- try {
1302
1332
  const result = await window.phantom.app.login({
1303
1333
  publicKey: options.publicKey,
1304
1334
  appId: options.appId,
@@ -1368,7 +1398,7 @@ var EmbeddedProvider = class extends import_embedded_provider_core.EmbeddedProvi
1368
1398
  // Full user agent for more detailed info
1369
1399
  [import_constants2.ANALYTICS_HEADERS.APP_ID]: config.appId,
1370
1400
  [import_constants2.ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
1371
- [import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.16"
1401
+ [import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.17"
1372
1402
  // Replaced at build time
1373
1403
  }
1374
1404
  };
@@ -1762,14 +1792,14 @@ var ProviderManager = class {
1762
1792
  };
1763
1793
 
1764
1794
  // src/waitForPhantomExtension.ts
1765
- var import_browser_injected_sdk3 = require("@phantom/browser-injected-sdk");
1795
+ var import_browser_injected_sdk4 = require("@phantom/browser-injected-sdk");
1766
1796
  async function waitForPhantomExtension(timeoutMs = 3e3) {
1767
1797
  return new Promise((resolve) => {
1768
1798
  const startTime = Date.now();
1769
1799
  const checkInterval = 100;
1770
1800
  const checkForExtension = () => {
1771
1801
  try {
1772
- if ((0, import_browser_injected_sdk3.isPhantomExtensionInstalled)()) {
1802
+ if ((0, import_browser_injected_sdk4.isPhantomExtensionInstalled)()) {
1773
1803
  resolve(true);
1774
1804
  return;
1775
1805
  }
@@ -2071,49 +2101,6 @@ function getDeeplinkToPhantom(ref) {
2071
2101
  return `https://phantom.app/ul/browse/${currentUrl}${refParam}`;
2072
2102
  }
2073
2103
 
2074
- // src/isPhantomLoginAvailable.ts
2075
- var import_browser_injected_sdk4 = require("@phantom/browser-injected-sdk");
2076
- async function isPhantomLoginAvailable(timeoutMs = 3e3) {
2077
- const extensionInstalled = await waitForExtension(timeoutMs);
2078
- if (!extensionInstalled) {
2079
- return false;
2080
- }
2081
- try {
2082
- if (!window.phantom?.app?.features || typeof window.phantom.app.features !== "function") {
2083
- return false;
2084
- }
2085
- const features = await window.phantom.app.features();
2086
- if (!Array.isArray(features)) {
2087
- return false;
2088
- }
2089
- return features.includes("phantom_login");
2090
- } catch (error) {
2091
- return false;
2092
- }
2093
- }
2094
- async function waitForExtension(timeoutMs) {
2095
- return new Promise((resolve) => {
2096
- const startTime = Date.now();
2097
- const checkInterval = 100;
2098
- const checkForExtension = () => {
2099
- try {
2100
- if ((0, import_browser_injected_sdk4.isPhantomExtensionInstalled)()) {
2101
- resolve(true);
2102
- return;
2103
- }
2104
- } catch (error) {
2105
- }
2106
- const elapsed = Date.now() - startTime;
2107
- if (elapsed >= timeoutMs) {
2108
- resolve(false);
2109
- return;
2110
- }
2111
- setTimeout(checkForExtension, checkInterval);
2112
- };
2113
- checkForExtension();
2114
- });
2115
- }
2116
-
2117
2104
  // src/index.ts
2118
2105
  var import_constants5 = require("@phantom/constants");
2119
2106
  var import_client5 = require("@phantom/client");
package/dist/index.mjs CHANGED
@@ -1103,7 +1103,7 @@ var BrowserAuthProvider = class {
1103
1103
  // OAuth session management - defaults to allow refresh unless explicitly clearing after logout
1104
1104
  clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
1105
1105
  allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
1106
- sdk_version: "1.0.0-beta.16",
1106
+ sdk_version: "1.0.0-beta.17",
1107
1107
  sdk_type: "browser",
1108
1108
  platform: detectBrowser().name
1109
1109
  });
@@ -1219,13 +1219,59 @@ var BrowserAuthProvider = class {
1219
1219
  };
1220
1220
 
1221
1221
  // src/providers/embedded/adapters/phantom-app.ts
1222
+ import { isPhantomExtensionInstalled as isPhantomExtensionInstalled2 } from "@phantom/browser-injected-sdk";
1223
+
1224
+ // src/isPhantomLoginAvailable.ts
1222
1225
  import { isPhantomExtensionInstalled } from "@phantom/browser-injected-sdk";
1226
+ async function isPhantomLoginAvailable(timeoutMs = 3e3) {
1227
+ const extensionInstalled = await waitForExtension(timeoutMs);
1228
+ if (!extensionInstalled) {
1229
+ return false;
1230
+ }
1231
+ try {
1232
+ if (!window.phantom?.app?.features || typeof window.phantom.app.features !== "function") {
1233
+ return false;
1234
+ }
1235
+ const response = await window.phantom.app.features();
1236
+ if (!Array.isArray(response.features)) {
1237
+ return false;
1238
+ }
1239
+ return response.features.includes("phantom_login");
1240
+ } catch (error) {
1241
+ console.error("Error checking Phantom extension features", error);
1242
+ return false;
1243
+ }
1244
+ }
1245
+ async function waitForExtension(timeoutMs) {
1246
+ return new Promise((resolve) => {
1247
+ const startTime = Date.now();
1248
+ const checkInterval = 100;
1249
+ const checkForExtension = () => {
1250
+ try {
1251
+ if (isPhantomExtensionInstalled()) {
1252
+ resolve(true);
1253
+ return;
1254
+ }
1255
+ } catch (error) {
1256
+ }
1257
+ const elapsed = Date.now() - startTime;
1258
+ if (elapsed >= timeoutMs) {
1259
+ resolve(false);
1260
+ return;
1261
+ }
1262
+ setTimeout(checkForExtension, checkInterval);
1263
+ };
1264
+ checkForExtension();
1265
+ });
1266
+ }
1267
+
1268
+ // src/providers/embedded/adapters/phantom-app.ts
1223
1269
  var BrowserPhantomAppProvider = class {
1224
1270
  /**
1225
1271
  * Check if the Phantom extension is installed in the browser
1226
1272
  */
1227
1273
  isAvailable() {
1228
- return isPhantomExtensionInstalled();
1274
+ return isPhantomExtensionInstalled2();
1229
1275
  }
1230
1276
  /**
1231
1277
  * Authenticate using the Phantom browser extension
@@ -1236,32 +1282,16 @@ var BrowserPhantomAppProvider = class {
1236
1282
  "Phantom extension is not installed. Please install the Phantom browser extension to use this authentication method."
1237
1283
  );
1238
1284
  }
1239
- if (!window.phantom?.app?.login || typeof window.phantom.app.login !== "function") {
1285
+ const loginAvailable = await isPhantomLoginAvailable();
1286
+ if (!loginAvailable) {
1240
1287
  throw new Error(
1241
- "Phantom extension authentication is not yet implemented. The extension needs to expose an app.login API (window.phantom.app.login)."
1288
+ "Phantom Login is not available. Please update your Phantom extension to use this authentication method."
1242
1289
  );
1243
1290
  }
1244
1291
  try {
1245
- if (!window.phantom?.app?.features || typeof window.phantom.app.features !== "function") {
1246
- throw new Error(
1247
- "Phantom Login is not available. The extension does not support the features API."
1248
- );
1249
- }
1250
- const features = await window.phantom.app.features();
1251
- if (!Array.isArray(features) || !features.includes("phantom_login")) {
1252
- throw new Error(
1253
- "Phantom Login is not available. Please update your Phantom extension to use this authentication method."
1254
- );
1255
- }
1256
- } catch (error) {
1257
- if (error instanceof Error) {
1258
- throw error;
1292
+ if (!window.phantom?.app?.login) {
1293
+ throw new Error("Phantom extension login method not found");
1259
1294
  }
1260
- throw new Error(
1261
- "Failed to check Phantom Login availability. Please ensure you have the latest version of the Phantom extension."
1262
- );
1263
- }
1264
- try {
1265
1295
  const result = await window.phantom.app.login({
1266
1296
  publicKey: options.publicKey,
1267
1297
  appId: options.appId,
@@ -1331,7 +1361,7 @@ var EmbeddedProvider = class extends CoreEmbeddedProvider {
1331
1361
  // Full user agent for more detailed info
1332
1362
  [ANALYTICS_HEADERS.APP_ID]: config.appId,
1333
1363
  [ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
1334
- [ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.16"
1364
+ [ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.17"
1335
1365
  // Replaced at build time
1336
1366
  }
1337
1367
  };
@@ -1725,14 +1755,14 @@ var ProviderManager = class {
1725
1755
  };
1726
1756
 
1727
1757
  // src/waitForPhantomExtension.ts
1728
- import { isPhantomExtensionInstalled as isPhantomExtensionInstalled2 } from "@phantom/browser-injected-sdk";
1758
+ import { isPhantomExtensionInstalled as isPhantomExtensionInstalled3 } from "@phantom/browser-injected-sdk";
1729
1759
  async function waitForPhantomExtension(timeoutMs = 3e3) {
1730
1760
  return new Promise((resolve) => {
1731
1761
  const startTime = Date.now();
1732
1762
  const checkInterval = 100;
1733
1763
  const checkForExtension = () => {
1734
1764
  try {
1735
- if (isPhantomExtensionInstalled2()) {
1765
+ if (isPhantomExtensionInstalled3()) {
1736
1766
  resolve(true);
1737
1767
  return;
1738
1768
  }
@@ -2034,49 +2064,6 @@ function getDeeplinkToPhantom(ref) {
2034
2064
  return `https://phantom.app/ul/browse/${currentUrl}${refParam}`;
2035
2065
  }
2036
2066
 
2037
- // src/isPhantomLoginAvailable.ts
2038
- import { isPhantomExtensionInstalled as isPhantomExtensionInstalled3 } from "@phantom/browser-injected-sdk";
2039
- async function isPhantomLoginAvailable(timeoutMs = 3e3) {
2040
- const extensionInstalled = await waitForExtension(timeoutMs);
2041
- if (!extensionInstalled) {
2042
- return false;
2043
- }
2044
- try {
2045
- if (!window.phantom?.app?.features || typeof window.phantom.app.features !== "function") {
2046
- return false;
2047
- }
2048
- const features = await window.phantom.app.features();
2049
- if (!Array.isArray(features)) {
2050
- return false;
2051
- }
2052
- return features.includes("phantom_login");
2053
- } catch (error) {
2054
- return false;
2055
- }
2056
- }
2057
- async function waitForExtension(timeoutMs) {
2058
- return new Promise((resolve) => {
2059
- const startTime = Date.now();
2060
- const checkInterval = 100;
2061
- const checkForExtension = () => {
2062
- try {
2063
- if (isPhantomExtensionInstalled3()) {
2064
- resolve(true);
2065
- return;
2066
- }
2067
- } catch (error) {
2068
- }
2069
- const elapsed = Date.now() - startTime;
2070
- if (elapsed >= timeoutMs) {
2071
- resolve(false);
2072
- return;
2073
- }
2074
- setTimeout(checkForExtension, checkInterval);
2075
- };
2076
- checkForExtension();
2077
- });
2078
- }
2079
-
2080
2067
  // src/index.ts
2081
2068
  import { NetworkId } from "@phantom/constants";
2082
2069
  import { AddressType as AddressType5 } from "@phantom/client";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantom/browser-sdk",
3
- "version": "1.0.0-beta.16",
3
+ "version": "1.0.0-beta.17",
4
4
  "description": "Browser SDK for Phantom Wallet",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,9 +31,9 @@
31
31
  "@phantom/base64url": "^1.0.0-beta.7",
32
32
  "@phantom/browser-injected-sdk": "^1.0.0-beta.5",
33
33
  "@phantom/chain-interfaces": "^1.0.0-beta.7",
34
- "@phantom/client": "^1.0.0-beta.16",
34
+ "@phantom/client": "^1.0.0-beta.17",
35
35
  "@phantom/constants": "^1.0.0-beta.7",
36
- "@phantom/embedded-provider-core": "^1.0.0-beta.16",
36
+ "@phantom/embedded-provider-core": "^1.0.0-beta.17",
37
37
  "@phantom/indexed-db-stamper": "^1.0.0-beta.1",
38
38
  "@phantom/parsers": "^1.0.0-beta.7",
39
39
  "@phantom/sdk-types": "^1.0.0-beta.7",