Support AuthClient 0.11.3 maxTimeToLive expiring in 10~ mins

So I recently upgraded DSCVR to 0.11.3 and Im setting my maxTimeToLive to 7 days. I checked the ic-delegation expiration and it calculates to be about 7 days in the future example:

expiration: "16fd8851c245d84b

If I don’t touch anything on DSCVR and just leave the page open, within about 10 mins the ic-delegation and the ic-delegation will be removed from my local storage and log me out. Sometimes it’s much faster. The only change that I believe has happened is the update to 0.11.3. I don’t see any errors or messages in my console and for testing purposes I only have a single tab open.

I also have not been able to keep up with the updates that have been happening, so I’m curious if there is something I’m doing wrong.

    "@dfinity/agent": "0.11.3",
    "@dfinity/auth-client": "0.11.3",
    "@dfinity/authentication": "0.11.3",
    "@dfinity/candid": "0.11.3",
    "@dfinity/identity": "0.11.3",
    "@dfinity/principal": "0.11.3",

I have my authClient configured as such the one below with the intention to mimic the example as much as possible to assist in debugging.

const authClient = await AuthClient.create();

      authClient.login({
        maxTimeToLive: BigInt(7 * 24 * 60 * 60 * 1000 * 1000 * 1000),

        onSuccess: async () => {
          const identity = await authClient.getIdentity();
          //abstractly like this
          agent = new HttpAgent({
            host: "https://boundary.ic0.app/",
            identity: identity,
          });
          await agent.fetchRootKey();
          this.actor = Actor.createActor(idl, {
            agent,
            canisterId: 'aaaa-a',
          });
        },
        onError: () => {
          
        }
      });

Thank you

I used to not set any particular maxTimeToLive and literally set a 1 hour duration yesterday. Now that you are saying it, I also noticed it actually expired after few minutes. I also use v0.11.3.

@anon74414410 maxTimeToLive is still the option to use to make session live longer right?

Looks like there is a IdleManager which logs the user out after 10 mins

This is what it watches

You are right. I remember the idle manager has an option (even though I had a look to the PR).

From README:

If you pass no options to the IdleManager, it will log you out after 10 minutes of inactivity by removing the DelegationIdentity from localStorage and then calling window.location.reload().

It seems there is also an issue with disableIdle that was reported: Logout happening periodically despite passing `disableIdle: true` in `idleOptions` · Issue #576 · dfinity/agent-js · GitHub

Actually disabling the idle checker seems alright. Had my browser open for more than 10min and the session was still on. Can you try following as well @rckprtr?

AuthClient.create({
          idleOptions: {
            disableIdle: true,
            disableDefaultIdleCallback: true
          }
        })...

I use create authClient in a couple places for different things, I had to disable it on every place I use it.

Rick

@rckprtr did it work out for you?

I’ve build a new dapp this weekend and set 7 days expiration and used above settings (cycles.watch/auth.store.ts at main · papyrs/cycles.watch · GitHub) but I actually still get logged out after few minutes …

Yes, I ran into a snag. I call AuthClient.create() in two different spots in my code. I had to make sure I passed in the idle disable for both of them. I also did not have time to fully test it so I also disable the onIdle call back also.

LMK

Thanks. Looks like that was my mistake too. I set the options on my sign-in function but forgot to set these for my sync and sign-out functions too. Extracted a utilities to create the auth-client seems to have done the tricks :crossed_fingers: