From 0c880666bf17852bb60dfa4f0f23d9e6ff4636b8 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Fri, 24 Apr 2026 00:34:34 +0200 Subject: [PATCH] added slingshot as a dependency --- app/index.tsx | 25 +++++++-- .../bad-example/identity/resolveMiniDoc.json | 52 +++++++++++++++++++ package-lock.json | 1 + package.json | 4 +- src/context/AuthContext.tsx | 2 +- src/lexicons/com.ts | 5 ++ src/lexicons/com/bad-example.ts | 5 ++ src/lexicons/com/bad-example/identity.ts | 5 ++ .../identity/resolveMiniDoc.defs.ts | 33 ++++++++++++ .../bad-example/identity/resolveMiniDoc.ts | 6 +++ src/lexicons/dev.ts | 2 +- src/lexicons/dev/maelstrom.ts | 2 +- src/lexicons/dev/maelstrom/bramblr.ts | 2 +- src/lexicons/dev/maelstrom/bramblr/post.ts | 4 +- src/lexicons/index.ts | 6 +++ src/util/handle.ts | 5 ++ src/util/slingshot.ts | 5 ++ 17 files changed, 152 insertions(+), 12 deletions(-) create mode 100644 lexicons/com/bad-example/identity/resolveMiniDoc.json create mode 100644 src/lexicons/com.ts create mode 100644 src/lexicons/com/bad-example.ts create mode 100644 src/lexicons/com/bad-example/identity.ts create mode 100644 src/lexicons/com/bad-example/identity/resolveMiniDoc.defs.ts create mode 100644 src/lexicons/com/bad-example/identity/resolveMiniDoc.ts create mode 100644 src/lexicons/index.ts create mode 100644 src/util/handle.ts create mode 100644 src/util/slingshot.ts diff --git a/app/index.tsx b/app/index.tsx index 5d46468..6cea0dc 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,14 +1,29 @@ -import { AuthContext, AuthProvider } from "@/src/context/AuthContext"; -import { useContext } from "react"; +import { AuthContext } from "@/src/context/AuthContext"; +import { useContext, useEffect, useState } from "react"; import { Text, View } from "react-native"; +import { com } from "@/src/lexicons"; +import { Slingshot } from "@/src/util/slingshot"; +import { AtIdentifierString } from "@atproto/lex"; export default function Index() { const authCtx = useContext(AuthContext); + const [handle, setHandle] = useState(); + useEffect(() => { + async function run() { + if (!authCtx.agent) + return; + + const result = await Slingshot.call(com["bad-example"].identity.resolveMiniDoc, { + identifier: authCtx.agent!.did as AtIdentifierString + }); + setHandle(result.handle); + } + run(); + }, [authCtx.agent, authCtx.agent?.did]); return ( - - You are logged in as {authCtx.agent?.did} + + You are logged in as {handle} ); } diff --git a/lexicons/com/bad-example/identity/resolveMiniDoc.json b/lexicons/com/bad-example/identity/resolveMiniDoc.json new file mode 100644 index 0000000..46fc428 --- /dev/null +++ b/lexicons/com/bad-example/identity/resolveMiniDoc.json @@ -0,0 +1,52 @@ +{ + "$type": "com.atproto.lexicon.schema", + "id": "com.bad-example.identity.resolveMiniDoc", + "lexicon": 1, + "defs": { + "main": { + "type": "query", + "description": "Get the identity of a user from did", + "parameters": { + "type": "params", + "required": [ + "identifier" + ], + "properties": { + "identifier": { + "type": "string", + "format": "at-identifier" + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [ + "did", + "handle", + "pds", + "signing_key" + ], + "properties": { + "did": { + "type": "string", + "format": "did" + }, + "handle": { + "type": "string", + "format": "handle" + }, + "pds": { + "type": "string", + "format": "uri" + }, + "signing_key": { + "type": "string" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index aa09f97..52d321f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@atproto/api": "^0.19.10", "@atproto/oauth-client": "^0.6.0", "@atproto/oauth-client-browser": "^0.3.41", + "@atproto/xrpc": "^0.7.7", "@expo/vector-icons": "^15.0.3", "@react-navigation/bottom-tabs": "^7.4.0", "@react-navigation/elements": "^2.6.3", diff --git a/package.json b/package.json index daf06a5..383520d 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,14 @@ "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", - "lint": "expo lint" + "lint": "expo lint", + "lex": "lex build --indexFile --override --importExt ''" }, "dependencies": { "@atproto/api": "^0.19.10", "@atproto/oauth-client": "^0.6.0", "@atproto/oauth-client-browser": "^0.3.41", + "@atproto/xrpc": "^0.7.7", "@expo/vector-icons": "^15.0.3", "@react-navigation/bottom-tabs": "^7.4.0", "@react-navigation/elements": "^2.6.3", diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index a927859..aa71556 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -19,7 +19,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { async function initialize() { const oauthClient = new BrowserOAuthClient({ clientMetadata: atprotoLoopbackClientMetadata(`http://localhost?redirect_uri=http://${window.location.host}/callback`), - handleResolver: "https://bsky.social", + handleResolver: "https://pds.maelstrom.dev", }); setOauthClient(oauthClient) diff --git a/src/lexicons/com.ts b/src/lexicons/com.ts new file mode 100644 index 0000000..07cafde --- /dev/null +++ b/src/lexicons/com.ts @@ -0,0 +1,5 @@ +/* + * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. + */ + +export * as 'bad-example' from './com/bad-example' diff --git a/src/lexicons/com/bad-example.ts b/src/lexicons/com/bad-example.ts new file mode 100644 index 0000000..784fe08 --- /dev/null +++ b/src/lexicons/com/bad-example.ts @@ -0,0 +1,5 @@ +/* + * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. + */ + +export * as identity from './bad-example/identity' diff --git a/src/lexicons/com/bad-example/identity.ts b/src/lexicons/com/bad-example/identity.ts new file mode 100644 index 0000000..f773c33 --- /dev/null +++ b/src/lexicons/com/bad-example/identity.ts @@ -0,0 +1,5 @@ +/* + * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. + */ + +export * as resolveMiniDoc from './identity/resolveMiniDoc' diff --git a/src/lexicons/com/bad-example/identity/resolveMiniDoc.defs.ts b/src/lexicons/com/bad-example/identity/resolveMiniDoc.defs.ts new file mode 100644 index 0000000..0168ed1 --- /dev/null +++ b/src/lexicons/com/bad-example/identity/resolveMiniDoc.defs.ts @@ -0,0 +1,33 @@ +/* + * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. + */ + +import { l } from '@atproto/lex' + +const $nsid = 'com.bad-example.identity.resolveMiniDoc' + +export { $nsid } + +/** Get the identity of a user from did */ +const main = l.query( + $nsid, + l.params({ identifier: l.string({ format: 'at-identifier' }) }), + l.jsonPayload({ + did: l.string({ format: 'did' }), + handle: l.string({ format: 'handle' }), + pds: l.string({ format: 'uri' }), + signing_key: l.string(), + }), +) +export { main } + +export type $Params = l.InferMethodParams +export type $Output = l.InferMethodOutput +export type $OutputBody = l.InferMethodOutputBody< + typeof main, + B +> + +export const $lxm = main.nsid, + $params = main.parameters, + $output = main.output diff --git a/src/lexicons/com/bad-example/identity/resolveMiniDoc.ts b/src/lexicons/com/bad-example/identity/resolveMiniDoc.ts new file mode 100644 index 0000000..c62626b --- /dev/null +++ b/src/lexicons/com/bad-example/identity/resolveMiniDoc.ts @@ -0,0 +1,6 @@ +/* + * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. + */ + +export * from './resolveMiniDoc.defs' +export * as $defs from './resolveMiniDoc.defs' diff --git a/src/lexicons/dev.ts b/src/lexicons/dev.ts index 012e322..7d2b3cb 100644 --- a/src/lexicons/dev.ts +++ b/src/lexicons/dev.ts @@ -2,4 +2,4 @@ * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. */ -export * as maelstrom from './dev/maelstrom.js' +export * as maelstrom from './dev/maelstrom' diff --git a/src/lexicons/dev/maelstrom.ts b/src/lexicons/dev/maelstrom.ts index ea3e634..1e4f137 100644 --- a/src/lexicons/dev/maelstrom.ts +++ b/src/lexicons/dev/maelstrom.ts @@ -2,4 +2,4 @@ * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. */ -export * as bramblr from './maelstrom/bramblr.js' +export * as bramblr from './maelstrom/bramblr' diff --git a/src/lexicons/dev/maelstrom/bramblr.ts b/src/lexicons/dev/maelstrom/bramblr.ts index 90e2330..bce57b8 100644 --- a/src/lexicons/dev/maelstrom/bramblr.ts +++ b/src/lexicons/dev/maelstrom/bramblr.ts @@ -2,4 +2,4 @@ * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. */ -export * as post from './bramblr/post.js' +export * as post from './bramblr/post' diff --git a/src/lexicons/dev/maelstrom/bramblr/post.ts b/src/lexicons/dev/maelstrom/bramblr/post.ts index 774a5f4..0a47436 100644 --- a/src/lexicons/dev/maelstrom/bramblr/post.ts +++ b/src/lexicons/dev/maelstrom/bramblr/post.ts @@ -2,5 +2,5 @@ * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. */ -export * from './post.defs.js' -export * as $defs from './post.defs.js' +export * from './post.defs' +export * as $defs from './post.defs' diff --git a/src/lexicons/index.ts b/src/lexicons/index.ts new file mode 100644 index 0000000..ed3d014 --- /dev/null +++ b/src/lexicons/index.ts @@ -0,0 +1,6 @@ +/* + * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT. + */ + +export * as com from './com' +export * as dev from './dev' diff --git a/src/util/handle.ts b/src/util/handle.ts new file mode 100644 index 0000000..9024296 --- /dev/null +++ b/src/util/handle.ts @@ -0,0 +1,5 @@ +import { Agent } from "@atproto/api"; + +export function resolveHandle(agent: Agent, did: string) { + +} \ No newline at end of file diff --git a/src/util/slingshot.ts b/src/util/slingshot.ts new file mode 100644 index 0000000..e7aa55a --- /dev/null +++ b/src/util/slingshot.ts @@ -0,0 +1,5 @@ +import { Client } from "@atproto/lex"; + +export const Slingshot = new Client({ + service: "https://slingshot.microcosm.blue/" +}); \ No newline at end of file -- 2.51.2