Fix working
* 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:
Родитель
0dc0b11000
Коммит
765b896676
|
@ -20,7 +20,6 @@ import { connect } from '@nextcloud/push'
|
|||
const connection = connect(
|
||||
'mail',
|
||||
'folder/INBOX',
|
||||
'gerda',
|
||||
e => console.info(e)
|
||||
)
|
||||
|
||||
|
|
10
lib/index.ts
10
lib/index.ts
|
@ -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
|
||||
}),
|
||||
|
|
Загрузка…
Ссылка в новой задаче