Add terms-of-service and privacy-policy links ()

* Add privacy-policy and terms-of-service to getAccountsConfig

* Add privacy policy and tos urls to dev environment
This commit is contained in:
Paul Frazee 2022-12-06 13:05:05 -06:00 committed by GitHub
parent aea590ef37
commit d7b4697b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 94 additions and 2 deletions
lexicons/com/atproto/server
packages
api/src/client
lexicons.ts
types/com/atproto/server
dev-env/src
pds
src
api/com/atproto
config.ts
lexicon
lexicons.ts
types/com/atproto/server
tests

@ -12,10 +12,18 @@
"required": ["availableUserDomains"],
"properties": {
"inviteCodeRequired": {"type": "boolean"},
"availableUserDomains": {"type": "array", "items": {"type": "string"}}
"availableUserDomains": {"type": "array", "items": {"type": "string"}},
"links": {"type": "ref", "ref": "#links"}
}
}
}
},
"links": {
"type": "object",
"properties": {
"privacyPolicy": {"type": "string"},
"termsOfService": {"type": "string"}
}
}
}
}

@ -669,10 +669,25 @@ export const lexicons: LexiconDoc[] = [
type: 'string',
},
},
links: {
type: 'ref',
ref: 'lex:com.atproto.server.getAccountsConfig#links',
},
},
},
},
},
links: {
type: 'object',
properties: {
privacyPolicy: {
type: 'string',
},
termsOfService: {
type: 'string',
},
},
},
},
},
{

@ -10,6 +10,7 @@ export type InputSchema = undefined
export interface OutputSchema {
inviteCodeRequired?: boolean
availableUserDomains: string[]
links?: Links
[k: string]: unknown
}
@ -28,3 +29,9 @@ export function toKnownErr(e: any) {
}
return e
}
export interface Links {
privacyPolicy?: string
termsOfService?: string
[k: string]: unknown
}

@ -84,6 +84,8 @@ export class DevEnvServer {
emailNoReplyAddress: 'noreply@blueskyweb.xyz',
adminPassword: 'password',
inviteRequired: false,
privacyPolicyUrl: 'https://example.com/privacy',
termsOfServiceUrl: 'https://example.com/tos',
}).listener,
)
break

@ -17,10 +17,16 @@ export default function (server: Server) {
const availableUserDomains = cfg.availableUserDomains
const inviteCodeRequired = cfg.inviteRequired
const privacyPolicy = cfg.privacyPolicyUrl
const termsOfService = cfg.termsOfServiceUrl
return {
encoding: 'application/json',
body: { availableUserDomains, inviteCodeRequired },
body: {
availableUserDomains,
inviteCodeRequired,
links: { privacyPolicy, termsOfService },
},
}
})

@ -19,6 +19,8 @@ export interface ServerConfigValues {
adminPassword: string
inviteRequired: boolean
privacyPolicyUrl?: string
termsOfServiceUrl?: string
blockstoreLocation?: string
databaseLocation?: string
@ -72,6 +74,8 @@ export class ServerConfig {
const adminPassword = process.env.ADMIN_PASSWORD || 'admin'
const inviteRequired = process.env.INVITE_REQUIRED === 'true' ? true : false
const privacyPolicyUrl = process.env.PRIVACY_POLICY_URL
const termsOfServiceUrl = process.env.TERMS_OF_SERVICE_URL
const blockstoreLocation = process.env.BLOCKSTORE_LOC
const databaseLocation = process.env.DATABASE_LOC
@ -106,6 +110,8 @@ export class ServerConfig {
serverDid,
adminPassword,
inviteRequired,
privacyPolicyUrl,
termsOfServiceUrl,
blockstoreLocation,
databaseLocation,
availableUserDomains,
@ -186,6 +192,26 @@ export class ServerConfig {
return this.cfg.inviteRequired
}
get privacyPolicyUrl() {
if (
this.cfg.privacyPolicyUrl &&
this.cfg.privacyPolicyUrl.startsWith('/')
) {
return this.publicUrl + this.cfg.privacyPolicyUrl
}
return this.cfg.privacyPolicyUrl
}
get termsOfServiceUrl() {
if (
this.cfg.termsOfServiceUrl &&
this.cfg.termsOfServiceUrl.startsWith('/')
) {
return this.publicUrl + this.cfg.termsOfServiceUrl
}
return this.cfg.termsOfServiceUrl
}
get blockstoreLocation() {
return this.cfg.blockstoreLocation
}

@ -669,10 +669,25 @@ export const lexicons: LexiconDoc[] = [
type: 'string',
},
},
links: {
type: 'ref',
ref: 'lex:com.atproto.server.getAccountsConfig#links',
},
},
},
},
},
links: {
type: 'object',
properties: {
privacyPolicy: {
type: 'string',
},
termsOfService: {
type: 'string',
},
},
},
},
},
{

@ -11,6 +11,7 @@ export type InputSchema = undefined
export interface OutputSchema {
inviteCodeRequired?: boolean
availableUserDomains: string[]
links?: Links
[k: string]: unknown
}
@ -34,3 +35,9 @@ export type Handler<HA extends HandlerAuth = never> = (ctx: {
req: express.Request
res: express.Response
}) => Promise<HandlerOutput> | HandlerOutput
export interface Links {
privacyPolicy?: string
termsOfService?: string
[k: string]: unknown
}

@ -45,6 +45,8 @@ describe('account', () => {
beforeAll(async () => {
const server = await util.runTestServer({
inviteRequired: true,
termsOfServiceUrl: 'https://example.com/tos',
privacyPolicyUrl: '/privacy-policy',
dbPostgresSchema: 'account',
})
close = server.close
@ -86,6 +88,10 @@ describe('account', () => {
expect(res.data.inviteCodeRequired).toBe(true)
expect(res.data.availableUserDomains[0]).toBe('.test')
expect(typeof res.data.inviteCodeRequired).toBe('boolean')
expect(res.data.links?.privacyPolicy).toBe(
'https://pds.public.url/privacy-policy',
)
expect(res.data.links?.termsOfService).toBe('https://example.com/tos')
})
it('fails on invalid handles', async () => {