Repository: auth0/auth0-spa-js (ts)

Issue:
OrgID missing parameter should be a recoverable error in Check Session

### Describe the problem

I believe this is the scenario:
When calling createAuth0Client it executes a getTokenSilently call as part of checksession which is currently throwing an error in the case where Organization wasn't set in the createAuth0Client and the cookie that is being stored with the org ID (a session cookie) is no longer valid however there exists a (non session cookie) logged in user.

The issue is that when we are initializing the client we do not know at that moment which user is currently trying to log in (and what org they belong to).

Ideally this error (invalid_request, parameter org ... is required) would be handled in check session as a recoverable error because in this case we just need to do a an actual login where we know what org this user is logging in with. 

Also Ideally would be that the ORG cookie were to match the login user Cookie so that they expired and had the same lifecycle (so that this state would never be hit in the first place. And better yet the currently logged in user will be returned if it was actually valid).


### What was the expected behavior?

At the bare minimum we expect the client to initialize in this state where there is a validly logged in user but the session cookie for the Org is missing

Ideally the Org cookie would match the workflow of the logged in user so that there would never be a case where the user is logged in but you don't know what org the user logged in with.

### Reproduction

I'm not 100% sure but this seems to work

Create the auth0 client with No org parameter
Call the LoginWithRedirect passing in an Org parameter
Login the user (succsssfully)
close the browser
** this step may not be necessary** 
walk away come back tomorrow (just happened to be how we reproduced)
****
open the browser and try to create the auth0client which now throws an error and does not initialize properly

**Can the behavior be reproduced using the [SPA SDK Playground](https://github.com/auth0/auth0-spa-js/blob/master/DEVELOPMENT.md#the-sdk-playground)?**

I didn't have time to try.
### Environment

- **Version of `auth0-spa-js` used:**
1.19.2

- **Which browsers have you tested in?**
Chrome, IE

- **Which framework are you using, if applicable (Angular, React, etc):**
Vanilla JS

- **Other modules/plugins/libraries that might be involved:**
too many to count.

Pull request description:
Org ID hint cookie expiry now aligns with is.authenticated cookie
<!-- By submitting a PR to this repository, you agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md). Please see the [contributing guidelines](https://github.com/auth0/.github/blob/master/CONTRIBUTING.md) for how to create and submit a high-quality PR for this repo. -->

### Changes

<!--
Please describe both what is changing and why this is important. Include:
- Classes and methods added, deleted, deprecated, or changed
- Screenshots of new or changed UI, if applicable
- A summary of usage if this is a new feature or change to a public API (this should also be added to relevant documentation once released)
-->

This PR aligns the Org ID hint cookie expiry with that of the `is.authenticated` cookie. This means that if you close the browser window, you shouldn't get a discrepancy where the authenticated hint cookie is there but not the org ID hint cookie. Thus the app should be able to re-log into the organization during `checkSession()` calls.

### References

<!--
Please include relevant links supporting this change such as a:

- support ticket
- community post
- StackOverflow post
- support forum thread

Please note any links that are not publicly accessible.
-->

Fixes #854

### Testing

<!--
Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.
-->

- [x] This change adds unit test coverage
- [ ] This change adds integration test coverage
- [x] This change has been tested on the latest version of the platform/language

### Checklist

- [x] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
- [x] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
- [x] All code quality tools/guidelines have been run/followed


Patch:
diff --git a/src/Auth0Client.ts b/src/Auth0Client.ts
index 345afef..66be802 100644
--- a/src/Auth0Client.ts
+++ b/src/Auth0Client.ts
@@ -379,7 +379,9 @@ export default class Auth0Client {
 
   private _processOrgIdHint(organizationId?: string) {
     if (organizationId) {
-      this.cookieStorage.save(this.orgHintCookieName, organizationId);
+      this.cookieStorage.save(this.orgHintCookieName, organizationId, {
+        daysUntilExpire: this.sessionCheckExpiryDays
+      });
     } else {
       this.cookieStorage.remove(this.orgHintCookieName);
     }


Test patch:
diff --git a/__tests__/Auth0Client/getTokenSilently.test.ts b/__tests__/Auth0Client/getTokenSilently.test.ts
index 673428b..2ee8803 100644
--- a/__tests__/Auth0Client/getTokenSilently.test.ts
+++ b/__tests__/Auth0Client/getTokenSilently.test.ts
@@ -1408,13 +1408,17 @@ describe('Auth0Client', () => {
       expect(esCookie.set).toHaveBeenCalledWith(
         `auth0.${TEST_CLIENT_ID}.organization_hint`,
         JSON.stringify(TEST_ORG_ID),
-        {}
+        {
+          expires: 1
+        }
       );
 
       expect(esCookie.set).toHaveBeenCalledWith(
         `_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`,
         JSON.stringify(TEST_ORG_ID),
-        {}
+        {
+          expires: 1
+        }
       );
     });
 
diff --git a/__tests__/Auth0Client/loginWithPopup.test.ts b/__tests__/Auth0Client/loginWithPopup.test.ts
index 192fe7b..57eb20f 100644
--- a/__tests__/Auth0Client/loginWithPopup.test.ts
+++ b/__tests__/Auth0Client/loginWithPopup.test.ts
@@ -634,13 +634,17 @@ describe('Auth0Client', () => {
       expect(<jest.Mock>esCookie.set).toHaveBeenCalledWith(
         `_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`,
         JSON.stringify(TEST_ORG_ID),
-        {}
+        {
+          expires: 1
+        }
       );
 
       expect(<jest.Mock>esCookie.set).toHaveBeenCalledWith(
         `auth0.${TEST_CLIENT_ID}.organization_hint`,
         JSON.stringify(TEST_ORG_ID),
-        {}
+        {
+          expires: 1
+        }
       );
     });
 
diff --git a/__tests__/Auth0Client/loginWithRedirect.test.ts b/__tests__/Auth0Client/loginWithRedirect.test.ts
index 28eae44..c4818ed 100644
--- a/__tests__/Auth0Client/loginWithRedirect.test.ts
+++ b/__tests__/Auth0Client/loginWithRedirect.test.ts
@@ -390,13 +390,17 @@ describe('Auth0Client', () => {
       expect(<jest.Mock>esCookie.set).toHaveBeenCalledWith(
         `auth0.${TEST_CLIENT_ID}.organization_hint`,
         JSON.stringify(TEST_ORG_ID),
-        {}
+        {
+          expires: 1
+        }
       );
 
       expect(<jest.Mock>esCookie.set).toHaveBeenCalledWith(
         `_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`,
         JSON.stringify(TEST_ORG_ID),
-        {}
+        {
+          expires: 1
+        }
       );
     });
 
diff --git a/__tests__/storage.test.ts b/__tests__/storage.test.ts
index 414ca35..6259769 100644
--- a/__tests__/storage.test.ts
+++ b/__tests__/storage.test.ts
@@ -12,7 +12,16 @@ describe('CookieStorage', () => {
     cookieMock = mocked(esCookie);
   });
 
-  it('saves object', () => {
+  it('saves a cookie', () => {
+    const key = 'key';
+    const value = { some: 'value' };
+
+    CookieStorage.save(key, value);
+
+    expect(cookieMock.set).toHaveBeenCalledWith(key, JSON.stringify(value), {});
+  });
+
+  it('saves a cookie with options', () => {
     const key = 'key';
     const value = { some: 'value' };
     const options = { daysUntilExpire: 1 };