Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.
TypeScript
/**
* Regression tests for the Sign in with Apple account-linking boundary.
*
* Run: node --import tsx --test server/src/__tests__/oauth-apple-email.test.ts
*/
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { resolveTrustedAppleEmail } from '../apple.js'
test('unlinked Apple identity rejects an email-less token even when the client supplies a victim email', () => {
const attackerInput = {
linkedEmail: null,
tokenEmail: null,
tokenEmailVerified: false,
// Extra request metadata must never enter the trusted selector.
fallbackEmail: '[email protected]',
}
assert.throws(
() => resolveTrustedAppleEmail(attackerInput),
/verified email not available for unlinked identity/,
)
})
test('unlinked Apple identity rejects an unverified token email', () => {
assert.throws(
() => resolveTrustedAppleEmail({
linkedEmail: null,
tokenEmail: '[email protected]',
tokenEmailVerified: false,
}),
/verified email not available for unlinked identity/,
)
})
test('unlinked Apple identity accepts and normalizes a verified token email', () => {
assert.equal(resolveTrustedAppleEmail({
linkedEmail: null,
tokenEmail: ' [email protected] ',
tokenEmailVerified: true,
}), '[email protected]')
})
test('linked Apple identity reauthenticates from its stored email without a token email', () => {
assert.equal(resolveTrustedAppleEmail({
linkedEmail: '[email protected]',
tokenEmail: null,
tokenEmailVerified: false,
}), '[email protected]')
})
test('linked Apple identity remains authoritative when a later token carries another email', () => {
assert.equal(resolveTrustedAppleEmail({
linkedEmail: '[email protected]',
tokenEmail: '[email protected]',
tokenEmailVerified: true,
}), '[email protected]')
})