Skip to content

Commit

Permalink
fix: Improve authentication client default storage initialization (#1613
Browse files Browse the repository at this point in the history
)
  • Loading branch information
daffl authored Oct 10, 2019
1 parent 1c6c374 commit d7f5107
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/authentication-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ declare module '@feathersjs/feathers' {
}
}

export const getDefaultStorage = () => {
try {
return new StorageWrapper(window.localStorage);
} catch (error) {}

return new MemoryStorage();
};

export { AuthenticationClient, AuthenticationClientOptions, Storage, MemoryStorage, hooks };

export type ClientConstructor = new (app: Application, options: AuthenticationClientOptions) => AuthenticationClient;

export const defaultStorage: Storage = typeof window !== 'undefined' ?
new StorageWrapper(window.localStorage) : new MemoryStorage();
export const defaultStorage: Storage = getDefaultStorage();

export const defaults: AuthenticationClientOptions = {
header: 'Authorization',
Expand Down

0 comments on commit d7f5107

Please # to comment.