#!/usr/bin/env bash # The Go scope lists (internal/atproto/oauth/scope.go: what a bidder's and a requester's identity check needs granted) and the # TS ones the QR page signs in with (typescript-helpers/lib/oauth-scope/mod.ts, generated into # did-key-associator/generated/oauth-scope.js) agree: a session granted the page's scope lacks nothing of the Go QR list # (oauth.MissingScopes, the identity check's own comparison), and with deno on PATH the TS list of each role lacks nothing of # the Go list of that role. Both sides are read from their source (the Go lists by go run, the generated file, deno eval). # A token only the TS side has (the page's own associateConfirm) is not a difference. set -euo pipefail cd "$(dirname "$0")/.." gen=did-key-associator/generated/oauth-scope.js rc=0 lacks() { local missing missing=$(go run ./hack/oauthscopes "$1" 2> >(grep -v '^exit status' >&2)) && return 0 echo "check-oauth-scope.sh: $2 lacks what scope.go's $1 list has:" >&2 cut -c1-300 <<<"$missing" | sed 's/^/ /' >&2 return 1 } sed -n 's/^export const OAUTH_SCOPE_FULL = \(".*"\);$/\1/p' "$gen" | jq -r . | lacks qr "$gen (regenerate: cd did-key-associator && deno task build:static)" || rc=1 if command -v deno >/dev/null; then for l in qr:DID_KEY_ASSOCIATOR_OAUTH_SCOPE bidder:BIDDER_OAUTH_SCOPE requester:REQUESTER_OAUTH_SCOPE; do deno eval --no-lock "import { ${l#*:} as s } from './typescript-helpers/lib/oauth-scope/mod.ts'; console.log(s.join(' '));" | lacks "${l%%:*}" "typescript-helpers/lib/oauth-scope/mod.ts ${l#*:}" || rc=1 done fi exit $rc