Privacy Module

Complete API reference for sso.privacy module - GDPR compliance, right to access, right to be forgotten

Updated Nov 28, 2025
Edit on GitHub

Privacy Module

The privacy module (sso.privacy) provides GDPR compliance features including data export and user anonymization.

GDPR Right to Access

Method: sso.privacy.exportData()

Signature:

exportData(userId: string): Promise<ExportUserDataResponse>

Description: Export all data for a user (GDPR Right to Access). Users can export their own data, or organization owners can export data for their members. Returns a complete data package including memberships, login events, linked identities, MFA configurations, and passkeys.

Parameters:

Name Type Description
userId string User ID to export data for

Returns: Promise<ExportUserDataResponse> - Complete user data export

Response Fields:

Field Type Description
user_id string User ID
email string User email address
created_at string ISO timestamp of account creation
memberships MembershipExport[] Organization memberships
oauth_identities OAuthIdentityExport[] Linked OAuth identities
passkeys PasskeyExport[] Registered FIDO2 passkeys
login_events LoginEventExport[] Recent login history
login_events_count number Total number of login events
mfa_events MfaEventExport[] MFA activity history

Example:

const userData = await sso.privacy.exportData('user-id');
console.log(`User: ${userData.email}`);
console.log(`Memberships: ${userData.memberships.length}`);
console.log(`Login events: ${userData.login_events_count}`);
console.log(`Linked identities: ${userData.oauth_identities.length}`);
console.log(`Registered passkeys: ${userData.passkeys.length}`);

// Export to JSON file
const dataBlob = new Blob([JSON.stringify(userData, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(dataBlob);
const link = document.createElement('a');
link.href = url;
link.download = `user-data-${userData.user_id}.json`;
link.click();

Throws:

  • SsoApiError -
    • When user is not authenticated
    • When user doesn’t have permission to export this data
    • When user ID not found

Related:


GDPR Right to be Forgotten

Method: sso.privacy.forgetUser()

Signature:

forgetUser(userId: string): Promise<ForgetUserResponse>

Description: Anonymize user data (GDPR Right to be Forgotten). This operation soft-deletes the user account and hard-deletes personally identifiable information from identities and passkeys tables. Audit logs are preserved for compliance. Requires organization owner permission for all organizations the user belongs to. Platform owners cannot be anonymized.

Parameters:

Name Type Description
userId string User ID to anonymize

Returns: Promise<ForgetUserResponse> - Anonymization confirmation

Response Fields:

Field Type Description
success boolean Whether the operation succeeded
message string Confirmation message
user_id string ID of anonymized user

Example:

if (confirm('Are you sure? This cannot be undone!')) {
  const result = await sso.privacy.forgetUser('user-id');
  console.log(result.message);
  // "User data has been anonymized. PII has been removed while preserving audit logs."
}

Throws:

  • SsoApiError -
    • When user is not authenticated
    • When user doesn’t have owner permission for all organizations
    • When trying to anonymize a platform owner
    • When user ID not found

Related:


Type Definitions

ExportUserDataResponse

interface ExportUserDataResponse {
  user_id: string;
  email: string;
  created_at: string;
  memberships: MembershipExport[];
  login_events_count: number;
  login_events: LoginEventExport[];
  oauth_identities: OAuthIdentityExport[];
  mfa_events: MfaEventExport[];
  passkeys: PasskeyExport[];
}

ForgetUserResponse

interface ForgetUserResponse {
  success: boolean;
  message: string;
  user_id: string;
}

MembershipExport

interface MembershipExport {
  organization_id: string;
  organization_slug: string;
  role: string;
  joined_at: string;
}

OAuthIdentityExport

interface OAuthIdentityExport {
  provider: string;
  provider_user_id: string;
  linked_at: string;
}

PasskeyExport

interface PasskeyExport {
  id: string;
  name: string | null;
  aaguid: string | null;
  backup_eligible: boolean;
  created_at: string;
  last_used_at: string | null;
}

LoginEventExport

interface LoginEventExport {
  id: string;
  timestamp: string;
  ip_address: string | null;
  user_agent: string | null;
  provider: string | null;
  success: boolean;
  risk_score: number | null;
  risk_factors: string | null;
  geo_country: string | null;
  geo_city: string | null;
}

MfaEventExport

interface MfaEventExport {
  event_type: string;
  timestamp: string;
  success: boolean;
}