Skip to content

Problem creating UserSession in Expo/React Native app #1783

@dacosta-dev

Description

@dacosta-dev

What version of Stacks.js are you using?

@stacks/auth: 7.0.2

Describe the bug

When a new instance of the UserSession class is trying to be created, in an Expo environment and without a valid second parameter for a sessionStore, the code in the constructor assumes that it is running in the browser and defaults to create an instance of LocalStorageStore rather than InstanceDataStore which leads to an error.

The class InstanceDataStore is not provided by the library

How to reproduce

import { AppConfig, UserSession } from '@stacks/auth';

const appConfig = new AppConfig(['store_write']);
const userSession = new UserSession({ appConfig });

Expected behavior

Code should correctly detect the mobile environment and/or perhaps provide access to InstanceDataStore

Additional context

  • Desktop/Smartphone OS: Android 15

https://github.com/hirosystems/stacks.js/blob/main/packages/auth/src/userSession.ts#L60

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnwanted or unintended logic causing harm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions