Skip to main content
See Members and authentication for the full flow, including popup fallback and token storage.

auth.isSignedIn()

Returns true if a member token is stored. This is a cheap synchronous check and doesn’t validate the token with the API; a stale token will still return true until the SDK discovers it’s invalid (on load, or on the next member request) and signs the member out.

auth.signIn()

Open the Cashback Hive sign-in window and resolve with the member once they’ve signed in.
Behaviour
  1. Opens a 480×640 popup to the sign-in page, passing your key, the current origin and the current URL.
  2. Waits for the sign-in page to post a cbh:auth message back (origin-checked), or for a token to appear in localStorage from another tab.
  3. Stores the token, fetches the member profile, emits auth:change, and resolves with the Member.
If the popup is blocked, the current page is redirected to the sign-in page instead and the promise never settles (the page unloads). The member is brought back afterwards and signed in on that load. In mock mode, resolves after ~300 ms with a sample member; no popup is opened. Rejects with an Error whose message is:
Call signIn() directly from a user gesture such as a click handler. Browsers block window.open that isn’t triggered synchronously by user input.

auth.signOut()

Removes the stored token, clears the cached member, and emits auth:change with member: null. Synchronous; makes no network request.