Loading examples/blog/federation/mod.ts +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ federation.setActorDispatcher("/users/{handle}", async (ctx, handle, key) => { summary: blog.description, preferredUsername: handle, url: new URL("/", ctx.request.url), published: blog.published, // A `Context<TContextData>` object has several purposes, and one of // them is to provide a way to generate URIs for the dispatchers and // the collections: Loading examples/blog/models/blog.ts +5 −0 Original line number Diff line number Diff line /// <reference lib="deno.unstable" /> import { Temporal } from "npm:@js-temporal/polyfill@^0.4.4"; import { hash, verify } from "scrypt"; import { openKv } from "./kv.ts"; Loading @@ -16,6 +17,7 @@ export interface Blog extends BlogBase { passwordHash: string; privateKey: CryptoKey; publicKey: CryptoKey; published: Temporal.Instant; } export async function setBlog(blog: BlogInput): Promise<void> { Loading @@ -34,6 +36,7 @@ export async function setBlog(blog: BlogInput): Promise<void> { handle: blog.handle, title: blog.title, description: blog.description, published: new Date().toISOString(), passwordHash: hash(blog.password, undefined, "scrypt"), privateKey: await crypto.subtle.exportKey("jwk", privateKey), publicKey: await crypto.subtle.exportKey("jwk", publicKey), Loading @@ -44,6 +47,7 @@ export interface BlogInternal extends BlogBase { passwordHash: string; privateKey: Record<string, unknown>; publicKey: Record<string, unknown>; published: string; } export async function getBlog(): Promise<Blog | null> { Loading @@ -66,6 +70,7 @@ export async function getBlog(): Promise<Blog | null> { true, ["verify"], ), published: Temporal.Instant.from(entry.value.published), }; } Loading Loading
examples/blog/federation/mod.ts +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ federation.setActorDispatcher("/users/{handle}", async (ctx, handle, key) => { summary: blog.description, preferredUsername: handle, url: new URL("/", ctx.request.url), published: blog.published, // A `Context<TContextData>` object has several purposes, and one of // them is to provide a way to generate URIs for the dispatchers and // the collections: Loading
examples/blog/models/blog.ts +5 −0 Original line number Diff line number Diff line /// <reference lib="deno.unstable" /> import { Temporal } from "npm:@js-temporal/polyfill@^0.4.4"; import { hash, verify } from "scrypt"; import { openKv } from "./kv.ts"; Loading @@ -16,6 +17,7 @@ export interface Blog extends BlogBase { passwordHash: string; privateKey: CryptoKey; publicKey: CryptoKey; published: Temporal.Instant; } export async function setBlog(blog: BlogInput): Promise<void> { Loading @@ -34,6 +36,7 @@ export async function setBlog(blog: BlogInput): Promise<void> { handle: blog.handle, title: blog.title, description: blog.description, published: new Date().toISOString(), passwordHash: hash(blog.password, undefined, "scrypt"), privateKey: await crypto.subtle.exportKey("jwk", privateKey), publicKey: await crypto.subtle.exportKey("jwk", publicKey), Loading @@ -44,6 +47,7 @@ export interface BlogInternal extends BlogBase { passwordHash: string; privateKey: Record<string, unknown>; publicKey: Record<string, unknown>; published: string; } export async function getBlog(): Promise<Blog | null> { Loading @@ -66,6 +70,7 @@ export async function getBlog(): Promise<Blog | null> { true, ["verify"], ), published: Temporal.Instant.from(entry.value.published), }; } Loading