@recursiv/sdk 0.7.17 → 0.7.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -189,7 +189,7 @@ export type { UploadMediaInput, UploadUrlInput, UploadUrlResult } from './resour
189
189
  export { WalletResource } from './resources/wallet.js';
190
190
  export { ProtocolsResource } from './resources/protocols.js';
191
191
  export { PROTOCOL_ADAPTER_MATURITIES, PROTOCOL_CAPABILITY_OPERATIONS, PROTOCOL_CAPABILITY_STATUSES, } from './resources/protocols.js';
192
- export type { HostedProtocolConnections, ListProtocolCandidatesParams, ProtocolAdapterMaturity, ProtocolAdapterMetadata, ProtocolCandidateListResponse, ProtocolCandidatePageMeta, ProtocolCapabilityOperation, ProtocolCapabilityStatus, ProtocolCollectionStatus, ProtocolQuarantinedCandidate, ProtocolRefreshResult, ProtocolSettings, ProtocolSettingsUpdateResult, UpdateSettingsInput as UpdateProtocolSettingsInput, } from './resources/protocols.js';
192
+ export type { HostedProtocolConnections, HostedProtocol, HostedProtocolIdentity, HostedNostrChallenge, HostedNostrIdentityProof, HostedPostPreview, ConnectHostedIdentityInput, PreviewHostedPostInput, PublishHostedPostInput, ListProtocolCandidatesParams, ProtocolAdapterMaturity, ProtocolAdapterMetadata, ProtocolCandidateListResponse, ProtocolCandidatePageMeta, ProtocolCapabilityOperation, ProtocolCapabilityStatus, ProtocolCollectionStatus, ProtocolQuarantinedCandidate, ProtocolRefreshResult, ProtocolSettings, ProtocolSettingsUpdateResult, UpdateSettingsInput as UpdateProtocolSettingsInput, } from './resources/protocols.js';
193
193
  export { InboxResource } from './resources/inbox.js';
194
194
  export { NetworkResource } from './resources/network.js';
195
195
  export { SimulatorResource } from './resources/simulator.js';
@@ -129,6 +129,69 @@ export interface HostedProtocolConnections {
129
129
  url: string;
130
130
  }[];
131
131
  }
132
+ export type HostedProtocol = 'atproto' | 'activitypub' | 'nostr';
133
+ export interface HostedProtocolIdentity {
134
+ id: string;
135
+ protocol: HostedProtocol;
136
+ serverUrl: string;
137
+ nativeId: string;
138
+ handle: string;
139
+ profileUrl: string | null;
140
+ verifiedAt: string;
141
+ createdAt: string;
142
+ }
143
+ export interface HostedNostrChallenge {
144
+ expiresAt: string;
145
+ /** Sign using a NIP-07 signer; never publish this kind-22242 event. */
146
+ event: {
147
+ kind: 22242;
148
+ content: string;
149
+ created_at: number;
150
+ tags: string[][];
151
+ };
152
+ }
153
+ export interface HostedNostrIdentityProof {
154
+ id: string;
155
+ pubkey: string;
156
+ sig: string;
157
+ kind: number;
158
+ content: string;
159
+ created_at: number;
160
+ tags: string[][];
161
+ }
162
+ export type ConnectHostedIdentityInput = {
163
+ protocol: 'atproto';
164
+ identifier: string; /** Prefer a native app password. Used once, never stored. */
165
+ password: string;
166
+ } | {
167
+ protocol: 'activitypub'; /** Native read:accounts/read:statuses token. Used once, never stored. */
168
+ accessToken: string;
169
+ } | {
170
+ protocol: 'nostr';
171
+ event: HostedNostrIdentityProof;
172
+ };
173
+ export interface PreviewHostedPostInput {
174
+ /** AT URI, GoToSocial status ID, or Nostr event ID. Never a fetch URL. */
175
+ nativePostId: string;
176
+ /** Required for ActivityPub reads; verified as the connected owner each time. */
177
+ accessToken?: string;
178
+ }
179
+ export interface HostedPostPreview {
180
+ identityId: string;
181
+ protocol: HostedProtocol;
182
+ externalId: string;
183
+ externalUrl: string;
184
+ content: string;
185
+ publishedAt: string;
186
+ isNsfw: boolean;
187
+ sourceVisibility: 'public' | 'unlisted';
188
+ contentHash: string;
189
+ }
190
+ export interface PublishHostedPostInput extends PreviewHostedPostInput {
191
+ contentHash: string;
192
+ /** Explicitly publish the previewed text publicly in this app. */
193
+ publishPublicly: true;
194
+ }
132
195
  export declare class ProtocolsResource {
133
196
  private client;
134
197
  constructor(client: HttpClient);
@@ -136,6 +199,24 @@ export declare class ProtocolsResource {
136
199
  list(): Promise<SingleResponse<ProtocolAdapterMetadata[]>>;
137
200
  /** Configured addresses for the current app. Does not attest runtime or account readiness. */
138
201
  hostedServers(): Promise<SingleResponse<HostedProtocolConnections>>;
202
+ /** Private connections belonging only to the signed-in person in the key's app. */
203
+ hostedIdentities(): Promise<SingleResponse<Array<HostedProtocolIdentity & {
204
+ configured: boolean;
205
+ }>>>;
206
+ /** Request a short-lived, single-use proof bound to this app, account and relay. */
207
+ hostedNostrChallenge(): Promise<SingleResponse<HostedNostrChallenge>>;
208
+ connectHostedIdentity(input: ConnectHostedIdentityInput): Promise<SingleResponse<HostedProtocolIdentity>>;
209
+ disconnectHostedIdentity(id: string): Promise<SingleResponse<{
210
+ disconnected: true;
211
+ }>>;
212
+ /** Preview one owned native text post. Does not create a Minds post. */
213
+ previewHostedPost(id: string, input: PreviewHostedPostInput): Promise<SingleResponse<HostedPostPreview>>;
214
+ /** Refetch/recheck the preview and create one canonical, scoped app post. */
215
+ publishHostedPost(id: string, input: PublishHostedPostInput): Promise<SingleResponse<{
216
+ postId: string;
217
+ protocol: HostedProtocol;
218
+ externalId: string;
219
+ }>>;
139
220
  /** Get project-scoped unpublished candidate status (admin) */
140
221
  status(): Promise<SingleResponse<ProtocolCollectionStatus[]>>;
141
222
  /**
@@ -28,6 +28,12 @@ export const PROTOCOL_ADAPTER_MATURITIES = Object.freeze([
28
28
  'beta',
29
29
  'stable',
30
30
  ]);
31
+ function hostedIdentityPath(id) {
32
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)) {
33
+ throw new ValidationError({ type: 'validation_error', code: 'invalid_identity_id', message: 'A valid hosted identity connection ID is required' });
34
+ }
35
+ return `/protocols/identities/${encodeURIComponent(id)}`;
36
+ }
31
37
  export class ProtocolsResource {
32
38
  client;
33
39
  constructor(client) {
@@ -41,6 +47,28 @@ export class ProtocolsResource {
41
47
  hostedServers() {
42
48
  return this.client.get('/protocols/servers');
43
49
  }
50
+ /** Private connections belonging only to the signed-in person in the key's app. */
51
+ hostedIdentities() {
52
+ return this.client.get('/protocols/identities');
53
+ }
54
+ /** Request a short-lived, single-use proof bound to this app, account and relay. */
55
+ hostedNostrChallenge() {
56
+ return this.client.post('/protocols/nostr-challenge', {});
57
+ }
58
+ connectHostedIdentity(input) {
59
+ return this.client.post('/protocols/identities', input);
60
+ }
61
+ async disconnectHostedIdentity(id) {
62
+ return this.client.delete(hostedIdentityPath(id));
63
+ }
64
+ /** Preview one owned native text post. Does not create a Minds post. */
65
+ async previewHostedPost(id, input) {
66
+ return this.client.post(`${hostedIdentityPath(id)}/posts/preview`, input);
67
+ }
68
+ /** Refetch/recheck the preview and create one canonical, scoped app post. */
69
+ async publishHostedPost(id, input) {
70
+ return this.client.post(`${hostedIdentityPath(id)}/posts`, input);
71
+ }
44
72
  /** Get project-scoped unpublished candidate status (admin) */
45
73
  status() {
46
74
  return this.client.get('/protocols/status');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recursiv/sdk",
3
- "version": "0.7.17",
3
+ "version": "0.7.18",
4
4
  "description": "TypeScript SDK for the Recursiv API",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",