Skip to content

Commit

Permalink
Merge pull request #36 from thisyahlen-deriv/thisyahlen/export-type-f…
Browse files Browse the repository at this point in the history
…or-better-usability

chore: export type and update docs
  • Loading branch information
thisyahlen-deriv authored Sep 24, 2024
2 parents e975870 + b7890da commit 203abe0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ In this phase, we use OAuth2 with Hydra for authentication.
1. Follow the [Hydra documentation](https://service-auth.deriv.team/resources/hydra-qa-setup/) to set up Hydra in QA box environment.
2. Configure your OAuth2 settings in the project.

### Using the OAuth2 Provider
### Using the OAuth2 Hook

Use the `useOAuth2` hook within your components.

```typescript
// src/App.tsx
import React from 'react';
import { useOAuth2 } from '@deriv-com/auth-client';
import { useOAuth2, TOAuth2EnabledAppList } from '@deriv-com/auth-client';
const YourComponent = () => {
const [OAuth2EnabledApps, OAuth2EnabledAppsInitialised] = useGrowthbookGetFeatureValue<hydraBEApps>({
const [OAuth2EnabledApps, OAuth2EnabledAppsInitialised] = useGrowthbookGetFeatureValue<TOAuth2EnabledAppList>({
featureFlag: 'hydra_be',
});
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { useOAuth2 } from './useOAuth2';
export { useIsOAuth2Enabled } from './useIsOAuth2Enabled';
export type { TOAuth2EnabledAppList } from './useOAuth2';
6 changes: 3 additions & 3 deletions src/hooks/useOAuth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ type MessageEvent = {
origin: string;
};

type hydraBEApps = {
export type TOAuth2EnabledAppList = {
enabled_for: number[];
};
}[];

type OAuth2GBConfig = {
OAuth2EnabledApps: hydraBEApps[];
OAuth2EnabledApps: TOAuth2EnabledAppList;
OAuth2EnabledAppsInitialised: boolean;
};

Expand Down

0 comments on commit 203abe0

Please sign in to comment.