Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@atproto/xrpc
Advanced tools
TypeScript client library for talking to atproto services, with Lexicon schema validation.
import { LexiconDoc } from '@atproto/lexicon'
import { XrpcClient } from '@atproto/xrpc'
const pingLexicon = {
lexicon: 1,
id: 'io.example.ping',
defs: {
main: {
type: 'query',
description: 'Ping the server',
parameters: {
type: 'params',
properties: { message: { type: 'string' } },
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['message'],
properties: { message: { type: 'string' } },
},
},
},
},
} satisfies LexiconDoc
const xrpc = new XrpcClient('https://ping.example.com', [
// Any number of lexicon here
pingLexicon,
])
const res1 = await xrpc.call('io.example.ping', {
message: 'hello world',
})
res1.encoding // => 'application/json'
res1.body // => {message: 'hello world'}
import { XrpcClient } from '@atproto/xrpc'
const session = {
serviceUrl: 'https://ping.example.com',
token: '<my-token>',
async refreshToken() {
const { token } = await fetch('https://auth.example.com/refresh', {
method: 'POST',
headers: { Authorization: `Bearer ${this.token}` },
}).then((res) => res.json())
this.token = token
return token
},
}
const sessionBasedFetch: FetchHandler = async (
url: string,
init: RequestInit,
) => {
const headers = new Headers(init.headers)
headers.set('Authorization', `Bearer ${session.token}`)
const response = await fetch(new URL(url, session.serviceUrl), {
...init,
headers,
})
if (response.status === 401) {
// Refresh token, then try again.
const newToken = await session.refreshToken()
headers.set('Authorization', `Bearer ${newToken}`)
return fetch(new URL(url, session.serviceUrl), { ...init, headers })
}
return response
}
const xrpc = new XrpcClient(sessionBasedFetch, [
// Any number of lexicon here
pingLexicon,
])
//
This project is dual-licensed under MIT and Apache 2.0 terms:
Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
FAQs
atproto HTTP API (XRPC) client library
The npm package @atproto/xrpc receives a total of 24,785 weekly downloads. As such, @atproto/xrpc popularity was classified as popular.
We found that @atproto/xrpc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.