Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atproto/xrpc

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atproto/xrpc - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

3

dist/client.d.ts
import { Lexicons } from '@atproto/lexicon';
import { FetchHandler, CallOptions, QueryParams, XRPCResponse } from './types';
import { FetchHandler, FetchHandlerResponse, Headers, CallOptions, QueryParams, XRPCResponse } from './types';
export declare class Client {

@@ -21,1 +21,2 @@ fetch: FetchHandler;

}
export declare function defaultFetchHandler(httpUri: string, httpMethod: string, httpHeaders: Headers, httpReqBody: unknown): Promise<FetchHandlerResponse>;

@@ -5,3 +5,3 @@ import { LexXrpcProcedure, LexXrpcQuery } from '@atproto/lexicon';

export declare function constructMethodCallUri(nsid: string, schema: LexXrpcProcedure | LexXrpcQuery, serviceUri: URL, params?: QueryParams): string;
export declare function encodeQueryParam(type: 'string' | 'number' | 'integer' | 'boolean' | 'datetime' | 'unknown', value: any): string;
export declare function encodeQueryParam(type: 'string' | 'number' | 'integer' | 'boolean' | 'datetime' | 'array' | 'unknown', value: any): string;
export declare function constructMethodCallHeaders(schema: LexXrpcProcedure | LexXrpcQuery, data?: any, opts?: CallOptions): Headers;

@@ -8,0 +8,0 @@ export declare function encodeMethodCallBody(headers: Headers, data?: any): ArrayBuffer | undefined;

{
"name": "@atproto/xrpc",
"version": "0.0.3",
"version": "0.0.4",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -133,3 +133,3 @@ import { Lexicons, ValidationError } from '@atproto/lexicon'

async function defaultFetchHandler(
export async function defaultFetchHandler(
httpUri: string,

@@ -141,7 +141,11 @@ httpMethod: string,

try {
const res = await fetch(httpUri, {
// The duplex field is now required for streaming bodies, but not yet reflected
// anywhere in docs or types. See whatwg/fetch#1438, nodejs/node#46221.
const reqInit: RequestInit & { duplex: string } = {
method: httpMethod,
headers: httpHeaders,
body: encodeMethodCallBody(httpHeaders, httpReqBody),
})
duplex: 'half',
}
const res = await fetch(httpUri, reqInit)
const resBody = await res.arrayBuffer()

@@ -148,0 +152,0 @@ return {

@@ -36,3 +36,13 @@ import { LexXrpcProcedure, LexXrpcQuery } from '@atproto/lexicon'

if (value !== undefined) {
uri.searchParams.set(key, encodeQueryParam(paramSchema.type, value))
if (paramSchema.type === 'array') {
const vals: typeof value[] = []
vals.concat(value).forEach((val) => {
uri.searchParams.append(
key,
encodeQueryParam(paramSchema.items.type, val),
)
})
} else {
uri.searchParams.set(key, encodeQueryParam(paramSchema.type, value))
}
}

@@ -46,3 +56,10 @@ }

export function encodeQueryParam(
type: 'string' | 'number' | 'integer' | 'boolean' | 'datetime' | 'unknown',
type:
| 'string'
| 'number'
| 'integer'
| 'boolean'
| 'datetime'
| 'array'
| 'unknown',
value: any,

@@ -49,0 +66,0 @@ ): string {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc