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