* Use Bearer in the authorization header
* UID doesn't have to passed to connect
* Always use the polyfill since we pass customer headers

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2020-07-10 14:28:05 +02:00
Родитель 0dc0b11000
Коммит 765b896676
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F941078878347C0C
2 изменённых файлов: 4 добавлений и 7 удалений

Просмотреть файл

@ -20,7 +20,6 @@ import { connect } from '@nextcloud/push'
const connection = connect(
'mail',
'folder/INBOX',
'gerda',
e => console.info(e)
)

Просмотреть файл

@ -1,11 +1,9 @@
import axios from '@nextcloud/axios'
import { EventSourcePolyfill, NativeEventSource } from 'event-source-polyfill'
import { EventSourcePolyfill } from 'event-source-polyfill'
import { generateOcsUrl } from '@nextcloud/router'
import { Listener } from './Listener'
import { Connection } from './Connection'
const EventSourceImplementation = NativeEventSource || EventSourcePolyfill
class ConnectionDetails {
url: string
@ -28,13 +26,13 @@ async function validateAccess(appId: string, topic: string): Promise<ConnectionD
return new ConnectionDetails(endpoint, jwt)
}
export async function connect(appId: string, topic: string, uid: string, listener: Listener): Promise<Connection> {
export async function connect(appId: string, topic: string, listener: Listener): Promise<Connection> {
const details = await validateAccess(appId, topic)
return new Connection(
new EventSourceImplementation(details.url, {
new EventSourcePolyfill(details.url, {
headers: {
authorization: details.jwt,
authorization: 'Bearer ' + details.jwt,
},
withCredentials: false
}),