Compare commits
2 commits
1dd74500f2
...
deb0e7302c
| Author | SHA1 | Date | |
|---|---|---|---|
| deb0e7302c | |||
| dbf653e7cd |
4 changed files with 36 additions and 46 deletions
|
|
@ -21,7 +21,7 @@ const fetchVideoRecord = async (
|
|||
|
||||
const xrpc = new XRPC<ATProtoUniverse>(pds);
|
||||
const record = await xrpc.get("com.atproto.repo.getRecord", {
|
||||
parameters: {
|
||||
params: {
|
||||
collection: "blue.cerulea.video.video",
|
||||
repo: did,
|
||||
rkey,
|
||||
|
|
@ -33,13 +33,13 @@ const fetchVideoRecord = async (
|
|||
};
|
||||
|
||||
const resolveVideoURL = async (
|
||||
did: `did:${string}`,
|
||||
repo: `did:${string}`,
|
||||
blob: string
|
||||
): Promise<string> => {
|
||||
const xrpc = new XRPC<VideoLexiconUniverse>(globalThis.location.href);
|
||||
try {
|
||||
const xrpc = new XRPC<VideoLexiconUniverse>(globalThis.location.href);
|
||||
const res = await xrpc.call("blue.cerulea.video.fetchVideo", {
|
||||
input: { repo: did, blob },
|
||||
input: { repo, blob },
|
||||
});
|
||||
return `/user-content/${res.filename}`;
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -1,26 +1,32 @@
|
|||
import type { DidDocument } from "@atcute/identity";
|
||||
import {
|
||||
CompositeDidDocumentResolver,
|
||||
PlcDidDocumentResolver,
|
||||
WebDidDocumentResolver,
|
||||
XrpcHandleResolver,
|
||||
} from "@atcute/identity-resolver";
|
||||
import type { WebDidDocumentResolver } from "@atcute/identity-resolver";
|
||||
import type { ATProtoUniverse } from "@char/lexicon.ts/atproto";
|
||||
import { XRPC } from "@char/lexicon.ts/rpc";
|
||||
|
||||
const handleResolver = new XrpcHandleResolver({
|
||||
serviceUrl: "https://public.api.bsky.app",
|
||||
});
|
||||
const bskyPublic = new XRPC<ATProtoUniverse>("https://public.api.bsky.app");
|
||||
|
||||
const didResolver = new CompositeDidDocumentResolver({
|
||||
methods: {
|
||||
plc: new PlcDidDocumentResolver(),
|
||||
web: new WebDidDocumentResolver(),
|
||||
},
|
||||
});
|
||||
|
||||
export function resolveHandle(handle: string): Promise<`did:${string}`> {
|
||||
return handleResolver.resolve(handle as `${string}.${string}`);
|
||||
export async function resolveHandle(handle: string): Promise<`did:${string}`> {
|
||||
const { did } = await bskyPublic.get("com.atproto.identity.resolveHandle", {
|
||||
params: { handle },
|
||||
});
|
||||
return did;
|
||||
}
|
||||
|
||||
export function resolveDid(did: string): Promise<DidDocument> {
|
||||
return didResolver.resolve(did as `did:${"plc" | "web"}:${string}`);
|
||||
export async function resolveDid(did: string): Promise<DidDocument> {
|
||||
if (did.startsWith("did:plc:")) {
|
||||
const doc = await fetch("https://plc.directory/" + did).then((r) =>
|
||||
r.json()
|
||||
);
|
||||
return doc;
|
||||
} else if (did.startsWith("did:web:")) {
|
||||
// TODO: write our own did:web resolver (maybe use a CORS proxy on clientside)
|
||||
const resolver: WebDidDocumentResolver = await import(
|
||||
"@atcute/identity-resolver"
|
||||
)
|
||||
.then((m) => m.WebDidDocumentResolver)
|
||||
.then((r) => new r());
|
||||
return resolver.resolve(did as `did:web:${string}`);
|
||||
}
|
||||
|
||||
throw new Error("unsupported did type: " + did);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,8 @@ export const videoLexicon = {
|
|||
accept: ["video/mp4", "video/webm"],
|
||||
maxSize: 536870912,
|
||||
},
|
||||
title: {
|
||||
type: "string",
|
||||
maxGraphemes: 300,
|
||||
maxLength: 3000,
|
||||
},
|
||||
description: {
|
||||
type: "string",
|
||||
},
|
||||
title: { type: "string", maxGraphemes: 300, maxLength: 3000 },
|
||||
description: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -42,14 +36,8 @@ export const fetchVideoLexicon = {
|
|||
type: "object",
|
||||
required: ["repo", "blob"],
|
||||
properties: {
|
||||
repo: {
|
||||
type: "string",
|
||||
format: "did",
|
||||
},
|
||||
blob: {
|
||||
type: "string",
|
||||
format: "cid",
|
||||
},
|
||||
repo: { type: "string", format: "did" },
|
||||
blob: { type: "string", format: "cid" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -58,11 +46,7 @@ export const fetchVideoLexicon = {
|
|||
schema: {
|
||||
type: "object",
|
||||
required: ["filename"],
|
||||
properties: {
|
||||
filename: {
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
properties: { filename: { type: "string" } },
|
||||
},
|
||||
},
|
||||
errors: [{ name: "Denied" }],
|
||||
|
|
|
|||
2
vendor/lexicon.ts
vendored
2
vendor/lexicon.ts
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 1edb68e5eac3ddfabdd77674ed8193ef9af05649
|
||||
Subproject commit 4b3c48591c21d976ab94d0ae6cf2160a2115471c
|
||||
Loading…
Reference in a new issue