@aptos-connect/web-transport
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -5,3 +5,4 @@ import { SerializedWalletRequest } from '@aptos-connect/wallet-api'; | ||
private readonly provider; | ||
constructor(baseUrl: string, provider?: 'google' | 'apple'); | ||
private readonly tgWebAppUrl?; | ||
constructor(baseUrl: string, provider?: 'google' | 'apple', tgWebAppUrl?: string | undefined); | ||
sendPromptRequest(request: SerializedWalletRequest): Promise<import("@aptos-connect/wallet-api").SerializedWalletResponse>; | ||
@@ -8,0 +9,0 @@ sendRequest(request: SerializedWalletRequest): Promise<import("@aptos-connect/wallet-api").SerializedWalletResponse>; |
@@ -249,3 +249,4 @@ "use strict"; | ||
// src/telegram/openTelegramPrompt.ts | ||
async function openTelegramPrompt(baseUrl, request) { | ||
async function openTelegramPrompt(args) { | ||
const { baseUrl, request: body, tgWebAppUrl = "/AptosConnectBot/AptosConnect" } = args; | ||
const identityKey = getClientIdentityKey(); | ||
@@ -255,6 +256,6 @@ const clientIdentityKey = identityKey.publicKey(); | ||
const timestamp = Date.now(); | ||
const challenge = (0, import_wallet_api5.makePopupWalletRequestChallenge)({ body: request, id: requestId, timestamp }); | ||
const challenge = (0, import_wallet_api5.makePopupWalletRequestChallenge)({ body, id: requestId, timestamp }); | ||
const signature = identityKey.sign(challenge); | ||
const signedWalletRequest = { | ||
body: request, | ||
body, | ||
clientIdentityKey, | ||
@@ -276,3 +277,3 @@ id: requestId, | ||
(0, import_bridge.postEvent)("web_app_open_tg_link", { | ||
path_full: `/AptosConnectBot/AptosConnect?startapp=${encodedRequest}` | ||
path_full: `${tgWebAppUrl}?startapp=${encodedRequest}` | ||
}); | ||
@@ -289,5 +290,6 @@ return getWalletResponse(baseUrl, clientIdentityKey, requestId); | ||
var WebWalletTransport = class { | ||
constructor(baseUrl, provider = "google") { | ||
constructor(baseUrl, provider = "google", tgWebAppUrl) { | ||
this.baseUrl = baseUrl; | ||
this.provider = provider; | ||
this.tgWebAppUrl = tgWebAppUrl; | ||
this.baseUrl = baseUrl; | ||
@@ -297,3 +299,7 @@ } | ||
if (isTelegramMiniApp()) { | ||
return openTelegramPrompt(this.baseUrl, request); | ||
return openTelegramPrompt({ | ||
baseUrl: this.baseUrl, | ||
request, | ||
tgWebAppUrl: this.tgWebAppUrl | ||
}); | ||
} | ||
@@ -300,0 +306,0 @@ const url = new URL(`${this.baseUrl}/prompt/`); |
import { SerializedWalletRequest } from '@aptos-connect/wallet-api'; | ||
export declare function openTelegramPrompt(baseUrl: string, request: SerializedWalletRequest): Promise<import("@aptos-connect/wallet-api").SerializedWalletResponse>; | ||
export declare function openTelegramPrompt(args: { | ||
baseUrl: string; | ||
request: SerializedWalletRequest; | ||
tgWebAppUrl?: string; | ||
}): Promise<import("@aptos-connect/wallet-api").SerializedWalletResponse>; | ||
//# sourceMappingURL=openTelegramPrompt.d.ts.map |
{ | ||
"name": "@aptos-connect/web-transport", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -28,2 +28,3 @@ // Copyright © Aptos | ||
private readonly provider: 'google' | 'apple' = 'google', | ||
private readonly tgWebAppUrl?: string, | ||
) { | ||
@@ -35,3 +36,7 @@ this.baseUrl = baseUrl; | ||
if (isTelegramMiniApp()) { | ||
return openTelegramPrompt(this.baseUrl, request); | ||
return openTelegramPrompt({ | ||
baseUrl: this.baseUrl, | ||
request, | ||
tgWebAppUrl: this.tgWebAppUrl, | ||
}); | ||
} | ||
@@ -38,0 +43,0 @@ |
@@ -16,3 +16,8 @@ // Copyright © Aptos | ||
export async function openTelegramPrompt(baseUrl: string, request: SerializedWalletRequest) { | ||
export async function openTelegramPrompt(args: { | ||
baseUrl: string; | ||
request: SerializedWalletRequest; | ||
tgWebAppUrl?: string; | ||
}) { | ||
const { baseUrl, request: body, tgWebAppUrl = '/AptosConnectBot/AptosConnect' } = args; | ||
const identityKey = getClientIdentityKey(); | ||
@@ -23,7 +28,7 @@ const clientIdentityKey = identityKey.publicKey(); | ||
const challenge = makePopupWalletRequestChallenge({ body: request, id: requestId, timestamp }); | ||
const challenge = makePopupWalletRequestChallenge({ body, id: requestId, timestamp }); | ||
const signature = identityKey.sign(challenge); | ||
const signedWalletRequest: SignedPopupWalletRequest = { | ||
body: request, | ||
body, | ||
clientIdentityKey, | ||
@@ -50,3 +55,3 @@ id: requestId, | ||
postTelegramEvent('web_app_open_tg_link', { | ||
path_full: `/AptosConnectBot/AptosConnect?startapp=${encodedRequest}`, | ||
path_full: `${tgWebAppUrl}?startapp=${encodedRequest}`, | ||
}); | ||
@@ -53,0 +58,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
92448
1138