feat(vue): allow extra params in ws subscribe messages#43
Open
BatLeDev wants to merge 1 commit into
Open
Conversation
useWS().subscribe now accepts an optional opaque params object that is merged into the subscribe message and replayed on reconnect. This lets a consumer authorize a channel for an unauthenticated client (e.g. data-fair passing an applicationKey to subscribe to a dataset journal/task-progress behind a protected-link application key) without lib-vue knowing about any specific auth scheme.
e12939e to
98d7567
Compare
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.
useWS().subscribegains an optional third argumentparams— an opaque bag of fields merged into the subscribe message ({ type: 'subscribe', channel, ...params }). The params are remembered per channel and replayed when the socket reconnects and re-subscribes, then dropped on unsubscribe. lib-vue stays agnostic about what they mean.Why: a consumer (data-fair) needs an unauthenticated client — a visualization opened through a protected-link application key — to subscribe to a dataset's realtime channels (journal, task-progress). A browser WebSocket handshake carries no
Referer, so the application key cannot reach the server the way it does over HTTP; passing it in the subscribe message is the way in. This gives the consumer a generic transport (subscribe(channel, cb, { applicationKey })) without lib-vue knowing about application keys.Regression risks:
subscribegains an optional third parameter — backward compatible, existing two-arg calls are unaffected.paramsis provided; the reconnect-replay and unsubscribe paths now also carry then clear these params. No exports renamed or removed.