@asgardeo/nextjs 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/AsgardeoNextClient.d.ts +6 -4
  2. package/dist/AsgardeoNextClient.js +89 -12
  3. package/dist/AsgardeoNextClient.js.map +1 -1
  4. package/dist/cjs/index.js +18 -0
  5. package/dist/cjs/index.js.map +3 -3
  6. package/dist/client/components/presentation/CreateOrganization/CreateOrganization.d.ts +67 -0
  7. package/dist/client/components/presentation/CreateOrganization/CreateOrganization.js +109 -0
  8. package/dist/client/components/presentation/CreateOrganization/CreateOrganization.js.map +1 -0
  9. package/dist/client/components/presentation/Organization/Organization.d.ts +66 -0
  10. package/dist/client/components/presentation/Organization/Organization.js +55 -0
  11. package/dist/client/components/presentation/Organization/Organization.js.map +1 -0
  12. package/dist/client/components/presentation/OrganizationList/OrganizationList.d.ts +92 -0
  13. package/dist/client/components/presentation/OrganizationList/OrganizationList.js +120 -0
  14. package/dist/client/components/presentation/OrganizationList/OrganizationList.js.map +1 -0
  15. package/dist/client/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +119 -0
  16. package/dist/client/components/presentation/OrganizationProfile/OrganizationProfile.js +145 -0
  17. package/dist/client/components/presentation/OrganizationProfile/OrganizationProfile.js.map +1 -0
  18. package/dist/client/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +71 -0
  19. package/dist/client/components/presentation/OrganizationSwitcher/OrganizationSwitcher.js +102 -0
  20. package/dist/client/components/presentation/OrganizationSwitcher/OrganizationSwitcher.js.map +1 -0
  21. package/dist/client/components/presentation/UserProfile/UserProfile.js +3 -4
  22. package/dist/client/components/presentation/UserProfile/UserProfile.js.map +1 -1
  23. package/dist/client/contexts/Asgardeo/AsgardeoContext.js +2 -0
  24. package/dist/client/contexts/Asgardeo/AsgardeoContext.js.map +1 -1
  25. package/dist/client/contexts/Asgardeo/AsgardeoProvider.d.ts +11 -1
  26. package/dist/client/contexts/Asgardeo/AsgardeoProvider.js +44 -6
  27. package/dist/client/contexts/Asgardeo/AsgardeoProvider.js.map +1 -1
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.js +3 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/server/AsgardeoProvider.js +28 -1
  32. package/dist/server/AsgardeoProvider.js.map +1 -1
  33. package/dist/server/actions/createOrganizationAction.d.ts +37 -0
  34. package/dist/server/actions/createOrganizationAction.js +40 -0
  35. package/dist/server/actions/createOrganizationAction.js.map +1 -0
  36. package/dist/server/actions/getCurrentOrganizationAction.d.ts +37 -0
  37. package/dist/server/actions/getCurrentOrganizationAction.js +40 -0
  38. package/dist/server/actions/getCurrentOrganizationAction.js.map +1 -0
  39. package/dist/server/actions/getOrganizationAction.d.ts +37 -0
  40. package/dist/server/actions/getOrganizationAction.js +40 -0
  41. package/dist/server/actions/getOrganizationAction.js.map +1 -0
  42. package/dist/server/actions/getOrganizationsAction.d.ts +37 -0
  43. package/dist/server/actions/getOrganizationsAction.js +40 -0
  44. package/dist/server/actions/getOrganizationsAction.js.map +1 -0
  45. package/dist/server/actions/switchOrganizationAction.d.ts +33 -0
  46. package/dist/server/actions/switchOrganizationAction.js +40 -0
  47. package/dist/server/actions/switchOrganizationAction.js.map +1 -0
  48. package/dist/server/actions/updateUserProfileAction.d.ts +2 -8
  49. package/dist/server/actions/updateUserProfileAction.js +2 -2
  50. package/dist/server/actions/updateUserProfileAction.js.map +1 -1
  51. package/dist/utils/decorateConfigWithNextEnv.js +3 -1
  52. package/dist/utils/decorateConfigWithNextEnv.js.map +1 -1
  53. package/package.json +3 -11
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Organization } from '@asgardeo/node';
19
+ /**
20
+ * Server action to create an organization.
21
+ */
22
+ declare const switchOrganizationAction: (organization: Organization, sessionId: string) => Promise<{
23
+ success: boolean;
24
+ error: null;
25
+ data?: undefined;
26
+ } | {
27
+ success: boolean;
28
+ data: {
29
+ user: {};
30
+ };
31
+ error: string;
32
+ }>;
33
+ export default switchOrganizationAction;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ 'use server';
19
+ import AsgardeoNextClient from '../../AsgardeoNextClient';
20
+ /**
21
+ * Server action to create an organization.
22
+ */
23
+ const switchOrganizationAction = async (organization, sessionId) => {
24
+ try {
25
+ const client = AsgardeoNextClient.getInstance();
26
+ await client.switchOrganization(organization, sessionId);
27
+ return { success: true, error: null };
28
+ }
29
+ catch (error) {
30
+ return {
31
+ success: false,
32
+ data: {
33
+ user: {},
34
+ },
35
+ error: 'Failed to switch to organization',
36
+ };
37
+ }
38
+ };
39
+ export default switchOrganizationAction;
40
+ //# sourceMappingURL=switchOrganizationAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchOrganizationAction.js","sourceRoot":"","sources":["../../../src/server/actions/switchOrganizationAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAGb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,wBAAwB,GAAG,KAAK,EAAE,YAA0B,EAAE,SAAiB,EAAE,EAAE;IACvF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,MAAM,CAAC,kBAAkB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QACzD,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE,EAAE;aACT;YACD,KAAK,EAAE,kCAAkC;SAC1C,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -15,22 +15,16 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { User } from '@asgardeo/node';
18
+ import { UpdateMeProfileConfig, User } from '@asgardeo/node';
19
19
  /**
20
20
  * Server action to get the current user.
21
21
  * Returns the user profile if signed in.
22
22
  */
23
- declare const updateUserProfileAction: (payload: any, sessionId: string) => Promise<{
23
+ declare const updateUserProfileAction: (payload: UpdateMeProfileConfig, sessionId?: string) => Promise<{
24
24
  success: boolean;
25
25
  data: {
26
26
  user: User;
27
27
  };
28
- error: null;
29
- } | {
30
- success: boolean;
31
- data: {
32
- user: {};
33
- };
34
28
  error: string;
35
29
  }>;
36
30
  export default updateUserProfileAction;
@@ -25,7 +25,7 @@ const updateUserProfileAction = async (payload, sessionId) => {
25
25
  try {
26
26
  const client = AsgardeoNextClient.getInstance();
27
27
  const user = await client.updateUserProfile(payload, sessionId);
28
- return { success: true, data: { user }, error: null };
28
+ return { success: true, data: { user }, error: "" };
29
29
  }
30
30
  catch (error) {
31
31
  return {
@@ -33,7 +33,7 @@ const updateUserProfileAction = async (payload, sessionId) => {
33
33
  data: {
34
34
  user: {},
35
35
  },
36
- error: 'Failed to get user profile',
36
+ error: `Failed to get user profile: ${error instanceof Error ? error.message : String(error)}`,
37
37
  };
38
38
  }
39
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"updateUserProfileAction.js","sourceRoot":"","sources":["../../../src/server/actions/updateUserProfileAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAGb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,uBAAuB,GAAG,KAAK,EAAE,OAAY,EAAE,SAAiB,EAAE,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,IAAI,GAAS,MAAM,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACtE,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE,EAAE;aACT;YACD,KAAK,EAAE,4BAA4B;SACpC,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"updateUserProfileAction.js","sourceRoot":"","sources":["../../../src/server/actions/updateUserProfileAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAGb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,uBAAuB,GAAG,KAAK,EACnC,OAA8B,EAC9B,SAAkB,EAC8C,EAAE;IAClE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,IAAI,GAAS,MAAM,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACtE,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,EAAE,EAAE,EAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE,EAAE;aACT;YACD,KAAK,EAAE,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SAC/F,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -16,9 +16,11 @@
16
16
  * under the License.
17
17
  */
18
18
  const decorateConfigWithNextEnv = (config) => {
19
- const { baseUrl, clientId, clientSecret, signInUrl, signUpUrl, afterSignInUrl, afterSignOutUrl, ...rest } = config;
19
+ const { organizationHandle, applicationId, baseUrl, clientId, clientSecret, signInUrl, signUpUrl, afterSignInUrl, afterSignOutUrl, ...rest } = config;
20
20
  return {
21
21
  ...rest,
22
+ organizationHandle: organizationHandle || process.env['NEXT_PUBLIC_ASGARDEO_ORGANIZATION_HANDLE'],
23
+ applicationId: applicationId || process.env['NEXT_PUBLIC_ASGARDEO_APPLICATION_ID'],
22
24
  baseUrl: baseUrl || process.env['NEXT_PUBLIC_ASGARDEO_BASE_URL'],
23
25
  clientId: clientId || process.env['NEXT_PUBLIC_ASGARDEO_CLIENT_ID'],
24
26
  clientSecret: clientSecret || process.env['ASGARDEO_CLIENT_SECRET'],
@@ -1 +1 @@
1
- {"version":3,"file":"decorateConfigWithNextEnv.js","sourceRoot":"","sources":["../../src/utils/decorateConfigWithNextEnv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,MAAM,yBAAyB,GAAG,CAAC,MAA0B,EAAsB,EAAE;IACnF,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,IAAI,EAAC,GAAG,MAAM,CAAC;IAEjH,OAAO;QACL,GAAG,IAAI;QACP,OAAO,EAAE,OAAO,IAAK,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAY;QAC5E,QAAQ,EAAE,QAAQ,IAAK,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAY;QAC/E,YAAY,EAAE,YAAY,IAAK,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAY;QAC/E,cAAc,EAAE,cAAc,IAAK,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAY;QACnG,SAAS,EAAE,SAAS,IAAK,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAY;QACnF,eAAe,EAAE,eAAe,IAAK,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAY;QACtG,SAAS,EAAE,SAAS,IAAK,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAY;KACpF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"decorateConfigWithNextEnv.js","sourceRoot":"","sources":["../../src/utils/decorateConfigWithNextEnv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,MAAM,yBAAyB,GAAG,CAAC,MAA0B,EAAsB,EAAE;IACnF,MAAM,EAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,IAAI,EAAC,GAAG,MAAM,CAAC;IAEpJ,OAAO;QACL,GAAG,IAAI;QACP,kBAAkB,EAAE,kBAAkB,IAAK,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAY;QAC7G,aAAa,EAAE,aAAa,IAAK,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAY;QAC9F,OAAO,EAAE,OAAO,IAAK,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAY;QAC5E,QAAQ,EAAE,QAAQ,IAAK,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAY;QAC/E,YAAY,EAAE,YAAY,IAAK,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAY;QAC/E,cAAc,EAAE,cAAc,IAAK,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAY;QACnG,SAAS,EAAE,SAAS,IAAK,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAY;QACnF,eAAe,EAAE,eAAe,IAAK,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAY;QACtG,SAAS,EAAE,SAAS,IAAK,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAY;KACpF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgardeo/nextjs",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Next.js implementation of Asgardeo JavaScript SDK.",
5
5
  "keywords": [
6
6
  "asgardeo",
@@ -22,14 +22,6 @@
22
22
  ".": {
23
23
  "import": "./dist/index.js",
24
24
  "require": "./dist/cjs/index.js"
25
- },
26
- "./middleware": {
27
- "import": "./dist/middleware/index.js",
28
- "require": "./dist/cjs/middleware/index.js"
29
- },
30
- "./server": {
31
- "import": "./dist/server/index.js",
32
- "require": "./dist/cjs/server/index.js"
33
25
  }
34
26
  },
35
27
  "files": [
@@ -46,8 +38,8 @@
46
38
  "dependencies": {
47
39
  "@types/react": "^19.1.4",
48
40
  "tslib": "^2.8.1",
49
- "@asgardeo/node": "^0.0.3",
50
- "@asgardeo/react": "^0.5.3"
41
+ "@asgardeo/node": "^0.0.4",
42
+ "@asgardeo/react": "^0.5.4"
51
43
  },
52
44
  "devDependencies": {
53
45
  "@types/node": "^22.15.3",