-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔄 synced local 'skyvern/' with remote 'skyvern/'
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Move TOTP functionality from `cloud` to `skyvern`, including routing, database methods, and prompts. > > - **Routing**: > - Remove `totp_router` from `cloud/app.py` and add it to `skyvern/forge/api_app.py`. > - **Database**: > - Remove `create_totp_code` from `cloud/db/db_client.py` and add it to `skyvern/forge/sdk/db/client.py`. > - Remove `TOTPCodeModel` import from `cloud/db/db_client.py` and add it to `skyvern/forge/sdk/db/client.py`. > - **Prompts**: > - Rename `cloud/prompts/cloud/parse-verification-code.j2` to `skyvern/forge/prompts/skyvern/parse-verification-code.j2`. > - **Misc**: > - Rename `cloud/routes/totp.py` to `skyvern/forge/sdk/routes/totp.py` and update imports accordingly. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral)<sup> for f469f4850f253c90865c3795f1257a4f42f4370b. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
- Loading branch information
1 parent
04e2a2b
commit 1d6e28c
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
You receive either an email or a text message containing 2FA/MFA code or activation key. Your job is to parse the content, identify the code and return the code. There should be only one code in the content. The code must be from the content | ||
|
||
The most common form of code will be a series of digits, although sometimes it may contain letters. | ||
|
||
"Here is your code: 123456" or "Your code is: 123456" or "123456 is your code", "Here is your activation key: abcdefg", "Here is your key: 123asd" are some examples of the possible content. | ||
|
||
MAKE SURE YOU OUTPUT VALID JSON. No text before or after JSON, no trailing commas, no comments (//), no unnecessary quotes, etc. | ||
|
||
Reply in the following JSON format: | ||
{ | ||
"reasoning": str, // How you figure out what the code is or why the code is missing. Be precise here to explain the data source and the context that makes you believe where the correct code is | ||
"code_found": bool, // true if the code is found. false if the code is not found | ||
"code": str, // the 2FA/MFA verification code. If you cannot identifiy any code, do not come up with a code and return null | ||
} | ||
|
||
Received Content containing 2FA/MFA code: | ||
``` | ||
{{ content }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import structlog | ||
from fastapi import APIRouter, Depends, HTTPException | ||
|
||
from skyvern.forge import app | ||
from skyvern.forge.prompts import prompt_engine | ||
from skyvern.forge.sdk.schemas.organizations import Organization | ||
from skyvern.forge.sdk.schemas.totp_codes import TOTPCode, TOTPCodeCreate | ||
from skyvern.forge.sdk.services import org_auth_service | ||
|
||
LOG = structlog.get_logger() | ||
totp_router = APIRouter() | ||
|
||
|
||
@totp_router.post("") | ||
@totp_router.post("/", include_in_schema=False) | ||
async def save_totp_code( | ||
data: TOTPCodeCreate, curr_org: Organization = Depends(org_auth_service.get_current_org) | ||
) -> TOTPCode: | ||
LOG.info( | ||
"Saving TOTP code", | ||
data=data, | ||
organization_id=curr_org.organization_id, | ||
totp_identifier=data.totp_identifier, | ||
task_id=data.task_id, | ||
workflow_id=data.workflow_id, | ||
) | ||
code = await parse_totp_code(data.content) | ||
if not code: | ||
raise HTTPException(status_code=400, detail="Failed to parse totp code") | ||
return await app.DATABASE.create_totp_code( | ||
organization_id=curr_org.organization_id, | ||
totp_identifier=data.totp_identifier, | ||
content=data.content, | ||
code=code, | ||
task_id=data.task_id, | ||
workflow_id=data.workflow_id, | ||
source=data.source, | ||
expired_at=data.expired_at, | ||
) | ||
|
||
|
||
async def parse_totp_code(content: str) -> str | None: | ||
prompt = prompt_engine.load_prompt("parse-verification-code", content=content) | ||
code_resp = await app.SECONDARY_LLM_API_HANDLER(prompt=prompt) | ||
return code_resp.get("code", None) |