{"id":16024713,"url":"https://github.com/stephenlb/pubnub-sse","last_synced_at":"2026-02-07T08:02:50.735Z","repository":{"id":257801702,"uuid":"863185850","full_name":"stephenlb/pubnub-sse","owner":"stephenlb","description":"PubNub SSE SDK","archived":false,"fork":false,"pushed_at":"2025-08-19T18:37:47.000Z","size":696,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-27T00:41:02.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephenlb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-25T21:36:40.000Z","updated_at":"2025-08-19T18:37:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"e05303e9-a6a4-4818-8a9b-ec4c627cb87f","html_url":"https://github.com/stephenlb/pubnub-sse","commit_stats":null,"previous_names":["stephenlb/pubnub-sse"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stephenlb/pubnub-sse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenlb%2Fpubnub-sse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenlb%2Fpubnub-sse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenlb%2Fpubnub-sse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenlb%2Fpubnub-sse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenlb","download_url":"https://codeload.github.com/stephenlb/pubnub-sse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenlb%2Fpubnub-sse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29189675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T19:23:18.126Z","updated_at":"2026-02-07T08:02:50.717Z","avatar_url":"https://github.com/stephenlb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PubNub SSE\n\nEasy to use PubNub SDK with SSE enabled by default.\n\n\n### NPM Install\n\n```shell\nnpm install pubnub-sse\n```\n\n### Run a Quick Demo\n\n```shell\ngit clone https://github.com/stephenlb/pubnub-sse.git\ncd pubnub-sse\nopen index.html\n```\n\n#### Important Files:\n\n - `pubnub.js` PubNub SSE Streaming SDK\n - `index.html` Example app open to see a demo using streaming data.\n\n![PubNub SSE Screenshot](media/screenshot.png)\n\nSetup the SDK as follows in the example.\n\n### Subscription Async Iterator\n\n```javascript\nconst pubnub = PubNub({ subscribeKey: 'demo', publishKey: 'demo'});\nconst subscription = pubnub.subscribe({channel: 'test'});\n\nlet count = 0;\nfor await (const msg of subscription) {\n    console.log(msg);\n    if (count++ \u003e= 2) break;\n}\n```\n\n### Subscription Callback\n```javascript\nconst pubnub = PubNub({ subscribeKey: 'demo', publishKey: 'demo'});\nconst subscription = pubnub.subscribe({channel: 'test', messages: reciever});\n\nfunction reciever(msg) {\n    console.log(msg);\n}\n```\n\n\n### Encryption Example\n\nUsing the `crypto-js` common crypto lib for encryption/decryption.\nWith added support for Cross-Platform messaging.\n\n```javascript\nconst PubNub = require('pubnub-sse');    // npm install pubnub-sse\nconst PubNubCryptor = require('pubnub'); // npm install pubnub\n\nconst pubkey = 'demo';\nconst subkey = 'demo';\nconst authKey = 'demo-auth-key';\nconst userId = 'test-user-id';\nconst cipherKey = 'pubnubenigma';\n\nconst pubnubInstance = PubNub({\n    publishKey: pubkey,\n    subscribeKey: subkey,\n    authKey: authKey,\n    userId: userId,\n});\n\nconst pubnubCryptor = new PubNubCryptor({\n    subscribeKey: subkey,\n    publishKey: pubkey,\n    uuid: userId,\n    authKey: authKey,\n    cipherKey: cipherKey,\n});\n\nconst message = { text: \"Hello World\" };\nconst stringData = JSON.stringify(message);\nconst encrypted = pubnubCryptor.encrypt(stringData);\nconst channel = `test-channel-${Math.random()}`;\nconst subscription = pubnubInstance.subscribe({channel: channel});\n\n// Publish\nsetTimeout(async () =\u003e {\n    await pubnubInstance.publish({ channel: channel, message: encrypted});\n}, 1000);\n\n// Subscription Stream\nfor await (const encryptedMessage of subscription) {\n    const decrypted = pubnubCryptor.decrypt(encryptedMessage);\n    expect(encryptedMessage).to.equal(encrypted);\n    expect(encryptedMessage).to.be.a('string');\n    expect(decrypted).to.be.an('object');\n    expect(message).to.deep.equal(decrypted);\n    break;\n}\n\nsubscription.unsubscribe();\n```\n\n### Example Code\n\n```html\n\u003cscript src=\"pubnub.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n\n// PubNub Setup\nconst userId = 'user-id';\nconst authKey = 'auth-key';\nconst channel = 'Commands';\nconst pubkey = 'pub-c-a88f5e0f-af28-4847-ad52-30495d0cbcb8';\nconst subkey = 'sub-c-a8cbfccb-676b-4034-9681-dfed95af8d7e';\nconst pubnub = PubNub({\n    subscribeKey: subkey,\n    publishKey: pubkey,\n    authKey: authKey,\n    userId: userId,\n});\n\n// Subscribe to Events \"Starts the Stream\"\nconst subscription = pubnub.subscribe({\n    channel: channel,\n    messages: receiveEvents,\n});\n\n// End subscription\n// subscription.unsubscribe();\n\n// Event Processing\nfunction receiveEvents(event) {\n    console.log(event);\n}\n\n// Publish Events Example\nlet eventId = 0;\nsetInterval(() =\u003e {\n    pubnub.publish({\n        channel: channel,\n        message: {\n            eventId: ++eventId, \n            userId: userId,\n            data: `Event ${eventId} from ${userId} at ${new Date().toISOString()}`,\n        },\n    });\n}, 1000);\n\n\u003c/script\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenlb%2Fpubnub-sse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenlb%2Fpubnub-sse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenlb%2Fpubnub-sse/lists"}