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

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
@@ -65,10 +65,13 @@ interface PhantomAppLoginResult {
65
65
  organizationId: string;
66
66
  accountDerivationIndex?: number;
67
67
  expiresInMs?: number;
68
+ authUserId?: string;
68
69
  }
69
70
  interface PhantomApp {
70
71
  login(options: PhantomAppLoginOptions): Promise<PhantomAppLoginResult>;
71
- features(): Promise<string[]>;
72
+ features(): Promise<{
73
+ features: string[];
74
+ }>;
72
75
  }
73
76
  declare global {
74
77
  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.18",
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,
@@ -1312,7 +1342,8 @@ var BrowserPhantomAppProvider = class {
1312
1342
  organizationId: result.organizationId,
1313
1343
  provider: "phantom",
1314
1344
  accountDerivationIndex: result.accountDerivationIndex ?? 0,
1315
- expiresInMs: result.expiresInMs ?? 0
1345
+ expiresInMs: result.expiresInMs ?? 0,
1346
+ authUserId: result.authUserId
1316
1347
  };
1317
1348
  } catch (error) {
1318
1349
  if (error instanceof Error) {
@@ -1368,7 +1399,7 @@ var EmbeddedProvider = class extends import_embedded_provider_core.EmbeddedProvi
1368
1399
  // Full user agent for more detailed info
1369
1400
  [import_constants2.ANALYTICS_HEADERS.APP_ID]: config.appId,
1370
1401
  [import_constants2.ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
1371
- [import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.16"
1402
+ [import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.18"
1372
1403
  // Replaced at build time
1373
1404
  }
1374
1405
  };
@@ -1762,14 +1793,14 @@ var ProviderManager = class {
1762
1793
  };
1763
1794
 
1764
1795
  // src/waitForPhantomExtension.ts
1765
- var import_browser_injected_sdk3 = require("@phantom/browser-injected-sdk");
1796
+ var import_browser_injected_sdk4 = require("@phantom/browser-injected-sdk");
1766
1797
  async function waitForPhantomExtension(timeoutMs = 3e3) {
1767
1798
  return new Promise((resolve) => {
1768
1799
  const startTime = Date.now();
1769
1800
  const checkInterval = 100;
1770
1801
  const checkForExtension = () => {
1771
1802
  try {
1772
- if ((0, import_browser_injected_sdk3.isPhantomExtensionInstalled)()) {
1803
+ if ((0, import_browser_injected_sdk4.isPhantomExtensionInstalled)()) {
1773
1804
  resolve(true);
1774
1805
  return;
1775
1806
  }
@@ -2071,49 +2102,6 @@ function getDeeplinkToPhantom(ref) {
2071
2102
  return `https://phantom.app/ul/browse/${currentUrl}${refParam}`;
2072
2103
  }
2073
2104
 
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
2105
  // src/index.ts
2118
2106
  var import_constants5 = require("@phantom/constants");
2119
2107
  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.18",
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,
@@ -1275,7 +1305,8 @@ var BrowserPhantomAppProvider = class {
1275
1305
  organizationId: result.organizationId,
1276
1306
  provider: "phantom",
1277
1307
  accountDerivationIndex: result.accountDerivationIndex ?? 0,
1278
- expiresInMs: result.expiresInMs ?? 0
1308
+ expiresInMs: result.expiresInMs ?? 0,
1309
+ authUserId: result.authUserId
1279
1310
  };
1280
1311
  } catch (error) {
1281
1312
  if (error instanceof Error) {
@@ -1331,7 +1362,7 @@ var EmbeddedProvider = class extends CoreEmbeddedProvider {
1331
1362
  // Full user agent for more detailed info
1332
1363
  [ANALYTICS_HEADERS.APP_ID]: config.appId,
1333
1364
  [ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
1334
- [ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.16"
1365
+ [ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.18"
1335
1366
  // Replaced at build time
1336
1367
  }
1337
1368
  };
@@ -1725,14 +1756,14 @@ var ProviderManager = class {
1725
1756
  };
1726
1757
 
1727
1758
  // src/waitForPhantomExtension.ts
1728
- import { isPhantomExtensionInstalled as isPhantomExtensionInstalled2 } from "@phantom/browser-injected-sdk";
1759
+ import { isPhantomExtensionInstalled as isPhantomExtensionInstalled3 } from "@phantom/browser-injected-sdk";
1729
1760
  async function waitForPhantomExtension(timeoutMs = 3e3) {
1730
1761
  return new Promise((resolve) => {
1731
1762
  const startTime = Date.now();
1732
1763
  const checkInterval = 100;
1733
1764
  const checkForExtension = () => {
1734
1765
  try {
1735
- if (isPhantomExtensionInstalled2()) {
1766
+ if (isPhantomExtensionInstalled3()) {
1736
1767
  resolve(true);
1737
1768
  return;
1738
1769
  }
@@ -2034,49 +2065,6 @@ function getDeeplinkToPhantom(ref) {
2034
2065
  return `https://phantom.app/ul/browse/${currentUrl}${refParam}`;
2035
2066
  }
2036
2067
 
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
2068
  // src/index.ts
2081
2069
  import { NetworkId } from "@phantom/constants";
2082
2070
  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.18",
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.18",
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.18",
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",