@asgardeo/nextjs 0.1.4 → 0.1.6
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.
- package/dist/client/components/presentation/CreateOrganization/CreateOrganization.d.ts +2 -2
- package/dist/client/components/presentation/CreateOrganization/CreateOrganization.js +11 -8
- package/dist/client/components/presentation/CreateOrganization/CreateOrganization.js.map +1 -1
- package/dist/client/contexts/Asgardeo/AsgardeoProvider.d.ts +16 -15
- package/dist/client/contexts/Asgardeo/AsgardeoProvider.js +3 -3
- package/dist/client/contexts/Asgardeo/AsgardeoProvider.js.map +1 -1
- package/dist/server/AsgardeoProvider.d.ts +1 -1
- package/dist/server/AsgardeoProvider.js +15 -27
- package/dist/server/AsgardeoProvider.js.map +1 -1
- package/dist/server/actions/{createOrganizationAction.d.ts → createOrganization.d.ts} +2 -16
- package/dist/server/actions/{createOrganizationAction.js → createOrganization.js} +7 -12
- package/dist/server/actions/createOrganization.js.map +1 -0
- package/dist/server/actions/getAllOrganizations.js +2 -1
- package/dist/server/actions/getAllOrganizations.js.map +1 -1
- package/dist/server/actions/switchOrganization.d.ts +1 -1
- package/dist/server/actions/switchOrganization.js +10 -3
- package/dist/server/actions/switchOrganization.js.map +1 -1
- package/package.json +2 -2
- package/dist/server/actions/createOrganizationAction.js.map +0 -1
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { FC, ReactElement } from 'react';
|
|
19
|
-
import { BaseCreateOrganizationProps } from '@asgardeo/react';
|
|
20
18
|
import { CreateOrganizationPayload } from '@asgardeo/node';
|
|
19
|
+
import { BaseCreateOrganizationProps } from '@asgardeo/react';
|
|
20
|
+
import { FC, ReactElement } from 'react';
|
|
21
21
|
/**
|
|
22
22
|
* Props interface for the CreateOrganization component.
|
|
23
23
|
*/
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
'use client';
|
|
19
19
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
-
import {
|
|
20
|
+
import { AsgardeoRuntimeError } from '@asgardeo/node';
|
|
21
21
|
import { BaseCreateOrganization, useOrganization } from '@asgardeo/react';
|
|
22
|
-
import
|
|
23
|
-
import createOrganizationAction from '../../../../server/actions/createOrganizationAction';
|
|
22
|
+
import { useState } from 'react';
|
|
24
23
|
import getSessionId from '../../../../server/actions/getSessionId';
|
|
24
|
+
import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
|
|
25
25
|
/**
|
|
26
26
|
* CreateOrganization component that provides organization creation functionality.
|
|
27
27
|
* This component automatically integrates with the Asgardeo and Organization contexts.
|
|
@@ -56,7 +56,7 @@ import getSessionId from '../../../../server/actions/getSessionId';
|
|
|
56
56
|
*/
|
|
57
57
|
export const CreateOrganization = ({ onCreateOrganization, fallback = _jsx(_Fragment, {}), onSuccess, defaultParentId, ...props }) => {
|
|
58
58
|
const { isSignedIn, baseUrl } = useAsgardeo();
|
|
59
|
-
const { currentOrganization, revalidateMyOrganizations } = useOrganization();
|
|
59
|
+
const { currentOrganization, revalidateMyOrganizations, createOrganization } = useOrganization();
|
|
60
60
|
const [loading, setLoading] = useState(false);
|
|
61
61
|
const [error, setError] = useState(null);
|
|
62
62
|
// Don't render if not authenticated
|
|
@@ -74,21 +74,24 @@ export const CreateOrganization = ({ onCreateOrganization, fallback = _jsx(_Frag
|
|
|
74
74
|
try {
|
|
75
75
|
let result;
|
|
76
76
|
if (onCreateOrganization) {
|
|
77
|
-
// Use the provided custom creation function
|
|
78
77
|
result = await onCreateOrganization(payload);
|
|
79
78
|
}
|
|
80
79
|
else {
|
|
81
|
-
// Use the default API
|
|
82
80
|
if (!baseUrl) {
|
|
83
81
|
throw new Error('Base URL is required for organization creation');
|
|
84
82
|
}
|
|
85
|
-
|
|
83
|
+
if (!createOrganization) {
|
|
84
|
+
throw new AsgardeoRuntimeError(`createOrganization function is not available.`, 'CreateOrganization-handleSubmit-RuntimeError-001', 'nextjs', 'The createOrganization function must be provided by the Organization context.');
|
|
85
|
+
}
|
|
86
|
+
result = await createOrganization({
|
|
86
87
|
...payload,
|
|
87
88
|
parentId,
|
|
88
89
|
}, (await getSessionId()));
|
|
89
90
|
}
|
|
90
91
|
// Refresh organizations list to include the new organization
|
|
91
|
-
|
|
92
|
+
if (revalidateMyOrganizations) {
|
|
93
|
+
await revalidateMyOrganizations();
|
|
94
|
+
}
|
|
92
95
|
// Call success callback if provided
|
|
93
96
|
if (onSuccess) {
|
|
94
97
|
onSuccess(result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateOrganization.js","sourceRoot":"","sources":["../../../../../src/client/components/presentation/CreateOrganization/CreateOrganization.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,
|
|
1
|
+
{"version":3,"file":"CreateOrganization.js","sourceRoot":"","sources":["../../../../../src/client/components/presentation/CreateOrganization/CreateOrganization.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAA4B,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAC,sBAAsB,EAA+B,eAAe,EAAC,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAmB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACjD,OAAO,YAAY,MAAM,yCAAyC,CAAC;AACnE,OAAO,WAAW,MAAM,wCAAwC,CAAC;AAgBjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgC,CAAC,EAC9D,oBAAoB,EACpB,QAAQ,GAAG,mBAAK,EAChB,SAAS,EACT,eAAe,EACf,GAAG,KAAK,EACgB,EAAgB,EAAE;IAC1C,MAAM,EAAC,UAAU,EAAE,OAAO,EAAC,GAAG,WAAW,EAAE,CA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,CAAC;gBAC9B,MAAM,yBAAyB,EAAE,CAAC;YACpC,CAAC;YAED,oCAAoC;YACpC,IAAI,SAAS,EAAE,CAAC;gBACd,SAAS,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAAC,OAAO,WAAW,EAAE,CAAC;YACrB,MAAM,YAAY,GAAW,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC;YAClH,QAAQ,CAAC,YAAY,CAAC,CAAC;YACvB,MAAM,WAAW,CAAC,CAAC,sCAAsC;QAC3D,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,sBAAsB,IACrB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,QAAQ,EACzB,SAAS,EAAE,SAAS,KAChB,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AllOrganizationsApiResponse, Organization, UpdateMeProfileConfig, User, UserProfile, BrandingPreference } from '@asgardeo/node';
|
|
18
|
+
import { AllOrganizationsApiResponse, Organization, UpdateMeProfileConfig, User, UserProfile, BrandingPreference, TokenResponse, CreateOrganizationPayload } from '@asgardeo/node';
|
|
19
19
|
import { AsgardeoProviderProps } from '@asgardeo/react';
|
|
20
20
|
import { FC, PropsWithChildren } from 'react';
|
|
21
21
|
import { AsgardeoContextProps } from './AsgardeoContext';
|
|
@@ -23,32 +23,33 @@ import { AsgardeoContextProps } from './AsgardeoContext';
|
|
|
23
23
|
* Props interface of {@link AsgardeoClientProvider}
|
|
24
24
|
*/
|
|
25
25
|
export type AsgardeoClientProviderProps = Partial<Omit<AsgardeoProviderProps, 'baseUrl' | 'clientId'>> & Pick<AsgardeoProviderProps, 'baseUrl' | 'clientId'> & {
|
|
26
|
-
signOut: AsgardeoContextProps['signOut'];
|
|
27
|
-
signIn: AsgardeoContextProps['signIn'];
|
|
28
|
-
signUp: AsgardeoContextProps['signUp'];
|
|
29
26
|
applicationId: AsgardeoContextProps['applicationId'];
|
|
30
|
-
|
|
27
|
+
brandingPreference?: BrandingPreference | null;
|
|
28
|
+
createOrganization: (payload: CreateOrganizationPayload, sessionId: string) => Promise<Organization>;
|
|
29
|
+
currentOrganization: Organization;
|
|
30
|
+
getAllOrganizations: (options?: any, sessionId?: string) => Promise<AllOrganizationsApiResponse>;
|
|
31
31
|
handleOAuthCallback: (code: string, state: string, sessionState?: string) => Promise<{
|
|
32
|
-
success: boolean;
|
|
33
32
|
error?: string;
|
|
34
33
|
redirectUrl?: string;
|
|
34
|
+
success: boolean;
|
|
35
35
|
}>;
|
|
36
36
|
isSignedIn: boolean;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
myOrganizations: Organization[];
|
|
38
|
+
organizationHandle: AsgardeoContextProps['organizationHandle'];
|
|
39
|
+
revalidateMyOrganizations?: (sessionId?: string) => Promise<Organization[]>;
|
|
40
|
+
signIn: AsgardeoContextProps['signIn'];
|
|
41
|
+
signOut: AsgardeoContextProps['signOut'];
|
|
42
|
+
signUp: AsgardeoContextProps['signUp'];
|
|
43
|
+
switchOrganization: (organization: Organization, sessionId?: string) => Promise<TokenResponse | Response>;
|
|
40
44
|
updateProfile: (requestConfig: UpdateMeProfileConfig, sessionId?: string) => Promise<{
|
|
41
|
-
success: boolean;
|
|
42
45
|
data: {
|
|
43
46
|
user: User;
|
|
44
47
|
};
|
|
45
48
|
error: string;
|
|
49
|
+
success: boolean;
|
|
46
50
|
}>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
revalidateMyOrganizations?: (sessionId?: string) => Promise<Organization[]>;
|
|
50
|
-
brandingPreference?: BrandingPreference | null;
|
|
51
|
-
switchOrganization: (organization: Organization, sessionId?: string) => Promise<void>;
|
|
51
|
+
user: User | null;
|
|
52
|
+
userProfile: UserProfile;
|
|
52
53
|
};
|
|
53
54
|
declare const AsgardeoClientProvider: FC<PropsWithChildren<AsgardeoClientProviderProps>>;
|
|
54
55
|
export default AsgardeoClientProvider;
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
import { generateFlattenedUserProfile, } from '@asgardeo/node';
|
|
21
21
|
import { I18nProvider, FlowProvider, UserProvider, ThemeProvider, OrganizationProvider, BrandingProvider, } from '@asgardeo/react';
|
|
22
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
23
22
|
import { useRouter, useSearchParams } from 'next/navigation';
|
|
23
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
24
24
|
import AsgardeoContext from './AsgardeoContext';
|
|
25
|
-
const AsgardeoClientProvider = ({ baseUrl, children, signIn, signOut, signUp, handleOAuthCallback, preferences, isSignedIn, signInUrl, signUpUrl, user: _user, userProfile: _userProfile, currentOrganization, updateProfile, applicationId, organizationHandle, myOrganizations, revalidateMyOrganizations, getAllOrganizations, switchOrganization, brandingPreference, }) => {
|
|
25
|
+
const AsgardeoClientProvider = ({ baseUrl, children, signIn, signOut, signUp, handleOAuthCallback, createOrganization, preferences, isSignedIn, signInUrl, signUpUrl, user: _user, userProfile: _userProfile, currentOrganization, updateProfile, applicationId, organizationHandle, myOrganizations, revalidateMyOrganizations, getAllOrganizations, switchOrganization, brandingPreference, }) => {
|
|
26
26
|
const reRenderCheckRef = useRef(false);
|
|
27
27
|
const router = useRouter();
|
|
28
28
|
const searchParams = useSearchParams();
|
|
@@ -174,7 +174,7 @@ const AsgardeoClientProvider = ({ baseUrl, children, signIn, signOut, signUp, ha
|
|
|
174
174
|
flattenedProfile: generateFlattenedUserProfile(payload, prev?.schemas),
|
|
175
175
|
}));
|
|
176
176
|
};
|
|
177
|
-
return (_jsx(AsgardeoContext.Provider, { value: contextValue, children: _jsx(I18nProvider, { preferences: preferences?.i18n, children: _jsx(BrandingProvider, { brandingPreference: brandingPreference, children: _jsx(ThemeProvider, { theme: preferences?.theme?.overrides, mode: isDarkMode ? 'dark' : 'light', children: _jsx(FlowProvider, { children: _jsx(UserProvider, { profile: userProfile, onUpdateProfile: handleProfileUpdate, updateProfile: updateProfile, children: _jsx(OrganizationProvider, { getAllOrganizations: getAllOrganizations, myOrganizations: myOrganizations, currentOrganization: currentOrganization, onOrganizationSwitch: switchOrganization, revalidateMyOrganizations: revalidateMyOrganizations, children: children }) }) }) }) }) }) }));
|
|
177
|
+
return (_jsx(AsgardeoContext.Provider, { value: contextValue, children: _jsx(I18nProvider, { preferences: preferences?.i18n, children: _jsx(BrandingProvider, { brandingPreference: brandingPreference, children: _jsx(ThemeProvider, { theme: preferences?.theme?.overrides, mode: isDarkMode ? 'dark' : 'light', children: _jsx(FlowProvider, { children: _jsx(UserProvider, { profile: userProfile, onUpdateProfile: handleProfileUpdate, updateProfile: updateProfile, children: _jsx(OrganizationProvider, { createOrganization: createOrganization, getAllOrganizations: getAllOrganizations, myOrganizations: myOrganizations, currentOrganization: currentOrganization, onOrganizationSwitch: switchOrganization, revalidateMyOrganizations: revalidateMyOrganizations, children: children }) }) }) }) }) }) }));
|
|
178
178
|
};
|
|
179
179
|
export default AsgardeoClientProvider;
|
|
180
180
|
//# sourceMappingURL=AsgardeoProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsgardeoProvider.js","sourceRoot":"","sources":["../../../../src/client/contexts/Asgardeo/AsgardeoProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,
|
|
1
|
+
{"version":3,"file":"AsgardeoProvider.js","sourceRoot":"","sources":["../../../../src/client/contexts/Asgardeo/AsgardeoProvider.tsx"],"names":[],"m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ChG,CAAC;IAEF,MAAM,mBAAmB,GAAG,CAAC,OAAa,EAAQ,EAAE;QAClD,OAAO,CAAC,OAAO,CAAC,CAAC;QACjB,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtB,GAAG,IAAI;YACP,OAAO,EAAE,OAAO;YAChB,gBAAgB,EAAE,4BAA4B,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC;SACvE,CAAC,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC3C,KAAC,YAAY,IAAC,WAAW,EAAE,WAAW,EAAE,IAAI,YAC1C,KAAC,gBAAgB,IAAC,kBAAkB,EAAE,kBAAkB,YACtD,KAAC,aAAa,IAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,YACtF,KAAC,YAAY,cACX,KAAC,YAAY,IAAC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,YACpG,KAAC,oBAAoB,IACnB,kBAAkB,EAAE,kBAAkB,EACtC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,oBAAoB,EAAE,kBAAyB,EAC/C,yBAAyB,EAAE,yBAAgC,YAE1D,QAAQ,GACY,GACV,GACF,GACD,GACC,GACN,GACU,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { FC, PropsWithChildren } from 'react';
|
|
19
18
|
import { AsgardeoProviderProps } from '@asgardeo/react';
|
|
19
|
+
import { FC, PropsWithChildren } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Props interface of {@link AsgardeoServerProvider}
|
|
22
22
|
*/
|
|
@@ -17,23 +17,24 @@
|
|
|
17
17
|
*/
|
|
18
18
|
'use server';
|
|
19
19
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
-
import { AsgardeoRuntimeError
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import getUserAction from './actions/getUserAction';
|
|
20
|
+
import { AsgardeoRuntimeError } from '@asgardeo/node';
|
|
21
|
+
import createOrganization from './actions/createOrganization';
|
|
22
|
+
import getAllOrganizations from './actions/getAllOrganizations';
|
|
23
|
+
import getBrandingPreference from './actions/getBrandingPreference';
|
|
24
|
+
import getCurrentOrganizationAction from './actions/getCurrentOrganizationAction';
|
|
25
|
+
import getMyOrganizations from './actions/getMyOrganizations';
|
|
27
26
|
import getSessionId from './actions/getSessionId';
|
|
27
|
+
import getUserAction from './actions/getUserAction';
|
|
28
28
|
import getUserProfileAction from './actions/getUserProfileAction';
|
|
29
|
-
import signUpAction from './actions/signUpAction';
|
|
30
29
|
import handleOAuthCallbackAction from './actions/handleOAuthCallbackAction';
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import getBrandingPreference from './actions/getBrandingPreference';
|
|
30
|
+
import isSignedIn from './actions/isSignedIn';
|
|
31
|
+
import signInAction from './actions/signInAction';
|
|
32
|
+
import signOutAction from './actions/signOutAction';
|
|
33
|
+
import signUpAction from './actions/signUpAction';
|
|
36
34
|
import switchOrganization from './actions/switchOrganization';
|
|
35
|
+
import updateUserProfileAction from './actions/updateUserProfileAction';
|
|
36
|
+
import AsgardeoNextClient from '../AsgardeoNextClient';
|
|
37
|
+
import AsgardeoClientProvider from '../client/contexts/Asgardeo/AsgardeoProvider';
|
|
37
38
|
/**
|
|
38
39
|
* Server-side provider component for Asgardeo authentication.
|
|
39
40
|
* Wraps the client-side provider and handles server-side authentication logic.
|
|
@@ -109,20 +110,7 @@ const AsgardeoServerProvider = async ({ children, afterSignInUrl, afterSignOutUr
|
|
|
109
110
|
console.warn('[AsgardeoServerProvider] Failed to fetch branding preference:', error);
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
'use server';
|
|
114
|
-
return await getAllOrganizations(options, sessionId);
|
|
115
|
-
};
|
|
116
|
-
const handleSwitchOrganization = async (organization, _sessionId) => {
|
|
117
|
-
'use server';
|
|
118
|
-
await switchOrganization(organization, sessionId);
|
|
119
|
-
// After switching organization, we need to refresh the page to get updated session data
|
|
120
|
-
// This is because server components don't maintain state between function calls
|
|
121
|
-
const { revalidatePath } = await import('next/cache');
|
|
122
|
-
// Revalidate the current path to refresh the component with new data
|
|
123
|
-
revalidatePath('/');
|
|
124
|
-
};
|
|
125
|
-
return (_jsx(AsgardeoClientProvider, { organizationHandle: config?.organizationHandle, applicationId: config?.applicationId, baseUrl: config?.baseUrl, signIn: signInAction, signOut: signOutAction, signUp: signUpAction, handleOAuthCallback: handleOAuthCallbackAction, signInUrl: config?.signInUrl, signUpUrl: config?.signUpUrl, preferences: config?.preferences, clientId: config?.clientId, user: user, currentOrganization: currentOrganization, userProfile: userProfile, updateProfile: updateUserProfileAction, isSignedIn: _isSignedIn, myOrganizations: myOrganizations, getAllOrganizations: handleGetAllOrganizations, switchOrganization: handleSwitchOrganization, brandingPreference: brandingPreference, children: children }));
|
|
113
|
+
return (_jsx(AsgardeoClientProvider, { organizationHandle: config?.organizationHandle, applicationId: config?.applicationId, baseUrl: config?.baseUrl, signIn: signInAction, signOut: signOutAction, signUp: signUpAction, handleOAuthCallback: handleOAuthCallbackAction, signInUrl: config?.signInUrl, signUpUrl: config?.signUpUrl, preferences: config?.preferences, clientId: config?.clientId, user: user, currentOrganization: currentOrganization, userProfile: userProfile, updateProfile: updateUserProfileAction, isSignedIn: _isSignedIn, myOrganizations: myOrganizations, getAllOrganizations: getAllOrganizations, switchOrganization: switchOrganization, brandingPreference: brandingPreference, createOrganization: createOrganization, children: children }));
|
|
126
114
|
};
|
|
127
115
|
export default AsgardeoServerProvider;
|
|
128
116
|
//# sourceMappingURL=AsgardeoProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsgardeoProvider.js","sourceRoot":"","sources":["../../src/server/AsgardeoProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;
|
|
1
|
+
{"version":3,"file":"AsgardeoProvider.js","sourceRoot":"","sources":["../../src/server/AsgardeoProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAqB,oBAAoB,EAAkC,MAAM,gBAAgB,CAAC;AAGzG,OAAO,kBAAkB,MAAM,8BAA8B,CAAC;AAC9D,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,qBAAqB,MAAM,iCAAiC,CAAC;AACpE,OAAO,4BAA4B,MAAM,wCAAwC,CAAC;AAClF,OAAO,kBAAkB,MAAM,8BAA8B,CAAC;AAC9D,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,oBAAoB,MAAM,gCAAgC,CAAC;AAClE,OAAO,yBAAyB,MAAM,qCAAqC,CAAC;AAC5E,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,kBAAkB,MAAM,8BAA8B,CAAC;AAC9D,OAAO,uBAAuB,MAAM,mCAAmC,CAAC;AACxE,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,sBAAsB,MAAM,8CAA8C,CAAC;AAUlF;;;;;;;;;;;;;;;GAeG;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,kBAAkB,EAC9C,aAAa,EAAE,MAAM,EAAE,aAAa,EACpC,OAAO,EAAE,MAAM,EAAE,OAAO,EACxB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,YAAY,EACpB,mBAAmB,EAAE,yBAAyB,EAC9C,SAAS,EAAE,MAAM,EAAE,SAAS,EAC5B,SAAS,EAAE,MAAM,EAAE,SAAS,EAC5B,WAAW,EAAE,MAAM,EAAE,WAAW,EAChC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAC1B,IAAI,EAAE,IAAI,EACV,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,uBAAuB,EACtC,UAAU,EAAE,WAAW,EACvB,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,kBAAkB,EACtC,kBAAkB,EAAE,kBAAkB,EACtC,kBAAkB,EAAE,kBAAkB,YAErC,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -19,19 +19,5 @@ import { CreateOrganizationPayload, Organization } from '@asgardeo/node';
|
|
|
19
19
|
/**
|
|
20
20
|
* Server action to create an organization.
|
|
21
21
|
*/
|
|
22
|
-
declare const
|
|
23
|
-
|
|
24
|
-
data: {
|
|
25
|
-
organization: Organization;
|
|
26
|
-
user?: undefined;
|
|
27
|
-
};
|
|
28
|
-
error: null;
|
|
29
|
-
} | {
|
|
30
|
-
success: boolean;
|
|
31
|
-
data: {
|
|
32
|
-
user: {};
|
|
33
|
-
organization?: undefined;
|
|
34
|
-
};
|
|
35
|
-
error: string;
|
|
36
|
-
}>;
|
|
37
|
-
export default createOrganizationAction;
|
|
22
|
+
declare const createOrganization: (payload: CreateOrganizationPayload, sessionId: string) => Promise<Organization>;
|
|
23
|
+
export default createOrganization;
|
|
@@ -16,25 +16,20 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
'use server';
|
|
19
|
+
import { AsgardeoAPIError } from '@asgardeo/node';
|
|
20
|
+
import getSessionId from './getSessionId';
|
|
19
21
|
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
20
22
|
/**
|
|
21
23
|
* Server action to create an organization.
|
|
22
24
|
*/
|
|
23
|
-
const
|
|
25
|
+
const createOrganization = async (payload, sessionId) => {
|
|
24
26
|
try {
|
|
25
27
|
const client = AsgardeoNextClient.getInstance();
|
|
26
|
-
|
|
27
|
-
return { success: true, data: { organization }, error: null };
|
|
28
|
+
return await client.createOrganization(payload, sessionId ?? (await getSessionId()));
|
|
28
29
|
}
|
|
29
30
|
catch (error) {
|
|
30
|
-
|
|
31
|
-
success: false,
|
|
32
|
-
data: {
|
|
33
|
-
user: {},
|
|
34
|
-
},
|
|
35
|
-
error: 'Failed to create organization',
|
|
36
|
-
};
|
|
31
|
+
throw new AsgardeoAPIError(`Failed to create the organization: ${error instanceof Error ? error.message : String(error)}`, 'createOrganization-ServerActionError-001', 'nextjs', error instanceof AsgardeoAPIError ? error.statusCode : undefined);
|
|
37
32
|
}
|
|
38
33
|
};
|
|
39
|
-
export default
|
|
40
|
-
//# sourceMappingURL=
|
|
34
|
+
export default createOrganization;
|
|
35
|
+
//# sourceMappingURL=createOrganization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOrganization.js","sourceRoot":"","sources":["../../../src/server/actions/createOrganization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAA0C,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AACzF,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAAkC,EAAE,SAAiB,EAAyB,EAAE;IAChH,IAAI,CAAC;QACH,MAAM,MAAM,GAAuB,kBAAkB,CAAC,WAAW,EAAE,CAAC;QACpE,OAAO,MAAM,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS,IAAK,CAAC,MAAM,YAAY,EAAE,CAAY,CAAC,CAAC;IACnG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,gBAAgB,CACxB,sCAAsC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC9F,0CAA0C,EAC1C,QAAQ,EACR,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CACjE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
'use server';
|
|
19
19
|
import { AsgardeoAPIError } from '@asgardeo/node';
|
|
20
|
+
import getSessionId from './getSessionId';
|
|
20
21
|
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
21
22
|
/**
|
|
22
23
|
* Server action to get organizations.
|
|
@@ -24,7 +25,7 @@ import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
|
24
25
|
const getAllOrganizations = async (options, sessionId) => {
|
|
25
26
|
try {
|
|
26
27
|
const client = AsgardeoNextClient.getInstance();
|
|
27
|
-
return client.getAllOrganizations(options, sessionId);
|
|
28
|
+
return await client.getAllOrganizations(options, sessionId ?? (await getSessionId()));
|
|
28
29
|
}
|
|
29
30
|
catch (error) {
|
|
30
31
|
throw new AsgardeoAPIError(`Failed to get all the organizations for the user: ${error instanceof Error ? error.message : String(error)}`, 'getAllOrganizations-ServerActionError-001', 'nextjs', error instanceof AsgardeoAPIError ? error.statusCode : undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAllOrganizations.js","sourceRoot":"","sources":["../../../src/server/actions/getAllOrganizations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAA8B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"getAllOrganizations.js","sourceRoot":"","sources":["../../../src/server/actions/getAllOrganizations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAA8B,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,mBAAmB,GAAG,KAAK,EAC/B,OAAa,EACb,SAA8B,EACQ,EAAE;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,GAAuB,kBAAkB,CAAC,WAAW,EAAE,CAAC;QACpE,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,SAAS,IAAK,CAAC,MAAM,YAAY,EAAE,CAAY,CAAC,CAAC;IACpG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,gBAAgB,CACxB,qDAAqD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC7G,2CAA2C,EAC3C,QAAQ,EACR,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CACjE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -19,5 +19,5 @@ import { Organization, TokenResponse } from '@asgardeo/node';
|
|
|
19
19
|
/**
|
|
20
20
|
* Server action to switch organization.
|
|
21
21
|
*/
|
|
22
|
-
declare const switchOrganization: (organization: Organization, sessionId: string) => Promise<TokenResponse | Response>;
|
|
22
|
+
declare const switchOrganization: (organization: Organization, sessionId: string | undefined) => Promise<TokenResponse | Response>;
|
|
23
23
|
export default switchOrganization;
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
'use server';
|
|
19
|
-
import { AsgardeoAPIError
|
|
19
|
+
import { AsgardeoAPIError } from '@asgardeo/node';
|
|
20
|
+
import getSessionId from './getSessionId';
|
|
20
21
|
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
21
22
|
/**
|
|
22
23
|
* Server action to switch organization.
|
|
@@ -24,10 +25,16 @@ import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
|
24
25
|
const switchOrganization = async (organization, sessionId) => {
|
|
25
26
|
try {
|
|
26
27
|
const client = AsgardeoNextClient.getInstance();
|
|
27
|
-
|
|
28
|
+
const response = await client.switchOrganization(organization, sessionId ?? (await getSessionId()));
|
|
29
|
+
// After switching organization, we need to refresh the page to get updated session data
|
|
30
|
+
// This is because server components don't maintain state between function calls
|
|
31
|
+
const { revalidatePath } = await import('next/cache');
|
|
32
|
+
// Revalidate the current path to refresh the component with new data
|
|
33
|
+
revalidatePath('/');
|
|
34
|
+
return response;
|
|
28
35
|
}
|
|
29
36
|
catch (error) {
|
|
30
|
-
throw new AsgardeoAPIError(`Failed to switch the organizations: ${error instanceof
|
|
37
|
+
throw new AsgardeoAPIError(`Failed to switch the organizations: ${error instanceof Error ? error.message : String(error)}`, 'switchOrganization-ServerActionError-001', 'nextjs', error instanceof AsgardeoAPIError ? error.statusCode : undefined);
|
|
31
38
|
}
|
|
32
39
|
};
|
|
33
40
|
export default switchOrganization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchOrganization.js","sourceRoot":"","sources":["../../../src/server/actions/switchOrganization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAAe,gBAAgB,
|
|
1
|
+
{"version":3,"file":"switchOrganization.js","sourceRoot":"","sources":["../../../src/server/actions/switchOrganization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAAe,gBAAgB,EAAgB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,kBAAkB,GAAG,KAAK,EAC9B,YAA0B,EAC1B,SAA6B,EACM,EAAE;IACrC,IAAI,CAAC;QACH,MAAM,MAAM,GAAuB,kBAAkB,CAAC,WAAW,EAAE,CAAC;QACpE,MAAM,QAAQ,GAA6B,MAAM,MAAM,CAAC,kBAAkB,CACxE,YAAY,EACZ,SAAS,IAAK,CAAC,MAAM,YAAY,EAAE,CAAY,CAChD,CAAC;QAEF,wFAAwF;QACxF,gFAAgF;QAChF,MAAM,EAAC,cAAc,EAAC,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QAEpD,qEAAqE;QACrE,cAAc,CAAC,GAAG,CAAC,CAAC;QAEpB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,gBAAgB,CACxB,uCAAuC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC/F,0CAA0C,EAC1C,QAAQ,EACR,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CACjE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/nextjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Next.js implementation of Asgardeo JavaScript SDK.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"asgardeo",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/react": "^19.1.4",
|
|
40
40
|
"tslib": "^2.8.1",
|
|
41
41
|
"@asgardeo/node": "^0.0.5",
|
|
42
|
-
"@asgardeo/react": "^0.5.
|
|
42
|
+
"@asgardeo/react": "^0.5.7"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.15.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createOrganizationAction.js","sourceRoot":"","sources":["../../../src/server/actions/createOrganizationAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAGb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,wBAAwB,GAAG,KAAK,EAAE,OAAkC,EAAE,SAAiB,EAAE,EAAE;IAC/F,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,YAAY,GAAiB,MAAM,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACvF,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,YAAY,EAAC,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IAC5D,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;SACvC,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|