Customize nip 46 perms
This commit is contained in:
+2
-2
@@ -46,7 +46,6 @@ import {
|
||||
nip44EncryptToSelf,
|
||||
loadRelay,
|
||||
addSession,
|
||||
nip46Perms,
|
||||
subscribe,
|
||||
} from "@welshman/app"
|
||||
import {
|
||||
@@ -55,6 +54,7 @@ import {
|
||||
userMembership,
|
||||
MEMBERSHIPS,
|
||||
INDEXER_RELAYS,
|
||||
NIP46_PERMS,
|
||||
loadMembership,
|
||||
loadSettings,
|
||||
getDefaultPubkeys,
|
||||
@@ -123,7 +123,7 @@ export const subscribePersistent = (request: SubscribeRequestWithHandlers) => {
|
||||
export const loginWithNip46 = async (token: string, handler: Nip46Handler) => {
|
||||
const secret = makeSecret()
|
||||
const broker = Nip46Broker.get({secret, handler})
|
||||
const result = await broker.connect(token, nip46Perms)
|
||||
const result = await broker.connect(token, NIP46_PERMS)
|
||||
|
||||
if (!result) return false
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {onDestroy} from "svelte"
|
||||
import {Nip46Broker} from "@welshman/signer"
|
||||
import {nip46Perms, addSession} from "@welshman/app"
|
||||
import {addSession} from "@welshman/app"
|
||||
import {slideAndFade} from "@lib/transition"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
@@ -15,14 +15,14 @@
|
||||
import {pushModal, clearModals} from "@app/modal"
|
||||
import {setChecked} from "@app/notifications"
|
||||
import {pushToast} from "@app/toast"
|
||||
import {PLATFORM_URL, PLATFORM_NAME, PLATFORM_LOGO, SIGNER_RELAYS} from "@app/state"
|
||||
import {NIP46_PERMS, PLATFORM_URL, PLATFORM_NAME, PLATFORM_LOGO, SIGNER_RELAYS} from "@app/state"
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const abortController = new AbortController()
|
||||
|
||||
const init = Nip46Broker.initiate({
|
||||
perms: nip46Perms,
|
||||
perms: NIP46_PERMS,
|
||||
url: PLATFORM_URL,
|
||||
name: PLATFORM_NAME,
|
||||
relays: SIGNER_RELAYS,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {makeSecret, Nip46Broker} from "@welshman/signer"
|
||||
import {addSession, nip46Perms, loadHandle} from "@welshman/app"
|
||||
import {addSession, loadHandle} from "@welshman/app"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Field from "@lib/components/Field.svelte"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
@@ -11,7 +11,7 @@
|
||||
import InfoNostr from "@app/components/InfoNostr.svelte"
|
||||
import {pushModal, clearModals} from "@app/modal"
|
||||
import {setChecked} from "@app/notifications"
|
||||
import {PLATFORM_NAME} from "@app/state"
|
||||
import {PLATFORM_NAME, NIP46_PERMS} from "@app/state"
|
||||
import {pushToast} from "@app/toast"
|
||||
|
||||
const login = () => pushModal(LogIn)
|
||||
@@ -28,7 +28,7 @@
|
||||
}
|
||||
|
||||
const signupBroker = Nip46Broker.get({secret, handler})
|
||||
const pubkey = await signupBroker.createAccount(username, nip46Perms)
|
||||
const pubkey = await signupBroker.createAccount(username, NIP46_PERMS)
|
||||
|
||||
if (!pubkey) {
|
||||
return pushToast({
|
||||
@@ -40,7 +40,7 @@
|
||||
// Gotta use user pubkey as the handler pubkey for historical reasons
|
||||
const loginBroker = Nip46Broker.get({secret, handler: {...handler, pubkey}})
|
||||
|
||||
if (await loginBroker.connect("", nip46Perms)) {
|
||||
if (await loginBroker.connect("", NIP46_PERMS)) {
|
||||
addSession({method: "nip46", pubkey, secret, handler: {...handler, pubkey}})
|
||||
pushToast({message: "Successfully logged in!"})
|
||||
setChecked("*")
|
||||
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
import {
|
||||
getIdFilters,
|
||||
WRAP,
|
||||
CLIENT_AUTH,
|
||||
AUTH_JOIN,
|
||||
REACTION,
|
||||
ZAP_RESPONSE,
|
||||
DIRECT_MESSAGE,
|
||||
@@ -99,6 +101,12 @@ export const IMGPROXY_URL = "https://imgproxy.coracle.social"
|
||||
|
||||
export const REACTION_KINDS = [REACTION, ZAP_RESPONSE]
|
||||
|
||||
export const NIP46_PERMS =
|
||||
"nip04_encrypt,nip04_decrypt,nip44_encrypt,nip44_decrypt" +
|
||||
[CLIENT_AUTH, AUTH_JOIN, MESSAGE, THREAD, COMMENT, MEMBERSHIPS, WRAP, REACTION]
|
||||
.map(k => `sign_event:${k}`)
|
||||
.join(",")
|
||||
|
||||
export const colors = [
|
||||
["amber", twColors.amber[600]],
|
||||
["blue", twColors.blue[600]],
|
||||
|
||||
Reference in New Issue
Block a user