@phantom/browser-sdk 1.0.0-beta.10 → 1.0.0-beta.12
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 +27 -7
- package/dist/index.mjs +27 -7
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -933,7 +933,7 @@ var BrowserAuthProvider = class {
|
|
|
933
933
|
}
|
|
934
934
|
const phantomOptions = options;
|
|
935
935
|
debug.info(DebugCategory.PHANTOM_CONNECT_AUTH, "Starting Phantom Connect authentication", {
|
|
936
|
-
|
|
936
|
+
publicKey: phantomOptions.publicKey,
|
|
937
937
|
appId: phantomOptions.appId,
|
|
938
938
|
provider: phantomOptions.provider,
|
|
939
939
|
authUrl: phantomOptions.authUrl,
|
|
@@ -942,12 +942,12 @@ var BrowserAuthProvider = class {
|
|
|
942
942
|
const baseUrl = phantomOptions.authUrl || import_constants.DEFAULT_AUTH_URL;
|
|
943
943
|
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Using auth URL", { baseUrl });
|
|
944
944
|
const params = new URLSearchParams({
|
|
945
|
-
|
|
945
|
+
public_key: phantomOptions.publicKey,
|
|
946
946
|
app_id: phantomOptions.appId,
|
|
947
947
|
redirect_uri: phantomOptions.redirectUrl || (typeof window !== "undefined" ? this.getValidatedCurrentUrl() : ""),
|
|
948
948
|
session_id: phantomOptions.sessionId,
|
|
949
949
|
clear_previous_session: true.toString(),
|
|
950
|
-
sdk_version: "1.0.0-beta.
|
|
950
|
+
sdk_version: "1.0.0-beta.12"
|
|
951
951
|
});
|
|
952
952
|
if (phantomOptions.provider) {
|
|
953
953
|
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Provider specified, will skip selection", {
|
|
@@ -963,7 +963,7 @@ var BrowserAuthProvider = class {
|
|
|
963
963
|
params.append("authData", JSON.stringify(phantomOptions.customAuthData));
|
|
964
964
|
}
|
|
965
965
|
const authContext = {
|
|
966
|
-
|
|
966
|
+
publicKey: phantomOptions.publicKey,
|
|
967
967
|
appId: phantomOptions.appId,
|
|
968
968
|
provider: phantomOptions.provider,
|
|
969
969
|
sessionId: phantomOptions.sessionId
|
|
@@ -972,7 +972,7 @@ var BrowserAuthProvider = class {
|
|
|
972
972
|
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Stored auth context in session storage", { authContext });
|
|
973
973
|
const authUrl = `${baseUrl}?${params.toString()}`;
|
|
974
974
|
debug.info(DebugCategory.PHANTOM_CONNECT_AUTH, "Redirecting to Phantom Connect", { authUrl });
|
|
975
|
-
if (!authUrl.startsWith("https:")) {
|
|
975
|
+
if (!authUrl.startsWith("https:") && !authUrl.startsWith("http://localhost")) {
|
|
976
976
|
throw new Error("Invalid auth URL - only HTTPS URLs are allowed for authentication");
|
|
977
977
|
}
|
|
978
978
|
window.location.href = authUrl;
|
|
@@ -1030,10 +1030,30 @@ var BrowserAuthProvider = class {
|
|
|
1030
1030
|
sessionId,
|
|
1031
1031
|
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) : void 0
|
|
1032
1032
|
});
|
|
1033
|
+
const organizationId = this.urlParamsAccessor.getParam("organization_id");
|
|
1034
|
+
const expiresInMs = this.urlParamsAccessor.getParam("expires_in_ms");
|
|
1035
|
+
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Auth redirect parameters", {
|
|
1036
|
+
walletId,
|
|
1037
|
+
organizationId,
|
|
1038
|
+
sessionId,
|
|
1039
|
+
accountDerivationIndex,
|
|
1040
|
+
expiresInMs
|
|
1041
|
+
});
|
|
1042
|
+
if (!organizationId) {
|
|
1043
|
+
debug.error(DebugCategory.PHANTOM_CONNECT_AUTH, "Missing organization_id in auth response");
|
|
1044
|
+
throw new Error("Missing organization_id in auth response");
|
|
1045
|
+
}
|
|
1046
|
+
if (organizationId.startsWith("temp-")) {
|
|
1047
|
+
debug.warn(DebugCategory.PHANTOM_CONNECT_AUTH, "Received temporary organization_id, server may not be configured properly", {
|
|
1048
|
+
organizationId
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1033
1051
|
return {
|
|
1034
1052
|
walletId,
|
|
1053
|
+
organizationId,
|
|
1035
1054
|
userInfo: context,
|
|
1036
|
-
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) :
|
|
1055
|
+
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) : 0,
|
|
1056
|
+
expiresInMs: expiresInMs ? parseInt(expiresInMs) : 0
|
|
1037
1057
|
};
|
|
1038
1058
|
} catch (error) {
|
|
1039
1059
|
sessionStorage.removeItem("phantom-auth-context");
|
|
@@ -1225,7 +1245,7 @@ var EmbeddedProvider = class extends import_embedded_provider_core.EmbeddedProvi
|
|
|
1225
1245
|
// Full user agent for more detailed info
|
|
1226
1246
|
[import_constants2.ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
1227
1247
|
[import_constants2.ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
1228
|
-
[import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.
|
|
1248
|
+
[import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.12"
|
|
1229
1249
|
// Replaced at build time
|
|
1230
1250
|
}
|
|
1231
1251
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -897,7 +897,7 @@ var BrowserAuthProvider = class {
|
|
|
897
897
|
}
|
|
898
898
|
const phantomOptions = options;
|
|
899
899
|
debug.info(DebugCategory.PHANTOM_CONNECT_AUTH, "Starting Phantom Connect authentication", {
|
|
900
|
-
|
|
900
|
+
publicKey: phantomOptions.publicKey,
|
|
901
901
|
appId: phantomOptions.appId,
|
|
902
902
|
provider: phantomOptions.provider,
|
|
903
903
|
authUrl: phantomOptions.authUrl,
|
|
@@ -906,12 +906,12 @@ var BrowserAuthProvider = class {
|
|
|
906
906
|
const baseUrl = phantomOptions.authUrl || DEFAULT_AUTH_URL;
|
|
907
907
|
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Using auth URL", { baseUrl });
|
|
908
908
|
const params = new URLSearchParams({
|
|
909
|
-
|
|
909
|
+
public_key: phantomOptions.publicKey,
|
|
910
910
|
app_id: phantomOptions.appId,
|
|
911
911
|
redirect_uri: phantomOptions.redirectUrl || (typeof window !== "undefined" ? this.getValidatedCurrentUrl() : ""),
|
|
912
912
|
session_id: phantomOptions.sessionId,
|
|
913
913
|
clear_previous_session: true.toString(),
|
|
914
|
-
sdk_version: "1.0.0-beta.
|
|
914
|
+
sdk_version: "1.0.0-beta.12"
|
|
915
915
|
});
|
|
916
916
|
if (phantomOptions.provider) {
|
|
917
917
|
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Provider specified, will skip selection", {
|
|
@@ -927,7 +927,7 @@ var BrowserAuthProvider = class {
|
|
|
927
927
|
params.append("authData", JSON.stringify(phantomOptions.customAuthData));
|
|
928
928
|
}
|
|
929
929
|
const authContext = {
|
|
930
|
-
|
|
930
|
+
publicKey: phantomOptions.publicKey,
|
|
931
931
|
appId: phantomOptions.appId,
|
|
932
932
|
provider: phantomOptions.provider,
|
|
933
933
|
sessionId: phantomOptions.sessionId
|
|
@@ -936,7 +936,7 @@ var BrowserAuthProvider = class {
|
|
|
936
936
|
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Stored auth context in session storage", { authContext });
|
|
937
937
|
const authUrl = `${baseUrl}?${params.toString()}`;
|
|
938
938
|
debug.info(DebugCategory.PHANTOM_CONNECT_AUTH, "Redirecting to Phantom Connect", { authUrl });
|
|
939
|
-
if (!authUrl.startsWith("https:")) {
|
|
939
|
+
if (!authUrl.startsWith("https:") && !authUrl.startsWith("http://localhost")) {
|
|
940
940
|
throw new Error("Invalid auth URL - only HTTPS URLs are allowed for authentication");
|
|
941
941
|
}
|
|
942
942
|
window.location.href = authUrl;
|
|
@@ -994,10 +994,30 @@ var BrowserAuthProvider = class {
|
|
|
994
994
|
sessionId,
|
|
995
995
|
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) : void 0
|
|
996
996
|
});
|
|
997
|
+
const organizationId = this.urlParamsAccessor.getParam("organization_id");
|
|
998
|
+
const expiresInMs = this.urlParamsAccessor.getParam("expires_in_ms");
|
|
999
|
+
debug.log(DebugCategory.PHANTOM_CONNECT_AUTH, "Auth redirect parameters", {
|
|
1000
|
+
walletId,
|
|
1001
|
+
organizationId,
|
|
1002
|
+
sessionId,
|
|
1003
|
+
accountDerivationIndex,
|
|
1004
|
+
expiresInMs
|
|
1005
|
+
});
|
|
1006
|
+
if (!organizationId) {
|
|
1007
|
+
debug.error(DebugCategory.PHANTOM_CONNECT_AUTH, "Missing organization_id in auth response");
|
|
1008
|
+
throw new Error("Missing organization_id in auth response");
|
|
1009
|
+
}
|
|
1010
|
+
if (organizationId.startsWith("temp-")) {
|
|
1011
|
+
debug.warn(DebugCategory.PHANTOM_CONNECT_AUTH, "Received temporary organization_id, server may not be configured properly", {
|
|
1012
|
+
organizationId
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
997
1015
|
return {
|
|
998
1016
|
walletId,
|
|
1017
|
+
organizationId,
|
|
999
1018
|
userInfo: context,
|
|
1000
|
-
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) :
|
|
1019
|
+
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) : 0,
|
|
1020
|
+
expiresInMs: expiresInMs ? parseInt(expiresInMs) : 0
|
|
1001
1021
|
};
|
|
1002
1022
|
} catch (error) {
|
|
1003
1023
|
sessionStorage.removeItem("phantom-auth-context");
|
|
@@ -1189,7 +1209,7 @@ var EmbeddedProvider = class extends CoreEmbeddedProvider {
|
|
|
1189
1209
|
// Full user agent for more detailed info
|
|
1190
1210
|
[ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
1191
1211
|
[ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
1192
|
-
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.
|
|
1212
|
+
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.12"
|
|
1193
1213
|
// Replaced at build time
|
|
1194
1214
|
}
|
|
1195
1215
|
};
|
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.12",
|
|
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.6",
|
|
32
32
|
"@phantom/browser-injected-sdk": "^1.0.0-beta.5",
|
|
33
33
|
"@phantom/chain-interfaces": "^1.0.0-beta.6",
|
|
34
|
-
"@phantom/client": "^1.0.0-beta.
|
|
34
|
+
"@phantom/client": "^1.0.0-beta.12",
|
|
35
35
|
"@phantom/constants": "^1.0.0-beta.6",
|
|
36
|
-
"@phantom/embedded-provider-core": "^1.0.0-beta.
|
|
36
|
+
"@phantom/embedded-provider-core": "^1.0.0-beta.12",
|
|
37
37
|
"@phantom/indexed-db-stamper": "^1.0.0-beta.1",
|
|
38
38
|
"@phantom/parsers": "^1.0.0-beta.6",
|
|
39
39
|
"@phantom/sdk-types": "^1.0.0-beta.6",
|