Gathering detailed insights and metrics for actioncable-vue-jwt
Gathering detailed insights and metrics for actioncable-vue-jwt
npm install actioncable-vue-jwt
Typescript
Module System
Node Version
NPM Version
64.5
Supply Chain
97.2
Quality
75.1
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,875
Last Day
1
Last Week
2
Last Month
15
Last Year
194
MIT License
4 Stars
54 Commits
2 Forks
1 Branches
1 Contributors
Updated on Dec 10, 2021
Latest Version
1.0.1
Package Id
actioncable-vue-jwt@1.0.1
Unpacked Size
25.05 kB
Size
7.91 kB
File Count
5
NPM Version
6.5.0
Node Version
11.7.0
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-50%
2
Compared to previous week
Last Month
66.7%
15
Compared to previous month
Last Year
-51.4%
194
Compared to previous year
ActionCableVueJWT is an easy-to-use Action Cable integration for VueJS when using JSON Web Tokens.
NOTE: ActionCableVueJWT was forked from ActionCableVue in order to add JWT authentication in the same vein as action-cable-react-jwt
. If you do not need JWT authentication, rather use ActionCableVue.
1npm install actioncable-vue-jwt --save
1import Vue from 'vue'; 2import App from './App.vue'; 3import ActionCableVueJWT from 'actioncable-vue-jwt'; 4 5Vue.use(ActionCableVueJWT, { 6 debug: true, 7 debugLevel: 'error', 8 connectionUrl: 'ws://localhost:5000/api/cable', 9 connectImmediately: false, 10 jwt: function() { this.$auth.getToken() } 11}); 12 13new Vue({ 14 router, 15 store, 16 render: h => h(App) 17}).$mount('#app');
Parameters | Type | Default | Required | Description |
---|---|---|---|---|
debug | Boolean | false | Optional | Enable logging for debug |
debugLevel | String | error | Optional | Debug level required for logging. Either info , error , or all |
connectionUrl | String | null | Required | ActionCable websocket server url |
connectImmediately | Boolean | true | Optional | Connect on initialization, otherwise first subscription |
jwt | Function | null | Optional | A way to obtain the JWT for the current user |
If you want to listen channel events from your Vue component, you need to add a `channels` object in the Vue component. Each defined object in `channels` will start to receive events provided you subscribe correctly.
1new Vue({ 2 data() { 3 return { 4 message: 'Hello world' 5 }; 6 }, 7 channels: { 8 ChatChannel: { 9 connected() {}, 10 rejected() {}, 11 received(data) {}, 12 disconnected() {} 13 } 14 }, 15 methods: { 16 sendMessage: function() { 17 this.$cable.perform({ 18 channel: 'ChatChannel', 19 action: 'send_message', 20 data: { content: this.message } 21 }); 22 } 23 }, 24 mounted() { 25 this.$cable.subscribe({ channel: 'ChatChannel', room: 'public' }); 26 } 27});
Requires that you have an object defined in your component's channels
object matching the action cable server channel name you passed for the subscription.
1new Vue({ 2 channels: { 3 ChatChannel: { 4 connected() { 5 console.log('I am connected.'); 6 } 7 } 8 }, 9 mounted() { 10 this.$cable.subscribe({ channel: 'ChatChannel' }); 11 } 12});
ActionCableVue automatically uses your ActionCable server channel name if you do not pass in a specific channel name to use in your
channels
. It will also override clashing channel names.
1new Vue({ 2 channels: { 3 chat_channel_public: { 4 connected() { 5 console.log('I am connected to the public chat channel.'); 6 } 7 }, 8 chat_channel_private: { 9 connected() { 10 console.log('I am connected to the private chat channel.'); 11 } 12 } 13 }, 14 mounted() { 15 this.$cable.subscribe( 16 { channel: 'ChatChannel', room: 'public' }, 17 'chat_channel_public' 18 ); 19 this.$cable.subscribe( 20 { channel: 'ChatChannel', room: 'private' }, 21 'chat_channel_private' 22 ); 23 } 24});
1new Vue({ 2 data() { 3 return { 4 user: { 5 id: 7 6 } 7 }; 8 }, 9 computed: { 10 channelId() { 11 return `${this.user.id}_chat_channel`; 12 } 13 }, 14 channels: { 15 [this.channelId]: { 16 connected() { 17 console.log("I am connected to a user's chat channel."); 18 } 19 } 20 }, 21 mounted() { 22 this.$cable.subscribe( 23 { channel: 'ChatChannel', room: this.user.id }, 24 this.channelId 25 ); 26 } 27});
When your component is destroyed ActionCableVue automatically unsubscribes from any channel that component was subscribed to.
1new Vue({ 2 methods: { 3 unsubscribe() { 4 this.$cable.unsubscribe('ChatChannel'); 5 } 6 }, 7 mounted() { 8 this.$cable.subscribe({ channel: 'ChatChannel' }); 9 } 10});
Requires that you have a method defined in your Rails Action Cable channel whose name matches the action property passed in.
1new Vue({ 2 channels: { 3 ChatChannel: { 4 connected() { 5 console.log('Connected to the chat channel'); 6 }, 7 received(data) { 8 console.log('Message received'); 9 } 10 } 11 }, 12 methods: { 13 sendMessage() { 14 this.$cable.perform({ 15 channel: 'ChatChannel', 16 action: 'send_message', 17 data: { content: 'Hi' } 18 }); 19 } 20 }, 21 mounted() { 22 this.$cable.subscribe({ channel: 'ChatChannel' }); 23 } 24});
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More