Label expiration (#2241)
* sketching out label sequencer * refactor sequencer * sequencer tests * tests * add query labels endpoint & tests * add pagination * fix label formatting on temp * tidy * format labels * make use listen/notify for sequencer * ensure sig on all outgoing labels from ozone * fixing up tests * fix sequencer tests * fix hanging server test * add log on failure to update label * update description for sig * add expiration to labels * fix test * use bytes for label sigs * fix tests * add ver to labels * tidy up background queue * store signing keys as ids * fix sequencer teest
This commit is contained in:
parent
cc11adda87
commit
38656e71ff
lexicons/com/atproto/label
packages
api/src/client
bsky/src/lexicon
ozone
src
db
lexicon
mod-service
tests
pds/src/lexicon
@ -40,6 +40,11 @@
|
||||
"format": "datetime",
|
||||
"description": "Timestamp when this label was created."
|
||||
},
|
||||
"exp": {
|
||||
"type": "string",
|
||||
"format": "datetime",
|
||||
"description": "Timestamp at which this label expires (no longer applies)."
|
||||
},
|
||||
"sig": {
|
||||
"type": "bytes",
|
||||
"description": "Signature of dag-cbor encoded label."
|
||||
|
@ -2239,6 +2239,12 @@ export const schemaDict = {
|
||||
format: 'datetime',
|
||||
description: 'Timestamp when this label was created.',
|
||||
},
|
||||
exp: {
|
||||
type: 'string',
|
||||
format: 'datetime',
|
||||
description:
|
||||
'Timestamp at which this label expires (no longer applies).',
|
||||
},
|
||||
sig: {
|
||||
type: 'bytes',
|
||||
description: 'Signature of dag-cbor encoded label.',
|
||||
|
@ -22,6 +22,8 @@ export interface Label {
|
||||
neg?: boolean
|
||||
/** Timestamp when this label was created. */
|
||||
cts: string
|
||||
/** Timestamp at which this label expires (no longer applies). */
|
||||
exp?: string
|
||||
/** Signature of dag-cbor encoded label. */
|
||||
sig?: Uint8Array
|
||||
[k: string]: unknown
|
||||
|
@ -2239,6 +2239,12 @@ export const schemaDict = {
|
||||
format: 'datetime',
|
||||
description: 'Timestamp when this label was created.',
|
||||
},
|
||||
exp: {
|
||||
type: 'string',
|
||||
format: 'datetime',
|
||||
description:
|
||||
'Timestamp at which this label expires (no longer applies).',
|
||||
},
|
||||
sig: {
|
||||
type: 'bytes',
|
||||
description: 'Signature of dag-cbor encoded label.',
|
||||
|
@ -22,6 +22,8 @@ export interface Label {
|
||||
neg?: boolean
|
||||
/** Timestamp when this label was created. */
|
||||
cts: string
|
||||
/** Timestamp at which this label expires (no longer applies). */
|
||||
exp?: string
|
||||
/** Signature of dag-cbor encoded label. */
|
||||
sig?: Uint8Array
|
||||
[k: string]: unknown
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Kysely, sql } from 'kysely'
|
||||
|
||||
export async function up(db: Kysely<unknown>): Promise<void> {
|
||||
await db.schema.alterTable('label').addColumn('exp', 'varchar').execute()
|
||||
await db.schema
|
||||
.alterTable('label')
|
||||
.addColumn('sig', sql`bytea`)
|
||||
@ -18,6 +19,7 @@ export async function up(db: Kysely<unknown>): Promise<void> {
|
||||
|
||||
export async function down(db: Kysely<unknown>): Promise<void> {
|
||||
await db.schema.dropTable('signing_key')
|
||||
await db.schema.alterTable('label').dropColumn('exp').execute()
|
||||
await db.schema.alterTable('label').dropColumn('sig').execute()
|
||||
await db.schema.alterTable('label').dropColumn('signingKey').execute()
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ export interface Label {
|
||||
val: string
|
||||
neg: boolean
|
||||
cts: string
|
||||
exp: string | null
|
||||
sig: Buffer | null
|
||||
signingKeyId: number | null
|
||||
}
|
||||
|
@ -2239,6 +2239,12 @@ export const schemaDict = {
|
||||
format: 'datetime',
|
||||
description: 'Timestamp when this label was created.',
|
||||
},
|
||||
exp: {
|
||||
type: 'string',
|
||||
format: 'datetime',
|
||||
description:
|
||||
'Timestamp at which this label expires (no longer applies).',
|
||||
},
|
||||
sig: {
|
||||
type: 'bytes',
|
||||
description: 'Signature of dag-cbor encoded label.',
|
||||
|
@ -22,6 +22,8 @@ export interface Label {
|
||||
neg?: boolean
|
||||
/** Timestamp when this label was created. */
|
||||
cts: string
|
||||
/** Timestamp at which this label expires (no longer applies). */
|
||||
exp?: string
|
||||
/** Signature of dag-cbor encoded label. */
|
||||
sig?: Uint8Array
|
||||
[k: string]: unknown
|
||||
|
@ -14,6 +14,7 @@ export const formatLabel = (row: LabelRow): Label => {
|
||||
val: row.val,
|
||||
neg: row.neg,
|
||||
cts: row.cts,
|
||||
exp: row.exp ?? undefined,
|
||||
sig: row.sig ? new Uint8Array(row.sig) : undefined,
|
||||
}) as Label
|
||||
}
|
||||
@ -29,6 +30,7 @@ export const formatLabelRow = (
|
||||
val: label.val,
|
||||
neg: !!label.neg,
|
||||
cts: label.cts,
|
||||
exp: label.exp ?? null,
|
||||
sig: label.sig ? Buffer.from(label.sig) : null,
|
||||
signingKeyId: signingKeyId ?? null,
|
||||
}
|
||||
@ -38,7 +40,7 @@ export const signLabel = async (
|
||||
label: Label,
|
||||
signingKey: Keypair,
|
||||
): Promise<SignedLabel> => {
|
||||
const { ver, src, uri, cid, val, neg, cts } = label
|
||||
const { ver, src, uri, cid, val, neg, cts, exp } = label
|
||||
const reformatted = noUndefinedVals({
|
||||
ver: ver ?? 1,
|
||||
src,
|
||||
@ -47,6 +49,7 @@ export const signLabel = async (
|
||||
val,
|
||||
neg,
|
||||
cts,
|
||||
exp,
|
||||
}) as Label
|
||||
|
||||
const bytes = cborEncode(reformatted)
|
||||
|
@ -38,6 +38,7 @@ describe('sequencer', () => {
|
||||
id: e.seq,
|
||||
...label,
|
||||
cid: label.cid ? label.cid : '',
|
||||
exp: null,
|
||||
sig: label.sig ? Buffer.from(label.sig) : null,
|
||||
signingKeyId: network.ozone.ctx.signingKeyId,
|
||||
}
|
||||
|
@ -2239,6 +2239,12 @@ export const schemaDict = {
|
||||
format: 'datetime',
|
||||
description: 'Timestamp when this label was created.',
|
||||
},
|
||||
exp: {
|
||||
type: 'string',
|
||||
format: 'datetime',
|
||||
description:
|
||||
'Timestamp at which this label expires (no longer applies).',
|
||||
},
|
||||
sig: {
|
||||
type: 'bytes',
|
||||
description: 'Signature of dag-cbor encoded label.',
|
||||
|
@ -22,6 +22,8 @@ export interface Label {
|
||||
neg?: boolean
|
||||
/** Timestamp when this label was created. */
|
||||
cts: string
|
||||
/** Timestamp at which this label expires (no longer applies). */
|
||||
exp?: string
|
||||
/** Signature of dag-cbor encoded label. */
|
||||
sig?: Uint8Array
|
||||
[k: string]: unknown
|
||||
|
Loading…
x
Reference in New Issue
Block a user