@supabase/realtime-js
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -25,3 +25,4 @@ export declare const DEFAULT_HEADERS: { | ||
reply = "phx_reply", | ||
leave = "phx_leave" | ||
leave = "phx_leave", | ||
access_token = "access_token" | ||
} | ||
@@ -28,0 +29,0 @@ export declare enum TRANSPORTS { |
@@ -31,2 +31,3 @@ "use strict"; | ||
CHANNEL_EVENTS["leave"] = "phx_leave"; | ||
CHANNEL_EVENTS["access_token"] = "access_token"; | ||
})(CHANNEL_EVENTS = exports.CHANNEL_EVENTS || (exports.CHANNEL_EVENTS = {})); | ||
@@ -33,0 +34,0 @@ var TRANSPORTS; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.2.1"; | ||
export declare const version = "1.3.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// generated by genversion | ||
exports.version = '1.2.1'; | ||
exports.version = '1.3.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -28,2 +28,3 @@ import Timer from './lib/timer'; | ||
export default class RealtimeClient { | ||
accessToken: string | null; | ||
channels: RealtimeSubscription[]; | ||
@@ -149,2 +150,8 @@ endPoint: string; | ||
makeRef(): string; | ||
/** | ||
* Sets the JWT access token used for channel subscription authorization and Realtime RLS. | ||
* | ||
* @param token A JWT string. | ||
*/ | ||
setAuth(token: string | null): void; | ||
private _onConnOpen; | ||
@@ -151,0 +158,0 @@ private _onConnClose; |
@@ -38,2 +38,3 @@ "use strict"; | ||
constructor(endPoint, options) { | ||
this.accessToken = null; | ||
this.channels = []; | ||
@@ -267,2 +268,13 @@ this.endPoint = ''; | ||
} | ||
/** | ||
* Sets the JWT access token used for channel subscription authorization and Realtime RLS. | ||
* | ||
* @param token A JWT string. | ||
*/ | ||
setAuth(token) { | ||
this.accessToken = token; | ||
this.channels.forEach((channel) => channel.push(constants_1.CHANNEL_EVENTS.access_token, { | ||
access_token: token, | ||
})); | ||
} | ||
_onConnOpen() { | ||
@@ -321,8 +333,3 @@ this.log('transport', `connected to ${this.endPointURL()}`); | ||
this.pendingHeartbeatRef = this.makeRef(); | ||
this.push({ | ||
topic: 'phoenix', | ||
event: 'heartbeat', | ||
payload: {}, | ||
ref: this.pendingHeartbeatRef, | ||
}); | ||
this.setAuth(this.accessToken); | ||
} | ||
@@ -329,0 +336,0 @@ } |
@@ -25,3 +25,4 @@ export declare const DEFAULT_HEADERS: { | ||
reply = "phx_reply", | ||
leave = "phx_leave" | ||
leave = "phx_leave", | ||
access_token = "access_token" | ||
} | ||
@@ -28,0 +29,0 @@ export declare enum TRANSPORTS { |
@@ -28,2 +28,3 @@ import { version } from './version'; | ||
CHANNEL_EVENTS["leave"] = "phx_leave"; | ||
CHANNEL_EVENTS["access_token"] = "access_token"; | ||
})(CHANNEL_EVENTS || (CHANNEL_EVENTS = {})); | ||
@@ -30,0 +31,0 @@ export var TRANSPORTS; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.2.1"; | ||
export declare const version = "1.3.0"; | ||
//# sourceMappingURL=version.d.ts.map |
// generated by genversion | ||
export const version = '1.2.1'; | ||
export const version = '1.3.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -28,2 +28,3 @@ import Timer from './lib/timer'; | ||
export default class RealtimeClient { | ||
accessToken: string | null; | ||
channels: RealtimeSubscription[]; | ||
@@ -149,2 +150,8 @@ endPoint: string; | ||
makeRef(): string; | ||
/** | ||
* Sets the JWT access token used for channel subscription authorization and Realtime RLS. | ||
* | ||
* @param token A JWT string. | ||
*/ | ||
setAuth(token: string | null): void; | ||
private _onConnOpen; | ||
@@ -151,0 +158,0 @@ private _onConnClose; |
@@ -33,2 +33,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
constructor(endPoint, options) { | ||
this.accessToken = null; | ||
this.channels = []; | ||
@@ -262,2 +263,13 @@ this.endPoint = ''; | ||
} | ||
/** | ||
* Sets the JWT access token used for channel subscription authorization and Realtime RLS. | ||
* | ||
* @param token A JWT string. | ||
*/ | ||
setAuth(token) { | ||
this.accessToken = token; | ||
this.channels.forEach((channel) => channel.push(CHANNEL_EVENTS.access_token, { | ||
access_token: token, | ||
})); | ||
} | ||
_onConnOpen() { | ||
@@ -316,10 +328,5 @@ this.log('transport', `connected to ${this.endPointURL()}`); | ||
this.pendingHeartbeatRef = this.makeRef(); | ||
this.push({ | ||
topic: 'phoenix', | ||
event: 'heartbeat', | ||
payload: {}, | ||
ref: this.pendingHeartbeatRef, | ||
}); | ||
this.setAuth(this.accessToken); | ||
} | ||
} | ||
//# sourceMappingURL=RealtimeClient.js.map |
{ | ||
"name": "@supabase/realtime-js", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Listen to realtime updates to your PostgreSQL database", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -32,2 +32,3 @@ import { version } from './version' | ||
leave = 'phx_leave', | ||
access_token = 'access_token', | ||
} | ||
@@ -34,0 +35,0 @@ |
// generated by genversion | ||
export const version = '1.2.1' | ||
export const version = '1.3.0' |
@@ -37,2 +37,3 @@ import { | ||
export default class RealtimeClient { | ||
accessToken: string | null = null | ||
channels: RealtimeSubscription[] = [] | ||
@@ -321,2 +322,17 @@ endPoint: string = '' | ||
/** | ||
* Sets the JWT access token used for channel subscription authorization and Realtime RLS. | ||
* | ||
* @param token A JWT string. | ||
*/ | ||
setAuth(token: string | null) { | ||
this.accessToken = token | ||
this.channels.forEach((channel) => | ||
channel.push(CHANNEL_EVENTS.access_token, { | ||
access_token: token, | ||
}) | ||
) | ||
} | ||
private _onConnOpen() { | ||
@@ -390,9 +406,4 @@ this.log('transport', `connected to ${this.endPointURL()}`) | ||
this.pendingHeartbeatRef = this.makeRef() | ||
this.push({ | ||
topic: 'phoenix', | ||
event: 'heartbeat', | ||
payload: {}, | ||
ref: this.pendingHeartbeatRef, | ||
}) | ||
this.setAuth(this.accessToken) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
210363
3758