Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: send raw json when callback uri #1323

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/keychain/src/components/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ export function Session() {
const headers = new Headers();
headers.append("Content-Type", "application/json");

// Remove any trailing '=' characters from the encoded response
// Telegram doesnt seem to be able to decode the response if there are any
const encodedResponse = btoa(JSON.stringify(response)).replace(/=+$/, "");

if (queries.callback_uri) {
try {
const url = sanitizeCallbackUrl(
Expand All @@ -75,7 +71,7 @@ export function Session() {
}

const res = await fetch(url, {
body: encodedResponse,
body: JSON.stringify(response),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this break slot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think slot goes through another flow no? the oauth stuff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah what about sozo though? doesn't it use this flow to create a cli controller?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok yes that will need to be changed to use the decode the raw json directly. i just wonder if the flow still works because the rev that slot uses for the account_sdk is outdated and when i used it, i had deserialization errors when initializing and using a session account. @glihm do you know if it still works fine?

headers,
method: "POST",
});
Expand All @@ -99,6 +95,13 @@ export function Session() {
}

if (queries.redirect_uri) {
// Remove any trailing '=' characters from the encoded response
// Telegram doesnt seem to be able to decode the response if there are any
const encodedResponse = btoa(JSON.stringify(response)).replace(
/=+$/,
"",
);

const url = decodeURIComponent(queries.redirect_uri);
const query_name = queries.redirect_query_name ?? "session";
window.location.href = `${url}?${query_name}=${encodedResponse}`;
Expand Down
Loading