Skip to content

Commit

Permalink
fix: fix sign in issue on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Dec 14, 2024
1 parent 3ae1526 commit c68f88f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
8 changes: 4 additions & 4 deletions proposals/proposal-271.sh → proposals/proposal-274.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ source "$(pwd)"/proposals/env.sh
# build and get batch_id, evidence:
# dfx deploy ic_message_frontend --ic --by-proposal

export BLOB="$(didc encode --format blob '(record {batch_id=44:nat; evidence=blob "\bf\ef\6d\20\99\de\7e\7c\ea\a5\0e\08\96\67\d0\a0\40\ff\44\c3\c3\5b\fa\ef\85\2f\72\ac\26\76\bf\2b"})')"
export BLOB="$(didc encode --format blob '(record {batch_id=46:nat; evidence=blob "\79\f7\db\d0\09\00\1e\e1\d5\39\b2\60\fb\80\40\bc\3b\34\16\37\9b\9c\02\6b\aa\09\97\19\f4\f0\c2\6b"})')"

quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal "(
record {
title = \"Execute commit_proposed_batch() to release ic_message_frontend v2.9.2\";
title = \"Execute commit_proposed_batch() to release ic_message_frontend v2.9.4\";
url = \"https://dMsg.net/\";
summary = \"This proposal executes commit_proposed_batch() on 2fvu6-tqaaa-aaaap-akksa-cai to release ic_message_frontend v2.9.2.\n\n1. fix: try to fix sign in issue on mobile.\";
summary = \"This proposal executes commit_proposed_batch() on 2fvu6-tqaaa-aaaap-akksa-cai to release ic_message_frontend v2.9.4.\n\n1. fix: try to fix sign in issue on mobile.\";
action = opt variant {
ExecuteGenericNervousSystemFunction = record {
function_id = 1100 : nat64;
Expand All @@ -22,4 +22,4 @@ quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $
}
)" > proposal-message.json

quill send proposal-message.json
# quill send proposal-message.json
2 changes: 1 addition & 1 deletion src/ic_message_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@
"test": "vitest run"
},
"type": "module",
"version": "2.9.2"
"version": "2.9.4"
}
2 changes: 1 addition & 1 deletion src/ic_message_frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const src = globalThis.location?.href || ''

export const APP_VERSION = '2.9.2'
export const APP_VERSION = '2.9.4'
export const IS_LOCAL = src.includes('localhost') || src.includes('127.0.0.1')
export const ENV = IS_LOCAL ? 'local' : 'ic'
export const APP_ORIGIN = IS_LOCAL
Expand Down
21 changes: 14 additions & 7 deletions src/ic_message_frontend/src/lib/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
setNameIdentity
} from '$lib/utils/auth'
import { encodeCBOR, toArrayBuffer } from '$lib/utils/crypto'
import { popupCenter } from '$lib/utils/window'
import type { DerEncodedPublicKey, Identity, Signature } from '@dfinity/agent'
import {
Delegation,
Expand Down Expand Up @@ -54,6 +55,7 @@ export interface AuthStore extends Readable<AuthStoreData> {
}

function initAuthStore(): AuthStore {
const authClientPromise = createAuthClient()
let identity: IdentityEx | null = null
let srcIdentity: IdentityEx | null = null
// srcAgent is used to sign in with username
Expand Down Expand Up @@ -151,10 +153,12 @@ function initAuthStore(): AuthStore {
window.location.assign('/_/messages')
},

signIn: async () => {
const authClient = await createAuthClient()
return new Promise<void>((resolve, reject) => {
authClient.login({
signIn: () =>
new Promise<void>(async (resolve, reject) => {
// Important: authClientPromise should be resolved here
// https://ffan0811.medium.com/window-open-returns-null-in-safari-and-firefox-after-allowing-pop-up-on-the-browser-4e4e45e7d926
const authClient = await authClientPromise
await authClient.login({
derivationOrigin: DERIVATION_ORIGIN as string,
maxTimeToLive: BigInt(EXPIRATION_MS) * 1000000n,
onSuccess: () => {
Expand All @@ -176,10 +180,13 @@ function initAuthStore(): AuthStore {
console.error(err)
reject(err)
},
identityProvider: IDENTITY_PROVIDER
identityProvider: IDENTITY_PROVIDER,
windowOpenerFeatures: popupCenter({
width: 576,
height: 625
})
})
})
},
}),

logout: async (url: string) => {
dynAgent.setIdentity(anonymousIdentity)
Expand Down

0 comments on commit c68f88f

Please sign in to comment.