# cliia/pku-iaaa-auto-login architecture

> Architecture diagram of the GitHub repository cliia/pku-iaaa-auto-login, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cliia/pku-iaaa-auto-login
- Repository: https://github.com/cliia/pku-iaaa-auto-login

## Overview

This Chromium extension lets a user configure or unlock saved IAAA credentials in its popup, then uses them on the PKU authentication page. The runtime separates credential management, encrypted credential storage, and page-side authentication: the content script retrieves and decrypts credentials, fills the login form, checks the required authentication mode, and either proceeds with ordinary login or exposes SMS/OTP steps for the user. The README documents cloud sync and the supported authentication modes; unsampled manifest wiring is not inferred.

Main entry points: [`iaaa.js`](https://github.com/cliia/pku-iaaa-auto-login/blob/main/iaaa.js) (Auto-login Script), [`popup.js`](https://github.com/cliia/pku-iaaa-auto-login/blob/main/popup.js) (Setup and Unlock), [`popup.html`](https://github.com/cliia/pku-iaaa-auto-login/blob/main/popup.html) (Configuration UI), [`crypto-utils.js`](https://github.com/cliia/pku-iaaa-auto-login/blob/main/crypto-utils.js) (Password Crypto)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_credentials["Credential Setup"]
  node_popup["Configuration UI<br/>[popup.html]"]
  node_popup_logic["Setup and Unlock<br/>[popup.js]"]
end

subgraph group_security["Encryption and Storage"]
  node_crypto["Password Crypto<br/>[crypto-utils.js]"]
  node_sync_store[("Synced Credentials")]
  node_local_store[("Local Key Cache")]
end

subgraph group_login["IAAA Login"]
  node_content_script["Auto-login Script<br/>[iaaa.js]"]
  node_login_form["IAAA Login Form"]
  node_auth_status["Auth Mode Endpoint"]
  node_sms_step["SMS Verification"]
  node_otp_step["OTP Verification"]
end

node_user(("User"))
node_google_sync(("Google Account Sync"))
node_iaaa_service(("IAAA Service"))

node_user -->|"configures"| node_popup
node_popup -->|"invokes"| node_popup_logic
node_popup_logic -->|"reads and writes"| node_sync_store
node_popup_logic -->|"reads and writes"| node_local_store
node_popup_logic -->|"encrypts and unlocks"| node_crypto
node_sync_store -.->|"syncs encrypted data"| node_google_sync
node_content_script -->|"reads credentials"| node_sync_store
node_content_script -->|"reads cached key"| node_local_store
node_content_script -->|"decrypts password"| node_crypto
node_content_script -->|"fills credentials"| node_login_form
node_content_script -->|"checks auth mode"| node_auth_status
node_auth_status -->|"returns auth mode"| node_content_script
node_content_script -->|"dispatches login"| node_login_form
node_content_script -->|"reveals and sends"| node_sms_step
node_content_script -->|"reveals input"| node_otp_step
node_user -->|"enters code"| node_sms_step
node_user -->|"enters code"| node_otp_step
node_login_form -->|"submits login"| node_iaaa_service

click node_popup "https://github.com/cliia/pku-iaaa-auto-login/blob/main/popup.html"
click node_popup_logic "https://github.com/cliia/pku-iaaa-auto-login/blob/main/popup.js"
click node_crypto "https://github.com/cliia/pku-iaaa-auto-login/blob/main/crypto-utils.js"
click node_content_script "https://github.com/cliia/pku-iaaa-auto-login/blob/main/iaaa.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_popup,node_popup_logic,node_user toneBlue
class node_crypto,node_sync_store,node_local_store toneAmber
class node_content_script,node_login_form,node_auth_status,node_sms_step,node_otp_step toneMint
class node_google_sync,node_iaaa_service toneIndigo
```

## Components

### Credential Setup

- [Configuration UI](https://github.com/cliia/pku-iaaa-auto-login/blob/main/popup.html): `popup.html`
- [Setup and Unlock](https://github.com/cliia/pku-iaaa-auto-login/blob/main/popup.js): `popup.js`

### Encryption and Storage

- [Password Crypto](https://github.com/cliia/pku-iaaa-auto-login/blob/main/crypto-utils.js): `crypto-utils.js`
- **Synced Credentials**
- **Local Key Cache**

### IAAA Login

- [Auto-login Script](https://github.com/cliia/pku-iaaa-auto-login/blob/main/iaaa.js): `iaaa.js`
- **IAAA Login Form**
- **Auth Mode Endpoint**
- **SMS Verification**
- **OTP Verification**

### Other components

- **User**
- **Google Account Sync**
- **IAAA Service**

## Connections

- User → Configuration UI: configures
- Configuration UI → Setup and Unlock: invokes
- Setup and Unlock → Synced Credentials: reads and writes
- Setup and Unlock → Local Key Cache: reads and writes
- Setup and Unlock → Password Crypto: encrypts and unlocks
- Synced Credentials → Google Account Sync: syncs encrypted data
- Auto-login Script → Synced Credentials: reads credentials
- Auto-login Script → Local Key Cache: reads cached key
- Auto-login Script → Password Crypto: decrypts password
- Auto-login Script → IAAA Login Form: fills credentials
- Auto-login Script → Auth Mode Endpoint: checks auth mode
- Auth Mode Endpoint → Auto-login Script: returns auth mode
- Auto-login Script → IAAA Login Form: dispatches login
- Auto-login Script → SMS Verification: reveals and sends
- Auto-login Script → OTP Verification: reveals input
- User → SMS Verification: enters code
- User → OTP Verification: enters code
- IAAA Login Form → IAAA Service: submits login
