Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"pg": "8.23.0",
"reflect-metadata": "0.2.2",
"rxjs": "7.8.2",
"tc-core-library-js": "https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/58de37670180e183e8378c3d203df0112a0414f6"
"tc-core-library-js": "https://codeload.github.com/topcoder-platform/tc-core-library-js/tar.gz/c2df92b2227089909ab6e229df0ec6b658bb431a"
},
"devDependencies": {
"@eslint/js": "9.39.2",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion test/auth-rs256.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function browserToken(
) {
const now = Math.floor(Date.now() / 1000);
const payload = {
emailVerified: true,
[`${namespace}roles`]: ['administrator', 'Topcoder User'],
[`${namespace}userId`]: '12345',
iss: issuer,
Expand Down Expand Up @@ -114,7 +115,7 @@ describe('reports directory with the shared Topcoder authenticator', () => {

it('still accepts legacy HS256 administrators on the same deployment', async () => {
const token = jwt.sign(
{ userId: '12345', roles: ['Administrator'] },
{ emailVerified: true, userId: '12345', roles: ['Administrator'] },
testSecret,
{
algorithm: 'HS256',
Expand All @@ -129,6 +130,9 @@ describe('reports directory with the shared Topcoder authenticator', () => {
});

it.each([
{ emailVerified: undefined },
{ emailVerified: false },
{ emailVerified: 'true' },
{ exp: 1 },
{ iss: 'https://untrusted.example/' },
{ exp: undefined },
Expand Down Expand Up @@ -159,6 +163,7 @@ describe('reports directory with the shared Topcoder authenticator', () => {

it('authorizes an RS256 machine by scopes rather than administrator roles', async () => {
const machine = {
emailVerified: undefined,
sub: 'client@clients',
gty: 'client-credentials',
azp: 'client',
Expand Down
1 change: 1 addition & 0 deletions test/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async function authenticate(
const { SignJWT } = await import('jose');
const now = Math.floor(Date.now() / 1000);
const jwt = await new SignJWT({
emailVerified: true,
userId: '12345',
roles: ['Administrator'],
iss: 'https://api.topcoder-dev.com',
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function testConfig() {
*/
export async function token(claims: Record<string, unknown>) {
const { SignJWT } = await import('jose');
return new SignJWT(claims)
return new SignJWT({ emailVerified: true, ...claims })
.setProtectedHeader({ alg: 'HS256' })
.setSubject('test-user')
.setIssuer('https://forms.test')
Expand Down
2 changes: 1 addition & 1 deletion test/forms.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ describe('forms API with real PostgreSQL', () => {
algorithm: 'HS384',
},
]) {
const bad = await new SignJWT(claims)
const bad = await new SignJWT({ emailVerified: true, ...claims })
.setProtectedHeader({ alg: settings.algorithm })
.setSubject('test-user')
.setIssuer(settings.issuer)
Expand Down
Loading