Internet Identity idle-timeout

I want to extend the idle timeout of the II (Internet Identity) to 24 hours. Below is my attempt at implementing this functionality. However, despite my changes, the idle timeout still triggers after 30 minutes, resulting in an automatic logout.

I’m unsure about the correct settings. It also seems that idleTimeout is measured in milliseconds, while maxTimeToLive is measured in nanoseconds.

Does anyone know how to extend the time to 24 hours? Thanks so much for your help!

public async doLogin():Promise<UserExists | string> {
    const MILLISECONDS_IN_A_DAY = 1000 * 60 * 60 * 24;
    const NANOSECONDS_IN_A_DAY = BigInt(1000 * 60 * 60 * 24) * BigInt(1_000_000);
    // create an auth client
    let authClient = await AuthClient.create({
      idleOptions: {
        // in milliseconds
        idleTimeout: MILLISECONDS_IN_A_DAY,
      }
    });

    // start the login process and wait for it to finish
    return await new Promise((resolve, reject) => {
        authClient.login({
          // in nanoseconds
          maxTimeToLive: NANOSECONDS_IN_A_DAY,

          identityProvider: this.IIcanisterId,
          onSuccess: async () => {

            // create new actor with the identity
            this.actor = this.createActor({});

            // get user data
            const r = await this.getUserData();
            resolve(r ? r : "err2");
          },
          onError: (err:string | undefined) => {
            reject(err);
          },
        });
    });
  }

I don’t know the answer but, to try debugging I would do the following:

  • Be sure you logout-login again before making a test or use an incognito window
  • Give a try fully disabling that idle stuffs
AuthClient.create({
		idleOptions: {
			disableIdle: true,
			disableDefaultIdleCallback: true
		}
	});

On a side note, it is advised not to create the AuthClient within the function that handles the login. Instead, declare it at a global level. If you don’t, the popup or tab opened for signing in to Internet Identity is likely to be blocked by Safari.

Thank you for the suggestion, but unfortunately, it didn’t have any effect. The system still logs out after 30 minutes.

After gaining a better understanding of the Angular compiler cache, I believe it’s now working. I still need to test it further, but it seems I’ve successfully extended the login session to 24 hours.

1 Like