@phantom/embedded-provider-core 1.0.0-beta.19 → 1.0.0-beta.20
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.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -144,7 +144,7 @@ interface SignAndSendTransactionParams {
|
|
|
144
144
|
interface SignedTransaction extends ParsedTransactionResult {
|
|
145
145
|
}
|
|
146
146
|
interface AuthOptions {
|
|
147
|
-
provider
|
|
147
|
+
provider: "google" | "apple" | "jwt" | "phantom" | "injected";
|
|
148
148
|
jwtToken?: string;
|
|
149
149
|
customAuthData?: Record<string, any>;
|
|
150
150
|
}
|
|
@@ -216,7 +216,7 @@ declare class EmbeddedProvider {
|
|
|
216
216
|
autoConnect(): Promise<void>;
|
|
217
217
|
private initializeStamper;
|
|
218
218
|
private createOrganizationForAppWallet;
|
|
219
|
-
connect(authOptions
|
|
219
|
+
connect(authOptions: AuthOptions): Promise<ConnectResult>;
|
|
220
220
|
disconnect(shouldClearPreviousSession?: boolean): Promise<void>;
|
|
221
221
|
signMessage(params: SignMessageParams): Promise<ParsedSignatureResult>;
|
|
222
222
|
signEthereumMessage(params: SignMessageParams): Promise<ParsedSignatureResult>;
|
package/dist/index.d.ts
CHANGED
|
@@ -144,7 +144,7 @@ interface SignAndSendTransactionParams {
|
|
|
144
144
|
interface SignedTransaction extends ParsedTransactionResult {
|
|
145
145
|
}
|
|
146
146
|
interface AuthOptions {
|
|
147
|
-
provider
|
|
147
|
+
provider: "google" | "apple" | "jwt" | "phantom" | "injected";
|
|
148
148
|
jwtToken?: string;
|
|
149
149
|
customAuthData?: Record<string, any>;
|
|
150
150
|
}
|
|
@@ -216,7 +216,7 @@ declare class EmbeddedProvider {
|
|
|
216
216
|
autoConnect(): Promise<void>;
|
|
217
217
|
private initializeStamper;
|
|
218
218
|
private createOrganizationForAppWallet;
|
|
219
|
-
connect(authOptions
|
|
219
|
+
connect(authOptions: AuthOptions): Promise<ConnectResult>;
|
|
220
220
|
disconnect(shouldClearPreviousSession?: boolean): Promise<void>;
|
|
221
221
|
signMessage(params: SignMessageParams): Promise<ParsedSignatureResult>;
|
|
222
222
|
signEthereumMessage(params: SignMessageParams): Promise<ParsedSignatureResult>;
|
package/dist/index.js
CHANGED
|
@@ -736,9 +736,7 @@ var EmbeddedProvider = class {
|
|
|
736
736
|
* This ensures only supported auth providers are used and required tokens are present.
|
|
737
737
|
*/
|
|
738
738
|
validateAuthOptions(authOptions) {
|
|
739
|
-
if (!authOptions)
|
|
740
|
-
return;
|
|
741
|
-
if (authOptions.provider && !["google", "apple", "jwt", "phantom"].includes(authOptions.provider)) {
|
|
739
|
+
if (!["google", "apple", "jwt", "phantom"].includes(authOptions.provider)) {
|
|
742
740
|
throw new Error(`Invalid auth provider: ${authOptions.provider}. Must be "google", "apple", "jwt", or "phantom"`);
|
|
743
741
|
}
|
|
744
742
|
if (authOptions.provider === "jwt" && !authOptions.jwtToken) {
|
|
@@ -881,14 +879,14 @@ var EmbeddedProvider = class {
|
|
|
881
879
|
async connect(authOptions) {
|
|
882
880
|
try {
|
|
883
881
|
this.logger.info("EMBEDDED_PROVIDER", "Starting embedded provider connect", {
|
|
884
|
-
authOptions:
|
|
882
|
+
authOptions: {
|
|
885
883
|
provider: authOptions.provider,
|
|
886
884
|
hasJwtToken: !!authOptions.jwtToken
|
|
887
|
-
}
|
|
885
|
+
}
|
|
888
886
|
});
|
|
889
887
|
this.emit("connect_start", {
|
|
890
888
|
source: "manual-connect",
|
|
891
|
-
authOptions:
|
|
889
|
+
authOptions: { provider: authOptions.provider }
|
|
892
890
|
});
|
|
893
891
|
const existingResult = await this.tryExistingConnection(false);
|
|
894
892
|
if (existingResult) {
|
|
@@ -916,7 +914,7 @@ var EmbeddedProvider = class {
|
|
|
916
914
|
providerType: "embedded"
|
|
917
915
|
};
|
|
918
916
|
}
|
|
919
|
-
if (
|
|
917
|
+
if (authOptions.provider === "jwt" || this.config.embeddedWalletType === "app-wallet") {
|
|
920
918
|
session.lastUsed = Date.now();
|
|
921
919
|
await this.storage.saveSession(session);
|
|
922
920
|
}
|
|
@@ -1150,11 +1148,11 @@ var EmbeddedProvider = class {
|
|
|
1150
1148
|
async handleAuthFlow(publicKey, stamperInfo, authOptions, expiresInMs) {
|
|
1151
1149
|
if (this.config.embeddedWalletType === "user-wallet") {
|
|
1152
1150
|
this.logger.info("EMBEDDED_PROVIDER", "Creating user-wallet, routing authentication", {
|
|
1153
|
-
authProvider: authOptions
|
|
1151
|
+
authProvider: authOptions.provider
|
|
1154
1152
|
});
|
|
1155
|
-
if (authOptions
|
|
1153
|
+
if (authOptions.provider === "jwt") {
|
|
1156
1154
|
return await this.handleJWTAuth(publicKey, stamperInfo, authOptions, expiresInMs);
|
|
1157
|
-
} else if (authOptions
|
|
1155
|
+
} else if (authOptions.provider === "phantom") {
|
|
1158
1156
|
return await this.handlePhantomAuth(publicKey, stamperInfo, expiresInMs);
|
|
1159
1157
|
} else {
|
|
1160
1158
|
this.logger.info("EMBEDDED_PROVIDER", "Starting redirect-based authentication flow", {
|
|
@@ -1308,7 +1306,7 @@ var EmbeddedProvider = class {
|
|
|
1308
1306
|
*/
|
|
1309
1307
|
async handleRedirectAuth(publicKey, stamperInfo, authOptions) {
|
|
1310
1308
|
this.logger.info("EMBEDDED_PROVIDER", "Using Phantom Connect authentication flow (redirect-based)", {
|
|
1311
|
-
provider: authOptions
|
|
1309
|
+
provider: authOptions.provider,
|
|
1312
1310
|
hasRedirectUrl: !!this.config.authOptions.redirectUrl,
|
|
1313
1311
|
authUrl: this.config.authOptions.authUrl
|
|
1314
1312
|
});
|
|
@@ -1322,7 +1320,7 @@ var EmbeddedProvider = class {
|
|
|
1322
1320
|
// Temporary ID, will be updated after redirect
|
|
1323
1321
|
appId: this.config.appId,
|
|
1324
1322
|
stamperInfo,
|
|
1325
|
-
authProvider:
|
|
1323
|
+
authProvider: authOptions.provider,
|
|
1326
1324
|
accountDerivationIndex: void 0,
|
|
1327
1325
|
// Will be set when redirect completes
|
|
1328
1326
|
status: "pending",
|