Skip to content

Commit

Permalink
Merge fb2d38f into 1ff891c
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanition authored Jul 5, 2023
2 parents 1ff891c + fb2d38f commit 975c3b3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-balloons-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/auth': major
---

Changed the type of ParsedToken value from any to unknown
2 changes: 1 addition & 1 deletion common/api-review/auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ export function parseActionCodeURL(link: string): ActionCodeURL | null;

// @public
export interface ParsedToken {
[key: string]: any;
[key: string]: unknown;
'auth_time'?: string;
'exp'?: string;
'firebase'?: {
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@
"@firebase/app": "0.9.13",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-strip": "2.1.0",
"@types/express": "4.17.17",
"chromedriver": "98.0.1",
"rollup": "2.79.1",
"rollup-plugin-sourcemaps": "0.6.3",
"rollup-plugin-typescript2": "0.31.2",
"selenium-webdriver": "4.8.0",
"typescript": "4.7.4",
"@types/express": "4.17.17",
"totp-generator": "0.0.14"
"totp-generator": "0.0.14",
"typescript": "4.7.4"
},
"repository": {
"directory": "packages/auth",
Expand Down
12 changes: 12 additions & 0 deletions packages/auth/src/core/user/id_token_result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import chaiAsPromised from 'chai-as-promised';
import * as sinon from 'sinon';

import { ProviderId } from '../../model/enums';
import { ParsedToken } from '../../model/public_types';
import { FirebaseError } from '@firebase/util';

import { makeJWT } from '../../../test/helpers/jwt';
Expand Down Expand Up @@ -139,4 +140,15 @@ describe('core/user/id_token_result', () => {
'Firebase: An internal AuthError has occurred. (auth/internal-error).'
);
});

it('Parses custom claims with multiple types', () => {
const token: ParsedToken = {
'string_claim': 'foo',
'object_claim': { key1: 'value1' },
'boolean_claim': true
};
expect(token.boolean_claim as boolean).to.equal(true);
expect(token.string_claim as string).to.equal('foo');
expect((token.object_claim as { key1: string }).key1).to.equal('value1');
});
});
2 changes: 1 addition & 1 deletion packages/auth/src/model/public_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export interface ParsedToken {
'identities'?: Record<string, string>;
};
/** Map of any additional custom claims. */
[key: string]: any;
[key: string]: unknown;
}

/**
Expand Down

0 comments on commit 975c3b3

Please sign in to comment.