Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions examples/nextjs-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"next": "^14.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@ssojet/ssokit-core": "workspace:*",
"@ssojet/ssokit-react": "workspace:*",
"@ssojet/ssokit-next": "workspace:*",
"@ssojet/ssokit-team": "workspace:*",
"@ssojet/ssokit-webhooks": "workspace:*",
"@ssojet/ssokit-css": "workspace:*",
"@ssojet/ssokit-core": "0.1.0",
"@ssojet/ssokit-react": "0.1.0",
"@ssojet/ssokit-next": "0.1.0",
"@ssojet/ssokit-team": "0.1.0",
"@ssojet/ssokit-webhooks": "0.1.0",
"@ssojet/ssokit-css": "0.1.0",
"next-auth": "^4.24.0",
"openid-client": "^5.6.1",
"jose": "^5.1.0",
Expand All @@ -38,4 +38,4 @@
"engines": {
"node": ">=18.0.0"
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build": "turbo run build",
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"prepare-npm": "node prepare-npm.js",
"format": "prettier --write \"**/*.{ts,tsx,md,json}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,md,json}\"",
"test": "turbo run test",
Expand Down
16 changes: 12 additions & 4 deletions packages/ssokit-next/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"name": "@ssojet/ssokit-next",
"name": "@ssojet/ssokit-next",
"version": "0.1.0",
"description": "Next.js App Router helpers and route handlers for SSOJet AuthKit",
"keywords": ["ssojet", "authkit", "nextjs", "app-router"],
"keywords": [
"ssojet",
"authkit",
"nextjs",
"app-router"
],
"homepage": "https://github.com/ssojet/ssojet-authkit#readme",
"repository": {
"type": "git",
Expand All @@ -24,7 +29,10 @@
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": ["dist", "README.md"],
"files": [
"dist",
"README.md"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
Expand All @@ -33,7 +41,7 @@
"clean": "rm -rf dist .turbo"
},
"dependencies": {
"@ssojet/ssokit-core": "workspace:*"
"@ssojet/ssokit-core": "0.1.0"
},
"peerDependencies": {
"next": "^14.0.0 || ^15.0.0"
Expand Down
2 changes: 0 additions & 2 deletions packages/ssokit-next/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export class SSOJetClient {

// Members
async listMembers(orgId: string, params?: Record<string, string>) {
// console.log("=== ssojet");
const query = params ? `?${new URLSearchParams(params).toString()}` : '';
return this.request(`/api/v1/auth/tenants/${orgId}/users${query}`);
}
Expand Down Expand Up @@ -293,7 +292,6 @@ export class SSOJetClient {

// Roles
async listRoles() {
//console.log('==== Listing roles from SSOJetClient');
return this.request(`/api/v1/auth/roles`);
}

Expand Down
16 changes: 12 additions & 4 deletions packages/ssokit-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"name": "@ssojet/ssokit-react",
"version": "0.1.0",
"description": "React hooks and providers for SSOJet AuthKit",
"keywords": ["ssojet", "authkit", "react", "hooks"],
"keywords": [
"ssojet",
"authkit",
"react",
"hooks"
],
"homepage": "https://github.com/ssojet/ssojet-authkit#readme",
"repository": {
"type": "git",
Expand All @@ -20,7 +25,10 @@
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": ["dist", "README.md"],
"files": [
"dist",
"README.md"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
Expand All @@ -30,8 +38,8 @@
"clean": "rm -rf dist .turbo"
},
"dependencies": {
"@ssojet/ssokit-core": "workspace:*",
"@ssojet/ssokit-css": "workspace:*"
"@ssojet/ssokit-core": "0.1.0",
"@ssojet/ssokit-css": "0.1.0"
},
"peerDependencies": {
"react": "^18.0.0"
Expand Down
10 changes: 5 additions & 5 deletions packages/ssokit-team/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ssojet/ssokit-team",
"name": "@ssojet/ssokit-team",
"version": "0.1.0",
"description": "Drop-in TeamManager widget for SSOJet AuthKit",
"type": "module",
Expand Down Expand Up @@ -27,10 +27,10 @@
"react-dom": "^18.0.0"
},
"dependencies": {
"@ssojet/ssokit-core": "workspace:*",
"@ssojet/ssokit-css": "workspace:*",
"@ssojet/ssokit-next": "workspace:*",
"@ssojet/ssokit-react": "workspace:*"
"@ssojet/ssokit-core": "0.1.0",
"@ssojet/ssokit-css": "0.1.0",
"@ssojet/ssokit-next": "0.1.0",
"@ssojet/ssokit-react": "0.1.0"
},
"devDependencies": {
"@types/react": "^18.2.47",
Expand Down
43 changes: 21 additions & 22 deletions packages/ssokit-team/src/TeamManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ export function TeamManager({
if (managerRoles && managerRoles.length > 0) {
return managerRoles;
}

// Check environment variable
const envRoles = typeof window !== 'undefined'
const envRoles = typeof window !== 'undefined'
? process.env.NEXT_PUBLIC_SSOKIT_TEAM_MANAGER_ROLES
: process.env.SSOKIT_TEAM_MANAGER_ROLES;

if (envRoles) {
return envRoles.split(',').map(role => role.trim());
}

// Default to Owner only
return ['Owner'];
}, [managerRoles]);
Expand All @@ -113,16 +113,21 @@ export function TeamManager({

// Get current user's role in this organization
const currentUserRole = useMemo(() => {
console.log('currentUserId', currentUserId);
console.log('members', members);
console.log('allowedManagerRoles', allowedManagerRoles);
if (!currentUserId) return null;
const currentMember = members.find(m => m.userId === currentUserId || m.id === currentUserId);
return currentMember?.role || null;
}, [currentUserId, members]);

// Check if current user has management permissions
const canManageTeam = useMemo(() => {

console.log("== Checking management permissions ==");
console.log("Current User Role:", currentUserRole);
console.log("Allowed Manager Roles:", allowedManagerRoles);

if (!currentUserRole) return false;
return allowedManagerRoles.includes(currentUserRole);
}, [currentUserRole, allowedManagerRoles]);
Expand All @@ -131,7 +136,7 @@ export function TeamManager({
const transformUserToMember = useCallback((user: any, targetTenantId: string): UIMember => {
const targetTenant = user.tenants?.find((t: any) => t.tenant_id === targetTenantId);
const primaryRole = targetTenant?.roles?.[0];

return {
id: user.id,
userId: user.id,
Expand All @@ -152,36 +157,34 @@ export function TeamManager({
try {
setLoading(true);
setError(null);

const [membersRes, invitationsRes, rolesRes] = await Promise.all([
client.listMembers(organizationId),
client.listInvites(organizationId, 'pending'),
client.listRoles(),
]);

// console.log('API Responses:', { membersRes, invitationsRes, rolesRes });


// Handle users API response format: { users: [...] }
const rawUsers = (membersRes as any)?.users || (membersRes as any)?.data || membersRes || [];
// Handle roles API response format: { roles: [...] }
const roles = (rolesRes as any)?.roles || (rolesRes as any)?.data || rolesRes || [];
// Handle invitations API response format: { invitation: [...] }
const rawInvitations = (invitationsRes as any)?.invitation || [];

// Transform users to active members only
const allMembers: UIMember[] = [];

if (Array.isArray(rawUsers)) {
rawUsers.forEach((user: any) => {
const member = transformUserToMember(user, organizationId);

// Only include active members
if (member.status === 'active' || !member.status) {
allMembers.push(member);
}
});
}

// Transform invitations to pending invites
const pendingInvites: UIMember[] = [];
if (Array.isArray(rawInvitations)) {
Expand All @@ -199,13 +202,9 @@ export function TeamManager({
pendingInvites.push(invite);
});
}

console.log('Processed data:', {
activeMembers: allMembers,
pendingInvites,
roles
});




setMembers(allMembers);
setInvites(pendingInvites);
setRoles(Array.isArray(roles) ? roles : []);
Expand Down Expand Up @@ -254,7 +253,7 @@ export function TeamManager({
[client, organizationId, fetchData, onMemberRemoved]
);

const handleInviteMember = useCallback(
const handleInviteMember = useCallback(
async (email: string, roleName: string) => {
try {
// Find the role ID by role name
Expand Down Expand Up @@ -396,7 +395,7 @@ export function TeamManager({

{/* Status Message */}
{statusMessage && (
<div
<div
className={`sk-status-message sk-status-message--${statusMessage.type}`}
role="alert"
aria-live="polite"
Expand Down
15 changes: 12 additions & 3 deletions packages/ssokit-webhooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
"name": "@ssojet/ssokit-webhooks",
"version": "0.1.0",
"description": "Webhook verification and SCIM provisioning for SSOJet AuthKit",
"keywords": ["ssojet", "authkit", "webhooks", "scim", "provisioning"],
"keywords": [
"ssojet",
"authkit",
"webhooks",
"scim",
"provisioning"
],
"homepage": "https://github.com/ssojet/ssojet-authkit#readme",
"repository": {
"type": "git",
Expand All @@ -20,7 +26,10 @@
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": ["dist", "README.md"],
"files": [
"dist",
"README.md"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
Expand All @@ -30,7 +39,7 @@
"clean": "rm -rf dist .turbo"
},
"dependencies": {
"@ssojet/ssokit-core": "workspace:*"
"@ssojet/ssokit-core": "0.1.0"
},
"devDependencies": {
"@types/node": "^20.11.24",
Expand Down
Loading
Loading