docs(sdk): say up front that writes need a key, and fix two broken examples - #142
Merged
Conversation
…amples
The quick start pointed at a public instance with no credentials and called
createNote — a 401 on every instance. The rule was buried 60 lines below the
copy-pasteable block. It now leads, with a table of what each kind of instance
allows and the commands to run one.
Also: the files example took a browser File where the option takes
{ name, type, data: Uint8Array }, retryBackoffMs was documented as a number
rather than a function, the CORS single-origin rule was undocumented, and the
timeoutMs / maxRetries defaults were shown as if active.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Someone who finds
@largerio/secret-sdkon npm and copy-pastes the quick start gets a401. The block pointed at the public demo instance with no credentials and then calledcreateNote— a write, which every instance rejects without an API key or a PoW token. The rule was stated correctly, 60 lines further down, after the reader had already given up.Verified against the live instance:
What changed
createCors([config.appUrl])(apps/api/src/app.ts:69) allows exactly one origin, so a front-end served from any other domain is blocked including on reads. That was nowhere.apps/web/src/lib/utils/cap.tspoints the widget at/api/cap/, so it is a same-origin browser path. Server-side callers need a key.Two examples that could not have worked
files: [new File([bytes], "report.pdf")]— the option takes{ name, type, data: Uint8Array }(types.ts:60). AFilehas no.data, so it failed to typecheck and would have thrown onf.data.length(client.ts:131). Replaced with a Node example, plus a line for converting a browserFile.retryBackoffMs: 300— the type is(attempt: number) => number(types.ts:54).Also corrects the
timeoutMs(none) andmaxRetries(0) defaults, which were shown as if active, and stops describing the two runtime dependencies as peer dependencies.Release
Includes a
patchchangeset. Merging this opens thechore: version packagesPR (1.1.0→1.1.1); merging that publishes and is what updates the README shown on npmjs.com.