diff --git a/.changeset/stale-waves-protect.md b/.changeset/stale-waves-protect.md new file mode 100644 index 00000000000..f118b29413a --- /dev/null +++ b/.changeset/stale-waves-protect.md @@ -0,0 +1,5 @@ +--- +"@atproto/api": patch +--- + +new com.atproto.identity endpoints: resolveDid, resolveIdentity, refreshIdentity diff --git a/lexicons/com/atproto/identity/defs.json b/lexicons/com/atproto/identity/defs.json new file mode 100644 index 00000000000..9449cdd9a1c --- /dev/null +++ b/lexicons/com/atproto/identity/defs.json @@ -0,0 +1,22 @@ +{ + "lexicon": 1, + "id": "com.atproto.identity.defs", + "defs": { + "identityInfo": { + "type": "object", + "required": ["did", "handle", "didDoc"], + "properties": { + "did": { "type": "string", "format": "did" }, + "handle": { + "type": "string", + "format": "handle", + "description": "The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document." + }, + "didDoc": { + "type": "unknown", + "description": "The complete DID document for the identity." + } + } + } + } +} diff --git a/lexicons/com/atproto/identity/refreshIdentity.json b/lexicons/com/atproto/identity/refreshIdentity.json new file mode 100644 index 00000000000..4c56084b9e7 --- /dev/null +++ b/lexicons/com/atproto/identity/refreshIdentity.json @@ -0,0 +1,44 @@ +{ + "lexicon": 1, + "id": "com.atproto.identity.refreshIdentity", + "defs": { + "main": { + "type": "procedure", + "description": "Request that the server re-resolve an identity (DID and handle). The server may ignore this request, or require authentication, depending on the role, implementation, and policy of the server.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["identifier"], + "properties": { + "identifier": { + "type": "string", + "format": "at-identifier" + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "ref", + "ref": "com.atproto.identity.defs#identityInfo" + } + }, + "errors": [ + { + "name": "HandleNotFound", + "description": "The resolution process confirmed that the handle does not resolve to any DID." + }, + { + "name": "DidNotFound", + "description": "The DID resolution process confirmed that there is no current DID." + }, + { + "name": "DidDeactivated", + "description": "The DID previously existed, but has been deactivated." + } + ] + } + } +} diff --git a/lexicons/com/atproto/identity/resolveDid.json b/lexicons/com/atproto/identity/resolveDid.json new file mode 100644 index 00000000000..24c129a3335 --- /dev/null +++ b/lexicons/com/atproto/identity/resolveDid.json @@ -0,0 +1,44 @@ +{ + "lexicon": 1, + "id": "com.atproto.identity.resolveDid", + "defs": { + "main": { + "type": "query", + "description": "Resolves DID to DID document. Does not bi-directionally verify handle.", + "parameters": { + "type": "params", + "required": ["did"], + "properties": { + "did": { + "type": "string", + "format": "did", + "description": "DID to resolve." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["didDoc"], + "properties": { + "didDoc": { + "type": "unknown", + "description": "The complete DID document for the identity." + } + } + } + }, + "errors": [ + { + "name": "DidNotFound", + "description": "The DID resolution process confirmed that there is no current DID." + }, + { + "name": "DidDeactivated", + "description": "The DID previously existed, but has been deactivated." + } + ] + } + } +} diff --git a/lexicons/com/atproto/identity/resolveHandle.json b/lexicons/com/atproto/identity/resolveHandle.json index 95885088a7b..69751a529ca 100644 --- a/lexicons/com/atproto/identity/resolveHandle.json +++ b/lexicons/com/atproto/identity/resolveHandle.json @@ -4,7 +4,7 @@ "defs": { "main": { "type": "query", - "description": "Resolves a handle (domain name) to a DID.", + "description": "Resolves an atproto handle (hostname) to a DID. Does not necessarily bi-directionally verify against the the DID document.", "parameters": { "type": "params", "required": ["handle"], @@ -25,7 +25,13 @@ "did": { "type": "string", "format": "did" } } } - } + }, + "errors": [ + { + "name": "HandleNotFound", + "description": "The resolution process confirmed that the handle does not resolve to any DID." + } + ] } } } diff --git a/lexicons/com/atproto/identity/resolveIdentity.json b/lexicons/com/atproto/identity/resolveIdentity.json new file mode 100644 index 00000000000..fe33441c4eb --- /dev/null +++ b/lexicons/com/atproto/identity/resolveIdentity.json @@ -0,0 +1,42 @@ +{ + "lexicon": 1, + "id": "com.atproto.identity.resolveIdentity", + "defs": { + "main": { + "type": "query", + "description": "Resolves an identity (DID or Handle) to a full identity (DID document and verified handle).", + "parameters": { + "type": "params", + "required": ["identifier"], + "properties": { + "identifier": { + "type": "string", + "format": "at-identifier", + "description": "Handle or DID to resolve." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "ref", + "ref": "com.atproto.identity.defs#identityInfo" + } + }, + "errors": [ + { + "name": "HandleNotFound", + "description": "The resolution process confirmed that the handle does not resolve to any DID." + }, + { + "name": "DidNotFound", + "description": "The DID resolution process confirmed that there is no current DID." + }, + { + "name": "DidDeactivated", + "description": "The DID previously existed, but has been deactivated." + } + ] + } + } +} diff --git a/packages/api/src/client/index.ts b/packages/api/src/client/index.ts index ed749b3d3d5..55dececc9a5 100644 --- a/packages/api/src/client/index.ts +++ b/packages/api/src/client/index.ts @@ -20,9 +20,13 @@ import * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/up import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle.js' import * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword.js' import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus.js' +import * as ComAtprotoIdentityDefs from './types/com/atproto/identity/defs.js' import * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials.js' +import * as ComAtprotoIdentityRefreshIdentity from './types/com/atproto/identity/refreshIdentity.js' import * as ComAtprotoIdentityRequestPlcOperationSignature from './types/com/atproto/identity/requestPlcOperationSignature.js' +import * as ComAtprotoIdentityResolveDid from './types/com/atproto/identity/resolveDid.js' import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle.js' +import * as ComAtprotoIdentityResolveIdentity from './types/com/atproto/identity/resolveIdentity.js' import * as ComAtprotoIdentitySignPlcOperation from './types/com/atproto/identity/signPlcOperation.js' import * as ComAtprotoIdentitySubmitPlcOperation from './types/com/atproto/identity/submitPlcOperation.js' import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle.js' @@ -254,9 +258,13 @@ export * as ComAtprotoAdminUpdateAccountEmail from './types/com/atproto/admin/up export * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/updateAccountHandle.js' export * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword.js' export * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus.js' +export * as ComAtprotoIdentityDefs from './types/com/atproto/identity/defs.js' export * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials.js' +export * as ComAtprotoIdentityRefreshIdentity from './types/com/atproto/identity/refreshIdentity.js' export * as ComAtprotoIdentityRequestPlcOperationSignature from './types/com/atproto/identity/requestPlcOperationSignature.js' +export * as ComAtprotoIdentityResolveDid from './types/com/atproto/identity/resolveDid.js' export * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle.js' +export * as ComAtprotoIdentityResolveIdentity from './types/com/atproto/identity/resolveIdentity.js' export * as ComAtprotoIdentitySignPlcOperation from './types/com/atproto/identity/signPlcOperation.js' export * as ComAtprotoIdentitySubmitPlcOperation from './types/com/atproto/identity/submitPlcOperation.js' export * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle.js' @@ -766,6 +774,17 @@ export class ComAtprotoIdentityNS { ) } + refreshIdentity( + data?: ComAtprotoIdentityRefreshIdentity.InputSchema, + opts?: ComAtprotoIdentityRefreshIdentity.CallOptions, + ): Promise { + return this._client + .call('com.atproto.identity.refreshIdentity', opts?.qp, data, opts) + .catch((e) => { + throw ComAtprotoIdentityRefreshIdentity.toKnownErr(e) + }) + } + requestPlcOperationSignature( data?: ComAtprotoIdentityRequestPlcOperationSignature.InputSchema, opts?: ComAtprotoIdentityRequestPlcOperationSignature.CallOptions, @@ -778,16 +797,37 @@ export class ComAtprotoIdentityNS { ) } + resolveDid( + params?: ComAtprotoIdentityResolveDid.QueryParams, + opts?: ComAtprotoIdentityResolveDid.CallOptions, + ): Promise { + return this._client + .call('com.atproto.identity.resolveDid', params, undefined, opts) + .catch((e) => { + throw ComAtprotoIdentityResolveDid.toKnownErr(e) + }) + } + resolveHandle( params?: ComAtprotoIdentityResolveHandle.QueryParams, opts?: ComAtprotoIdentityResolveHandle.CallOptions, ): Promise { - return this._client.call( - 'com.atproto.identity.resolveHandle', - params, - undefined, - opts, - ) + return this._client + .call('com.atproto.identity.resolveHandle', params, undefined, opts) + .catch((e) => { + throw ComAtprotoIdentityResolveHandle.toKnownErr(e) + }) + } + + resolveIdentity( + params?: ComAtprotoIdentityResolveIdentity.QueryParams, + opts?: ComAtprotoIdentityResolveIdentity.CallOptions, + ): Promise { + return this._client + .call('com.atproto.identity.resolveIdentity', params, undefined, opts) + .catch((e) => { + throw ComAtprotoIdentityResolveIdentity.toKnownErr(e) + }) } signPlcOperation( diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 23b00b79fb5..6463e7c6ec3 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -637,6 +637,32 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityDefs: { + lexicon: 1, + id: 'com.atproto.identity.defs', + defs: { + identityInfo: { + type: 'object', + required: ['did', 'handle', 'didDoc'], + properties: { + did: { + type: 'string', + format: 'did', + }, + handle: { + type: 'string', + format: 'handle', + description: + "The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document.", + }, + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + }, ComAtprotoIdentityGetRecommendedDidCredentials: { lexicon: 1, id: 'com.atproto.identity.getRecommendedDidCredentials', @@ -676,6 +702,54 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityRefreshIdentity: { + lexicon: 1, + id: 'com.atproto.identity.refreshIdentity', + defs: { + main: { + type: 'procedure', + description: + 'Request that the server re-resolve an identity (DID and handle). The server may ignore this request, or require authentication, depending on the role, implementation, and policy of the server.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + }, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityRequestPlcOperationSignature: { lexicon: 1, id: 'com.atproto.identity.requestPlcOperationSignature', @@ -687,13 +761,61 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityResolveDid: { + lexicon: 1, + id: 'com.atproto.identity.resolveDid', + defs: { + main: { + type: 'query', + description: + 'Resolves DID to DID document. Does not bi-directionally verify handle.', + parameters: { + type: 'params', + required: ['did'], + properties: { + did: { + type: 'string', + format: 'did', + description: 'DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['didDoc'], + properties: { + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + errors: [ + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityResolveHandle: { lexicon: 1, id: 'com.atproto.identity.resolveHandle', defs: { main: { type: 'query', - description: 'Resolves a handle (domain name) to a DID.', + description: + 'Resolves an atproto handle (hostname) to a DID. Does not necessarily bi-directionally verify against the the DID document.', parameters: { type: 'params', required: ['handle'], @@ -718,6 +840,59 @@ export const schemaDict = { }, }, }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + ], + }, + }, + }, + ComAtprotoIdentityResolveIdentity: { + lexicon: 1, + id: 'com.atproto.identity.resolveIdentity', + defs: { + main: { + type: 'query', + description: + 'Resolves an identity (DID or Handle) to a full identity (DID document and verified handle).', + parameters: { + type: 'params', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + description: 'Handle or DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], }, }, }, @@ -14394,11 +14569,15 @@ export const ids = { ComAtprotoAdminUpdateAccountPassword: 'com.atproto.admin.updateAccountPassword', ComAtprotoAdminUpdateSubjectStatus: 'com.atproto.admin.updateSubjectStatus', + ComAtprotoIdentityDefs: 'com.atproto.identity.defs', ComAtprotoIdentityGetRecommendedDidCredentials: 'com.atproto.identity.getRecommendedDidCredentials', + ComAtprotoIdentityRefreshIdentity: 'com.atproto.identity.refreshIdentity', ComAtprotoIdentityRequestPlcOperationSignature: 'com.atproto.identity.requestPlcOperationSignature', + ComAtprotoIdentityResolveDid: 'com.atproto.identity.resolveDid', ComAtprotoIdentityResolveHandle: 'com.atproto.identity.resolveHandle', + ComAtprotoIdentityResolveIdentity: 'com.atproto.identity.resolveIdentity', ComAtprotoIdentitySignPlcOperation: 'com.atproto.identity.signPlcOperation', ComAtprotoIdentitySubmitPlcOperation: 'com.atproto.identity.submitPlcOperation', diff --git a/packages/api/src/client/types/com/atproto/identity/defs.ts b/packages/api/src/client/types/com/atproto/identity/defs.ts new file mode 100644 index 00000000000..30b400f4fd3 --- /dev/null +++ b/packages/api/src/client/types/com/atproto/identity/defs.ts @@ -0,0 +1,30 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.defs' + +export interface IdentityInfo { + $type?: 'com.atproto.identity.defs#identityInfo' + did: string + /** The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document. */ + handle: string + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +const hashIdentityInfo = 'identityInfo' + +export function isIdentityInfo(v: V) { + return is$typed(v, id, hashIdentityInfo) +} + +export function validateIdentityInfo(v: V) { + return validate(v, id, hashIdentityInfo) +} diff --git a/packages/api/src/client/types/com/atproto/identity/refreshIdentity.ts b/packages/api/src/client/types/com/atproto/identity/refreshIdentity.ts new file mode 100644 index 00000000000..43251787ec9 --- /dev/null +++ b/packages/api/src/client/types/com/atproto/identity/refreshIdentity.ts @@ -0,0 +1,62 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { HeadersMap, XRPCError } from '@atproto/xrpc' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.refreshIdentity' + +export interface QueryParams {} + +export interface InputSchema { + identifier: string +} + +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo + +export interface CallOptions { + signal?: AbortSignal + headers?: HeadersMap + qp?: QueryParams + encoding?: 'application/json' +} + +export interface Response { + success: boolean + headers: HeadersMap + data: OutputSchema +} + +export class HandleNotFoundError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export class DidNotFoundError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export class DidDeactivatedError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export function toKnownErr(e: any) { + if (e instanceof XRPCError) { + if (e.error === 'HandleNotFound') return new HandleNotFoundError(e) + if (e.error === 'DidNotFound') return new DidNotFoundError(e) + if (e.error === 'DidDeactivated') return new DidDeactivatedError(e) + } + + return e +} diff --git a/packages/api/src/client/types/com/atproto/identity/resolveDid.ts b/packages/api/src/client/types/com/atproto/identity/resolveDid.ts new file mode 100644 index 00000000000..3896b7c4ac1 --- /dev/null +++ b/packages/api/src/client/types/com/atproto/identity/resolveDid.ts @@ -0,0 +1,56 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { HeadersMap, XRPCError } from '@atproto/xrpc' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveDid' + +export interface QueryParams { + /** DID to resolve. */ + did: string +} + +export type InputSchema = undefined + +export interface OutputSchema { + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +export interface CallOptions { + signal?: AbortSignal + headers?: HeadersMap +} + +export interface Response { + success: boolean + headers: HeadersMap + data: OutputSchema +} + +export class DidNotFoundError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export class DidDeactivatedError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export function toKnownErr(e: any) { + if (e instanceof XRPCError) { + if (e.error === 'DidNotFound') return new DidNotFoundError(e) + if (e.error === 'DidDeactivated') return new DidDeactivatedError(e) + } + + return e +} diff --git a/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts b/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts index 3610d75c0a2..5609983fa68 100644 --- a/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts +++ b/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts @@ -33,6 +33,16 @@ export interface Response { data: OutputSchema } +export class HandleNotFoundError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + export function toKnownErr(e: any) { + if (e instanceof XRPCError) { + if (e.error === 'HandleNotFound') return new HandleNotFoundError(e) + } + return e } diff --git a/packages/api/src/client/types/com/atproto/identity/resolveIdentity.ts b/packages/api/src/client/types/com/atproto/identity/resolveIdentity.ts new file mode 100644 index 00000000000..a88f62188ba --- /dev/null +++ b/packages/api/src/client/types/com/atproto/identity/resolveIdentity.ts @@ -0,0 +1,60 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { HeadersMap, XRPCError } from '@atproto/xrpc' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveIdentity' + +export interface QueryParams { + /** Handle or DID to resolve. */ + identifier: string +} + +export type InputSchema = undefined +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo + +export interface CallOptions { + signal?: AbortSignal + headers?: HeadersMap +} + +export interface Response { + success: boolean + headers: HeadersMap + data: OutputSchema +} + +export class HandleNotFoundError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export class DidNotFoundError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export class DidDeactivatedError extends XRPCError { + constructor(src: XRPCError) { + super(src.status, src.error, src.message, src.headers, { cause: src }) + } +} + +export function toKnownErr(e: any) { + if (e instanceof XRPCError) { + if (e.error === 'HandleNotFound') return new HandleNotFoundError(e) + if (e.error === 'DidNotFound') return new DidNotFoundError(e) + if (e.error === 'DidDeactivated') return new DidDeactivatedError(e) + } + + return e +} diff --git a/packages/bsky/src/lexicon/index.ts b/packages/bsky/src/lexicon/index.ts index dc073de665a..a2ab37da2f3 100644 --- a/packages/bsky/src/lexicon/index.ts +++ b/packages/bsky/src/lexicon/index.ts @@ -24,8 +24,11 @@ import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/u import * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword.js' import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus.js' import * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials.js' +import * as ComAtprotoIdentityRefreshIdentity from './types/com/atproto/identity/refreshIdentity.js' import * as ComAtprotoIdentityRequestPlcOperationSignature from './types/com/atproto/identity/requestPlcOperationSignature.js' +import * as ComAtprotoIdentityResolveDid from './types/com/atproto/identity/resolveDid.js' import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle.js' +import * as ComAtprotoIdentityResolveIdentity from './types/com/atproto/identity/resolveIdentity.js' import * as ComAtprotoIdentitySignPlcOperation from './types/com/atproto/identity/signPlcOperation.js' import * as ComAtprotoIdentitySubmitPlcOperation from './types/com/atproto/identity/submitPlcOperation.js' import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle.js' @@ -436,6 +439,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + refreshIdentity( + cfg: ConfigOf< + AV, + ComAtprotoIdentityRefreshIdentity.Handler>, + ComAtprotoIdentityRefreshIdentity.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.refreshIdentity' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + requestPlcOperationSignature( cfg: ConfigOf< AV, @@ -449,6 +463,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + resolveDid( + cfg: ConfigOf< + AV, + ComAtprotoIdentityResolveDid.Handler>, + ComAtprotoIdentityResolveDid.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.resolveDid' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + resolveHandle( cfg: ConfigOf< AV, @@ -460,6 +485,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + resolveIdentity( + cfg: ConfigOf< + AV, + ComAtprotoIdentityResolveIdentity.Handler>, + ComAtprotoIdentityResolveIdentity.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.resolveIdentity' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + signPlcOperation( cfg: ConfigOf< AV, diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index dd2ab9fe455..2468340216a 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -637,6 +637,32 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityDefs: { + lexicon: 1, + id: 'com.atproto.identity.defs', + defs: { + identityInfo: { + type: 'object', + required: ['did', 'handle', 'didDoc'], + properties: { + did: { + type: 'string', + format: 'did', + }, + handle: { + type: 'string', + format: 'handle', + description: + "The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document.", + }, + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + }, ComAtprotoIdentityGetRecommendedDidCredentials: { lexicon: 1, id: 'com.atproto.identity.getRecommendedDidCredentials', @@ -676,6 +702,54 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityRefreshIdentity: { + lexicon: 1, + id: 'com.atproto.identity.refreshIdentity', + defs: { + main: { + type: 'procedure', + description: + 'Request that the server re-resolve an identity (DID and handle). The server may ignore this request, or require authentication, depending on the role, implementation, and policy of the server.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + }, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityRequestPlcOperationSignature: { lexicon: 1, id: 'com.atproto.identity.requestPlcOperationSignature', @@ -687,13 +761,61 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityResolveDid: { + lexicon: 1, + id: 'com.atproto.identity.resolveDid', + defs: { + main: { + type: 'query', + description: + 'Resolves DID to DID document. Does not bi-directionally verify handle.', + parameters: { + type: 'params', + required: ['did'], + properties: { + did: { + type: 'string', + format: 'did', + description: 'DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['didDoc'], + properties: { + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + errors: [ + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityResolveHandle: { lexicon: 1, id: 'com.atproto.identity.resolveHandle', defs: { main: { type: 'query', - description: 'Resolves a handle (domain name) to a DID.', + description: + 'Resolves an atproto handle (hostname) to a DID. Does not necessarily bi-directionally verify against the the DID document.', parameters: { type: 'params', required: ['handle'], @@ -718,6 +840,59 @@ export const schemaDict = { }, }, }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + ], + }, + }, + }, + ComAtprotoIdentityResolveIdentity: { + lexicon: 1, + id: 'com.atproto.identity.resolveIdentity', + defs: { + main: { + type: 'query', + description: + 'Resolves an identity (DID or Handle) to a full identity (DID document and verified handle).', + parameters: { + type: 'params', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + description: 'Handle or DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], }, }, }, @@ -11364,11 +11539,15 @@ export const ids = { ComAtprotoAdminUpdateAccountPassword: 'com.atproto.admin.updateAccountPassword', ComAtprotoAdminUpdateSubjectStatus: 'com.atproto.admin.updateSubjectStatus', + ComAtprotoIdentityDefs: 'com.atproto.identity.defs', ComAtprotoIdentityGetRecommendedDidCredentials: 'com.atproto.identity.getRecommendedDidCredentials', + ComAtprotoIdentityRefreshIdentity: 'com.atproto.identity.refreshIdentity', ComAtprotoIdentityRequestPlcOperationSignature: 'com.atproto.identity.requestPlcOperationSignature', + ComAtprotoIdentityResolveDid: 'com.atproto.identity.resolveDid', ComAtprotoIdentityResolveHandle: 'com.atproto.identity.resolveHandle', + ComAtprotoIdentityResolveIdentity: 'com.atproto.identity.resolveIdentity', ComAtprotoIdentitySignPlcOperation: 'com.atproto.identity.signPlcOperation', ComAtprotoIdentitySubmitPlcOperation: 'com.atproto.identity.submitPlcOperation', diff --git a/packages/bsky/src/lexicon/types/com/atproto/identity/defs.ts b/packages/bsky/src/lexicon/types/com/atproto/identity/defs.ts new file mode 100644 index 00000000000..30b400f4fd3 --- /dev/null +++ b/packages/bsky/src/lexicon/types/com/atproto/identity/defs.ts @@ -0,0 +1,30 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.defs' + +export interface IdentityInfo { + $type?: 'com.atproto.identity.defs#identityInfo' + did: string + /** The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document. */ + handle: string + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +const hashIdentityInfo = 'identityInfo' + +export function isIdentityInfo(v: V) { + return is$typed(v, id, hashIdentityInfo) +} + +export function validateIdentityInfo(v: V) { + return validate(v, id, hashIdentityInfo) +} diff --git a/packages/bsky/src/lexicon/types/com/atproto/identity/refreshIdentity.ts b/packages/bsky/src/lexicon/types/com/atproto/identity/refreshIdentity.ts new file mode 100644 index 00000000000..8ee156bdbbd --- /dev/null +++ b/packages/bsky/src/lexicon/types/com/atproto/identity/refreshIdentity.ts @@ -0,0 +1,52 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.refreshIdentity' + +export interface QueryParams {} + +export interface InputSchema { + identifier: string +} + +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo + +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'HandleNotFound' | 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/bsky/src/lexicon/types/com/atproto/identity/resolveDid.ts b/packages/bsky/src/lexicon/types/com/atproto/identity/resolveDid.ts new file mode 100644 index 00000000000..78862549432 --- /dev/null +++ b/packages/bsky/src/lexicon/types/com/atproto/identity/resolveDid.ts @@ -0,0 +1,52 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveDid' + +export interface QueryParams { + /** DID to resolve. */ + did: string +} + +export type InputSchema = undefined + +export interface OutputSchema { + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/bsky/src/lexicon/types/com/atproto/identity/resolveHandle.ts b/packages/bsky/src/lexicon/types/com/atproto/identity/resolveHandle.ts index 7c7fd5fe225..935094e5d25 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/identity/resolveHandle.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/identity/resolveHandle.ts @@ -34,6 +34,7 @@ export interface HandlerSuccess { export interface HandlerError { status: number message?: string + error?: 'HandleNotFound' } export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough diff --git a/packages/bsky/src/lexicon/types/com/atproto/identity/resolveIdentity.ts b/packages/bsky/src/lexicon/types/com/atproto/identity/resolveIdentity.ts new file mode 100644 index 00000000000..2a6b3fbf400 --- /dev/null +++ b/packages/bsky/src/lexicon/types/com/atproto/identity/resolveIdentity.ts @@ -0,0 +1,48 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveIdentity' + +export interface QueryParams { + /** Handle or DID to resolve. */ + identifier: string +} + +export type InputSchema = undefined +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'HandleNotFound' | 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/ozone/src/lexicon/index.ts b/packages/ozone/src/lexicon/index.ts index 028452a5f1e..b9985b5f42e 100644 --- a/packages/ozone/src/lexicon/index.ts +++ b/packages/ozone/src/lexicon/index.ts @@ -24,8 +24,11 @@ import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/u import * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword.js' import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus.js' import * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials.js' +import * as ComAtprotoIdentityRefreshIdentity from './types/com/atproto/identity/refreshIdentity.js' import * as ComAtprotoIdentityRequestPlcOperationSignature from './types/com/atproto/identity/requestPlcOperationSignature.js' +import * as ComAtprotoIdentityResolveDid from './types/com/atproto/identity/resolveDid.js' import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle.js' +import * as ComAtprotoIdentityResolveIdentity from './types/com/atproto/identity/resolveIdentity.js' import * as ComAtprotoIdentitySignPlcOperation from './types/com/atproto/identity/signPlcOperation.js' import * as ComAtprotoIdentitySubmitPlcOperation from './types/com/atproto/identity/submitPlcOperation.js' import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle.js' @@ -480,6 +483,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + refreshIdentity( + cfg: ConfigOf< + AV, + ComAtprotoIdentityRefreshIdentity.Handler>, + ComAtprotoIdentityRefreshIdentity.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.refreshIdentity' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + requestPlcOperationSignature( cfg: ConfigOf< AV, @@ -493,6 +507,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + resolveDid( + cfg: ConfigOf< + AV, + ComAtprotoIdentityResolveDid.Handler>, + ComAtprotoIdentityResolveDid.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.resolveDid' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + resolveHandle( cfg: ConfigOf< AV, @@ -504,6 +529,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + resolveIdentity( + cfg: ConfigOf< + AV, + ComAtprotoIdentityResolveIdentity.Handler>, + ComAtprotoIdentityResolveIdentity.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.resolveIdentity' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + signPlcOperation( cfg: ConfigOf< AV, diff --git a/packages/ozone/src/lexicon/lexicons.ts b/packages/ozone/src/lexicon/lexicons.ts index 23b00b79fb5..6463e7c6ec3 100644 --- a/packages/ozone/src/lexicon/lexicons.ts +++ b/packages/ozone/src/lexicon/lexicons.ts @@ -637,6 +637,32 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityDefs: { + lexicon: 1, + id: 'com.atproto.identity.defs', + defs: { + identityInfo: { + type: 'object', + required: ['did', 'handle', 'didDoc'], + properties: { + did: { + type: 'string', + format: 'did', + }, + handle: { + type: 'string', + format: 'handle', + description: + "The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document.", + }, + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + }, ComAtprotoIdentityGetRecommendedDidCredentials: { lexicon: 1, id: 'com.atproto.identity.getRecommendedDidCredentials', @@ -676,6 +702,54 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityRefreshIdentity: { + lexicon: 1, + id: 'com.atproto.identity.refreshIdentity', + defs: { + main: { + type: 'procedure', + description: + 'Request that the server re-resolve an identity (DID and handle). The server may ignore this request, or require authentication, depending on the role, implementation, and policy of the server.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + }, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityRequestPlcOperationSignature: { lexicon: 1, id: 'com.atproto.identity.requestPlcOperationSignature', @@ -687,13 +761,61 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityResolveDid: { + lexicon: 1, + id: 'com.atproto.identity.resolveDid', + defs: { + main: { + type: 'query', + description: + 'Resolves DID to DID document. Does not bi-directionally verify handle.', + parameters: { + type: 'params', + required: ['did'], + properties: { + did: { + type: 'string', + format: 'did', + description: 'DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['didDoc'], + properties: { + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + errors: [ + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityResolveHandle: { lexicon: 1, id: 'com.atproto.identity.resolveHandle', defs: { main: { type: 'query', - description: 'Resolves a handle (domain name) to a DID.', + description: + 'Resolves an atproto handle (hostname) to a DID. Does not necessarily bi-directionally verify against the the DID document.', parameters: { type: 'params', required: ['handle'], @@ -718,6 +840,59 @@ export const schemaDict = { }, }, }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + ], + }, + }, + }, + ComAtprotoIdentityResolveIdentity: { + lexicon: 1, + id: 'com.atproto.identity.resolveIdentity', + defs: { + main: { + type: 'query', + description: + 'Resolves an identity (DID or Handle) to a full identity (DID document and verified handle).', + parameters: { + type: 'params', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + description: 'Handle or DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], }, }, }, @@ -14394,11 +14569,15 @@ export const ids = { ComAtprotoAdminUpdateAccountPassword: 'com.atproto.admin.updateAccountPassword', ComAtprotoAdminUpdateSubjectStatus: 'com.atproto.admin.updateSubjectStatus', + ComAtprotoIdentityDefs: 'com.atproto.identity.defs', ComAtprotoIdentityGetRecommendedDidCredentials: 'com.atproto.identity.getRecommendedDidCredentials', + ComAtprotoIdentityRefreshIdentity: 'com.atproto.identity.refreshIdentity', ComAtprotoIdentityRequestPlcOperationSignature: 'com.atproto.identity.requestPlcOperationSignature', + ComAtprotoIdentityResolveDid: 'com.atproto.identity.resolveDid', ComAtprotoIdentityResolveHandle: 'com.atproto.identity.resolveHandle', + ComAtprotoIdentityResolveIdentity: 'com.atproto.identity.resolveIdentity', ComAtprotoIdentitySignPlcOperation: 'com.atproto.identity.signPlcOperation', ComAtprotoIdentitySubmitPlcOperation: 'com.atproto.identity.submitPlcOperation', diff --git a/packages/ozone/src/lexicon/types/com/atproto/identity/defs.ts b/packages/ozone/src/lexicon/types/com/atproto/identity/defs.ts new file mode 100644 index 00000000000..30b400f4fd3 --- /dev/null +++ b/packages/ozone/src/lexicon/types/com/atproto/identity/defs.ts @@ -0,0 +1,30 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.defs' + +export interface IdentityInfo { + $type?: 'com.atproto.identity.defs#identityInfo' + did: string + /** The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document. */ + handle: string + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +const hashIdentityInfo = 'identityInfo' + +export function isIdentityInfo(v: V) { + return is$typed(v, id, hashIdentityInfo) +} + +export function validateIdentityInfo(v: V) { + return validate(v, id, hashIdentityInfo) +} diff --git a/packages/ozone/src/lexicon/types/com/atproto/identity/refreshIdentity.ts b/packages/ozone/src/lexicon/types/com/atproto/identity/refreshIdentity.ts new file mode 100644 index 00000000000..8ee156bdbbd --- /dev/null +++ b/packages/ozone/src/lexicon/types/com/atproto/identity/refreshIdentity.ts @@ -0,0 +1,52 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.refreshIdentity' + +export interface QueryParams {} + +export interface InputSchema { + identifier: string +} + +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo + +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'HandleNotFound' | 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/ozone/src/lexicon/types/com/atproto/identity/resolveDid.ts b/packages/ozone/src/lexicon/types/com/atproto/identity/resolveDid.ts new file mode 100644 index 00000000000..78862549432 --- /dev/null +++ b/packages/ozone/src/lexicon/types/com/atproto/identity/resolveDid.ts @@ -0,0 +1,52 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveDid' + +export interface QueryParams { + /** DID to resolve. */ + did: string +} + +export type InputSchema = undefined + +export interface OutputSchema { + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/ozone/src/lexicon/types/com/atproto/identity/resolveHandle.ts b/packages/ozone/src/lexicon/types/com/atproto/identity/resolveHandle.ts index 7c7fd5fe225..935094e5d25 100644 --- a/packages/ozone/src/lexicon/types/com/atproto/identity/resolveHandle.ts +++ b/packages/ozone/src/lexicon/types/com/atproto/identity/resolveHandle.ts @@ -34,6 +34,7 @@ export interface HandlerSuccess { export interface HandlerError { status: number message?: string + error?: 'HandleNotFound' } export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough diff --git a/packages/ozone/src/lexicon/types/com/atproto/identity/resolveIdentity.ts b/packages/ozone/src/lexicon/types/com/atproto/identity/resolveIdentity.ts new file mode 100644 index 00000000000..2a6b3fbf400 --- /dev/null +++ b/packages/ozone/src/lexicon/types/com/atproto/identity/resolveIdentity.ts @@ -0,0 +1,48 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveIdentity' + +export interface QueryParams { + /** Handle or DID to resolve. */ + identifier: string +} + +export type InputSchema = undefined +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'HandleNotFound' | 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/pds/src/lexicon/index.ts b/packages/pds/src/lexicon/index.ts index 028452a5f1e..b9985b5f42e 100644 --- a/packages/pds/src/lexicon/index.ts +++ b/packages/pds/src/lexicon/index.ts @@ -24,8 +24,11 @@ import * as ComAtprotoAdminUpdateAccountHandle from './types/com/atproto/admin/u import * as ComAtprotoAdminUpdateAccountPassword from './types/com/atproto/admin/updateAccountPassword.js' import * as ComAtprotoAdminUpdateSubjectStatus from './types/com/atproto/admin/updateSubjectStatus.js' import * as ComAtprotoIdentityGetRecommendedDidCredentials from './types/com/atproto/identity/getRecommendedDidCredentials.js' +import * as ComAtprotoIdentityRefreshIdentity from './types/com/atproto/identity/refreshIdentity.js' import * as ComAtprotoIdentityRequestPlcOperationSignature from './types/com/atproto/identity/requestPlcOperationSignature.js' +import * as ComAtprotoIdentityResolveDid from './types/com/atproto/identity/resolveDid.js' import * as ComAtprotoIdentityResolveHandle from './types/com/atproto/identity/resolveHandle.js' +import * as ComAtprotoIdentityResolveIdentity from './types/com/atproto/identity/resolveIdentity.js' import * as ComAtprotoIdentitySignPlcOperation from './types/com/atproto/identity/signPlcOperation.js' import * as ComAtprotoIdentitySubmitPlcOperation from './types/com/atproto/identity/submitPlcOperation.js' import * as ComAtprotoIdentityUpdateHandle from './types/com/atproto/identity/updateHandle.js' @@ -480,6 +483,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + refreshIdentity( + cfg: ConfigOf< + AV, + ComAtprotoIdentityRefreshIdentity.Handler>, + ComAtprotoIdentityRefreshIdentity.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.refreshIdentity' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + requestPlcOperationSignature( cfg: ConfigOf< AV, @@ -493,6 +507,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + resolveDid( + cfg: ConfigOf< + AV, + ComAtprotoIdentityResolveDid.Handler>, + ComAtprotoIdentityResolveDid.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.resolveDid' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + resolveHandle( cfg: ConfigOf< AV, @@ -504,6 +529,17 @@ export class ComAtprotoIdentityNS { return this._server.xrpc.method(nsid, cfg) } + resolveIdentity( + cfg: ConfigOf< + AV, + ComAtprotoIdentityResolveIdentity.Handler>, + ComAtprotoIdentityResolveIdentity.HandlerReqCtx> + >, + ) { + const nsid = 'com.atproto.identity.resolveIdentity' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + signPlcOperation( cfg: ConfigOf< AV, diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index 23b00b79fb5..6463e7c6ec3 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -637,6 +637,32 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityDefs: { + lexicon: 1, + id: 'com.atproto.identity.defs', + defs: { + identityInfo: { + type: 'object', + required: ['did', 'handle', 'didDoc'], + properties: { + did: { + type: 'string', + format: 'did', + }, + handle: { + type: 'string', + format: 'handle', + description: + "The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document.", + }, + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + }, ComAtprotoIdentityGetRecommendedDidCredentials: { lexicon: 1, id: 'com.atproto.identity.getRecommendedDidCredentials', @@ -676,6 +702,54 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityRefreshIdentity: { + lexicon: 1, + id: 'com.atproto.identity.refreshIdentity', + defs: { + main: { + type: 'procedure', + description: + 'Request that the server re-resolve an identity (DID and handle). The server may ignore this request, or require authentication, depending on the role, implementation, and policy of the server.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + }, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityRequestPlcOperationSignature: { lexicon: 1, id: 'com.atproto.identity.requestPlcOperationSignature', @@ -687,13 +761,61 @@ export const schemaDict = { }, }, }, + ComAtprotoIdentityResolveDid: { + lexicon: 1, + id: 'com.atproto.identity.resolveDid', + defs: { + main: { + type: 'query', + description: + 'Resolves DID to DID document. Does not bi-directionally verify handle.', + parameters: { + type: 'params', + required: ['did'], + properties: { + did: { + type: 'string', + format: 'did', + description: 'DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['didDoc'], + properties: { + didDoc: { + type: 'unknown', + description: 'The complete DID document for the identity.', + }, + }, + }, + }, + errors: [ + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], + }, + }, + }, ComAtprotoIdentityResolveHandle: { lexicon: 1, id: 'com.atproto.identity.resolveHandle', defs: { main: { type: 'query', - description: 'Resolves a handle (domain name) to a DID.', + description: + 'Resolves an atproto handle (hostname) to a DID. Does not necessarily bi-directionally verify against the the DID document.', parameters: { type: 'params', required: ['handle'], @@ -718,6 +840,59 @@ export const schemaDict = { }, }, }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + ], + }, + }, + }, + ComAtprotoIdentityResolveIdentity: { + lexicon: 1, + id: 'com.atproto.identity.resolveIdentity', + defs: { + main: { + type: 'query', + description: + 'Resolves an identity (DID or Handle) to a full identity (DID document and verified handle).', + parameters: { + type: 'params', + required: ['identifier'], + properties: { + identifier: { + type: 'string', + format: 'at-identifier', + description: 'Handle or DID to resolve.', + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'ref', + ref: 'lex:com.atproto.identity.defs#identityInfo', + }, + }, + errors: [ + { + name: 'HandleNotFound', + description: + 'The resolution process confirmed that the handle does not resolve to any DID.', + }, + { + name: 'DidNotFound', + description: + 'The DID resolution process confirmed that there is no current DID.', + }, + { + name: 'DidDeactivated', + description: + 'The DID previously existed, but has been deactivated.', + }, + ], }, }, }, @@ -14394,11 +14569,15 @@ export const ids = { ComAtprotoAdminUpdateAccountPassword: 'com.atproto.admin.updateAccountPassword', ComAtprotoAdminUpdateSubjectStatus: 'com.atproto.admin.updateSubjectStatus', + ComAtprotoIdentityDefs: 'com.atproto.identity.defs', ComAtprotoIdentityGetRecommendedDidCredentials: 'com.atproto.identity.getRecommendedDidCredentials', + ComAtprotoIdentityRefreshIdentity: 'com.atproto.identity.refreshIdentity', ComAtprotoIdentityRequestPlcOperationSignature: 'com.atproto.identity.requestPlcOperationSignature', + ComAtprotoIdentityResolveDid: 'com.atproto.identity.resolveDid', ComAtprotoIdentityResolveHandle: 'com.atproto.identity.resolveHandle', + ComAtprotoIdentityResolveIdentity: 'com.atproto.identity.resolveIdentity', ComAtprotoIdentitySignPlcOperation: 'com.atproto.identity.signPlcOperation', ComAtprotoIdentitySubmitPlcOperation: 'com.atproto.identity.submitPlcOperation', diff --git a/packages/pds/src/lexicon/types/com/atproto/identity/defs.ts b/packages/pds/src/lexicon/types/com/atproto/identity/defs.ts new file mode 100644 index 00000000000..30b400f4fd3 --- /dev/null +++ b/packages/pds/src/lexicon/types/com/atproto/identity/defs.ts @@ -0,0 +1,30 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.defs' + +export interface IdentityInfo { + $type?: 'com.atproto.identity.defs#identityInfo' + did: string + /** The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document. */ + handle: string + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +const hashIdentityInfo = 'identityInfo' + +export function isIdentityInfo(v: V) { + return is$typed(v, id, hashIdentityInfo) +} + +export function validateIdentityInfo(v: V) { + return validate(v, id, hashIdentityInfo) +} diff --git a/packages/pds/src/lexicon/types/com/atproto/identity/refreshIdentity.ts b/packages/pds/src/lexicon/types/com/atproto/identity/refreshIdentity.ts new file mode 100644 index 00000000000..8ee156bdbbd --- /dev/null +++ b/packages/pds/src/lexicon/types/com/atproto/identity/refreshIdentity.ts @@ -0,0 +1,52 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.refreshIdentity' + +export interface QueryParams {} + +export interface InputSchema { + identifier: string +} + +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo + +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'HandleNotFound' | 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/pds/src/lexicon/types/com/atproto/identity/resolveDid.ts b/packages/pds/src/lexicon/types/com/atproto/identity/resolveDid.ts new file mode 100644 index 00000000000..78862549432 --- /dev/null +++ b/packages/pds/src/lexicon/types/com/atproto/identity/resolveDid.ts @@ -0,0 +1,52 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveDid' + +export interface QueryParams { + /** DID to resolve. */ + did: string +} + +export type InputSchema = undefined + +export interface OutputSchema { + /** The complete DID document for the identity. */ + didDoc: { [_ in string]: unknown } +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/pds/src/lexicon/types/com/atproto/identity/resolveHandle.ts b/packages/pds/src/lexicon/types/com/atproto/identity/resolveHandle.ts index 7c7fd5fe225..935094e5d25 100644 --- a/packages/pds/src/lexicon/types/com/atproto/identity/resolveHandle.ts +++ b/packages/pds/src/lexicon/types/com/atproto/identity/resolveHandle.ts @@ -34,6 +34,7 @@ export interface HandlerSuccess { export interface HandlerError { status: number message?: string + error?: 'HandleNotFound' } export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough diff --git a/packages/pds/src/lexicon/types/com/atproto/identity/resolveIdentity.ts b/packages/pds/src/lexicon/types/com/atproto/identity/resolveIdentity.ts new file mode 100644 index 00000000000..2a6b3fbf400 --- /dev/null +++ b/packages/pds/src/lexicon/types/com/atproto/identity/resolveIdentity.ts @@ -0,0 +1,48 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { CID } from 'multiformats/cid' +import { validate as _validate } from '../../../../lexicons' +import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import type * as ComAtprotoIdentityDefs from './defs.js' + +const is$typed = _is$typed, + validate = _validate +const id = 'com.atproto.identity.resolveIdentity' + +export interface QueryParams { + /** Handle or DID to resolve. */ + identifier: string +} + +export type InputSchema = undefined +export type OutputSchema = ComAtprotoIdentityDefs.IdentityInfo +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string + error?: 'HandleNotFound' | 'DidNotFound' | 'DidDeactivated' +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response + resetRouteRateLimits: () => Promise +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput