Repository navigation
Add a read-only SkuVault adapter - #1834
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
helpcodeai
left a comment
There was a problem hiding this comment.
Thanks! SkuVault on its official API is a good fit for the catalog, and the adapter itself looks clean.
A few things before we can run CI:
- CLA. The check reads the commit author, and the commits are authored by Cursor Agent (
cursoragent), which has not signed. Please rewrite the commits under your own account, for examplegit rebase -i mainwithgit commit --amend --reset-author --no-editon each commit, then force-push. - Login token in raw and form bodies. In
rest.engine.ts,loginTokenandloginAudare added tobodyParamsfor everybodyMappingbranch, butrenderTokenBodyis set only in the JSON branch. For__raw,form-urlencodedandform-datathis means two things: the body is not marked as carrying credentials, so it can follow a cross-origin redirect with the token, and after a re-login the retry goes out with the old token. Please either inject the values only in the JSON branch, or setrenderTokenBodyfor the other branches too. Please add a spec for it: abodyMappingthat carries$loginTokenis not re-sent after a cross-origin 307, and the retry after a re-login carries the new token. - Rebase on main. Only
package.jsonconflicts (the count text next to the 0.55.10 bump). Then runnode scripts/adapter-count.mjs --checkagain. - Please run the full backend suite once (
npm testinpackages/backend), not only the single specs.
Optional: the email pattern ^[^@\s]+@[^@\s]+\.[^@\s]+$ can backtrack, because . overlaps [^@\s]. A linear form is ^[^@\s]+@[^@\s.]+(\.[^@\s.]+)+$.
The engine part ($loginToken / $loginAud in bodyMapping) changes how connector credentials are sent, so we also look at it on our side. We will tell you here if we want it done differently.
15685f9 to
9b66a4d
Compare
9b66a4d to
cf867d7
Compare
|
Thanks a lot for the fixes. I went through the new commits: the token now reaches every body format, the body is marked as carrying credentials so a cross-origin redirect is refused, the re-login retry rebuilds the body with the new token, and the engine values win over caller parameters with the same name. The adapter itself looks good to me. Because this extends how the login-token engine places credentials, it needs one more sign-off on our side before it can merge. I'll come back to you here as soon as that is done. The new conflict in |
SkuVault puts a TenantToken and a UserToken in every JSON body. LOGIN_TOKEN can now place both after getTokens, and a null token is reported as a refused login. Fixes HelpCode-ai#1406 Signed-off-by: yuzhou <1991039819@qq.com>
The null-token message is chosen after the login is already rejected, so a field in the remote body cannot skip a lookup or the throw. Signed-off-by: yuzhou <1991039819@qq.com>
A bodyMapping that carries the login token now refuses a cross-origin redirect and is rebuilt after a re-login for raw and form bodies, the same as JSON. The SkuVault email pattern no longer overlaps on the dot. Signed-off-by: yuzhou <1991039819@qq.com>
268aafd to
54dc801
Compare
|
Rebased onto current The conflicts were the advertised adapter counts next to the version line. The catalog is now 962, the version stays at 0.55.17, and The earlier review notes are in this history: |
|
Thanks for the rebase and for cleaning up the commits. CI is green and the adapter count check passes. The change to the login token engine still needs one sign-off on our side. As soon as that is done I will update the branch and merge it. |
helpcodeai
left a comment
There was a problem hiding this comment.
Thanks for the rebase and the careful engine change. We reviewed it for security and found one thing to change before we can merge.
The SkuVault UserToken is stored in plain text. The adapter reads the second token from the getTokens answer through audJsonPath. LoginTokenService caches that value as aud in connectorAuthCache.metadata (see login-token.service.ts on main, where the cache row is written: metadata = bundle.metadata || { aud }). Only token is encrypted with ENCRYPTION_KEY. For the existing adapters aud is a public audience value, so that was fine. For SkuVault it is half of the credential pair: anyone who can read the database could call the SkuVault API with it.
What we need:
- Encrypt
audbefore it is written toconnectorAuthCacheand decrypt it when the row is read, the same way astoken. A simple way is an opt-in flag on the auth config (for exampleaudSecret: true) that the SkuVault adapter sets, so the other adapters keep their current rows. If you prefer to encryptaudfor every adapter, the read path must still accept old plain rows. - Make sure
audnever appears in logs or error messages (the same rule as fortoken). - A unit test in
login-token.service.spec.tsthat checks the stored metadata does not contain the plain UserToken and that a cached row still gives the right value back. - Update the branch with main afterwards (it has conflicts in the counts).
The rest looks good to us: the $loginToken / $loginAud body mapping, the null-token refusal message and the static spec. When this is done we review again.
Keep upstream's version (0.55.21) and metadata; the advertised adapter count is upstream's 974 plus SkuVault (975). In rest.engine.ts keep both the form-data login-token re-render and upstream's binary body encoding.
…oken cache SkuVault's UserToken (audJsonPath / $loginAud) was cached in plain text in connectorAuthCache.metadata. With authConfig.audSecret: true it is now stored as metadata.audEnc, encrypted with ENCRYPTION_KEY like the token, decrypted on read, and never logged. Rows cached without the flag still read. SkuVault sets the flag; the validator checks it; tests cover storage, round trip, legacy rows, the unflagged default and the logs.
|
Addressed the plaintext
|
helpcodeai
left a comment
There was a problem hiding this comment.
Thanks for the update. The UserToken is now stored encrypted with audSecret, it is never logged, and a body that carries the token is not sent to another origin on a redirect. The tests cover both the old and the new cache rows. Looks good to me, merging.
Summary
People searching the connector catalog for SkuVault were getting nothing. This adds a read-only SkuVault (Linnworks) adapter so an assistant can look up products, bin-level inventory, warehouses, and sales that are ready to ship or pending.
SkuVault's
getTokenscall returns a tenant token and a user token, and every later call sends both in the JSON body.LOGIN_TOKENcould place only one issued value. The engine now also places the second login field (audJsonPath) as$loginAudin a body mapping or${loginAud}in a body template, and a token field that comes back null is reported as a refused login. A wrong SkuVault password answers HTTP 200 with both tokens null, so that message is what the setup check shows.The same connector works on AnythingMCP Cloud and on a self-hosted instance:
app.skuvault.comis a public HTTPS API.Changes
packages/backend/src/adapters/intl/skuvault.jsonwith four read-only tools: products, inventory by location, warehouses, and sales. No write tools.POST /gettokens(SKUVAULT_EMAIL,SKUVAULT_PASSWORD) and sendTenantTokenandUserTokenon every call.intl/skuvault.live.spec.ts(static checks always; live calls only whenRUN_SKUVAULT_LIVE=1) and a logo.llms.txt/llms-full.txt.Type
Testing
Built from the public reference at https://dev.skuvault.com/. I do not have a SkuVault account, so
RUN_SKUVAULT_LIVEwas not set and no authenticated call was made.I did call the public API with credentials that are not an account, to learn the refusal shape:
POST https://app.skuvault.com/api/gettokenswith a fake email and password returned HTTP 200 and{"TenantToken":null,"UserToken":null}.POST https://app.skuvault.com/api/inventory/getWarehouseswith fake tokens returned HTTP 401 and{"Warehouses":[]}.Local commands, from the repo root unless noted:
node scripts/validate-adapters.mjs --warnpassed: 976 adapters, 0 failed. SkuVault added no new warning. The run still reports the existing warnings (for examplede/nina-warnung.jsontool prefixes andintl/hubspot.jsonTODO markers).node --test scripts/validate-adapters.test.mjspassed: 45 tests.node scripts/regenerate-catalog.mjsregeneratedcatalog.ts(958 adapters in the count check).node scripts/adapter-count.mjs --checkpassed after the quoted counts moved from 957 to 958.node scripts/generate-llms-txt.mjsandnode scripts/generate-llms-txt.mjs --checkpassed.packages/backend, afterDATABASE_URL=postgresql://localhost:5433/anythingmcp npx prisma generate:npx jest src/connectors/engines/login-token.service.spec.ts --runInBandpassed: 96 tests.npx jest src/connectors/engines/rest.engine.login-token-body.spec.ts --runInBandpassed: 23 tests.npx jest src/adapters/intl/skuvault.live.spec.ts --runInBandpassed: 10 tests, 1 skipped (the live suite).npx jest src/adapters/catalog.spec.ts --runInBandpassed: 23287 tests.npx tsc --noEmit -p tsconfig.jsoninpackages/backendpassed.npx eslinton the touched backend TypeScript files passed.The full
npm testinpackages/backendwas not run. Jest workers ran out of memory when several suites loaded the catalog at once, so the suites above were run one at a time.Checklist
npm test)Related Issues
Fixes #1406