Helpers
Reveal helpers¶
Convenience helpers for backend consumers of the financial instrument reveal API.
These helpers wrap the full reveal lifecycle (key generation, registration, reveal, decryption) into single atomic function calls. The ephemeral RSA key pair is generated internally and never exposed to the caller.
Usage
from components.payment_gateway.public.parties import ( FinancialInstrumentRevealQueries, ) from components.payment_gateway.subcomponents.parties.protected.business_logic.reveal import ( backend_reveal_actor, reveal_iban_account_details, )
reveal_queries = FinancialInstrumentRevealQueries.create() details = reveal_iban_account_details( reveal_queries, session, financial_instrument_id, reason="legal_document_generation", actor=backend_reveal_actor("banking_documents"), )
components.payment_gateway.subcomponents.parties.protected.business_logic.reveal.backend_reveal_actor ¶
Build an actor string for backend component callers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_name
|
str
|
Name of the calling component (e.g. "banking_documents"). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted actor string like "component:banking_documents". |
Source code in components/payment_gateway/subcomponents/parties/protected/business_logic/reveal.py
components.payment_gateway.subcomponents.parties.protected.business_logic.reveal.decrypt_reveal_jwe ¶
Decrypt a JWE token from a reveal operation and parse the JSON payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
private_key_pem
|
str
|
RSA private key in PEM format. |
required |
jwe_token
|
str
|
JWE token string returned by a reveal method. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Parsed JSON payload as a dictionary. |
Source code in components/payment_gateway/subcomponents/parties/protected/business_logic/reveal.py
components.payment_gateway.subcomponents.parties.protected.business_logic.reveal.frontend_reveal_actor ¶
Build an actor string for frontend callers (used in controllers).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
User role (e.g. "member", "admin", "care"). |
required |
user_id
|
str
|
User identifier. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted actor string like "member:{user_id}". |
Source code in components/payment_gateway/subcomponents/parties/protected/business_logic/reveal.py
components.payment_gateway.subcomponents.parties.protected.business_logic.reveal.generate_reveal_key_pair ¶
Generate an ephemeral RSA key pair for a reveal operation.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
Tuple of (private_key_pem, public_key_pem) as strings. |
Source code in components/payment_gateway/subcomponents/parties/protected/business_logic/reveal.py
components.payment_gateway.subcomponents.parties.protected.business_logic.reveal.reveal_ca_local_account_details ¶
Reveal Canadian local account details in a single atomic operation.
Generates an ephemeral RSA key pair, registers it, calls reveal, decrypts the JWE response, and returns the cleartext details. The private key never leaves this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reveal_queries
|
FinancialInstrumentRevealQueries
|
FinancialInstrumentRevealQueries instance. |
required |
session
|
Session
|
Database session. |
required |
id
|
FinancialInstrumentId
|
Financial instrument ID. |
required |
reason
|
str
|
Why the reveal is needed (free-form, non-empty). |
required |
actor
|
str
|
Who is requesting the reveal (use backend_actor() helper). |
required |
Returns:
| Type | Description |
|---|---|
CALocalAccountDetails
|
CALocalAccountDetails with the full Canadian local account data. |
Source code in components/payment_gateway/subcomponents/parties/protected/business_logic/reveal.py
components.payment_gateway.subcomponents.parties.protected.business_logic.reveal.reveal_iban_account_details ¶
Reveal IBAN account details in a single atomic operation.
Generates an ephemeral RSA key pair, registers it, calls reveal, decrypts the JWE response, and returns the cleartext details. The private key never leaves this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reveal_queries
|
FinancialInstrumentRevealQueries
|
FinancialInstrumentRevealQueries instance. |
required |
session
|
Session
|
Database session. |
required |
id
|
FinancialInstrumentId
|
Financial instrument ID. |
required |
reason
|
str
|
Why the reveal is needed (free-form, non-empty). |
required |
actor
|
str
|
Who is requesting the reveal (use backend_actor() helper). |
required |
Returns:
| Type | Description |
|---|---|
IBANAccountDetails
|
IBANAccountDetails with the full IBAN account data. |