Privacy Module

API reference for sso.privacy data-export and anonymization operations

AuthOS release 0.8.5 TypeScript SDK 0.8.0 Latest-only documentation
Updated Jul 15, 2026
On this page

The privacy module (sso.privacy) exposes data-export and user-anonymization operations that can support an operator’s privacy workflows. These methods do not establish GDPR compliance or guarantee coverage of backups, logs, integrations, or downstream systems.

GDPR Right to Access

Method: sso.privacy.exportData()

Signature:

exportData(userId: string): Promise<ExportUserDataResponse>

Description: Export the user-related data returned by the AuthOS endpoint. Users can request their own export, and organization owners can request exports for their members subject to API authorization. Operators must verify whether other stores contain additional personal data.

Parameters:

Name Type Description
userId string User ID to export data for

Returns: Promise<ExportUserDataResponse> - AuthOS endpoint export response

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, payload?: ForgetUserRequest): Promise<ForgetUserResponse>

Description: Anonymize the user fields handled by the AuthOS endpoint. This operation soft-deletes the account and removes identified fields from selected tables while retaining audit context. It does not guarantee erasure from backups, logs, integrations, or downstream systems. Authorization requires organization-owner permission for every organization the user belongs to; platform owners cannot be anonymized through this method.

Parameters:

Name Type Description
userId string User ID to anonymize
payload.current_password string (optional) Required for self-service deletion when confirming with the current password
payload.mfa_code string (optional) Required for self-service deletion when confirming with MFA

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."
}

const selfDelete = await sso.privacy.forgetUser('current-user-id', {
  current_password: 'SecurePass123!'
});
console.log(selfDelete.success);

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;
}

ForgetUserRequest

interface ForgetUserRequest {
  current_password?: string;
  mfa_code?: 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;
}