@atproto/bsky 0.0.274 → 0.0.275
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/CHANGELOG.md +14 -0
- package/dist/auth-verifier.d.ts.map +1 -1
- package/dist/auth-verifier.js +16 -9
- package/dist/auth-verifier.js.map +1 -1
- package/dist/lexicons/app/bsky/embed/video.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/embed/video.defs.js +2 -4
- package/dist/lexicons/app/bsky/embed/video.defs.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atproto/bsky
|
|
2
2
|
|
|
3
|
+
## 0.0.275
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5350](https://github.com/bluesky-social/atproto/pull/5350) [`1f3f67c`](https://github.com/bluesky-social/atproto/commit/1f3f67c4b5bac19cc226b24f55d90ffd431d0d72) Thanks [@mary-ext](https://github.com/mary-ext)! - Remove the `maxGraphemes` and `maxLength` constraints from the `alt` field of `app.bsky.embed.video`, matching `app.bsky.embed.images`
|
|
8
|
+
|
|
9
|
+
- [#5348](https://github.com/bluesky-social/atproto/pull/5348) [`5c3b7c9`](https://github.com/bluesky-social/atproto/commit/5c3b7c9c87efa4d48d41bc55af61f5b1f1e04920) Thanks [@dreyfus92](https://github.com/dreyfus92)! - Remove `key-encoder` dependency (and its `elliptic`/`asn1.js`/`bn.js` transitive tree) in favor of Node's native JWK key import and the already-present `@noble/curves`
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`1f3f67c`](https://github.com/bluesky-social/atproto/commit/1f3f67c4b5bac19cc226b24f55d90ffd431d0d72), [`5c3b7c9`](https://github.com/bluesky-social/atproto/commit/5c3b7c9c87efa4d48d41bc55af61f5b1f1e04920)]:
|
|
12
|
+
- @atproto/api@0.20.41
|
|
13
|
+
- @atproto/xrpc-server@0.12.5
|
|
14
|
+
- @atproto-labs/xrpc-utils@0.1.18
|
|
15
|
+
- @atproto/sync@0.4.5
|
|
16
|
+
|
|
3
17
|
## 0.0.274
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-verifier.d.ts","sourceRoot":"","sources":["../src/auth-verifier.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"auth-verifier.d.ts","sourceRoot":"","sources":["../src/auth-verifier.ts"],"names":[],"mappings":"AAAA,OAAe,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAIlC,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,cAAc,CAAA;AAC1D,OAAO,EAEL,KAAK,wBAAwB,EAI9B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAEL,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAA;AAG9B,KAAK,MAAM,GAAG;IACZ,GAAG,EAAE,OAAO,CAAC,OAAO,CAAA;CACrB,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;CACxC,CAAA;AAED,oBAAY,UAAU;IACpB,KAAK,IAAA;IACL,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,KAAK,UAAU,GAAG;IAChB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,IAAI,CAAA;KACV,CAAA;CACF,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,UAAU,CAAA;QAChB,8FAA8F;QAC9F,GAAG,EAAE,MAAM,CAAA;QACX,GAAG,EAAE,SAAS,GAAG,GAAG,SAAS,IAAI,M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,CAAA;AAED,eAAO,MAAM,cAAc,aAAc,MAAM,YAAY,MAAM,KAAG,MAKnE,CAAA;AAkBD,eAAO,MAAM,qBAAqB,iBAAkB,MAAM,KAAG,SAE5D,CAAA;AAoBD,eAAO,MAAM,sBAAsB,EAAE,wBAgBpC,CAAA"}
|
package/dist/auth-verifier.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import crypto, {} from 'node:crypto';
|
|
2
|
+
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
2
3
|
import * as jose from 'jose';
|
|
3
|
-
import KeyEncoderModule from 'key-encoder';
|
|
4
4
|
import * as ui8 from 'uint8arrays';
|
|
5
5
|
import { SECP256K1_JWT_ALG, parseDidKey } from '@atproto/crypto';
|
|
6
6
|
import { isDidString } from '@atproto/lex';
|
|
7
7
|
import { AuthRequiredError, cryptoVerifySignatureWithKey, parseReqNsid, verifyJwt as verifyServiceJwt, } from '@atproto/xrpc-server';
|
|
8
8
|
import { Code, getKeyAsDidKey, isDataplaneError, unpackIdentityKeys, } from './data-plane/index.js';
|
|
9
|
-
// key-encoder is CJS with exports.default; Node ESM interop wraps it as { default: Class }
|
|
10
|
-
const KeyEncoder = ((m) => m.default ?? m)(KeyEncoderModule);
|
|
11
9
|
export var RoleStatus;
|
|
12
10
|
(function (RoleStatus) {
|
|
13
11
|
RoleStatus[RoleStatus["Valid"] = 0] = "Valid";
|
|
@@ -325,15 +323,24 @@ export const buildBasicAuth = (username, password) => {
|
|
|
325
323
|
return (BASIC +
|
|
326
324
|
ui8.toString(ui8.fromString(`${username}:${password}`, 'utf8'), 'base64pad'));
|
|
327
325
|
};
|
|
328
|
-
const
|
|
326
|
+
const createSecp256k1KeyObject = (publicKey) => {
|
|
327
|
+
// accepts compressed or uncompressed keys; validates the point is on-curve
|
|
328
|
+
const point = secp256k1.ProjectivePoint.fromHex(publicKey).toRawBytes(false);
|
|
329
|
+
return crypto.createPublicKey({
|
|
330
|
+
format: 'jwk',
|
|
331
|
+
key: {
|
|
332
|
+
kty: 'EC',
|
|
333
|
+
crv: 'secp256k1',
|
|
334
|
+
x: ui8.toString(point.subarray(1, 33), 'base64url'),
|
|
335
|
+
y: ui8.toString(point.subarray(33, 65), 'base64url'),
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
};
|
|
329
339
|
export const createPublicKeyObject = (publicKeyHex) => {
|
|
330
|
-
|
|
331
|
-
return crypto.createPublicKey({ format: 'pem', key });
|
|
340
|
+
return createSecp256k1KeyObject(publicKeyHex);
|
|
332
341
|
};
|
|
333
342
|
const verifySig = (publicKey, data, sig) => {
|
|
334
|
-
const
|
|
335
|
-
const pemKey = keyEncoder.encodePublic(ui8.toString(publicKey, 'hex'), 'raw', 'pem');
|
|
336
|
-
const key = crypto.createPublicKey({ format: 'pem', key: pemKey });
|
|
343
|
+
const key = createSecp256k1KeyObject(publicKey);
|
|
337
344
|
return crypto.verify('sha256', data, {
|
|
338
345
|
key,
|
|
339
346
|
dsaEncoding: 'ieee-p1363',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-verifier.js","sourceRoot":"","sources":["../src/auth-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAkB,MAAM,aAAa,CAAA;AAEpD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,gBAAgB,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAkB,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EACL,iBAAiB,EAEjB,4BAA4B,EAC5B,YAAY,EACZ,SAAS,IAAI,gBAAgB,GAC9B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,IAAI,EAEJ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAG9B,2FAA2F;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M,CAClB,QAAQ,EACR,IAAI,EACJ;QACE,GAAG;QACH,WAAW,EAAE,YAAY;KAC1B,EACD,GAAG,CACJ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAA6B,KAAK,EACnE,MAAc,EACd,QAAoB,EACpB,QAAoB,EACpB,GAAW,EACX,EAAE;IACF,IAAI,GAAG,KAAK,iBAAiB,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;QAClE,CAAC;QAED,OAAO,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACvD,CAAC;IAED,OAAO,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AACtE,CAAC,CAAA","sourcesContent":["import crypto, { type KeyObject } from 'node:crypto'\nimport type express from 'express'\nimport * as jose from 'jose'\nimport KeyEncoderModule from 'key-encoder'\nimport * as ui8 from 'uint8arrays'\nimport { SECP256K1_JWT_ALG, parseDidKey } from '@atproto/crypto'\nimport { type DidString, isDidString } from '@atproto/lex'\nimport {\n AuthRequiredError,\n type VerifySignatureWithKeyFn,\n cryptoVerifySignatureWithKey,\n parseReqNsid,\n verifyJwt as verifyServiceJwt,\n} from '@atproto/xrpc-server'\nimport {\n Code,\n type DataPlaneClient,\n getKeyAsDidKey,\n isDataplaneError,\n unpackIdentityKeys,\n} from './data-plane/index.js'\nimport type { GetIdentityByDidResponse } from './proto/bsky_pb.js'\n\n// key-encoder is CJS with exports.default; Node ESM interop wraps it as { default: Class }\nconst KeyEncoder = ((m) => m.default ?? m)(KeyEncoderModule)\n\ntype ReqCtx = {\n req: express.Request\n}\n\ntype StandardAuthOpts = {\n skipAudCheck?: boolean\n lxmCheck?: (method?: string) => boolean\n}\n\nexport enum RoleStatus {\n Valid,\n Invalid,\n Missing,\n}\n\ntype NullOutput = {\n credentials: {\n type: 'none'\n iss: null\n }\n}\n\ntype StandardOutput = {\n credentials: {\n type: 'standard'\n /** @note we don't validate this to be a {@link DidString} (we might want to in the future) */\n aud: string\n iss: DidString | `${DidString}#${string}`\n }\n}\n\ntype RoleOutput = {\n credentials: {\n type: 'role'\n admin: boolean\n }\n}\n\ntype ModServiceOutput = {\n credentials: {\n type: 'mod_service'\n aud: DidString\n iss: DidString | `${DidString}#${string}`\n }\n}\n\nconst ALLOWED_AUTH_SCOPES = new Set([\n 'com.atproto.access',\n 'com.atproto.appPass',\n 'com.atproto.appPassPrivileged',\n])\n\nexport type AuthVerifierOpts = {\n ownDid: DidString\n alternateAudienceDids: DidString[]\n modServiceDid: DidString\n adminPasses: string[]\n entrywayJwtPublicKey?: KeyObject\n}\n\nexport class AuthVerifier {\n public ownDid: DidString\n public standardAudienceDids: Set<DidString>\n public modServiceDid: DidString\n private adminPasses: Set<string>\n private entrywayJwtPublicKey?: KeyObject\n\n constructor(\n public dataplane: DataPlaneClient,\n opts: AuthVerifierOpts,\n ) {\n this.ownDid = opts.ownDid\n this.standardAudienceDids = new Set([\n opts.ownDid,\n ...opts.alternateAudienceDids,\n ])\n this.modServiceDid = opts.modServiceDid\n this.adminPasses = new Set(opts.adminPasses)\n this.entrywayJwtPublicKey = opts.entrywayJwtPublicKey\n }\n\n // verifiers (arrow fns to preserve scope)\n standardOptionalParameterized =\n (opts: StandardAuthOpts) =>\n async (ctx: ReqCtx): Promise<StandardOutput | NullOutput> => {\n // @TODO remove! basic auth + did supported just for testing.\n if (isBasicToken(ctx.req)) {\n const aud = this.ownDid\n const iss = ctx.req.headers['appview-as-did']\n if (typeof iss !== 'string' || !isDidString(iss)) {\n throw new AuthRequiredError('bad issuer')\n }\n if (!this.parseRoleCreds(ctx.req).admin) {\n throw new AuthRequiredError('bad credentials')\n }\n return {\n credentials: { type: 'standard', iss, aud },\n }\n } else if (isBearerToken(ctx.req)) {\n // @NOTE temporarily accept entryway session tokens to shed load from PDS instances\n const token = bearerTokenFromReq(ctx.req)\n const header = token ? jose.decodeProtectedHeader(token) : undefined\n if (header?.typ === 'at+jwt') {\n // we should never use entryway session tokens in the case of flexible auth audiences (namely in the case of getFeed)\n if (opts.skipAudCheck) {\n throw new AuthRequiredError('Malformed token', 'InvalidToken')\n }\n return this.entrywaySession(ctx)\n }\n\n const { iss, aud } = await this.verifyServiceJwt(ctx, {\n lxmCheck: opts.lxmCheck,\n iss: null,\n aud: null,\n })\n if (\n !opts.skipAudCheck &&\n !(this.standardAudienceDids as Set<string>).has(aud)\n ) {\n throw new AuthRequiredError(\n 'jwt audience does not match service did',\n 'BadJwtAudience',\n )\n }\n return {\n credentials: {\n type: 'standard',\n iss,\n aud,\n },\n }\n } else {\n return this.nullCreds()\n }\n }\n\n standardOptional: (ctx: ReqCtx) => Promise<StandardOutput | NullOutput> =\n this.standardOptionalParameterized({})\n\n standard = async (ctx: ReqCtx): Promise<StandardOutput> => {\n const output = await this.standardOptional(ctx)\n if (output.credentials.type === 'none') {\n throw new AuthRequiredError(undefined, 'AuthMissing')\n }\n return output as StandardOutput\n }\n\n role = (ctx: ReqCtx): RoleOutput => {\n const creds = this.parseRoleCreds(ctx.req)\n if (creds.status !== RoleStatus.Valid) {\n throw new AuthRequiredError()\n }\n return {\n credentials: {\n ...creds,\n type: 'role',\n },\n }\n }\n\n standardOrRole = async (\n ctx: ReqCtx,\n ): Promise<StandardOutput | RoleOutput> => {\n if (isBearerToken(ctx.req)) {\n return this.standard(ctx)\n } else {\n return this.role(ctx)\n }\n }\n\n optionalStandardOrRole = async (\n ctx: ReqCtx,\n ): Promise<StandardOutput | RoleOutput | NullOutput> => {\n if (isBearerToken(ctx.req)) {\n return await this.standard(ctx)\n } else {\n const creds = this.parseRoleCreds(ctx.req)\n if (creds.status === RoleStatus.Valid) {\n return {\n credentials: {\n ...creds,\n type: 'role',\n },\n }\n } else if (creds.status === RoleStatus.Missing) {\n return this.nullCreds()\n } else {\n throw new AuthRequiredError()\n }\n }\n }\n\n // @NOTE this auth verifier method is not recommended to be implemented by most appviews\n // this is a short term fix to remove proxy load from Bluesky's PDS and in line with possible\n // future plans to have the client talk directly with the appview\n entrywaySession = async (reqCtx: ReqCtx): Promise<StandardOutput> => {\n const token = bearerTokenFromReq(reqCtx.req)\n if (!token) {\n throw new AuthRequiredError(undefined, 'AuthMissing')\n }\n\n // if entryway jwt key not configured then do not parsed these tokens\n if (!this.entrywayJwtPublicKey) {\n throw new AuthRequiredError('Malformed token', 'InvalidToken')\n }\n\n const res = await jose\n .jwtVerify(token, this.entrywayJwtPublicKey)\n .catch((err) => {\n if (err?.['code'] === 'ERR_JWT_EXPIRED') {\n throw new AuthRequiredError('Token has expired', 'ExpiredToken')\n }\n throw new AuthRequiredError(\n 'Token could not be verified',\n 'InvalidToken',\n )\n })\n\n const { sub, aud, scope, cnf } = res.payload\n if (typeof cnf !== 'undefined') {\n // Proof-of-Possession (PoP) tokens are not allowed here\n // https://www.rfc-editor.org/rfc/rfc7800.html\n throw new AuthRequiredError(\n 'Malformed token: DPoP not supported',\n 'InvalidToken',\n )\n }\n if (typeof sub !== 'string' || !sub.startsWith('did:')) {\n throw new AuthRequiredError('Malformed token', 'InvalidToken')\n } else if (\n typeof aud !== 'string' ||\n !aud.startsWith('did:web:') ||\n !aud.endsWith('.bsky.network')\n ) {\n throw new AuthRequiredError('Bad token aud', 'InvalidToken')\n } else if (typeof scope !== 'string' || !ALLOWED_AUTH_SCOPES.has(scope)) {\n throw new AuthRequiredError('Bad token scope', 'InvalidToken')\n }\n\n return {\n credentials: {\n type: 'standard',\n aud: this.ownDid,\n iss: sub as DidString | `${DidString}#${string}`,\n },\n }\n }\n\n modService = async (reqCtx: ReqCtx): Promise<ModServiceOutput> => {\n const { iss, aud } = await this.verifyServiceJwt(reqCtx, {\n aud: this.ownDid,\n iss: [this.modServiceDid, `${this.modServiceDid}#atproto_labeler`],\n })\n return { credentials: { type: 'mod_service', aud, iss } }\n }\n\n roleOrModService = async (\n reqCtx: ReqCtx,\n ): Promise<RoleOutput | ModServiceOutput> => {\n if (isBearerToken(reqCtx.req)) {\n return this.modService(reqCtx)\n } else {\n return this.role(reqCtx)\n }\n }\n\n parseRoleCreds(req: express.Request) {\n const parsed = parseBasicAuth(req.headers.authorization || '')\n const { Missing, Valid, Invalid } = RoleStatus\n if (!parsed) {\n return { status: Missing, admin: false, moderator: false, triage: false }\n }\n const { username, password } = parsed\n if (username === 'admin' && this.adminPasses.has(password)) {\n return { status: Valid, admin: true }\n }\n return { status: Invalid, admin: false }\n }\n\n async verifyServiceJwt<\n TOptions extends {\n iss: string[] | null\n aud: string | null\n lxmCheck?: (method?: string) => boolean\n },\n >(reqCtx: ReqCtx, opts: TOptions) {\n const getSigningKey = async (\n iss: string,\n _forceRefresh: boolean, // @TODO consider propagating to dataplane\n ): Promise<string> => {\n if (opts.iss !== null && !opts.iss.includes(iss)) {\n throw new AuthRequiredError('Untrusted issuer', 'UntrustedIss')\n }\n const [did, serviceId] = iss.split('#')\n if (!isDidString(did)) {\n throw new AuthRequiredError('identity unknown')\n }\n\n const keyId =\n serviceId === 'atproto_labeler' ? 'atproto_label' : 'atproto'\n let identity: GetIdentityByDidResponse\n try {\n identity = await this.dataplane.getIdentityByDid({ did })\n } catch (err) {\n if (isDataplaneError(err, Code.NotFound)) {\n throw new AuthRequiredError('identity unknown')\n }\n throw err\n }\n const keys = unpackIdentityKeys(identity.keys)\n const didKey = getKeyAsDidKey(keys, { id: keyId })\n if (!didKey) {\n throw new AuthRequiredError('missing or bad key')\n }\n return didKey\n }\n const assertLxmCheck = () => {\n const lxm = parseReqNsid(reqCtx.req)\n if (\n (opts.lxmCheck && !opts.lxmCheck(payload.lxm)) ||\n (!opts.lxmCheck && payload.lxm !== lxm)\n ) {\n throw new AuthRequiredError(\n payload.lxm !== undefined\n ? `bad jwt lexicon method (\"lxm\"). must match: ${lxm}`\n : `missing jwt lexicon method (\"lxm\"). must match: ${lxm}`,\n 'BadJwtLexiconMethod',\n )\n }\n }\n\n const jwtStr = bearerTokenFromReq(reqCtx.req)\n if (!jwtStr) {\n throw new AuthRequiredError('missing jwt', 'MissingJwt')\n }\n // if validating additional scopes, skip scope check in initial validation & follow up afterwards\n const payload = await verifyServiceJwt(\n jwtStr,\n opts.aud,\n null,\n getSigningKey,\n verifySignatureWithKey,\n )\n if (\n !payload.iss.endsWith('#atproto_labeler') ||\n payload.lxm !== undefined\n ) {\n // @TODO currently permissive of labelers who dont set lxm yet.\n // we'll allow ozone self-hosters to upgrade before removing this condition.\n assertLxmCheck()\n }\n\n return {\n iss: payload.iss as (DidString | `${DidString}#${string}`) &\n (TOptions extends { iss: ReadonlyArray<infer I> } ? I : unknown),\n aud: payload.aud as string &\n (TOptions extends { aud: infer A extends string } ? A : unknown),\n }\n }\n\n isModService(iss: string): iss is DidString | `${DidString}#atproto_labeler` {\n return [\n this.modServiceDid,\n `${this.modServiceDid}#atproto_labeler`,\n ].includes(iss)\n }\n\n nullCreds(): NullOutput {\n return {\n credentials: {\n type: 'none',\n iss: null,\n },\n }\n }\n\n parseCreds(\n creds: StandardOutput | RoleOutput | ModServiceOutput | NullOutput,\n ) {\n const viewer =\n creds.credentials.type === 'standard' ? creds.credentials.iss : null\n const includeTakedownsAnd3pBlocks =\n (creds.credentials.type === 'role' && creds.credentials.admin) ||\n creds.credentials.type === 'mod_service' ||\n (creds.credentials.type === 'standard' &&\n this.isModService(creds.credentials.iss))\n const canPerformTakedown =\n (creds.credentials.type === 'role' && creds.credentials.admin) ||\n creds.credentials.type === 'mod_service'\n const isModService =\n creds.credentials.type === 'mod_service' ||\n (creds.credentials.type === 'standard' &&\n this.isModService(creds.credentials.iss))\n\n return {\n viewer,\n includeTakedowns: includeTakedownsAnd3pBlocks,\n include3pBlocks: includeTakedownsAnd3pBlocks,\n canPerformTakedown,\n isModService,\n skipViewerBlocks: isModService && viewer !== null,\n }\n }\n}\n\n// HELPERS\n// ---------\n\nconst BEARER = 'Bearer '\nconst BASIC = 'Basic '\n\nconst isBearerToken = (req: express.Request): boolean => {\n return req.headers.authorization?.startsWith(BEARER) ?? false\n}\n\nconst isBasicToken = (req: express.Request): boolean => {\n return req.headers.authorization?.startsWith(BASIC) ?? false\n}\n\nconst bearerTokenFromReq = (req: express.Request) => {\n const header = req.headers.authorization || ''\n if (!header.startsWith(BEARER)) return null\n return header.slice(BEARER.length).trim()\n}\n\nexport const parseBasicAuth = (\n token: string,\n): { username: string; password: string } | null => {\n if (!token.startsWith(BASIC)) return null\n const b64 = token.slice(BASIC.length)\n let parsed: string[]\n try {\n parsed = ui8.toString(ui8.fromString(b64, 'base64pad'), 'utf8').split(':')\n } catch (err) {\n return null\n }\n const [username, password] = parsed\n if (!username || !password) return null\n return { username, password }\n}\n\nexport const buildBasicAuth = (username: string, password: string): string => {\n return (\n BASIC +\n ui8.toString(ui8.fromString(`${username}:${password}`, 'utf8'), 'base64pad')\n )\n}\n\nconst keyEncoder = new KeyEncoder('secp256k1')\nexport const createPublicKeyObject = (publicKeyHex: string): KeyObject => {\n const key = keyEncoder.encodePublic(publicKeyHex, 'raw', 'pem')\n return crypto.createPublicKey({ format: 'pem', key })\n}\n\nconst verifySig = (\n publicKey: Uint8Array,\n data: Uint8Array,\n sig: Uint8Array,\n) => {\n const keyEncoder = new KeyEncoder('secp256k1')\n\n const pemKey = keyEncoder.encodePublic(\n ui8.toString(publicKey, 'hex'),\n 'raw',\n 'pem',\n )\n const key = crypto.createPublicKey({ format: 'pem', key: pemKey })\n\n return crypto.verify(\n 'sha256',\n data,\n {\n key,\n dsaEncoding: 'ieee-p1363',\n },\n sig,\n )\n}\n\nexport const verifySignatureWithKey: VerifySignatureWithKeyFn = async (\n didKey: string,\n msgBytes: Uint8Array,\n sigBytes: Uint8Array,\n alg: string,\n) => {\n if (alg === SECP256K1_JWT_ALG) {\n const parsed = parseDidKey(didKey)\n if (alg !== parsed.jwtAlg) {\n throw new Error(`Expected key alg ${alg}, got ${parsed.jwtAlg}`)\n }\n\n return verifySig(parsed.keyBytes, msgBytes, sigBytes)\n }\n\n return cryptoVerifySignatureWithKey(didKey, msgBytes, sigBytes, alg)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-verifier.js","sourceRoot":"","sources":["../src/auth-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAkB,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAkB,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EACL,iBAAiB,EAEjB,4BAA4B,EAC5B,YAAY,EACZ,SAAS,IAAI,gBAAgB,GAC9B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,IAAI,EAEJ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAY9B,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6CAAK,CAAA;IACL,iDAAO,CAAA;IACP,iDAAO,CAAA;AACT,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAiCD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,oBAAoB;IACpB,qBAAqB;IACrB,+BAA+B;CAChC,CAAC,CAAA;AAUF,MAAM,OAAO,YAAY;IAOvB,YACS,SAA0B,EACjC,IAAsB;QADf,cAAS,GAAT,SAAS,CAAiB;QAanC,0CAA0C;QAC1C,kCAA6B,GAC3B,CAAC,IAAsB,EAAE,EAAE,CAC3B,KAAK,EAAE,GAAW,EAAwC,EAAE;YAC1D,6DAA6D;YA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C;QAED,OAAO,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACvD,CAAC;IAED,OAAO,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AACtE,CAAC,CAAA","sourcesContent":["import crypto, { type KeyObject } from 'node:crypto'\nimport { secp256k1 } from '@noble/curves/secp256k1'\nimport type express from 'express'\nimport * as jose from 'jose'\nimport * as ui8 from 'uint8arrays'\nimport { SECP256K1_JWT_ALG, parseDidKey } from '@atproto/crypto'\nimport { type DidString, isDidString } from '@atproto/lex'\nimport {\n AuthRequiredError,\n type VerifySignatureWithKeyFn,\n cryptoVerifySignatureWithKey,\n parseReqNsid,\n verifyJwt as verifyServiceJwt,\n} from '@atproto/xrpc-server'\nimport {\n Code,\n type DataPlaneClient,\n getKeyAsDidKey,\n isDataplaneError,\n unpackIdentityKeys,\n} from './data-plane/index.js'\nimport type { GetIdentityByDidResponse } from './proto/bsky_pb.js'\n\ntype ReqCtx = {\n req: express.Request\n}\n\ntype StandardAuthOpts = {\n skipAudCheck?: boolean\n lxmCheck?: (method?: string) => boolean\n}\n\nexport enum RoleStatus {\n Valid,\n Invalid,\n Missing,\n}\n\ntype NullOutput = {\n credentials: {\n type: 'none'\n iss: null\n }\n}\n\ntype StandardOutput = {\n credentials: {\n type: 'standard'\n /** @note we don't validate this to be a {@link DidString} (we might want to in the future) */\n aud: string\n iss: DidString | `${DidString}#${string}`\n }\n}\n\ntype RoleOutput = {\n credentials: {\n type: 'role'\n admin: boolean\n }\n}\n\ntype ModServiceOutput = {\n credentials: {\n type: 'mod_service'\n aud: DidString\n iss: DidString | `${DidString}#${string}`\n }\n}\n\nconst ALLOWED_AUTH_SCOPES = new Set([\n 'com.atproto.access',\n 'com.atproto.appPass',\n 'com.atproto.appPassPrivileged',\n])\n\nexport type AuthVerifierOpts = {\n ownDid: DidString\n alternateAudienceDids: DidString[]\n modServiceDid: DidString\n adminPasses: string[]\n entrywayJwtPublicKey?: KeyObject\n}\n\nexport class AuthVerifier {\n public ownDid: DidString\n public standardAudienceDids: Set<DidString>\n public modServiceDid: DidString\n private adminPasses: Set<string>\n private entrywayJwtPublicKey?: KeyObject\n\n constructor(\n public dataplane: DataPlaneClient,\n opts: AuthVerifierOpts,\n ) {\n this.ownDid = opts.ownDid\n this.standardAudienceDids = new Set([\n opts.ownDid,\n ...opts.alternateAudienceDids,\n ])\n this.modServiceDid = opts.modServiceDid\n this.adminPasses = new Set(opts.adminPasses)\n this.entrywayJwtPublicKey = opts.entrywayJwtPublicKey\n }\n\n // verifiers (arrow fns to preserve scope)\n standardOptionalParameterized =\n (opts: StandardAuthOpts) =>\n async (ctx: ReqCtx): Promise<StandardOutput | NullOutput> => {\n // @TODO remove! basic auth + did supported just for testing.\n if (isBasicToken(ctx.req)) {\n const aud = this.ownDid\n const iss = ctx.req.headers['appview-as-did']\n if (typeof iss !== 'string' || !isDidString(iss)) {\n throw new AuthRequiredError('bad issuer')\n }\n if (!this.parseRoleCreds(ctx.req).admin) {\n throw new AuthRequiredError('bad credentials')\n }\n return {\n credentials: { type: 'standard', iss, aud },\n }\n } else if (isBearerToken(ctx.req)) {\n // @NOTE temporarily accept entryway session tokens to shed load from PDS instances\n const token = bearerTokenFromReq(ctx.req)\n const header = token ? jose.decodeProtectedHeader(token) : undefined\n if (header?.typ === 'at+jwt') {\n // we should never use entryway session tokens in the case of flexible auth audiences (namely in the case of getFeed)\n if (opts.skipAudCheck) {\n throw new AuthRequiredError('Malformed token', 'InvalidToken')\n }\n return this.entrywaySession(ctx)\n }\n\n const { iss, aud } = await this.verifyServiceJwt(ctx, {\n lxmCheck: opts.lxmCheck,\n iss: null,\n aud: null,\n })\n if (\n !opts.skipAudCheck &&\n !(this.standardAudienceDids as Set<string>).has(aud)\n ) {\n throw new AuthRequiredError(\n 'jwt audience does not match service did',\n 'BadJwtAudience',\n )\n }\n return {\n credentials: {\n type: 'standard',\n iss,\n aud,\n },\n }\n } else {\n return this.nullCreds()\n }\n }\n\n standardOptional: (ctx: ReqCtx) => Promise<StandardOutput | NullOutput> =\n this.standardOptionalParameterized({})\n\n standard = async (ctx: ReqCtx): Promise<StandardOutput> => {\n const output = await this.standardOptional(ctx)\n if (output.credentials.type === 'none') {\n throw new AuthRequiredError(undefined, 'AuthMissing')\n }\n return output as StandardOutput\n }\n\n role = (ctx: ReqCtx): RoleOutput => {\n const creds = this.parseRoleCreds(ctx.req)\n if (creds.status !== RoleStatus.Valid) {\n throw new AuthRequiredError()\n }\n return {\n credentials: {\n ...creds,\n type: 'role',\n },\n }\n }\n\n standardOrRole = async (\n ctx: ReqCtx,\n ): Promise<StandardOutput | RoleOutput> => {\n if (isBearerToken(ctx.req)) {\n return this.standard(ctx)\n } else {\n return this.role(ctx)\n }\n }\n\n optionalStandardOrRole = async (\n ctx: ReqCtx,\n ): Promise<StandardOutput | RoleOutput | NullOutput> => {\n if (isBearerToken(ctx.req)) {\n return await this.standard(ctx)\n } else {\n const creds = this.parseRoleCreds(ctx.req)\n if (creds.status === RoleStatus.Valid) {\n return {\n credentials: {\n ...creds,\n type: 'role',\n },\n }\n } else if (creds.status === RoleStatus.Missing) {\n return this.nullCreds()\n } else {\n throw new AuthRequiredError()\n }\n }\n }\n\n // @NOTE this auth verifier method is not recommended to be implemented by most appviews\n // this is a short term fix to remove proxy load from Bluesky's PDS and in line with possible\n // future plans to have the client talk directly with the appview\n entrywaySession = async (reqCtx: ReqCtx): Promise<StandardOutput> => {\n const token = bearerTokenFromReq(reqCtx.req)\n if (!token) {\n throw new AuthRequiredError(undefined, 'AuthMissing')\n }\n\n // if entryway jwt key not configured then do not parsed these tokens\n if (!this.entrywayJwtPublicKey) {\n throw new AuthRequiredError('Malformed token', 'InvalidToken')\n }\n\n const res = await jose\n .jwtVerify(token, this.entrywayJwtPublicKey)\n .catch((err) => {\n if (err?.['code'] === 'ERR_JWT_EXPIRED') {\n throw new AuthRequiredError('Token has expired', 'ExpiredToken')\n }\n throw new AuthRequiredError(\n 'Token could not be verified',\n 'InvalidToken',\n )\n })\n\n const { sub, aud, scope, cnf } = res.payload\n if (typeof cnf !== 'undefined') {\n // Proof-of-Possession (PoP) tokens are not allowed here\n // https://www.rfc-editor.org/rfc/rfc7800.html\n throw new AuthRequiredError(\n 'Malformed token: DPoP not supported',\n 'InvalidToken',\n )\n }\n if (typeof sub !== 'string' || !sub.startsWith('did:')) {\n throw new AuthRequiredError('Malformed token', 'InvalidToken')\n } else if (\n typeof aud !== 'string' ||\n !aud.startsWith('did:web:') ||\n !aud.endsWith('.bsky.network')\n ) {\n throw new AuthRequiredError('Bad token aud', 'InvalidToken')\n } else if (typeof scope !== 'string' || !ALLOWED_AUTH_SCOPES.has(scope)) {\n throw new AuthRequiredError('Bad token scope', 'InvalidToken')\n }\n\n return {\n credentials: {\n type: 'standard',\n aud: this.ownDid,\n iss: sub as DidString | `${DidString}#${string}`,\n },\n }\n }\n\n modService = async (reqCtx: ReqCtx): Promise<ModServiceOutput> => {\n const { iss, aud } = await this.verifyServiceJwt(reqCtx, {\n aud: this.ownDid,\n iss: [this.modServiceDid, `${this.modServiceDid}#atproto_labeler`],\n })\n return { credentials: { type: 'mod_service', aud, iss } }\n }\n\n roleOrModService = async (\n reqCtx: ReqCtx,\n ): Promise<RoleOutput | ModServiceOutput> => {\n if (isBearerToken(reqCtx.req)) {\n return this.modService(reqCtx)\n } else {\n return this.role(reqCtx)\n }\n }\n\n parseRoleCreds(req: express.Request) {\n const parsed = parseBasicAuth(req.headers.authorization || '')\n const { Missing, Valid, Invalid } = RoleStatus\n if (!parsed) {\n return { status: Missing, admin: false, moderator: false, triage: false }\n }\n const { username, password } = parsed\n if (username === 'admin' && this.adminPasses.has(password)) {\n return { status: Valid, admin: true }\n }\n return { status: Invalid, admin: false }\n }\n\n async verifyServiceJwt<\n TOptions extends {\n iss: string[] | null\n aud: string | null\n lxmCheck?: (method?: string) => boolean\n },\n >(reqCtx: ReqCtx, opts: TOptions) {\n const getSigningKey = async (\n iss: string,\n _forceRefresh: boolean, // @TODO consider propagating to dataplane\n ): Promise<string> => {\n if (opts.iss !== null && !opts.iss.includes(iss)) {\n throw new AuthRequiredError('Untrusted issuer', 'UntrustedIss')\n }\n const [did, serviceId] = iss.split('#')\n if (!isDidString(did)) {\n throw new AuthRequiredError('identity unknown')\n }\n\n const keyId =\n serviceId === 'atproto_labeler' ? 'atproto_label' : 'atproto'\n let identity: GetIdentityByDidResponse\n try {\n identity = await this.dataplane.getIdentityByDid({ did })\n } catch (err) {\n if (isDataplaneError(err, Code.NotFound)) {\n throw new AuthRequiredError('identity unknown')\n }\n throw err\n }\n const keys = unpackIdentityKeys(identity.keys)\n const didKey = getKeyAsDidKey(keys, { id: keyId })\n if (!didKey) {\n throw new AuthRequiredError('missing or bad key')\n }\n return didKey\n }\n const assertLxmCheck = () => {\n const lxm = parseReqNsid(reqCtx.req)\n if (\n (opts.lxmCheck && !opts.lxmCheck(payload.lxm)) ||\n (!opts.lxmCheck && payload.lxm !== lxm)\n ) {\n throw new AuthRequiredError(\n payload.lxm !== undefined\n ? `bad jwt lexicon method (\"lxm\"). must match: ${lxm}`\n : `missing jwt lexicon method (\"lxm\"). must match: ${lxm}`,\n 'BadJwtLexiconMethod',\n )\n }\n }\n\n const jwtStr = bearerTokenFromReq(reqCtx.req)\n if (!jwtStr) {\n throw new AuthRequiredError('missing jwt', 'MissingJwt')\n }\n // if validating additional scopes, skip scope check in initial validation & follow up afterwards\n const payload = await verifyServiceJwt(\n jwtStr,\n opts.aud,\n null,\n getSigningKey,\n verifySignatureWithKey,\n )\n if (\n !payload.iss.endsWith('#atproto_labeler') ||\n payload.lxm !== undefined\n ) {\n // @TODO currently permissive of labelers who dont set lxm yet.\n // we'll allow ozone self-hosters to upgrade before removing this condition.\n assertLxmCheck()\n }\n\n return {\n iss: payload.iss as (DidString | `${DidString}#${string}`) &\n (TOptions extends { iss: ReadonlyArray<infer I> } ? I : unknown),\n aud: payload.aud as string &\n (TOptions extends { aud: infer A extends string } ? A : unknown),\n }\n }\n\n isModService(iss: string): iss is DidString | `${DidString}#atproto_labeler` {\n return [\n this.modServiceDid,\n `${this.modServiceDid}#atproto_labeler`,\n ].includes(iss)\n }\n\n nullCreds(): NullOutput {\n return {\n credentials: {\n type: 'none',\n iss: null,\n },\n }\n }\n\n parseCreds(\n creds: StandardOutput | RoleOutput | ModServiceOutput | NullOutput,\n ) {\n const viewer =\n creds.credentials.type === 'standard' ? creds.credentials.iss : null\n const includeTakedownsAnd3pBlocks =\n (creds.credentials.type === 'role' && creds.credentials.admin) ||\n creds.credentials.type === 'mod_service' ||\n (creds.credentials.type === 'standard' &&\n this.isModService(creds.credentials.iss))\n const canPerformTakedown =\n (creds.credentials.type === 'role' && creds.credentials.admin) ||\n creds.credentials.type === 'mod_service'\n const isModService =\n creds.credentials.type === 'mod_service' ||\n (creds.credentials.type === 'standard' &&\n this.isModService(creds.credentials.iss))\n\n return {\n viewer,\n includeTakedowns: includeTakedownsAnd3pBlocks,\n include3pBlocks: includeTakedownsAnd3pBlocks,\n canPerformTakedown,\n isModService,\n skipViewerBlocks: isModService && viewer !== null,\n }\n }\n}\n\n// HELPERS\n// ---------\n\nconst BEARER = 'Bearer '\nconst BASIC = 'Basic '\n\nconst isBearerToken = (req: express.Request): boolean => {\n return req.headers.authorization?.startsWith(BEARER) ?? false\n}\n\nconst isBasicToken = (req: express.Request): boolean => {\n return req.headers.authorization?.startsWith(BASIC) ?? false\n}\n\nconst bearerTokenFromReq = (req: express.Request) => {\n const header = req.headers.authorization || ''\n if (!header.startsWith(BEARER)) return null\n return header.slice(BEARER.length).trim()\n}\n\nexport const parseBasicAuth = (\n token: string,\n): { username: string; password: string } | null => {\n if (!token.startsWith(BASIC)) return null\n const b64 = token.slice(BASIC.length)\n let parsed: string[]\n try {\n parsed = ui8.toString(ui8.fromString(b64, 'base64pad'), 'utf8').split(':')\n } catch (err) {\n return null\n }\n const [username, password] = parsed\n if (!username || !password) return null\n return { username, password }\n}\n\nexport const buildBasicAuth = (username: string, password: string): string => {\n return (\n BASIC +\n ui8.toString(ui8.fromString(`${username}:${password}`, 'utf8'), 'base64pad')\n )\n}\n\nconst createSecp256k1KeyObject = (\n publicKey: Uint8Array | string,\n): KeyObject => {\n // accepts compressed or uncompressed keys; validates the point is on-curve\n const point = secp256k1.ProjectivePoint.fromHex(publicKey).toRawBytes(false)\n return crypto.createPublicKey({\n format: 'jwk',\n key: {\n kty: 'EC',\n crv: 'secp256k1',\n x: ui8.toString(point.subarray(1, 33), 'base64url'),\n y: ui8.toString(point.subarray(33, 65), 'base64url'),\n },\n })\n}\n\nexport const createPublicKeyObject = (publicKeyHex: string): KeyObject => {\n return createSecp256k1KeyObject(publicKeyHex)\n}\n\nconst verifySig = (\n publicKey: Uint8Array,\n data: Uint8Array,\n sig: Uint8Array,\n) => {\n const key = createSecp256k1KeyObject(publicKey)\n\n return crypto.verify(\n 'sha256',\n data,\n {\n key,\n dsaEncoding: 'ieee-p1363',\n },\n sig,\n )\n}\n\nexport const verifySignatureWithKey: VerifySignatureWithKeyFn = async (\n didKey: string,\n msgBytes: Uint8Array,\n sigBytes: Uint8Array,\n alg: string,\n) => {\n if (alg === SECP256K1_JWT_ALG) {\n const parsed = parseDidKey(didKey)\n if (alg !== parsed.jwtAlg) {\n throw new Error(`Expected key alg ${alg}, got ${parsed.jwtAlg}`)\n }\n\n return verifySig(parsed.keyBytes, msgBytes, sigBytes)\n }\n\n return cryptoVerifySignatureWithKey(didKey, msgBytes, sigBytes, alg)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/app/bsky/embed/video.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAChC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,QAAA,MAAM,KAAK,yBAAyB,CAAA;AAEpC,KAAK,K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E,CAAC,CAAC,SAAS,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,SAAS,CAAC,WAAW,CAAA;IAEnC;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC,aAAa,CAAA;CACnD,CAAA;AAED,YAAY,EAAE,IAAI,EAAE,CAAA;AAEpB,QAAA,MAAM,IAAI,2EAmBT,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -11,8 +11,7 @@ const main = /*#__PURE__*/ l.typedObject($nsid, 'main',
|
|
|
11
11
|
captions: /*#__PURE__*/ l.optional(
|
|
12
12
|
/*#__PURE__*/ l.array(
|
|
13
13
|
/*#__PURE__*/ l.ref((() => caption)), { maxLength: 20 })),
|
|
14
|
-
alt: /*#__PURE__*/ l.optional(
|
|
15
|
-
/*#__PURE__*/ l.string({ maxGraphemes: 1000, maxLength: 10000 })),
|
|
14
|
+
alt: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
|
|
16
15
|
aspectRatio: /*#__PURE__*/ l.optional(
|
|
17
16
|
/*#__PURE__*/ l.ref((() => EmbedDefs.aspectRatio))),
|
|
18
17
|
presentation: /*#__PURE__*/ l.optional(
|
|
@@ -44,8 +43,7 @@ const view = /*#__PURE__*/ l.typedObject($nsid, 'view',
|
|
|
44
43
|
playlist: /*#__PURE__*/ l.string({ format: 'uri' }),
|
|
45
44
|
thumbnail: /*#__PURE__*/ l.optional(
|
|
46
45
|
/*#__PURE__*/ l.string({ format: 'uri' })),
|
|
47
|
-
alt: /*#__PURE__*/ l.optional(
|
|
48
|
-
/*#__PURE__*/ l.string({ maxGraphemes: 1000, maxLength: 10000 })),
|
|
46
|
+
alt: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
|
|
49
47
|
aspectRatio: /*#__PURE__*/ l.optional(
|
|
50
48
|
/*#__PURE__*/ l.ref((() => EmbedDefs.aspectRatio))),
|
|
51
49
|
presentation: /*#__PURE__*/ l.optional(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/app/bsky/embed/video.defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAChC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,MAAM,KAAK,GAAG,sBAAsB,CAAA;AAIpC,OAAO,EAAE,KAAK,EAAE,CAAA;AAyBhB,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CACtC,KAAK,EACL,MAAM;AACN,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;IACrB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC1E,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IAChC,aAAa,CAAC,CAAC,CAAC,KAAK;IACnB,aAAa,CAAC,CAAC,CAAC,GAAG,CAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAQ,CAAC,EACpD,EAAE,SAAS,EAAE,EAAE,EAAE,CAClB,CACF;IACD,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ
|
|
1
|
+
{"version":3,"file":"video.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/app/bsky/embed/video.defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAChC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,MAAM,KAAK,GAAG,sBAAsB,CAAA;AAIpC,OAAO,EAAE,KAAK,EAAE,CAAA;AAyBhB,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CACtC,KAAK,EACL,MAAM;AACN,aAAa,CAAC,CAAC,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CAAC,CAAC,MAAM,CAAC;IACrB,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACnD,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IACjC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAC1C;IACD,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACvD,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IACnC,aAAa,CAAC,CAAC,CAAC,GAAG,CACjB,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,WAAW,CAAQ,CACrC,CACF;IACD,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IACpC,aAAa,CAAC,CAAC,CAAC,MAAM,EAAuC,CAC9D;CACF,CAAC,CACH,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex'\nimport * as EmbedDefs from './defs.defs.js'\n\nconst $nsid = 'app.bsky.embed.video'\n\ntype $nsid = typeof $nsid\n\nexport { $nsid }\n\ntype Main = {\n $type?: 'app.bsky.embed.video'\n\n /**\n * The mp4 video file. May be up to 300mb, formerly limited to 100mb.\n */\n video: l.BlobRef\n captions?: Caption[]\n\n /**\n * Alt text description of the video, for accessibility.\n */\n alt?: string\n aspectRatio?: EmbedDefs.AspectRatio\n\n /**\n * A hint to the client about how to present the video.\n */\n presentation?: 'default' | 'gif' | l.UnknownString\n}\n\nexport type { Main }\n\nconst main = /*#__PURE__*/ l.typedObject<Main>(\n $nsid,\n 'main',\n /*#__PURE__*/ l.object({\n video: /*#__PURE__*/ l.blob({ accept: ['video/mp4'], maxSize: 300000000 }),\n captions: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.array(\n /*#__PURE__*/ l.ref<Caption>((() => caption) as any),\n { maxLength: 20 },\n ),\n ),\n alt: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n aspectRatio: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<EmbedDefs.AspectRatio>(\n (() => EmbedDefs.aspectRatio) as any,\n ),\n ),\n presentation: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string<{ knownValues: ['default', 'gif'] }>(),\n ),\n }),\n)\n\nexport { main }\n\nconst $type = $nsid\n\ntype $type = typeof $type\n\nexport { $type }\n\nexport const $isTypeOf = /*#__PURE__*/ main.isTypeOf.bind(main)\nexport const $build = /*#__PURE__*/ main.build.bind(main)\nexport const $assert = /*#__PURE__*/ main.assert.bind(main)\nexport const $check = /*#__PURE__*/ main.check.bind(main)\nexport const $cast = /*#__PURE__*/ main.cast.bind(main)\nexport const $ifMatches = /*#__PURE__*/ main.ifMatches.bind(main)\nexport const $matches = /*#__PURE__*/ main.matches.bind(main)\nexport const $parse = /*#__PURE__*/ main.parse.bind(main)\nexport const $safeParse = /*#__PURE__*/ main.safeParse.bind(main)\nexport const $validate = /*#__PURE__*/ main.validate.bind(main)\nexport const $safeValidate = /*#__PURE__*/ main.safeValidate.bind(main)\n\ntype Caption = {\n $type?: 'app.bsky.embed.video#caption'\n lang: l.LanguageString\n file: l.BlobRef\n}\n\nexport type { Caption }\n\nconst caption = /*#__PURE__*/ l.typedObject<Caption>(\n $nsid,\n 'caption',\n /*#__PURE__*/ l.object({\n lang: /*#__PURE__*/ l.string({ format: 'language' }),\n file: /*#__PURE__*/ l.blob({ accept: ['text/vtt'], maxSize: 20000 }),\n }),\n)\n\nexport { caption }\n\ntype View = {\n $type?: 'app.bsky.embed.video#view'\n cid: l.CidString\n playlist: l.UriString\n thumbnail?: l.UriString\n alt?: string\n aspectRatio?: EmbedDefs.AspectRatio\n\n /**\n * A hint to the client about how to present the video.\n */\n presentation?: 'default' | 'gif' | l.UnknownString\n}\n\nexport type { View }\n\nconst view = /*#__PURE__*/ l.typedObject<View>(\n $nsid,\n 'view',\n /*#__PURE__*/ l.object({\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n playlist: /*#__PURE__*/ l.string({ format: 'uri' }),\n thumbnail: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'uri' }),\n ),\n alt: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n aspectRatio: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<EmbedDefs.AspectRatio>(\n (() => EmbedDefs.aspectRatio) as any,\n ),\n ),\n presentation: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string<{ knownValues: ['default', 'gif'] }>(),\n ),\n }),\n)\n\nexport { view }\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/bsky",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.275",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Reference implementation of app.bsky App View (Bluesky API)",
|
|
6
6
|
"keywords": [
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@connectrpc/connect-express": "^1.1.4",
|
|
35
35
|
"@connectrpc/connect-node": "^1.1.4",
|
|
36
36
|
"@did-plc/lib": "^0.0.1",
|
|
37
|
+
"@noble/curves": "^1.7.0",
|
|
37
38
|
"@growthbook/growthbook": "^1.6.2",
|
|
38
39
|
"@hapi/address": "^5.1.1",
|
|
39
40
|
"@types/http-errors": "^2.0.1",
|
|
@@ -46,7 +47,6 @@
|
|
|
46
47
|
"http-terminator": "^3.2.0",
|
|
47
48
|
"ioredis": "^5.3.2",
|
|
48
49
|
"jose": "^5.0.1",
|
|
49
|
-
"key-encoder": "^2.0.3",
|
|
50
50
|
"kysely": "^0.29.2",
|
|
51
51
|
"leo-profanity": "^1.8.0",
|
|
52
52
|
"murmurhash": "^2.0.1",
|
|
@@ -60,17 +60,17 @@
|
|
|
60
60
|
"undici": "^8.5.0",
|
|
61
61
|
"zod": "3.23.8",
|
|
62
62
|
"@atproto-labs/fetch-node": "^0.3.7",
|
|
63
|
-
"@atproto-labs/xrpc-utils": "^0.1.
|
|
63
|
+
"@atproto-labs/xrpc-utils": "^0.1.18",
|
|
64
|
+
"@atproto/api": "^0.20.41",
|
|
65
|
+
"@atproto/crypto": "^0.5.4",
|
|
64
66
|
"@atproto/common": "^0.8.0",
|
|
65
|
-
"@atproto/api": "^0.20.40",
|
|
66
67
|
"@atproto/identity": "^0.5.9",
|
|
67
|
-
"@atproto/lex": "^0.3.6",
|
|
68
68
|
"@atproto/did": "^0.5.4",
|
|
69
|
-
"@atproto/
|
|
70
|
-
"@atproto/
|
|
71
|
-
"@atproto/sync": "^0.4.4",
|
|
69
|
+
"@atproto/lex": "^0.3.6",
|
|
70
|
+
"@atproto/sync": "^0.4.5",
|
|
72
71
|
"@atproto/syntax": "^0.7.4",
|
|
73
|
-
"@atproto/
|
|
72
|
+
"@atproto/repo": "^0.10.11",
|
|
73
|
+
"@atproto/xrpc-server": "^0.12.5"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@bufbuild/buf": "^1.28.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@types/pg": "^8.15.5",
|
|
85
85
|
"@types/qs": "^6.9.7",
|
|
86
86
|
"vitest": "^4.1.10",
|
|
87
|
-
"@atproto/pds": "^0.5.
|
|
87
|
+
"@atproto/pds": "^0.5.29"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"codegen:buf": "buf generate ../bsync/proto && buf generate ./proto",
|