@atcute/client 1.0.0 → 2.0.1

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.js CHANGED
@@ -1,207 +1,4 @@
1
- /**
2
- * @module
3
- * Handles the actual XRPC client functionalities.
4
- */
5
- /** Possible response status from an XRPC service, status <100 is used for the library itself. */
6
- export var ResponseType;
7
- (function (ResponseType) {
8
- /** Unknown error from the library */
9
- ResponseType[ResponseType["Unknown"] = 1] = "Unknown";
10
- /** The server returned an invalid response */
11
- ResponseType[ResponseType["InvalidResponse"] = 2] = "InvalidResponse";
12
- /** Successful response from the service */
13
- ResponseType[ResponseType["Success"] = 200] = "Success";
14
- /** Request was considered invalid by the service */
15
- ResponseType[ResponseType["InvalidRequest"] = 400] = "InvalidRequest";
16
- /** Service requires an authentication token */
17
- ResponseType[ResponseType["AuthRequired"] = 401] = "AuthRequired";
18
- /** Request is forbidden by the service */
19
- ResponseType[ResponseType["Forbidden"] = 403] = "Forbidden";
20
- /** Not a XRPC service */
21
- ResponseType[ResponseType["XRPCNotSupported"] = 404] = "XRPCNotSupported";
22
- /** Payload is considered too large by the service */
23
- ResponseType[ResponseType["PayloadTooLarge"] = 413] = "PayloadTooLarge";
24
- /** Ratelimit was exceeded */
25
- ResponseType[ResponseType["RateLimitExceeded"] = 429] = "RateLimitExceeded";
26
- /** Internal server error */
27
- ResponseType[ResponseType["InternalServerError"] = 500] = "InternalServerError";
28
- /** Method hasn't been implemented */
29
- ResponseType[ResponseType["MethodNotImplemented"] = 501] = "MethodNotImplemented";
30
- /** Failure by an upstream service */
31
- ResponseType[ResponseType["UpstreamFailure"] = 502] = "UpstreamFailure";
32
- /** Not enough resources */
33
- ResponseType[ResponseType["NotEnoughResouces"] = 503] = "NotEnoughResouces";
34
- /** Timeout from upstream service */
35
- ResponseType[ResponseType["UpstreamTimeout"] = 504] = "UpstreamTimeout";
36
- })(ResponseType || (ResponseType = {}));
37
- /** XRPC response status which are recoverable (network error) */
38
- export const RECOVERABLE_RESPONSE_STATUS = [1, 408, 425, 429, 500, 502, 503, 504, 522, 524];
39
- /** Error coming from the XRPC service */
40
- export class XRPCError extends Error {
41
- name = 'XRPCError';
42
- /** Response status */
43
- status;
44
- /** Response headers */
45
- headers;
46
- /** Error kind */
47
- kind;
48
- constructor(status, { kind, message, headers, cause } = {}) {
49
- super(message || `Unspecified error message`, { cause });
50
- this.status = status;
51
- this.kind = kind;
52
- this.headers = headers || {};
53
- }
54
- }
55
- /** The client that sends out requests. */
56
- export class XRPC {
57
- /** The service it should connect to */
58
- service;
59
- /** XRPC fetch handler */
60
- fetch = fetchHandler;
61
- constructor(options) {
62
- this.service = options.service;
63
- }
64
- /**
65
- * Adds a hook to intercept XRPC requests.
66
- * Hooks are executed from last-registered to first-registered
67
- * @param fn Hook function
68
- */
69
- hook(fn) {
70
- this.fetch = fn(this.fetch);
71
- }
72
- /**
73
- * Makes a query (GET) request
74
- * @param nsid Namespace ID of a query endpoint
75
- * @param options Options to include like parameters
76
- * @returns The response of the request
77
- */
78
- get(nsid, options) {
79
- return this.#call({ type: 'get', nsid: nsid, ...options });
80
- }
81
- /**
82
- * Makes a procedure (POST) request
83
- * @param nsid Namespace ID of a procedure endpoint
84
- * @param options Options to include like input body or parameters
85
- * @returns The response of the request
86
- */
87
- call(nsid, options) {
88
- return this.#call({ type: 'post', nsid: nsid, ...options });
89
- }
90
- async #call(request) {
91
- const { status, headers, body } = await this.fetch({
92
- ...request,
93
- service: this.service,
94
- headers: request.headers === undefined ? {} : request.headers,
95
- params: request.params === undefined ? {} : request.params,
96
- });
97
- if (status === ResponseType.Success) {
98
- return { data: body, headers: headers };
99
- }
100
- else if (isErrorResponse(body)) {
101
- throw new XRPCError(status, { kind: body.error, message: body.message, headers });
102
- }
103
- else {
104
- throw new XRPCError(status, { headers });
105
- }
106
- }
107
- }
108
- /**
109
- * Clones an XRPC instance
110
- * @param rpc Base instance
111
- * @returns The cloned instance
112
- */
113
- export const clone = (rpc) => {
114
- const cloned = new XRPC({ service: rpc.service });
115
- cloned.fetch = rpc.fetch;
116
- return cloned;
117
- };
118
- /**
119
- * Clones an existing XRPC instance, with a proxy on top.
120
- * @param rpc Base instance
121
- * @param opts Proxying options
122
- * @returns Cloned instance with a proxy added
123
- */
124
- export const withProxy = (rpc, opts) => {
125
- const cloned = clone(rpc);
126
- cloned.hook((next) => (request) => {
127
- return next({
128
- ...request,
129
- headers: {
130
- ...request.headers,
131
- 'atproto-proxy': `${opts.service}#${opts.type}`,
132
- },
133
- });
134
- });
135
- return cloned;
136
- };
137
- /** Default fetch handler */
138
- export const fetchHandler = async ({ service, type, nsid, headers, params, encoding, data: input, signal, }) => {
139
- const uri = new URL(`/xrpc/${nsid}`, service);
140
- const searchParams = uri.searchParams;
141
- for (const key in params) {
142
- const value = params[key];
143
- if (value !== undefined) {
144
- if (Array.isArray(value)) {
145
- for (let idx = 0, len = value.length; idx < len; idx++) {
146
- const val = value[idx];
147
- searchParams.append(key, val);
148
- }
149
- }
150
- else {
151
- searchParams.set(key, value);
152
- }
153
- }
154
- }
155
- const isProcedure = type === 'post';
156
- const isJson = typeof input === 'object' &&
157
- !(input instanceof FormData || input instanceof Blob || ArrayBuffer.isView(input));
158
- const response = await fetch(uri, {
159
- signal: signal,
160
- method: isProcedure ? 'POST' : 'GET',
161
- headers: encoding || isJson ? { ...headers, 'Content-Type': encoding || 'application/json' } : headers,
162
- body: isJson ? JSON.stringify(input) : input,
163
- });
164
- const responseHeaders = response.headers;
165
- const responseType = responseHeaders.get('Content-Type');
166
- let promise;
167
- let data;
168
- if (responseType) {
169
- if (responseType.startsWith('application/json')) {
170
- promise = response.json();
171
- }
172
- else if (responseType.startsWith('text/')) {
173
- promise = response.text();
174
- }
175
- }
176
- try {
177
- data = await (promise || response.arrayBuffer().then((buffer) => new Uint8Array(buffer)));
178
- }
179
- catch (err) {
180
- throw new XRPCError(ResponseType.InvalidResponse, {
181
- cause: err,
182
- message: `Failed to parse response body`,
183
- });
184
- }
185
- return {
186
- status: response.status,
187
- headers: Object.fromEntries(responseHeaders),
188
- body: data,
189
- };
190
- };
191
- /**
192
- * Check if provided value is an error object
193
- * @param value Response value
194
- * @param names If provided, also checks if the error name matches what you expect
195
- * @returns A boolean on the check
196
- */
197
- export const isErrorResponse = (value, names) => {
198
- if (typeof value !== 'object' || !value) {
199
- return false;
200
- }
201
- const kindType = typeof value.error;
202
- const messageType = typeof value.message;
203
- return ((kindType === 'undefined' || kindType === 'string') &&
204
- (messageType === 'undefined' || messageType === 'string') &&
205
- (!names || names.includes(value.error)));
206
- };
1
+ export * from './rpc.js';
2
+ export * from './fetch-handler.js';
3
+ export * from './credential-manager.js';
207
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,iGAAiG;AACjG,MAAM,CAAN,IAAkB,YA8BjB;AA9BD,WAAkB,YAAY;IAC7B,qCAAqC;IACrC,qDAAW,CAAA;IACX,8CAA8C;IAC9C,qEAAmB,CAAA;IAEnB,2CAA2C;IAC3C,uDAAa,CAAA;IACb,oDAAoD;IACpD,qEAAoB,CAAA;IACpB,+CAA+C;IAC/C,iEAAkB,CAAA;IAClB,0CAA0C;IAC1C,2DAAe,CAAA;IACf,yBAAyB;IACzB,yEAAsB,CAAA;IACtB,qDAAqD;IACrD,uEAAqB,CAAA;IACrB,6BAA6B;IAC7B,2EAAuB,CAAA;IACvB,4BAA4B;IAC5B,+EAAyB,CAAA;IACzB,qCAAqC;IACrC,iFAA0B,CAAA;IAC1B,qCAAqC;IACrC,uEAAqB,CAAA;IACrB,2BAA2B;IAC3B,2EAAuB,CAAA;IACvB,oCAAoC;IACpC,uEAAqB,CAAA;AACtB,CAAC,EA9BiB,YAAY,KAAZ,YAAY,QA8B7B;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,2BAA2B,GAAa,CAAC,C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namespace ComAtprotoRepoApplyWrites {
483
483
  writes: Brand.Union<Create | Delete | Update>[];
484
484
  /** If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. */
485
485
  swapCommit?: At.CID;
486
- /**
487
- * Can be set to 'false' to skip Lexicon schema validation of record data, for all operations.
488
- * @default true
489
- */
486
+ /** Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons. */
490
487
  validate?: boolean;
491
488
  }
492
- type Output = undefined;
489
+ interface Output {
490
+ commit?: ComAtprotoRepoDefs.CommitMeta;
491
+ results?: Brand.Union<CreateResult | DeleteResult | UpdateResult>[];
492
+ }
493
493
  interface Errors {
494
494
  InvalidSwap: {};
495
495
  }
@@ -501,12 +501,21 @@ export declare namespace ComAtprotoRepoApplyWrites {
501
501
  /** Maximum string length: 15 */
502
502
  rkey?: string;
503
503
  }
504
+ interface CreateResult {
505
+ [Brand.Type]?: 'com.atproto.repo.applyWrites#createResult';
506
+ cid: At.CID;
507
+ uri: At.Uri;
508
+ validationStatus?: 'unknown' | 'valid' | (string & {});
509
+ }
504
510
  /** Operation which deletes an existing record. */
505
511
  interface Delete {
506
512
  [Brand.Type]?: 'com.atproto.repo.applyWrites#delete';
507
513
  collection: string;
508
514
  rkey: string;
509
515
  }
516
+ interface DeleteResult {
517
+ [Brand.Type]?: 'com.atproto.repo.applyWrites#deleteResult';
518
+ }
510
519
  /** Operation which updates an existing record. */
511
520
  interface Update {
512
521
  [Brand.Type]?: 'com.atproto.repo.applyWrites#update';
@@ -514,6 +523,12 @@ export declare namespace ComAtprotoRepoApplyWrites {
514
523
  rkey: string;
515
524
  value: unknown;
516
525
  }
526
+ interface UpdateResult {
527
+ [Brand.Type]?: 'com.atproto.repo.applyWrites#updateResult';
528
+ cid: At.CID;
529
+ uri: At.Uri;
530
+ validationStatus?: 'unknown' | 'valid' | (string & {});
531
+ }
517
532
  }
518
533
  /** Create a single new repository record. Requires auth, implemented by PDS. */
519
534
  export declare namespace ComAtprotoRepoCreateRecord {
@@ -533,20 +548,26 @@ export declare namespace ComAtprotoRepoCreateRecord {
533
548
  rkey?: string;
534
549
  /** Compare and swap with the previous commit by CID. */
535
550
  swapCommit?: At.CID;
536
- /**
537
- * Can be set to 'false' to skip Lexicon schema validation of record data.
538
- * @default true
539
- */
551
+ /** Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. */
540
552
  validate?: boolean;
541
553
  }
542
554
  interface Output {
543
555
  cid: At.CID;
544
556
  uri: At.Uri;
557
+ commit?: ComAtprotoRepoDefs.CommitMeta;
558
+ validationStatus?: 'unknown' | 'valid' | (string & {});
545
559
  }
546
560
  interface Errors {
547
561
  InvalidSwap: {};
548
562
  }
549
563
  }
564
+ export declare namespace ComAtprotoRepoDefs {
565
+ interface CommitMeta {
566
+ [Brand.Type]?: 'com.atproto.repo.defs#commitMeta';
567
+ cid: At.CID;
568
+ rev: string;
569
+ }
570
+ }
550
571
  /** Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. */
551
572
  export declare namespace ComAtprotoRepoDeleteRecord {
552
573
  interface Params {
@@ -563,7 +584,9 @@ export declare namespace ComAtprotoRepoDeleteRecord {
563
584
  /** Compare and swap with the previous record by CID. */
564
585
  swapRecord?: At.CID;
565
586
  }
566
- type Output = undefined;
587
+ interface Output {
588
+ commit?: ComAtprotoRepoDefs.CommitMeta;
589
+ }
567
590
  interface Errors {
568
591
  InvalidSwap: {};
569
592
  }
@@ -694,15 +717,14 @@ export declare namespace ComAtprotoRepoPutRecord {
694
717
  swapCommit?: At.CID;
695
718
  /** Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation */
696
719
  swapRecord?: At.CID | null;
697
- /**
698
- * Can be set to 'false' to skip Lexicon schema validation of record data.
699
- * @default true
700
- */
720
+ /** Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. */
701
721
  validate?: boolean;
702
722
  }
703
723
  interface Output {
704
724
  cid: At.CID;
705
725
  uri: At.Uri;
726
+ commit?: ComAtprotoRepoDefs.CommitMeta;
727
+ validationStatus?: 'unknown' | 'valid' | (string & {});
706
728
  }
707
729
  interface Errors {
708
730
  InvalidSwap: {};
@@ -1662,6 +1684,7 @@ export declare interface Procedures {
1662
1684
  };
1663
1685
  'com.atproto.repo.applyWrites': {
1664
1686
  input: ComAtprotoRepoApplyWrites.Input;
1687
+ output: ComAtprotoRepoApplyWrites.Output;
1665
1688
  };
1666
1689
  'com.atproto.repo.createRecord': {
1667
1690
  input: ComAtprotoRepoCreateRecord.Input;
@@ -1669,6 +1692,7 @@ export declare interface Procedures {
1669
1692
  };
1670
1693
  'com.atproto.repo.deleteRecord': {
1671
1694
  input: ComAtprotoRepoDeleteRecord.Input;
1695
+ output: ComAtprotoRepoDeleteRecord.Output;
1672
1696
  };
1673
1697
  'com.atproto.repo.importRepo': {
1674
1698
  input: ComAtprotoRepoImportRepo.Input;
package/dist/rpc.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ import type { At, Procedures, Queries } from './lexicons.js';
2
+ import { type FetchHandler, type FetchHandlerObject } from './fetch-handler.js';
3
+ export type HeadersObject = Record<string, string>;
4
+ /** Response from XRPC service */
5
+ export interface XRPCResponse<T = any> {
6
+ data: T;
7
+ headers: HeadersObject;
8
+ }
9
+ /** Options for constructing an XRPC error */
10
+ export interface XRPCErrorOptions {
11
+ kind?: string;
12
+ description?: string;
13
+ headers?: HeadersObject;
14
+ cause?: unknown;
15
+ }
16
+ /** Error coming from the XRPC service */
17
+ export declare class XRPCError extends Error {
18
+ name: string;
19
+ /** Response status */
20
+ status: number;
21
+ /** Response headers */
22
+ headers: HeadersObject;
23
+ /** Error kind */
24
+ kind?: string;
25
+ /** Error description */
26
+ description?: string;
27
+ constructor(status: number, { kind, description, headers, cause }?: XRPCErrorOptions);
28
+ }
29
+ /** Service proxy options */
30
+ export interface XRPCProxyOptions {
31
+ type: 'atproto_pds' | 'atproto_labeler' | 'bsky_fg' | 'bsky_notif' | ({} & string);
32
+ service: At.DID;
33
+ }
34
+ /** Options for constructing an XRPC */
35
+ export interface XRPCOptions {
36
+ handler: FetchHandler | FetchHandlerObject;
37
+ proxy?: XRPCProxyOptions;
38
+ }
39
+ /** XRPC request options */
40
+ export interface XRPCRequestOptions {
41
+ type: 'get' | 'post';
42
+ nsid: string;
43
+ headers?: HeadersInit;
44
+ params?: Record<string, unknown>;
45
+ data?: FormData | Blob | ArrayBufferView | Record<string, unknown>;
46
+ signal?: AbortSignal;
47
+ }
48
+ /** XRPC response */
49
+ export interface XRPCResponse<T = any> {
50
+ data: T;
51
+ headers: HeadersObject;
52
+ }
53
+ /** Base options for the query/procedure request */
54
+ interface BaseRPCOptions {
55
+ /** Request headers to make */
56
+ headers?: HeadersInit;
57
+ /** Signal for aborting the request */
58
+ signal?: AbortSignal;
59
+ }
60
+ /** Options for the query/procedure request */
61
+ export type RPCOptions<T> = BaseRPCOptions & (T extends {
62
+ params: any;
63
+ } ? {
64
+ params: T['params'];
65
+ } : {}) & (T extends {
66
+ input: any;
67
+ } ? {
68
+ data: T['input'];
69
+ } : {});
70
+ type OutputOf<T> = T extends {
71
+ output: any;
72
+ } ? T['output'] : never;
73
+ export declare class XRPC {
74
+ handle: FetchHandler;
75
+ proxy: XRPCProxyOptions | undefined;
76
+ constructor({ handler, proxy }: XRPCOptions);
77
+ /**
78
+ * Makes a query (GET) request
79
+ * @param nsid Namespace ID of a query endpoint
80
+ * @param options Options to include like parameters
81
+ * @returns The response of the request
82
+ */
83
+ get<K extends keyof Queries>(nsid: K, options: RPCOptions<Queries[K]>): Promise<XRPCResponse<OutputOf<Queries[K]>>>;
84
+ /**
85
+ * Makes a procedure (POST) request
86
+ * @param nsid Namespace ID of a procedure endpoint
87
+ * @param options Options to include like input body or parameters
88
+ * @returns The response of the request
89
+ */
90
+ call<K extends keyof Procedures>(nsid: K, options: RPCOptions<Procedures[K]>): Promise<XRPCResponse<OutputOf<Procedures[K]>>>;
91
+ /** Makes a request to the XRPC service */
92
+ request(options: XRPCRequestOptions): Promise<XRPCResponse>;
93
+ }
94
+ export declare const clone: (rpc: XRPC) => XRPC;
95
+ export declare const withProxy: (rpc: XRPC, options: XRPCProxyOptions) => XRPC;
96
+ export {};
package/dist/rpc.js ADDED
@@ -0,0 +1,173 @@
1
+ import { buildFetchHandler } from './fetch-handler.js';
2
+ import { mergeHeaders } from './utils/http.js';
3
+ /** Possible response status from an XRPC service, status <100 is used for the library itself. */
4
+ var ResponseType;
5
+ (function (ResponseType) {
6
+ /** Unknown error from the library */
7
+ ResponseType[ResponseType["Unknown"] = 1] = "Unknown";
8
+ /** The server returned an invalid response */
9
+ ResponseType[ResponseType["InvalidResponse"] = 2] = "InvalidResponse";
10
+ /** Successful response from the service */
11
+ ResponseType[ResponseType["Success"] = 200] = "Success";
12
+ /** Request was considered invalid by the service */
13
+ ResponseType[ResponseType["InvalidRequest"] = 400] = "InvalidRequest";
14
+ /** Service requires an authentication token */
15
+ ResponseType[ResponseType["AuthRequired"] = 401] = "AuthRequired";
16
+ /** Request is forbidden by the service */
17
+ ResponseType[ResponseType["Forbidden"] = 403] = "Forbidden";
18
+ /** Not a XRPC service */
19
+ ResponseType[ResponseType["XRPCNotSupported"] = 404] = "XRPCNotSupported";
20
+ /** Payload is considered too large by the service */
21
+ ResponseType[ResponseType["PayloadTooLarge"] = 413] = "PayloadTooLarge";
22
+ /** Ratelimit was exceeded */
23
+ ResponseType[ResponseType["RateLimitExceeded"] = 429] = "RateLimitExceeded";
24
+ /** Internal server error */
25
+ ResponseType[ResponseType["InternalServerError"] = 500] = "InternalServerError";
26
+ /** Method hasn't been implemented */
27
+ ResponseType[ResponseType["MethodNotImplemented"] = 501] = "MethodNotImplemented";
28
+ /** Failure by an upstream service */
29
+ ResponseType[ResponseType["UpstreamFailure"] = 502] = "UpstreamFailure";
30
+ /** Not enough resources */
31
+ ResponseType[ResponseType["NotEnoughResouces"] = 503] = "NotEnoughResouces";
32
+ /** Timeout from upstream service */
33
+ ResponseType[ResponseType["UpstreamTimeout"] = 504] = "UpstreamTimeout";
34
+ })(ResponseType || (ResponseType = {}));
35
+ /** Error coming from the XRPC service */
36
+ export class XRPCError extends Error {
37
+ constructor(status, { kind, description, headers, cause } = {}) {
38
+ super(`${kind || 'UnspecifiedKind'} > ${description || `Unspecified error description`}`, { cause });
39
+ this.name = 'XRPCError';
40
+ this.status = status;
41
+ this.kind = kind;
42
+ this.description = description;
43
+ this.headers = headers || {};
44
+ }
45
+ }
46
+ export class XRPC {
47
+ constructor({ handler, proxy }) {
48
+ this.handle = buildFetchHandler(handler);
49
+ this.proxy = proxy;
50
+ }
51
+ /**
52
+ * Makes a query (GET) request
53
+ * @param nsid Namespace ID of a query endpoint
54
+ * @param options Options to include like parameters
55
+ * @returns The response of the request
56
+ */
57
+ get(nsid, options) {
58
+ return this.request({ type: 'get', nsid: nsid, ...options });
59
+ }
60
+ /**
61
+ * Makes a procedure (POST) request
62
+ * @param nsid Namespace ID of a procedure endpoint
63
+ * @param options Options to include like input body or parameters
64
+ * @returns The response of the request
65
+ */
66
+ call(nsid, options) {
67
+ return this.request({ type: 'post', nsid: nsid, ...options });
68
+ }
69
+ /** Makes a request to the XRPC service */
70
+ async request(options) {
71
+ const data = options.data;
72
+ const url = `/xrpc/${options.nsid}` + constructSearchParams(options.params);
73
+ const isInputJson = isJsonValue(data);
74
+ const response = await this.handle(url, {
75
+ method: options.type,
76
+ signal: options.signal,
77
+ body: isInputJson ? JSON.stringify(data) : data,
78
+ headers: mergeHeaders(options.headers, {
79
+ 'content-type': isInputJson ? 'application/json' : null,
80
+ 'atproto-proxy': constructProxyHeader(this.proxy),
81
+ }),
82
+ });
83
+ const responseStatus = response.status;
84
+ const responseHeaders = Object.fromEntries(response.headers);
85
+ const responseType = responseHeaders['content-type'];
86
+ let promise;
87
+ let ret;
88
+ if (responseType) {
89
+ if (responseType.startsWith('application/json')) {
90
+ promise = response.json();
91
+ }
92
+ else if (responseType.startsWith('text/')) {
93
+ promise = response.text();
94
+ }
95
+ }
96
+ try {
97
+ ret = await (promise || response.arrayBuffer().then((buffer) => new Uint8Array(buffer)));
98
+ }
99
+ catch (err) {
100
+ throw new XRPCError(ResponseType.InvalidResponse, {
101
+ cause: err,
102
+ kind: 'InvalidResponse',
103
+ description: `Failed to parse response body`,
104
+ headers: responseHeaders,
105
+ });
106
+ }
107
+ if (responseStatus === ResponseType.Success) {
108
+ return {
109
+ data: ret,
110
+ headers: responseHeaders,
111
+ };
112
+ }
113
+ if (isErrorResponse(ret)) {
114
+ throw new XRPCError(responseStatus, {
115
+ kind: ret.error,
116
+ description: ret.message,
117
+ headers: responseHeaders,
118
+ });
119
+ }
120
+ throw new XRPCError(responseStatus, { headers: responseHeaders });
121
+ }
122
+ }
123
+ const constructProxyHeader = (proxy) => {
124
+ if (proxy) {
125
+ return `${proxy.service}#${proxy.type}`;
126
+ }
127
+ return null;
128
+ };
129
+ const constructSearchParams = (params) => {
130
+ let searchParams;
131
+ for (const key in params) {
132
+ const value = params[key];
133
+ if (value !== undefined) {
134
+ searchParams ??= new URLSearchParams();
135
+ if (Array.isArray(value)) {
136
+ for (let idx = 0, len = value.length; idx < len; idx++) {
137
+ const val = value[idx];
138
+ searchParams.append(key, '' + val);
139
+ }
140
+ }
141
+ else {
142
+ searchParams.set(key, '' + value);
143
+ }
144
+ }
145
+ }
146
+ return searchParams ? `?` + searchParams.toString() : '';
147
+ };
148
+ const isJsonValue = (o) => {
149
+ if (typeof o !== 'object' || o === null) {
150
+ return false;
151
+ }
152
+ if ('toJSON' in o) {
153
+ return true;
154
+ }
155
+ const proto = Object.getPrototypeOf(o);
156
+ return proto === null || proto === Object.prototype;
157
+ };
158
+ const isErrorResponse = (value) => {
159
+ if (typeof value !== 'object' || value === null) {
160
+ return false;
161
+ }
162
+ const kindType = typeof value.error;
163
+ const messageType = typeof value.message;
164
+ return ((kindType === 'undefined' || kindType === 'string') &&
165
+ (messageType === 'undefined' || messageType === 'string'));
166
+ };
167
+ export const clone = (rpc) => {
168
+ return new XRPC({ handler: rpc.handle, proxy: rpc.proxy });
169
+ };
170
+ export const withProxy = (rpc, options) => {
171
+ return new XRPC({ handler: rpc.handle, proxy: options });
172
+ };
173
+ //# sourceMappingURL=rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../lib/rpc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAA8C,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,iGAAiG;AACjG,IAAW,YA8BV;AA9BD,WAAW,YAAY;IACtB,qCAAqC;IACrC,qDAAW,CAAA;IACX,8CAA8C;IAC9C,qEAAmB,CAAA;IAEnB,2CAA2C;IAC3C,uDAAa,CAAA;IACb,oDAAoD;IACpD,qEAAoB,CAAA;IACpB,+CAA+C;IAC/C,iEAAkB,CAAA;IAClB,0CAA0C;IAC1C,2DAAe,CAAA;IACf,yBAAyB;IACzB,yEAAsB,CAAA;IACtB,qDAAqD;IACrD,uEAAqB,CAAA;IACrB,6BAA6B;IAC7B,2EAAuB,CAAA;IACvB,4BAA4B;IAC5B,+EAAyB,CAAA;IACzB,qCAAqC;IACrC,iFAA0B,CAAA;IAC1B,qCAAqC;IACrC,uEAAqB,CAAA;IACrB,2BAA2B;IAC3B,2EAAuB,CAAA;IACvB,oCAAoC;IACpC,uEAAqB,CAAA;AACtB,CAAC,EA9BU,YAAY,KAAZ,YAAY,QA8BtB;AAkBD,yCAAyC;AACzC,MAAM,OAAO,SAAU,SAAQ,KAAK;IAYnC,YAAY,MAAc,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,KAAuB,EAAE;QACvF,KAAK,CAAC,GAAG,IAAI,IAAI,iBAAiB,MAAM,WAAW,IAAI,+BAA+B,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAZ7F,SAA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AAK,EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAS,EAAE,OAAyB,EAAE,EAAE;IACjE,OAAO,IAAI,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC"}
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * @module
3
- * DID document-related functionalities
3
+ * DID document-related functionalities.
4
+ * This module is exported for convenience and is no way part of public API,
5
+ * it can be removed at any time.
4
6
  */
5
7
  /**
6
8
  * Retrieves AT Protocol PDS endpoint from the DID document, if available
package/dist/utils/did.js CHANGED
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * @module
3
- * DID document-related functionalities
3
+ * DID document-related functionalities.
4
+ * This module is exported for convenience and is no way part of public API,
5
+ * it can be removed at any time.
4
6
  */
5
7
  /**
6
8
  * Retrieves AT Protocol PDS endpoint from the DID document, if available
@@ -1 +1 @@
1
- {"version":3,"file":"did.js","sourceRoot":"","sources":["../../lib/utils/did.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAgB,EAAsB,EAAE;IACtE,OAAO,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,2BAA2B,CAAC,CAAC;AAC7E,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CACjC,GAAgB,EAChB,SAAiB,EACjB,WAAmB,EACE,EAAE;IACvB,MAAM,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC;IAEnB,MAAM,YAAY,GAAG,GAAG,GAAG,SAAS,CAAC;IACrC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,E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AAE,KAAK,SAAS,IAAI,OAAO,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC;IAEtG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,KAAK,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;QACvF,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,MAAc,EAAsB,EAAE;IAC1D,IAAI,GAAG,CAAC;IACR,IAAI,CAAC;QACJ,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC;IAE3B,IAAI,GAAG,CAAC,QAAQ,IAAI,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC/D,OAAO,MAAM,CAAC;IACf,CAAC;AACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @module
3
+ * Assortment of HTTP utilities
4
+ * This module is exported for convenience and is no way part of public API,
5
+ * it can be removed at any time.
6
+ */
7
+ export declare const mergeHeaders: (init: HeadersInit | undefined, defaults: Record<string, string | null>) => HeadersInit | undefined;