Skip to content

Commit c68f88f

Browse files
committed
fix: fix sign in issue on mobile
1 parent 3ae1526 commit c68f88f

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

proposals/proposal-271.sh renamed to proposals/proposal-274.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ source "$(pwd)"/proposals/env.sh
66
# build and get batch_id, evidence:
77
# dfx deploy ic_message_frontend --ic --by-proposal
88

9-
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"})')"
9+
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"})')"
1010

1111
quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal "(
1212
record {
13-
title = \"Execute commit_proposed_batch() to release ic_message_frontend v2.9.2\";
13+
title = \"Execute commit_proposed_batch() to release ic_message_frontend v2.9.4\";
1414
url = \"https://dMsg.net/\";
15-
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.\";
15+
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.\";
1616
action = opt variant {
1717
ExecuteGenericNervousSystemFunction = record {
1818
function_id = 1100 : nat64;
@@ -22,4 +22,4 @@ quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $
2222
}
2323
)" > proposal-message.json
2424

25-
quill send proposal-message.json
25+
# quill send proposal-message.json

src/ic_message_frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@
8484
"test": "vitest run"
8585
},
8686
"type": "module",
87-
"version": "2.9.2"
87+
"version": "2.9.4"
8888
}

src/ic_message_frontend/src/lib/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const src = globalThis.location?.href || ''
22

3-
export const APP_VERSION = '2.9.2'
3+
export const APP_VERSION = '2.9.4'
44
export const IS_LOCAL = src.includes('localhost') || src.includes('127.0.0.1')
55
export const ENV = IS_LOCAL ? 'local' : 'ic'
66
export const APP_ORIGIN = IS_LOCAL

src/ic_message_frontend/src/lib/stores/auth.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
setNameIdentity
1414
} from '$lib/utils/auth'
1515
import { encodeCBOR, toArrayBuffer } from '$lib/utils/crypto'
16+
import { popupCenter } from '$lib/utils/window'
1617
import type { DerEncodedPublicKey, Identity, Signature } from '@dfinity/agent'
1718
import {
1819
Delegation,
@@ -54,6 +55,7 @@ export interface AuthStore extends Readable<AuthStoreData> {
5455
}
5556

5657
function initAuthStore(): AuthStore {
58+
const authClientPromise = createAuthClient()
5759
let identity: IdentityEx | null = null
5860
let srcIdentity: IdentityEx | null = null
5961
// srcAgent is used to sign in with username
@@ -151,10 +153,12 @@ function initAuthStore(): AuthStore {
151153
window.location.assign('/_/messages')
152154
},
153155

154-
signIn: async () => {
155-
const authClient = await createAuthClient()
156-
return new Promise<void>((resolve, reject) => {
157-
authClient.login({
156+
signIn: () =>
157+
new Promise<void>(async (resolve, reject) => {
158+
// Important: authClientPromise should be resolved here
159+
// https://ffan0811.medium.com/window-open-returns-null-in-safari-and-firefox-after-allowing-pop-up-on-the-browser-4e4e45e7d926
160+
const authClient = await authClientPromise
161+
await authClient.login({
158162
derivationOrigin: DERIVATION_ORIGIN as string,
159163
maxTimeToLive: BigInt(EXPIRATION_MS) * 1000000n,
160164
onSuccess: () => {
@@ -176,10 +180,13 @@ function initAuthStore(): AuthStore {
176180
console.error(err)
177181
reject(err)
178182
},
179-
identityProvider: IDENTITY_PROVIDER
183+
identityProvider: IDENTITY_PROVIDER,
184+
windowOpenerFeatures: popupCenter({
185+
width: 576,
186+
height: 625
187+
})
180188
})
181-
})
182-
},
189+
}),
183190

184191
logout: async (url: string) => {
185192
dynAgent.setIdentity(anonymousIdentity)

0 commit comments

Comments
 (0)