Migrate issueSyncToken serverless endpoint to lambdas/account-scoped#4006
Migrate issueSyncToken serverless endpoint to lambdas/account-scoped#4006
Conversation
…coped Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
stephenhand
left a comment
There was a problem hiding this comment.
Fit the linter error in the test file
| }); | ||
| } | ||
|
|
||
| try { |
There was a problem hiding this comment.
This try ... catch wrapper is redundant as it duplicates the error handling further up the stack
There was a problem hiding this comment.
Removed the try/catch — errors now propagate to the top-level handler in index.ts. Updated the corresponding test to expect a rejects.toThrow instead. Done in b8250d7.
… error in test Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Fixed in b8250d7 — the import list is now formatted across separate lines as prettier requires. |
stephenhand
left a comment
There was a problem hiding this comment.
Move the issueSyncToken client method from ServerlessService.ts to SyncService.ts
Add a feature flag called use_twilio_lambda_to_issue_sync_token to toggle using the legacy or new endpoint for issuing sync tokens. If the flag is set, use the new endpoint
…sue_sync_token feature flag Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Done in 9981e0c:
|
Migrates
issueSyncTokenfrom the Twilio Serverless runtime into thelambdas/account-scopedpackage, placing the handler at the root ofsrc/per the issue spec. Also wires up the client-side call inplugin-hrm-formto support toggling between the legacy serverless endpoint and the new lambda via a feature flag.Changes
lambdas/account-scopedsrc/issueSyncToken.ts— New handler issuing a Twilio Sync JWT (SyncGrant) for the authenticated worker's identity. UsesgetSyncServiceSidfrom@tech-matters/twilio-configurationand shared API key/secret helpers. Errors propagate to the top-level handler rather than being caught locally.src/router.ts— RegistersissueSyncTokenroute withvalidateFlexTokenRequest({ tokenMode: 'agent' })pipeline (mirrors the originalTokenValidatorwrapper).src/validation/flexToken.ts— Addsidentity?: stringtoTokenValidatorResponseto expose the caller identity from the validated Flex token.src/webchatAuthentication/createToken.ts— ExportsgetApiKeyalongside the existinggetApiSecretto avoid duplication;createTokenupdated to use the exported helper.tests/unit/issueSyncToken.test.ts— Unit tests covering success path and missing identity (400).plugin-hrm-formsrc/services/SyncService.ts— Moves theissueSyncTokenclient call fromServerlessService.tsintoSyncService.ts(as a private function). Reads theuse_twilio_lambda_to_issue_sync_tokenfeature flag to toggle between the legacy serverless endpoint and the new lambda endpoint.src/services/ServerlessService.ts— RemovesissueSyncToken(now handled inSyncService.ts).src/types/FeatureFlags.ts— Addsuse_twilio_lambda_to_issue_sync_token: booleanflag to enable the new lambda endpoint for issuing sync tokens.Checklist
Other Related Issues
None
Verification steps
POST /lambda/twilio/account-scoped/{accountSid}/issueSyncTokenendpoint returns a valid Twilio Sync JWT when called with a valid Flex agent token.use_twilio_lambda_to_issue_sync_token: truein the Flex service configuration feature flags and confirm the plugin uses the new lambda endpoint.false), the legacy serverless endpoint is used.AFTER YOU MERGE
You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.