mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-13 06:35:24 +03:00
Implement public key encoding
This commit is contained in:
parent
afe2032085
commit
5398a661ff
@ -3,6 +3,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from cryptography.hazmat.primitives import serialization
|
||||||
from flask import (
|
from flask import (
|
||||||
Blueprint,
|
Blueprint,
|
||||||
current_app,
|
current_app,
|
||||||
@ -11,7 +12,7 @@ from flask import (
|
|||||||
request,
|
request,
|
||||||
)
|
)
|
||||||
from peewee import DoesNotExist
|
from peewee import DoesNotExist
|
||||||
from py_vapid import Vapid01
|
from py_vapid import Vapid01, utils
|
||||||
|
|
||||||
from frigate.const import CONFIG_DIR
|
from frigate.const import CONFIG_DIR
|
||||||
from frigate.models import User
|
from frigate.models import User
|
||||||
@ -30,7 +31,10 @@ def get_vapid_pub_key():
|
|||||||
)
|
)
|
||||||
|
|
||||||
key = Vapid01.from_file(os.path.join(CONFIG_DIR, "notifications.pem"))
|
key = Vapid01.from_file(os.path.join(CONFIG_DIR, "notifications.pem"))
|
||||||
return jsonify(key.public_key), 200
|
raw_pub = key.public_key.public_bytes(
|
||||||
|
serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint
|
||||||
|
)
|
||||||
|
return jsonify(utils.b64urlencode(raw_pub)), 200
|
||||||
|
|
||||||
|
|
||||||
@NotificationBp.route("/notifications/register", methods=["POST"])
|
@NotificationBp.route("/notifications/register", methods=["POST"])
|
||||||
|
|||||||
@ -13,6 +13,12 @@ const NOTIFICATION_SERVICE_WORKER = "notifications-worker.ts";
|
|||||||
export default function NotificationView() {
|
export default function NotificationView() {
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
|
|
||||||
|
// notification key handling
|
||||||
|
|
||||||
|
const { data: publicKey } = useSWR(
|
||||||
|
config?.notifications?.enabled ? "notifications/pubkey" : null,
|
||||||
|
);
|
||||||
|
|
||||||
// notification state
|
// notification state
|
||||||
|
|
||||||
const [notificationsSubscribed, setNotificationsSubscribed] =
|
const [notificationsSubscribed, setNotificationsSubscribed] =
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user