Skip to content
Merged
38 changes: 19 additions & 19 deletions packages/kyc-controller/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ graph TB

Exposed messenger actions (`MESSENGER_EXPOSED_METHODS`):

`initialize`, `loadDisclaimers`, `acceptTermsAndStartSession`,
`initialize`, `loadDisclaimers`, `fetchSessionDisclaimers`, `acceptTermsAndStartSession`,
`createVendorCustomer`, `clearSavedTerms`, `handleFrameMessage`,
`buildCheckFrameUrl`, `buildAuthFrameUrl`, `buildResetFrameUrl`,
`checkKycRequired`, `getKycStatus`, `getCustomerIdentity`, `refreshKycStatus`,
Expand All @@ -122,29 +122,29 @@ Exposed messenger actions (`MESSENGER_EXPOSED_METHODS`):
Exposed messenger actions (`MESSENGER_EXPOSED_METHODS`):

`getGeoCountry`, `fetchVendorDisclaimers`, `createSession`, `checkKycRequired`,
`createVendorCustomer`, `submitVendorDisclaimers`, `fetchDisclaimersCatalog`, `fetchSessionDisclaimers`, `submitSessionDisclaimers`,
`createVendorCustomer`, `submitVendorDisclaimers`, `fetchSessionDisclaimersByCountry`, `fetchSessionDisclaimersBySessionId`, `submitSessionDisclaimers`,
`fetchKycStatus`, `fetchIdosEnclaveJwks`, `fetchIdosRelayJwks`, `createUkycSession`, `setAuthorizations`,
`createJourney`, `getSessionStatus`.

Endpoints:

| Method | HTTP | Endpoint | Purpose |
| -------------------------- | ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- |
| `getGeoCountry` | — | (geolocation action) | Resolve alpha-3 country |
| `fetchVendorDisclaimers` | `GET` | `/vendors/{vendor}/disclaimers?country=` | Vendor T&Cs to accept (`vendor` defaults to `moonpay`) |
| `createSession` | `POST` | `/vendors/moonpay/sessions` | Create MoonPay vendor session |
| `checkKycRequired` | `POST` | `/vendors/{vendor}/kyc-required` | Is KYC required? (normalizes `required` → `kycRequired`) |
| `createVendorCustomer` | `POST` | `/vendors/{vendor}/customers` | Create or resume an empty-shell vendor customer |
| `submitVendorDisclaimers` | `POST` | `/vendors/{vendor}/disclaimers` | Record vendor T&C signings (`disclaimerIds`) |
| `fetchDisclaimersCatalog` | `GET` | `/disclaimers?country=` | Global idOS + KYC-provider catalog (no consent state) |
| `fetchSessionDisclaimers` | `GET` | `/sessions/{id}/disclaimers` | Session-scoped catalog, with `consented` flags + credential-reuse flag |
| `submitSessionDisclaimers` | `POST` | `/sessions/{id}/disclaimers` | Record `{ idOS, kycProvider, credentialReusabilityConsentGiven }` consents |
| `fetchKycStatus` | `GET` | `/kyc/status` | User-keyed simplified KYC status |
| `fetchIdosEnclaveJwks` | `GET` | `{idosEnclaveBaseUrl}/.well-known/jwks.json` | idOS enclave JWKS for `encryptionDataKey` attestation |
| `fetchIdosRelayJwks` | `GET` | `{idosRelayBaseUrl}/.well-known/jwks.json` | idOS relay JWKS for `ukycCapabilityToken` attestation |
| `createUkycSession` | `POST` | `/sessions` | Start SumSub sub-flow; registers session client public key; returns encryption schemas |
| `setAuthorizations` | `POST` | `/sessions/{id}/authorizations` | Submit wrapped `data_encryption_key` and wrapped `ukyc_capability_token` |
| `createJourney` | `POST` | `/sessions/{id}/journey` | Create verification journey → applicant token |
| Method | HTTP | Endpoint | Purpose |
| ------------------------------------ | ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- |
| `getGeoCountry` | — | (geolocation action) | Resolve alpha-3 country |
| `fetchVendorDisclaimers` | `GET` | `/vendors/{vendor}/disclaimers?country=` | Vendor T&Cs to accept (`vendor` defaults to `moonpay`) |
| `createSession` | `POST` | `/vendors/moonpay/sessions` | Create MoonPay vendor session |
| `checkKycRequired` | `POST` | `/vendors/{vendor}/kyc-required` | Is KYC required? (normalizes `required` → `kycRequired`) |
| `createVendorCustomer` | `POST` | `/vendors/{vendor}/customers` | Create or resume an empty-shell vendor customer |
| `submitVendorDisclaimers` | `POST` | `/vendors/{vendor}/disclaimers` | Record vendor T&C signings (`disclaimerIds`) |
| `fetchSessionDisclaimersByCountry` | `GET` | `/disclaimers?country=` | Global idOS + KYC-provider catalog (no consent state) |
| `fetchSessionDisclaimersBySessionId` | `GET` | `/sessions/{id}/disclaimers` | Session-scoped catalog, with `consented` flags + credential-reuse flag |
| `submitSessionDisclaimers` | `POST` | `/sessions/{id}/disclaimers` | Record `{ idOS, kycProvider, credentialReusabilityConsentGiven }` consents |
| `fetchKycStatus` | `GET` | `/kyc/status` | User-keyed simplified KYC status |
| `fetchIdosEnclaveJwks` | `GET` | `{idosEnclaveBaseUrl}/.well-known/jwks.json` | idOS enclave JWKS for `encryptionDataKey` attestation |
| `fetchIdosRelayJwks` | `GET` | `{idosRelayBaseUrl}/.well-known/jwks.json` | idOS relay JWKS for `ukycCapabilityToken` attestation |
| `createUkycSession` | `POST` | `/sessions` | Start SumSub sub-flow; registers session client public key; returns encryption schemas |
| `setAuthorizations` | `POST` | `/sessions/{id}/authorizations` | Submit wrapped `data_encryption_key` and wrapped `ukyc_capability_token` |
| `createJourney` | `POST` | `/sessions/{id}/journey` | Create verification journey → applicant token |

### 2.3 `crypto.ts`

Expand Down
13 changes: 13 additions & 0 deletions packages/kyc-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `KycController.fetchSessionDisclaimers`, which fetches the idOS + KYC-provider disclaimers by `{ sessionId }` or `{ country }`. ([#10162](https://github.com/MetaMask/core/pull/10162))

### Changed

- **BREAKING:** Rename `KycService.fetchDisclaimersCatalog` to `fetchSessionDisclaimersByCountry`. ([#10162](https://github.com/MetaMask/core/pull/10162))
- Rename `FetchDisclaimersCatalogParams` to `FetchSessionDisclaimersByCountryParams`.
- Rename the messenger action `KycService:fetchDisclaimersCatalog` to `KycService:fetchSessionDisclaimersByCountry`.
- **BREAKING:** Rename `KycService.fetchSessionDisclaimers` to `fetchSessionDisclaimersBySessionId` ([#10162](https://github.com/MetaMask/core/pull/10162))
- Rename `FetchSessionDisclaimersParams` to `FetchSessionDisclaimersBySessionIdParams`.
- Rename the messenger action `KycService:fetchSessionDisclaimers` to `KycService:fetchSessionDisclaimersBySessionId`.

## [0.2.0]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ export type KycControllerLoadDisclaimersAction = {
handler: KycController['loadDisclaimers'];
};

/**
* Fetches the idOS + KYC-provider disclaimer catalog. Pass exactly one of
* `sessionId` or `country`:
*
* - `{ sessionId }` → {@link KycService.fetchSessionDisclaimersBySessionId}
* (`GET /sessions/{sessionId}/disclaimers`)
* - `{ country }` → {@link KycService.fetchSessionDisclaimersByCountry}
* (`GET /disclaimers?country=`)
*
* A session-id fetch also writes the catalog to `sessionDisclaimers`.
*
* @param params - The parameters. Provide exactly one of `sessionId` or
* `country`.
* @param params.sessionId - The UKYC session id.
* @param params.country - ISO 3166-1 alpha-3 country code.
* @returns The catalog. Session fetches include consent state; country
* fetches do not.
*/
export type KycControllerFetchSessionDisclaimersAction = {
type: `KycController:fetchSessionDisclaimers`;
handler: KycController['fetchSessionDisclaimers'];
};

/**
* Captures terms acceptance for the currently loaded disclaimers and creates
* a session.
Expand Down Expand Up @@ -264,6 +287,7 @@ export type KycControllerMethodActions =
| KycControllerInitializeAction
| KycControllerCreateVendorCustomerAction
| KycControllerLoadDisclaimersAction
| KycControllerFetchSessionDisclaimersAction
| KycControllerAcceptTermsAndStartSessionAction
| KycControllerClearSavedTermsAction
| KycControllerHandleFrameMessageAction
Expand Down
Loading