mirror of
https://github.com/coracle-social/coracle.git
synced 2024-10-01 17:31:24 +00:00
Sign upload auth
This commit is contained in:
parent
f49c7caca5
commit
625718fbf9
@ -173,8 +173,7 @@ export class Builder {
|
|||||||
|
|
||||||
createLabel = (payload: EventOpts) => buildEvent(1985, payload)
|
createLabel = (payload: EventOpts) => buildEvent(1985, payload)
|
||||||
|
|
||||||
createNip98AuthHeader = (tags: string[][]) =>
|
nip98Auth = (tags: string[][]) => buildEvent(27235, {tags})
|
||||||
`Nostr ${btoa(JSON.stringify(buildEvent(27235, {tags})))}`
|
|
||||||
|
|
||||||
initialize(engine: Engine) {
|
initialize(engine: Engine) {
|
||||||
this.engine = engine
|
this.engine = engine
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
import Spinner from "src/partials/Spinner.svelte"
|
import Spinner from "src/partials/Spinner.svelte"
|
||||||
import Anchor from "src/partials/Anchor.svelte"
|
import Anchor from "src/partials/Anchor.svelte"
|
||||||
import {listenForFile, stripExifData, blobToFile} from "src/util/html"
|
import {listenForFile, stripExifData, blobToFile} from "src/util/html"
|
||||||
import {Builder} from "src/app/engine"
|
import {Builder, Outbox} from "src/app/engine"
|
||||||
|
|
||||||
export let icon = null
|
export let icon = null
|
||||||
export let value = null
|
export let value = null
|
||||||
@ -41,14 +41,18 @@
|
|||||||
body.append("file[]", file)
|
body.append("file[]", file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const event = Outbox.prep(
|
||||||
|
Builder.nip98Auth([
|
||||||
|
["u", url],
|
||||||
|
["method", "POST"],
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
const result = await Fetch.fetchJson(url, {
|
const result = await Fetch.fetchJson(url, {
|
||||||
body,
|
body,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: Builder.createNip98AuthHeader([
|
Authorization: `Nostr ${btoa(JSON.stringify(event))}`,
|
||||||
["u", url],
|
|
||||||
["method", "POST"],
|
|
||||||
]),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user