@geekapps/auth-elements-nextjs 0.1.1 → 0.2.0
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/index.d.ts +160 -20
- package/dist/index.js +759 -755
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,132 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
|
|
4
4
|
type ElementSize = "sm" | "md" | "lg";
|
|
5
5
|
type ElementTone = "default" | "primary" | "danger" | "ghost";
|
|
6
|
+
type ConnectedAccount = {
|
|
7
|
+
id: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
isActive: boolean;
|
|
10
|
+
user: {
|
|
11
|
+
id?: string;
|
|
12
|
+
name: string | null;
|
|
13
|
+
email: string | null;
|
|
14
|
+
imageUrl: string | null;
|
|
15
|
+
phone?: string | null;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
type Organization = {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string | null;
|
|
22
|
+
slug: string;
|
|
23
|
+
domain: string | null;
|
|
24
|
+
imageUrl: string | null;
|
|
25
|
+
faviconUrl: string | null;
|
|
26
|
+
members?: Array<{
|
|
27
|
+
id: string;
|
|
28
|
+
user: {
|
|
29
|
+
name: string | null;
|
|
30
|
+
email: string | null;
|
|
31
|
+
imageUrl: string | null;
|
|
32
|
+
};
|
|
33
|
+
roleAssignments?: Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
roleDefinition?: {
|
|
36
|
+
name: string;
|
|
37
|
+
} | null;
|
|
38
|
+
customRole?: {
|
|
39
|
+
name: string;
|
|
40
|
+
} | null;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
type Permission = {
|
|
45
|
+
id: string;
|
|
46
|
+
key: string;
|
|
47
|
+
category: string | null;
|
|
48
|
+
};
|
|
49
|
+
type Role = {
|
|
50
|
+
id: string;
|
|
51
|
+
key: string;
|
|
52
|
+
name: string;
|
|
53
|
+
permissions: unknown[];
|
|
54
|
+
};
|
|
55
|
+
type UserSession = {
|
|
56
|
+
id: string;
|
|
57
|
+
deviceName: string | null;
|
|
58
|
+
ip: string | null;
|
|
59
|
+
expiresAt: string | Date;
|
|
60
|
+
};
|
|
61
|
+
type User = {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string | null;
|
|
64
|
+
email: string | null;
|
|
65
|
+
imageUrl: string | null;
|
|
66
|
+
phone?: string | null;
|
|
67
|
+
};
|
|
68
|
+
type AuthResult<T> = {
|
|
69
|
+
success: true;
|
|
70
|
+
data: T;
|
|
71
|
+
} | {
|
|
72
|
+
success: false;
|
|
73
|
+
error?: string;
|
|
74
|
+
};
|
|
75
|
+
type UseAuthHook = () => {
|
|
76
|
+
user: User | null;
|
|
77
|
+
signIn: (opts?: {
|
|
78
|
+
redirectTo?: string;
|
|
79
|
+
}) => Promise<void> | void;
|
|
80
|
+
signOut: () => Promise<void> | void;
|
|
81
|
+
signOutAll: () => Promise<void> | void;
|
|
82
|
+
accounts: ConnectedAccount[];
|
|
83
|
+
addAccount: (opts?: {
|
|
84
|
+
redirectTo?: string;
|
|
85
|
+
}) => Promise<void> | void;
|
|
86
|
+
isLoadingAccounts: boolean;
|
|
87
|
+
refreshAccounts: () => Promise<void>;
|
|
88
|
+
switchAccount: (id: string, opts?: {
|
|
89
|
+
redirectTo?: string;
|
|
90
|
+
}) => Promise<void>;
|
|
91
|
+
organizations: Organization[];
|
|
92
|
+
currentOrg: Organization | null;
|
|
93
|
+
currentOrgId?: string | null;
|
|
94
|
+
isLoadingOrganizations: boolean;
|
|
95
|
+
refreshOrganizations: () => Promise<void>;
|
|
96
|
+
setCurrentOrg: (id: string) => Promise<void>;
|
|
97
|
+
createOrganization: (input: {
|
|
98
|
+
name: string;
|
|
99
|
+
slug: string;
|
|
100
|
+
}) => Promise<AuthResult<Organization>>;
|
|
101
|
+
updateOrganization: (id: string, input: Partial<{
|
|
102
|
+
name: string;
|
|
103
|
+
slug: string;
|
|
104
|
+
description: string | null;
|
|
105
|
+
domain: string | null;
|
|
106
|
+
imageUrl: string | null;
|
|
107
|
+
faviconUrl: string | null;
|
|
108
|
+
}>) => Promise<AuthResult<Organization>>;
|
|
109
|
+
updateUser: (id: string, input: {
|
|
110
|
+
name?: string | null;
|
|
111
|
+
phone?: string | null;
|
|
112
|
+
imageUrl?: string | null;
|
|
113
|
+
}) => Promise<AuthResult<User>>;
|
|
114
|
+
listUserSessions: (params: {
|
|
115
|
+
userId?: string;
|
|
116
|
+
organizationId?: string;
|
|
117
|
+
}) => Promise<UserSession[]>;
|
|
118
|
+
revokeUserSession: (sessionId: string) => Promise<AuthResult<null>>;
|
|
119
|
+
listPermissions: (params?: {
|
|
120
|
+
applicationId?: string;
|
|
121
|
+
roleId?: string;
|
|
122
|
+
}) => Promise<Permission[]>;
|
|
123
|
+
listRoles: (params?: {
|
|
124
|
+
organizationId?: string;
|
|
125
|
+
applicationId?: string;
|
|
126
|
+
type?: string;
|
|
127
|
+
}) => Promise<{
|
|
128
|
+
systemRoles: Role[];
|
|
129
|
+
customRoles: Role[];
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
6
132
|
declare function Avatar({ src, name, size, className, }: {
|
|
7
133
|
src?: string | null;
|
|
8
134
|
name?: string | null;
|
|
@@ -17,24 +143,38 @@ declare function Modal({ open, onOpenChange, title, description, children, foote
|
|
|
17
143
|
children: ReactNode;
|
|
18
144
|
footer?: ReactNode;
|
|
19
145
|
}): react_jsx_runtime.JSX.Element | null;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
declare function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Creates auth UI components bound to the provided `useAuth` hook instance.
|
|
148
|
+
* This lets consumers supply their own auth-nextjs instance without requiring
|
|
149
|
+
* a separate installed copy inside auth-elements-nextjs.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* import { createAuthElements } from '@geekapps/auth-elements-nextjs'
|
|
153
|
+
* import { useAuth } from '@geekapps/auth-nextjs/client'
|
|
154
|
+
* export const { SignInButton, ProfileModal } = createAuthElements({ useAuth })
|
|
155
|
+
*/
|
|
156
|
+
declare function createAuthElements(hooks: {
|
|
157
|
+
useAuth: UseAuthHook;
|
|
158
|
+
}): {
|
|
159
|
+
SignInButton: ({ children, redirectTo, }: {
|
|
160
|
+
children?: ReactNode;
|
|
161
|
+
redirectTo?: string;
|
|
162
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
163
|
+
SignOutButton: ({ children }: {
|
|
164
|
+
children?: ReactNode;
|
|
165
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
166
|
+
AccountSwitcher: () => react_jsx_runtime.JSX.Element;
|
|
167
|
+
OrgSwitcher: () => react_jsx_runtime.JSX.Element;
|
|
168
|
+
UserButton: () => react_jsx_runtime.JSX.Element;
|
|
169
|
+
OrganizationButton: () => react_jsx_runtime.JSX.Element;
|
|
170
|
+
ProfileModal: ({ open, onOpenChange, }: {
|
|
171
|
+
open: boolean;
|
|
172
|
+
onOpenChange: (open: boolean) => void;
|
|
173
|
+
}) => react_jsx_runtime.JSX.Element | null;
|
|
174
|
+
ManageOrganizationModal: ({ open, onOpenChange, }: {
|
|
175
|
+
open: boolean;
|
|
176
|
+
onOpenChange: (open: boolean) => void;
|
|
177
|
+
}) => react_jsx_runtime.JSX.Element | null;
|
|
178
|
+
};
|
|
39
179
|
|
|
40
|
-
export {
|
|
180
|
+
export { Avatar, type ConnectedAccount, type ElementSize, type ElementTone, Modal, type Organization, type Permission, type Role, type UserSession, createAuthElements };
|