Skip to content

Commit e876890

Browse files
authored
Merge pull request #68 from brionmario/next
feat: `SignIn` component for `@asgardeo/react`
2 parents 525d579 + cdcc723 commit e876890

File tree

381 files changed

+18171
-8764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+18171
-8764
lines changed

.changeset/smart-spiders-film.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@asgardeo/browser': minor
3+
'@asgardeo/javascript': minor
4+
'@asgardeo/react': minor
5+
---
6+
7+
Support `SignIn` component in `@asgardeo/react`.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This repository contains the source code of JavaScript SDKs that can be used to
3434
| [![@asgardeo/browser](https://img.shields.io/npm/v/@asgardeo/browser?color=%234B32C3&label=%40asgardeo%2Fbrowser&logo=firefox)](./packages/browser/) | Browser-based JavaScript SDK |
3535
| [![@asgardeo/nextjs](https://img.shields.io/npm/v/@asgardeo/nextjs?color=%23000000&label=%40asgardeo%2Fnext&logo=next.js)](./packages/next/) | Next.js SDK for building applications with Asgardeo |
3636
| [![@asgardeo/node](https://img.shields.io/npm/v/@asgardeo/node?color=%23339933&label=%40asgardeo%2Fnode&logo=node.js)](./packages/node/) | Node.js SDK for server-side integration |
37+
| [![@asgardeo/express](https://img.shields.io/npm/v/@asgardeo/express?color=%23339933&label=%40asgardeo%2Fexpress&logo=express)](./packages/express/) | Express.js SDK for server-side integration |
3738
| [![@asgardeo/nuxt](https://img.shields.io/npm/v/@asgardeo/nuxt?color=%2300DC82&label=%40asgardeo%2Fnuxt&logo=nuxt)](./packages/nuxt/) | Nuxt.js SDK for building applications with Asgardeo |
3839
| [![@asgardeo/react](https://img.shields.io/npm/v/@asgardeo/react?color=%2361DAFB&label=%40asgardeo%2Freact&logo=react)](./packages/react/) | React SDK for building applications with Asgardeo |
3940
| [![@asgardeo/vue](https://img.shields.io/npm/v/@asgardeo/vue?color=%234FC08D&label=%40asgardeo%2Fvue&logo=vue.js)](./packages/vue/) | Vue.js SDK for building applications with Asgardeo |

docs/src/react/components/asgardeo-provider.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ import { AsgardeoProvider } from "@asgardeo/react";
3838

3939
- `baseURL`: The base URL of asgardeo.
4040

41-
- `signInRedirectURL`: The URL where users should be redirected after they sign in. This should be a page in your application.
41+
- `afterSignInUrl`: The URL where users should be redirected after they sign in. This should be a page in your application.
4242

43-
- `clientID`: The ID of your application. You get this when you register your application with Asgardeo.
43+
- `clientId`: The ID of your application. You get this when you register your application with Asgardeo.
4444

4545
- `scope`: The scope of the access request. This is a list of scopes separated by spaces. Scopes allow your application to request access only to the resources it needs, and also allow users to control how much access they grant to your application.
4646

docs/src/react/hooks/use-authentication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { useAuthentication } from "@asgardeo/react";
3131
Then, you can use it in your component:
3232

3333
```ts
34-
const { user, isAuthenticated, accessToken, signOut } = useAuthentication();
34+
const { user, isSignedIn, accessToken, signOut } = useAuthentication();
3535
```
3636

3737
## Return Value
@@ -40,7 +40,7 @@ The `useAuthentication` hook returns an object with the following properties:
4040

4141
- `user`: The current user. This is an object that contains information about the user.
4242

43-
- `isAuthenticated`: A boolean that indicates whether the user is authenticated.
43+
- `isSignedIn`: A boolean that indicates whether the user is authenticated.
4444

4545
- `accessToken`: The access token for the authenticated user.
4646

@@ -49,9 +49,9 @@ The `useAuthentication` hook returns an object with the following properties:
4949
Here's an example of how to use these values:
5050

5151
```ts
52-
const { user, isAuthenticated, signOut } = useAuthentication();
52+
const { user, isSignedIn, signOut } = useAuthentication();
5353

54-
if (isAuthenticated) {
54+
if (isSignedIn) {
5555
console.log(`User ${user.username} is authenticated.`);
5656
} else {
5757
console.log("User is not authenticated.");

docs/src/react/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ Then, wrap your application with the `AsgardeoProvider` and pass the basic confi
7171
<AsgardeoProvider
7272
config={{
7373
baseUrl: "https://api.asgardeo.io/t/org_name",
74-
clientID: "gqtroUbA1Qsulqr*****",
74+
clientId: "gqtroUbA1Qsulqr*****",
7575
scope: ["openid", "internal_login", "profile"],
76-
signInRedirectURL: "https://domain_name:8080",
76+
afterSignInUrl: "https://domain_name:8080",
7777
}}>
7878
<App />
7979
</AsgardeoProvider>

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"description": "Workspace to hold the Asgardeo JavaScript SDKs.",
66
"author": "WSO2",
77
"license": "Apache-2.0",
8-
"homepage": "https://github.com/asgardeo/javascript#readme",
8+
"homepage": "https://github.com/asgardeo/web-ui-sdks#readme",
99
"bugs": {
10-
"url": "https://github.com/asgardeo/javascript/issues"
10+
"url": "https://github.com/asgardeo/web-ui-sdks/issues"
1111
},
1212
"repository": {
1313
"type": "git",
14-
"url": "https://github.com/asgardeo/javascript"
14+
"url": "https://github.com/asgardeo/web-ui-sdks"
1515
},
1616
"keywords": [
1717
"asgardeo",
@@ -24,6 +24,7 @@
2424
"lint": "nx run-many --target=lint --all --parallel",
2525
"publish:packages": "changeset publish",
2626
"test": "nx run-many --target=test --all --parallel",
27+
"typecheck": "nx run-many --target=typecheck --all --parallel",
2728
"version:packages": "changeset version && pnpm install --lockfile-only"
2829
},
2930
"devDependencies": {
@@ -39,4 +40,4 @@
3940
"publishConfig": {
4041
"access": "restricted"
4142
}
42-
}
43+
}

packages/__legacy__/core/src/api/authenticate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const authenticate = async (props: AuthenticateProps): Promise<AuthApiResponse>
4444
};
4545

4646
/* Getting baseURL from authClient's data layer */
47-
const {baseUrl} = await AuthClient.getInstance().getDataLayer().getConfigData();
47+
const {baseUrl} = await AuthClient.getInstance().getStorageManager().getConfigData();
4848

4949
authnRequest = new Request(`${baseUrl}/oauth2/authn`, requestOptions);
5050
} catch (error) {

packages/__legacy__/core/src/api/authorize.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ const authorize = async (): Promise<AuthApiResponse> => {
3232

3333
try {
3434
const authInstace: UIAuthClient = AuthClient.getInstance();
35-
const params: Map<string, string> = await authInstace.getAuthorizationURLParams();
35+
// FIXME: We should be able to get the URL itself.
36+
// const params: Map<string, string> = await authInstace.getAuthorizationURLParams();
37+
const params: Map<string, string> = new Map();
3638

3739
const formBody: URLSearchParams = new URLSearchParams();
3840

@@ -41,7 +43,7 @@ const authorize = async (): Promise<AuthApiResponse> => {
4143
});
4244

4345
/* Save the state temporarily in the data layer, this needs to be passed when token is requested */
44-
await authInstace.getDataLayer().setTemporaryDataParameter('state', params.get('state'));
46+
await authInstace.getStorageManager().setTemporaryDataParameter('state', params.get('state'));
4547

4648
const headers: Headers = new Headers();
4749
headers.append('Accept', 'application/json');
@@ -53,7 +55,7 @@ const authorize = async (): Promise<AuthApiResponse> => {
5355
method: 'POST',
5456
};
5557

56-
authzURL = (await authInstace.getOIDCServiceEndpoints()).authorizationEndpoint;
58+
authzURL = (await authInstace.getOpenIDProviderEndpoints()).authorizationEndpoint;
5759
} catch (error) {
5860
throw new AsgardeoUIException('JS_UI_CORE-AUTHZ-A-NF', 'Authorization request building failed', error.stack);
5961
}

packages/__legacy__/core/src/api/get-branding-preference-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const getBrandingPreferenceText = async (
5050
params.append('screen', screen);
5151
params.append('type', type);
5252

53-
const {baseUrl} = await AuthClient.getInstance().getDataLayer().getConfigData();
53+
const {baseUrl} = await AuthClient.getInstance().getStorageManager().getConfigData();
5454
const textUrl: string = `${baseUrl}/api/server/v1/branding-preference/text/resolve`;
5555
const urlWithParams: string = `${textUrl}?${params.toString()}`;
5656
let response: Response;

packages/__legacy__/core/src/api/get-branding-preference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const getBrandingPreference = async (): Promise<BrandingPreferenceAPIResponse> =
3131
baseUrl,
3232
type = BrandingPreferenceTypes.Org,
3333
name = 'WSO2',
34-
} = await AuthClient.getInstance().getDataLayer().getConfigData();
34+
} = await AuthClient.getInstance().getStorageManager().getConfigData();
3535
const brandingUrl: string = `${baseUrl}/api/server/v1/branding-preference?type=${type}&name=${name}`;
3636
let response: Response;
3737

0 commit comments

Comments
 (0)