Something went wrong. Try again.
A live media wall for your Bluesky follows
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import assert from 'node:assert/strict';import { test } from 'node:test';import { clientMetadata, loopbackMetadata, oauthReadEndpoints, oauthScope, oauthInteractionScopes} from './auth.js';
void test('combined login includes exactly the required read and interaction permissions', () => { const scopes = oauthScope.split(' ').slice(0, 1 + oauthReadEndpoints.length); assert.equal(scopes[0], 'atproto'); assert.equal(scopes.length, 10); assert.equal(oauthReadEndpoints.length, 9); assert.ok(oauthReadEndpoints.includes('app.bsky.feed.getAuthorFeed')); assert.ok( scopes.includes('rpc:app.bsky.feed.getPostThread?aud=did:web:api.bsky.app%23bsky_appview') ); for (const scope of scopes.slice(1)) { assert.match( scope, /^rpc:app\.bsky\.[a-z]+\.get[A-Za-z]+\?aud=did:web:api\.bsky\.app%23bsky_appview$/ ); } assert.equal(clientMetadata('https://mural.example').scope, oauthScope); assert.deepEqual(oauthScope.split(' '), [...scopes, ...oauthInteractionScopes]);});
void test('interaction permissions are narrowly scoped and included in the single login', () => { assert.deepEqual(oauthInteractionScopes, [ 'repo:app.bsky.feed.like?action=create&action=delete', 'repo:app.bsky.feed.repost?action=create&action=delete', 'repo:app.bsky.graph.block?action=create&action=delete', 'repo:app.bsky.graph.follow?action=create&action=delete', 'rpc:app.bsky.bookmark.createBookmark?aud=did:web:api.bsky.app%23bsky_appview', 'rpc:app.bsky.bookmark.deleteBookmark?aud=did:web:api.bsky.app%23bsky_appview', 'rpc:app.bsky.graph.muteActor?aud=did:web:api.bsky.app%23bsky_appview', 'rpc:app.bsky.graph.unmuteActor?aud=did:web:api.bsky.app%23bsky_appview' ]); for (const permission of oauthInteractionScopes) assert.ok(oauthScope.split(' ').includes(permission));});
void test('loopback client identity and metadata declare the same granular scopes', () => { const metadata = loopbackMetadata(new URL('http://localhost:5174/')); assert.equal(metadata.scope, oauthScope); assert.equal(new URL(metadata.client_id).searchParams.get('scope'), oauthScope); assert.deepEqual(metadata.redirect_uris, ['http://127.0.0.1:5174/']);});