lumera 0.54.4__tar.gz → 0.54.5.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lumera-0.54.4 → lumera-0.54.5.dev1}/PKG-INFO +1 -1
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/__init__.py +2 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/_utils.py +36 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera.egg-info/PKG-INFO +1 -1
- {lumera-0.54.4 → lumera-0.54.5.dev1}/pyproject.toml +1 -1
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_sdk.py +15 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/_live.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/_log_redaction.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/agents.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/automations.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/documents.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/email.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/exceptions.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/files.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/flags.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/function_resources.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/__init__.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/__main__.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_artifacts.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_config.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_context.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_contract.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_dependencies.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_errors.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_execution.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_jsonschema.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_registry.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_remote.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_runner.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/_runtime.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/functions/testing.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/google.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/__init__.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/bill.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/client.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/finch.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/google.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/kafka.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/netsuite.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/personal.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/salesforce.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/slack.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/integrations/snowflake.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/llm.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/pb.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/__init__.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/__main__.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_api_child.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_archive.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_automation_event.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_builder.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_config.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_contracts.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_errors.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_projection.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_rpc_diagnostics.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_rpc_event.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_rpc_process.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_runtime.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_runtime_child.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_schemas.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_target.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/releases/_timing.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/sdk.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/storage.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/transactions.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera/webhooks.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera.egg-info/SOURCES.txt +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera.egg-info/dependency_links.txt +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera.egg-info/requires.txt +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/lumera.egg-info/top_level.txt +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/setup.cfg +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_agents_live.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_automations.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_documents.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_flags.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_function_resources.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integration_client.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_bill.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_finch.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_google.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_kafka.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_netsuite.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_personal.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_salesforce.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_slack.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_integrations_snowflake.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_lazy_imports.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_log_redaction.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_transactions.py +0 -0
- {lumera-0.54.4 → lumera-0.54.5.dev1}/tests/test_webhooks.py +0 -0
|
@@ -39,6 +39,7 @@ except PackageNotFoundError:
|
|
|
39
39
|
__all__ = [
|
|
40
40
|
# Authentication & utilities
|
|
41
41
|
"Credentials",
|
|
42
|
+
"as_app_user",
|
|
42
43
|
"get_access_token",
|
|
43
44
|
"get_credentials",
|
|
44
45
|
"get_google_access_token", # Kept for backwards compatibility
|
|
@@ -133,6 +134,7 @@ _LAZY_ATTRIBUTES = {
|
|
|
133
134
|
"LumeraAPIError": ("._utils", "LumeraAPIError"),
|
|
134
135
|
"RecordNotUniqueError": ("._utils", "RecordNotUniqueError"),
|
|
135
136
|
"get_access_token": ("._utils", "get_access_token"),
|
|
137
|
+
"as_app_user": ("._utils", "as_app_user"),
|
|
136
138
|
"get_credentials": ("._utils", "get_credentials"),
|
|
137
139
|
"get_google_access_token": ("._utils", "get_google_access_token"),
|
|
138
140
|
"list_integration_connections": ("._utils", "list_integration_connections"),
|
|
@@ -68,6 +68,37 @@ def _reset_runtime_lumera_token(token: Token[str]) -> None:
|
|
|
68
68
|
_runtime_lumera_token.reset(token)
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
APP_USER_ASSERTION_HEADER = "X-Lumera-App-User-Assertion"
|
|
72
|
+
_app_user_assertion: ContextVar[str] = ContextVar("lumera_app_user_assertion", default="")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@contextlib.contextmanager
|
|
76
|
+
def as_app_user(assertion: str | None) -> Iterator[None]:
|
|
77
|
+
"""Attribute the SDK calls made inside the block to an external app user.
|
|
78
|
+
|
|
79
|
+
An App API route receives the signed ``X-Lumera-App-User-Assertion`` header
|
|
80
|
+
for a signed-in external user. Pass that value here and every SDK call in
|
|
81
|
+
the block forwards it, so the platform records the app user as the actor
|
|
82
|
+
instead of the project runtime. The platform verifies the assertion; an
|
|
83
|
+
invalid one is ignored. ``None`` or an empty value forwards nothing, which
|
|
84
|
+
is the case in dev, for organization members, and for anonymous visitors.
|
|
85
|
+
|
|
86
|
+
The binding is local to the current request (a context variable), so
|
|
87
|
+
concurrent requests do not see each other's assertion.
|
|
88
|
+
|
|
89
|
+
Example::
|
|
90
|
+
|
|
91
|
+
with as_app_user(request.headers.get("X-Lumera-App-User-Assertion")):
|
|
92
|
+
pb.update("invoices", invoice_id, {"status": "approved"})
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
token = _app_user_assertion.set((assertion or "").strip())
|
|
96
|
+
try:
|
|
97
|
+
yield
|
|
98
|
+
finally:
|
|
99
|
+
_app_user_assertion.reset(token)
|
|
100
|
+
|
|
101
|
+
|
|
71
102
|
def _credentials_paths() -> tuple[str, ...]:
|
|
72
103
|
explicit = os.getenv(CREDENTIALS_PATH_ENV, "").strip()
|
|
73
104
|
return tuple(
|
|
@@ -865,6 +896,11 @@ def _api_headers(
|
|
|
865
896
|
if _user_id:
|
|
866
897
|
headers["X-Lumera-User-Id"] = _user_id
|
|
867
898
|
|
|
899
|
+
# App user context: set by as_app_user() for the current request only.
|
|
900
|
+
_assertion = _app_user_assertion.get()
|
|
901
|
+
if _assertion:
|
|
902
|
+
headers[APP_USER_ASSERTION_HEADER] = _assertion
|
|
903
|
+
|
|
868
904
|
return headers
|
|
869
905
|
|
|
870
906
|
|
|
@@ -213,6 +213,21 @@ def test_api_headers_uses_request_local_runtime_actor(monkeypatch: pytest.Monkey
|
|
|
213
213
|
assert _utils._api_headers()["X-Lumera-User-Id"] == "fallback-member"
|
|
214
214
|
|
|
215
215
|
|
|
216
|
+
def test_as_app_user_forwards_the_assertion_only_inside_the_block(
|
|
217
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
218
|
+
) -> None:
|
|
219
|
+
monkeypatch.setenv(sdk.TOKEN_ENV, "tok")
|
|
220
|
+
header = _utils.APP_USER_ASSERTION_HEADER
|
|
221
|
+
|
|
222
|
+
with _utils.as_app_user(" signed-assertion "):
|
|
223
|
+
assert _utils._api_headers()[header] == "signed-assertion"
|
|
224
|
+
with _utils.as_app_user(None):
|
|
225
|
+
assert header not in _utils._api_headers()
|
|
226
|
+
assert _utils._api_headers()[header] == "signed-assertion"
|
|
227
|
+
|
|
228
|
+
assert header not in _utils._api_headers()
|
|
229
|
+
|
|
230
|
+
|
|
216
231
|
def test_api_headers_forwards_execution_correlation(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
217
232
|
monkeypatch.setenv(sdk.TOKEN_ENV, "tok")
|
|
218
233
|
monkeypatch.setenv("LUMERA_REQUEST_ID", " request_1 ")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|