@phantom/embedded-provider-core 1.0.4 → 1.0.6
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 +6 -10
- package/dist/index.d.ts +6 -10
- package/dist/index.js +47 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,8 @@ import { NetworkId, ClientSideSdkHeaders } from '@phantom/constants';
|
|
|
3
3
|
import { ParsedSignatureResult, ParsedTransactionResult } from '@phantom/parsers';
|
|
4
4
|
import { Algorithm, StamperWithKeyManagement, Transaction, VersionedTransaction } from '@phantom/sdk-types';
|
|
5
5
|
import { ISolanaChain, IEthereumChain, EthTransactionRequest } from '@phantom/chain-interfaces';
|
|
6
|
+
import { Logger } from '@phantom/utils';
|
|
7
|
+
export { Logger as DebugLogger } from '@phantom/utils';
|
|
6
8
|
|
|
7
9
|
interface WalletAddress {
|
|
8
10
|
addressType: AddressType;
|
|
@@ -157,12 +159,6 @@ interface PlatformAdapter {
|
|
|
157
159
|
stamper: StamperWithKeyManagement;
|
|
158
160
|
analyticsHeaders?: Partial<ClientSideSdkHeaders>;
|
|
159
161
|
}
|
|
160
|
-
interface DebugLogger {
|
|
161
|
-
info(category: string, message: string, data?: any): void;
|
|
162
|
-
warn(category: string, message: string, data?: any): void;
|
|
163
|
-
error(category: string, message: string, data?: any): void;
|
|
164
|
-
log(category: string, message: string, data?: any): void;
|
|
165
|
-
}
|
|
166
162
|
|
|
167
163
|
type EmbeddedProviderEvent = "connect" | "connect_start" | "connect_error" | "disconnect" | "error" | "spending_limit_reached";
|
|
168
164
|
interface ConnectEventData extends ConnectResult {
|
|
@@ -208,7 +204,7 @@ declare class EmbeddedProvider {
|
|
|
208
204
|
readonly solana: ISolanaChain;
|
|
209
205
|
readonly ethereum: IEthereumChain;
|
|
210
206
|
private eventListeners;
|
|
211
|
-
constructor(config: EmbeddedProviderConfig, platform: PlatformAdapter, logger:
|
|
207
|
+
constructor(config: EmbeddedProviderConfig, platform: PlatformAdapter, logger: Logger);
|
|
212
208
|
on<K extends EmbeddedProviderEvent>(event: K, callback: EventCallback<EmbeddedProviderEventMap[K]>): void;
|
|
213
209
|
off<K extends EmbeddedProviderEvent>(event: K, callback: EventCallback<EmbeddedProviderEventMap[K]>): void;
|
|
214
210
|
private emit;
|
|
@@ -248,7 +244,7 @@ declare class EmbeddedProvider {
|
|
|
248
244
|
|
|
249
245
|
declare function generateSessionId(): string;
|
|
250
246
|
|
|
251
|
-
declare function retryWithBackoff<T>(operation: () => Promise<T>, operationName: string, logger:
|
|
247
|
+
declare function retryWithBackoff<T>(operation: () => Promise<T>, operationName: string, logger: Logger, maxRetries?: number, baseDelay?: number): Promise<T>;
|
|
252
248
|
|
|
253
249
|
/**
|
|
254
250
|
* Embedded Solana chain implementation that is wallet adapter compliant
|
|
@@ -323,7 +319,7 @@ declare class EmbeddedEthereumChain implements IEthereumChain {
|
|
|
323
319
|
|
|
324
320
|
/**
|
|
325
321
|
* How long an authenticator is valid before it expires (in milliseconds)
|
|
326
|
-
* Default:
|
|
322
|
+
* Default: 31 days
|
|
327
323
|
* For testing: Use smaller values like 5 * 60 * 1000 (5 minutes)
|
|
328
324
|
*/
|
|
329
325
|
declare const AUTHENTICATOR_EXPIRATION_TIME_MS: number;
|
|
@@ -335,4 +331,4 @@ declare const AUTHENTICATOR_EXPIRATION_TIME_MS: number;
|
|
|
335
331
|
declare const AUTHENTICATOR_RENEWAL_WINDOW_MS: number;
|
|
336
332
|
declare const EMBEDDED_PROVIDER_AUTH_TYPES: EmbeddedProviderAuthType[];
|
|
337
333
|
|
|
338
|
-
export { AUTHENTICATOR_EXPIRATION_TIME_MS, AUTHENTICATOR_RENEWAL_WINDOW_MS, AuthOptions, AuthProvider, AuthResult, ConnectErrorEventData, ConnectEventData, ConnectResult, ConnectStartEventData,
|
|
334
|
+
export { AUTHENTICATOR_EXPIRATION_TIME_MS, AUTHENTICATOR_RENEWAL_WINDOW_MS, AuthOptions, AuthProvider, AuthResult, ConnectErrorEventData, ConnectEventData, ConnectResult, ConnectStartEventData, DisconnectEventData, EMBEDDED_PROVIDER_AUTH_TYPES, EmbeddedEthereumChain, EmbeddedProvider, EmbeddedProviderAuthType, EmbeddedProviderConfig, EmbeddedProviderEvent, EmbeddedProviderEventMap, EmbeddedSolanaChain, EmbeddedStorage, EventCallback, Keypair, PhantomAppAuthOptions, PhantomAppProvider, PhantomConnectOptions, PlatformAdapter, Session, SignAndSendTransactionParams, SignMessageParams, SignMessageResult, SignTransactionParams, SignTypedDataV4Params, SignedTransaction, StamperInfo, URLParamsAccessor, WalletAddress, generateSessionId, retryWithBackoff };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { NetworkId, ClientSideSdkHeaders } from '@phantom/constants';
|
|
|
3
3
|
import { ParsedSignatureResult, ParsedTransactionResult } from '@phantom/parsers';
|
|
4
4
|
import { Algorithm, StamperWithKeyManagement, Transaction, VersionedTransaction } from '@phantom/sdk-types';
|
|
5
5
|
import { ISolanaChain, IEthereumChain, EthTransactionRequest } from '@phantom/chain-interfaces';
|
|
6
|
+
import { Logger } from '@phantom/utils';
|
|
7
|
+
export { Logger as DebugLogger } from '@phantom/utils';
|
|
6
8
|
|
|
7
9
|
interface WalletAddress {
|
|
8
10
|
addressType: AddressType;
|
|
@@ -157,12 +159,6 @@ interface PlatformAdapter {
|
|
|
157
159
|
stamper: StamperWithKeyManagement;
|
|
158
160
|
analyticsHeaders?: Partial<ClientSideSdkHeaders>;
|
|
159
161
|
}
|
|
160
|
-
interface DebugLogger {
|
|
161
|
-
info(category: string, message: string, data?: any): void;
|
|
162
|
-
warn(category: string, message: string, data?: any): void;
|
|
163
|
-
error(category: string, message: string, data?: any): void;
|
|
164
|
-
log(category: string, message: string, data?: any): void;
|
|
165
|
-
}
|
|
166
162
|
|
|
167
163
|
type EmbeddedProviderEvent = "connect" | "connect_start" | "connect_error" | "disconnect" | "error" | "spending_limit_reached";
|
|
168
164
|
interface ConnectEventData extends ConnectResult {
|
|
@@ -208,7 +204,7 @@ declare class EmbeddedProvider {
|
|
|
208
204
|
readonly solana: ISolanaChain;
|
|
209
205
|
readonly ethereum: IEthereumChain;
|
|
210
206
|
private eventListeners;
|
|
211
|
-
constructor(config: EmbeddedProviderConfig, platform: PlatformAdapter, logger:
|
|
207
|
+
constructor(config: EmbeddedProviderConfig, platform: PlatformAdapter, logger: Logger);
|
|
212
208
|
on<K extends EmbeddedProviderEvent>(event: K, callback: EventCallback<EmbeddedProviderEventMap[K]>): void;
|
|
213
209
|
off<K extends EmbeddedProviderEvent>(event: K, callback: EventCallback<EmbeddedProviderEventMap[K]>): void;
|
|
214
210
|
private emit;
|
|
@@ -248,7 +244,7 @@ declare class EmbeddedProvider {
|
|
|
248
244
|
|
|
249
245
|
declare function generateSessionId(): string;
|
|
250
246
|
|
|
251
|
-
declare function retryWithBackoff<T>(operation: () => Promise<T>, operationName: string, logger:
|
|
247
|
+
declare function retryWithBackoff<T>(operation: () => Promise<T>, operationName: string, logger: Logger, maxRetries?: number, baseDelay?: number): Promise<T>;
|
|
252
248
|
|
|
253
249
|
/**
|
|
254
250
|
* Embedded Solana chain implementation that is wallet adapter compliant
|
|
@@ -323,7 +319,7 @@ declare class EmbeddedEthereumChain implements IEthereumChain {
|
|
|
323
319
|
|
|
324
320
|
/**
|
|
325
321
|
* How long an authenticator is valid before it expires (in milliseconds)
|
|
326
|
-
* Default:
|
|
322
|
+
* Default: 31 days
|
|
327
323
|
* For testing: Use smaller values like 5 * 60 * 1000 (5 minutes)
|
|
328
324
|
*/
|
|
329
325
|
declare const AUTHENTICATOR_EXPIRATION_TIME_MS: number;
|
|
@@ -335,4 +331,4 @@ declare const AUTHENTICATOR_EXPIRATION_TIME_MS: number;
|
|
|
335
331
|
declare const AUTHENTICATOR_RENEWAL_WINDOW_MS: number;
|
|
336
332
|
declare const EMBEDDED_PROVIDER_AUTH_TYPES: EmbeddedProviderAuthType[];
|
|
337
333
|
|
|
338
|
-
export { AUTHENTICATOR_EXPIRATION_TIME_MS, AUTHENTICATOR_RENEWAL_WINDOW_MS, AuthOptions, AuthProvider, AuthResult, ConnectErrorEventData, ConnectEventData, ConnectResult, ConnectStartEventData,
|
|
334
|
+
export { AUTHENTICATOR_EXPIRATION_TIME_MS, AUTHENTICATOR_RENEWAL_WINDOW_MS, AuthOptions, AuthProvider, AuthResult, ConnectErrorEventData, ConnectEventData, ConnectResult, ConnectStartEventData, DisconnectEventData, EMBEDDED_PROVIDER_AUTH_TYPES, EmbeddedEthereumChain, EmbeddedProvider, EmbeddedProviderAuthType, EmbeddedProviderConfig, EmbeddedProviderEvent, EmbeddedProviderEventMap, EmbeddedSolanaChain, EmbeddedStorage, EventCallback, Keypair, PhantomAppAuthOptions, PhantomAppProvider, PhantomConnectOptions, PlatformAdapter, Session, SignAndSendTransactionParams, SignMessageParams, SignMessageResult, SignTransactionParams, SignTypedDataV4Params, SignedTransaction, StamperInfo, URLParamsAccessor, WalletAddress, generateSessionId, retryWithBackoff };
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ var import_buffer = require("buffer");
|
|
|
50
50
|
var import_bs582 = __toESM(require("bs58"));
|
|
51
51
|
|
|
52
52
|
// src/constants.ts
|
|
53
|
-
var AUTHENTICATOR_EXPIRATION_TIME_MS =
|
|
53
|
+
var AUTHENTICATOR_EXPIRATION_TIME_MS = 31 * 24 * 60 * 60 * 1e3;
|
|
54
54
|
var AUTHENTICATOR_RENEWAL_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
55
55
|
var EMBEDDED_PROVIDER_AUTH_TYPES = ["google", "apple", "phantom"];
|
|
56
56
|
|
|
@@ -375,7 +375,7 @@ async function retryWithBackoff(operation, operationName, logger, maxRetries = 3
|
|
|
375
375
|
let lastError;
|
|
376
376
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
377
377
|
try {
|
|
378
|
-
logger.
|
|
378
|
+
logger.debug("EMBEDDED_PROVIDER", `Attempting ${operationName}`, {
|
|
379
379
|
attempt,
|
|
380
380
|
maxRetries
|
|
381
381
|
});
|
|
@@ -394,7 +394,7 @@ async function retryWithBackoff(operation, operationName, logger, maxRetries = 3
|
|
|
394
394
|
break;
|
|
395
395
|
}
|
|
396
396
|
const delay = baseDelay * Math.pow(2, attempt - 1);
|
|
397
|
-
logger.
|
|
397
|
+
logger.debug("EMBEDDED_PROVIDER", `Retrying ${operationName} in ${delay}ms`, {
|
|
398
398
|
attempt: attempt + 1,
|
|
399
399
|
delay
|
|
400
400
|
});
|
|
@@ -410,6 +410,16 @@ function generateSessionId() {
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
// src/embedded-provider.ts
|
|
413
|
+
var noopLogger = {
|
|
414
|
+
info: () => {
|
|
415
|
+
},
|
|
416
|
+
warn: () => {
|
|
417
|
+
},
|
|
418
|
+
error: () => {
|
|
419
|
+
},
|
|
420
|
+
debug: () => {
|
|
421
|
+
}
|
|
422
|
+
};
|
|
413
423
|
var EmbeddedProvider = class {
|
|
414
424
|
constructor(config, platform, logger) {
|
|
415
425
|
this.client = null;
|
|
@@ -417,7 +427,7 @@ var EmbeddedProvider = class {
|
|
|
417
427
|
this.addresses = [];
|
|
418
428
|
this.eventListeners = /* @__PURE__ */ new Map();
|
|
419
429
|
this.logger = logger;
|
|
420
|
-
this.logger.
|
|
430
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Initializing EmbeddedProvider", { config });
|
|
421
431
|
if (config.embeddedWalletType === "app-wallet") {
|
|
422
432
|
throw new Error("app-wallet type is not currently supported. Please use 'user-wallet' instead.");
|
|
423
433
|
}
|
|
@@ -440,19 +450,19 @@ var EmbeddedProvider = class {
|
|
|
440
450
|
this.eventListeners.set(event, /* @__PURE__ */ new Set());
|
|
441
451
|
}
|
|
442
452
|
this.eventListeners.get(event)?.add(callback);
|
|
443
|
-
this.logger.
|
|
453
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Event listener added", { event });
|
|
444
454
|
}
|
|
445
455
|
off(event, callback) {
|
|
446
456
|
const listeners = this.eventListeners.get(event);
|
|
447
457
|
if (listeners) {
|
|
448
458
|
listeners.delete(callback);
|
|
449
|
-
this.logger.
|
|
459
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Event listener removed", { event });
|
|
450
460
|
}
|
|
451
461
|
}
|
|
452
462
|
emit(event, data) {
|
|
453
463
|
const listeners = this.eventListeners.get(event);
|
|
454
464
|
if (listeners && listeners.size > 0) {
|
|
455
|
-
this.logger.
|
|
465
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Emitting event", { event, listenerCount: listeners.size, data });
|
|
456
466
|
listeners.forEach((callback) => {
|
|
457
467
|
try {
|
|
458
468
|
callback(data);
|
|
@@ -520,7 +530,7 @@ var EmbeddedProvider = class {
|
|
|
520
530
|
async validateAndCleanSession(session) {
|
|
521
531
|
if (!session)
|
|
522
532
|
return null;
|
|
523
|
-
this.logger.
|
|
533
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Found existing session, validating", {
|
|
524
534
|
sessionId: session.sessionId,
|
|
525
535
|
status: session.status,
|
|
526
536
|
walletId: session.walletId
|
|
@@ -566,11 +576,11 @@ var EmbeddedProvider = class {
|
|
|
566
576
|
* Returns ConnectResult if connection succeeds, null if should continue with new auth flow.
|
|
567
577
|
*/
|
|
568
578
|
async tryExistingConnection(isAutoConnect) {
|
|
569
|
-
this.logger.
|
|
579
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Getting existing session");
|
|
570
580
|
let session = await this.storage.getSession();
|
|
571
581
|
session = await this.validateAndCleanSession(session);
|
|
572
582
|
if (!session) {
|
|
573
|
-
this.logger.
|
|
583
|
+
this.logger.debug("EMBEDDED_PROVIDER", "No existing session found");
|
|
574
584
|
return null;
|
|
575
585
|
}
|
|
576
586
|
if (session.status === "completed") {
|
|
@@ -599,7 +609,7 @@ var EmbeddedProvider = class {
|
|
|
599
609
|
});
|
|
600
610
|
return result;
|
|
601
611
|
}
|
|
602
|
-
this.logger.
|
|
612
|
+
this.logger.debug("EMBEDDED_PROVIDER", "No completed session found, checking for redirect resume");
|
|
603
613
|
if (this.authProvider.resumeAuthFromRedirect) {
|
|
604
614
|
const authResult = await this.authProvider.resumeAuthFromRedirect(session.authProvider);
|
|
605
615
|
if (authResult) {
|
|
@@ -649,7 +659,7 @@ var EmbeddedProvider = class {
|
|
|
649
659
|
return false;
|
|
650
660
|
}
|
|
651
661
|
if (!session.walletId || !session.organizationId || !session.stamperInfo) {
|
|
652
|
-
this.logger.
|
|
662
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Session missing required fields", {
|
|
653
663
|
hasWalletId: !!session.walletId,
|
|
654
664
|
hasOrganizationId: !!session.organizationId,
|
|
655
665
|
hasStamperInfo: !!session.stamperInfo
|
|
@@ -657,23 +667,23 @@ var EmbeddedProvider = class {
|
|
|
657
667
|
return false;
|
|
658
668
|
}
|
|
659
669
|
if (session.status !== "completed") {
|
|
660
|
-
this.logger.
|
|
670
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Session not completed", { status: session.status });
|
|
661
671
|
return false;
|
|
662
672
|
}
|
|
663
673
|
if (!session.authenticatorExpiresAt) {
|
|
664
|
-
this.logger.
|
|
674
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Session invalid - missing authenticator timing", {
|
|
665
675
|
sessionId: session.sessionId
|
|
666
676
|
});
|
|
667
677
|
return false;
|
|
668
678
|
}
|
|
669
679
|
if (Date.now() >= session.authenticatorExpiresAt) {
|
|
670
|
-
this.logger.
|
|
680
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Authenticator expired, session invalid", {
|
|
671
681
|
authenticatorExpiresAt: new Date(session.authenticatorExpiresAt).toISOString(),
|
|
672
682
|
now: (/* @__PURE__ */ new Date()).toISOString()
|
|
673
683
|
});
|
|
674
684
|
return false;
|
|
675
685
|
}
|
|
676
|
-
this.logger.
|
|
686
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Session is valid", {
|
|
677
687
|
sessionId: session.sessionId,
|
|
678
688
|
walletId: session.walletId,
|
|
679
689
|
authenticatorExpires: new Date(session.authenticatorExpiresAt).toISOString()
|
|
@@ -687,7 +697,7 @@ var EmbeddedProvider = class {
|
|
|
687
697
|
*/
|
|
688
698
|
async autoConnect() {
|
|
689
699
|
try {
|
|
690
|
-
this.logger.
|
|
700
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Starting auto-connect attempt");
|
|
691
701
|
this.emit("connect_start", { source: "auto-connect" });
|
|
692
702
|
const result = await this.tryExistingConnection(true);
|
|
693
703
|
if (result) {
|
|
@@ -701,7 +711,7 @@ var EmbeddedProvider = class {
|
|
|
701
711
|
});
|
|
702
712
|
return;
|
|
703
713
|
}
|
|
704
|
-
this.logger.
|
|
714
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Auto-connect failed: no valid session found");
|
|
705
715
|
this.emit("connect_error", {
|
|
706
716
|
error: "No valid session found",
|
|
707
717
|
source: "auto-connect"
|
|
@@ -722,11 +732,11 @@ var EmbeddedProvider = class {
|
|
|
722
732
|
* This is the first step when no existing session is found and we need to set up a new wallet.
|
|
723
733
|
*/
|
|
724
734
|
async initializeStamper() {
|
|
725
|
-
this.logger.
|
|
735
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Initializing stamper");
|
|
726
736
|
await this.stamper.init();
|
|
727
|
-
this.logger.
|
|
737
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Resetting keypair to avoid conflicts with existing keypairs");
|
|
728
738
|
const stamperInfo = await this.stamper.resetKeyPair();
|
|
729
|
-
this.logger.
|
|
739
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Stamper initialized with fresh keypair", {
|
|
730
740
|
publicKey: stamperInfo.publicKey,
|
|
731
741
|
keyId: stamperInfo.keyId,
|
|
732
742
|
algorithm: this.stamper.algorithm
|
|
@@ -743,12 +753,13 @@ var EmbeddedProvider = class {
|
|
|
743
753
|
apiBaseUrl: this.config.apiBaseUrl,
|
|
744
754
|
headers: {
|
|
745
755
|
...this.platform.analyticsHeaders || {}
|
|
746
|
-
}
|
|
756
|
+
},
|
|
757
|
+
logger: noopLogger
|
|
747
758
|
});
|
|
748
759
|
const platformName = this.platform.name || "unknown";
|
|
749
760
|
const shortPubKey = stamperInfo.publicKey.slice(0, 8);
|
|
750
761
|
const organizationName = `${this.config.appId.substring(0, 8)}-${platformName}-${shortPubKey}`;
|
|
751
|
-
this.logger.
|
|
762
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Creating organization for app-wallet", {
|
|
752
763
|
organizationName,
|
|
753
764
|
publicKey: stamperInfo.publicKey,
|
|
754
765
|
platform: platformName
|
|
@@ -868,7 +879,7 @@ var EmbeddedProvider = class {
|
|
|
868
879
|
async disconnect(shouldClearPreviousSession = true) {
|
|
869
880
|
const wasConnected = this.client !== null;
|
|
870
881
|
await this.storage.setShouldClearPreviousSession(shouldClearPreviousSession);
|
|
871
|
-
this.logger.
|
|
882
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Set flag to clear previous session on next login");
|
|
872
883
|
await this.storage.clearSession();
|
|
873
884
|
this.client = null;
|
|
874
885
|
this.walletId = null;
|
|
@@ -985,7 +996,7 @@ var EmbeddedProvider = class {
|
|
|
985
996
|
const parsedTransaction = await (0, import_parsers2.parseToKmsTransaction)(params.transaction, params.networkId);
|
|
986
997
|
const session = await this.storage.getSession();
|
|
987
998
|
const derivationIndex = session?.accountDerivationIndex ?? 0;
|
|
988
|
-
this.logger.
|
|
999
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Parsed transaction for signing", {
|
|
989
1000
|
walletId: this.walletId,
|
|
990
1001
|
transaction: parsedTransaction,
|
|
991
1002
|
derivationIndex
|
|
@@ -1024,7 +1035,7 @@ var EmbeddedProvider = class {
|
|
|
1024
1035
|
const parsedTransaction = await (0, import_parsers2.parseToKmsTransaction)(params.transaction, params.networkId);
|
|
1025
1036
|
const session = await this.storage.getSession();
|
|
1026
1037
|
const derivationIndex = session?.accountDerivationIndex ?? 0;
|
|
1027
|
-
this.logger.
|
|
1038
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Parsed transaction for signing", {
|
|
1028
1039
|
walletId: this.walletId,
|
|
1029
1040
|
transaction: parsedTransaction,
|
|
1030
1041
|
derivationIndex
|
|
@@ -1088,7 +1099,8 @@ var EmbeddedProvider = class {
|
|
|
1088
1099
|
organizationId,
|
|
1089
1100
|
headers: {
|
|
1090
1101
|
...this.platform.analyticsHeaders || {}
|
|
1091
|
-
}
|
|
1102
|
+
},
|
|
1103
|
+
logger: noopLogger
|
|
1092
1104
|
},
|
|
1093
1105
|
this.stamper
|
|
1094
1106
|
);
|
|
@@ -1167,7 +1179,7 @@ var EmbeddedProvider = class {
|
|
|
1167
1179
|
lastRenewalAttempt: void 0,
|
|
1168
1180
|
authUserId: authResult.authUserId
|
|
1169
1181
|
};
|
|
1170
|
-
this.logger.
|
|
1182
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Saving Phantom session");
|
|
1171
1183
|
await this.storage.saveSession(session);
|
|
1172
1184
|
return session;
|
|
1173
1185
|
}
|
|
@@ -1202,7 +1214,7 @@ var EmbeddedProvider = class {
|
|
|
1202
1214
|
authenticatorExpiresAt: now + AUTHENTICATOR_EXPIRATION_TIME_MS,
|
|
1203
1215
|
lastRenewalAttempt: void 0
|
|
1204
1216
|
};
|
|
1205
|
-
this.logger.
|
|
1217
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Saving temporary session before redirect", {
|
|
1206
1218
|
sessionId: tempSession.sessionId,
|
|
1207
1219
|
tempWalletId: tempSession.walletId
|
|
1208
1220
|
});
|
|
@@ -1249,14 +1261,14 @@ var EmbeddedProvider = class {
|
|
|
1249
1261
|
const now2 = Date.now();
|
|
1250
1262
|
tempSession.authenticatorCreatedAt = now2;
|
|
1251
1263
|
tempSession.authenticatorExpiresAt = now2 + authResult.expiresInMs;
|
|
1252
|
-
this.logger.
|
|
1264
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Updated authenticator expiration from immediate auth response", {
|
|
1253
1265
|
expiresInMs: authResult.expiresInMs,
|
|
1254
1266
|
expiresAt: new Date(tempSession.authenticatorExpiresAt).toISOString()
|
|
1255
1267
|
});
|
|
1256
1268
|
}
|
|
1257
1269
|
await this.storage.saveSession(tempSession);
|
|
1258
1270
|
await this.storage.setShouldClearPreviousSession(false);
|
|
1259
|
-
this.logger.
|
|
1271
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Cleared logout flag after successful authentication");
|
|
1260
1272
|
return tempSession;
|
|
1261
1273
|
}
|
|
1262
1274
|
this.logger.info("EMBEDDED_PROVIDER", "Redirect authentication initiated, waiting for redirect completion");
|
|
@@ -1279,14 +1291,14 @@ var EmbeddedProvider = class {
|
|
|
1279
1291
|
const now = Date.now();
|
|
1280
1292
|
session.authenticatorCreatedAt = now;
|
|
1281
1293
|
session.authenticatorExpiresAt = now + authResult.expiresInMs;
|
|
1282
|
-
this.logger.
|
|
1294
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Updated authenticator expiration from auth response", {
|
|
1283
1295
|
expiresInMs: authResult.expiresInMs,
|
|
1284
1296
|
expiresAt: new Date(session.authenticatorExpiresAt).toISOString()
|
|
1285
1297
|
});
|
|
1286
1298
|
}
|
|
1287
1299
|
await this.storage.saveSession(session);
|
|
1288
1300
|
await this.storage.setShouldClearPreviousSession(false);
|
|
1289
|
-
this.logger.
|
|
1301
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Cleared logout flag after successful authentication");
|
|
1290
1302
|
await this.initializeClientFromSession(session);
|
|
1291
1303
|
await this.ensureValidAuthenticator();
|
|
1292
1304
|
return {
|
|
@@ -1313,7 +1325,7 @@ var EmbeddedProvider = class {
|
|
|
1313
1325
|
throw new Error("Invalid session - missing authenticator timing");
|
|
1314
1326
|
}
|
|
1315
1327
|
const timeUntilExpiry = session.authenticatorExpiresAt - now;
|
|
1316
|
-
this.logger.
|
|
1328
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Checking authenticator expiration", {
|
|
1317
1329
|
expiresAt: new Date(session.authenticatorExpiresAt).toISOString(),
|
|
1318
1330
|
timeUntilExpiry
|
|
1319
1331
|
});
|
|
@@ -1328,7 +1340,7 @@ var EmbeddedProvider = class {
|
|
|
1328
1340
|
* This is the final step that sets up the provider's client state and retrieves available addresses.
|
|
1329
1341
|
*/
|
|
1330
1342
|
async initializeClientFromSession(session) {
|
|
1331
|
-
this.logger.
|
|
1343
|
+
this.logger.debug("EMBEDDED_PROVIDER", "Initializing PhantomClient from session", {
|
|
1332
1344
|
organizationId: session.organizationId,
|
|
1333
1345
|
walletId: session.walletId,
|
|
1334
1346
|
appId: session.appId
|