Skip to content

Commit dec5303

Browse files
authored
Merge b0bb415 into 5380e00
2 parents 5380e00 + b0bb415 commit dec5303

File tree

4 files changed

+64
-5
lines changed

4 files changed

+64
-5
lines changed

packages/auth/gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -114,7 +114,7 @@ gulp.task('serve', () => {
114114
);
115115
app.use(express.static(__dirname));
116116

117-
app.listen(4000);
117+
app.listen(4001);
118118
});
119119

120120
gulp.task('default', gulp.parallel('cjs', 'esm'));

packages/auth/protractor_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717

1818
var allTests = require('./generated/all_tests');
1919

20-
var TEST_SERVER = 'http://localhost:4000';
20+
var TEST_SERVER = 'http://localhost:4001';
2121

2222
var FLAKY_TEST_RETRIAL = 3;
2323

packages/auth/src/idtoken.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
goog.provide('fireauth.IdToken');
2323

24+
goog.require('goog.crypt');
2425
goog.require('goog.crypt.base64');
2526

2627

@@ -244,7 +245,9 @@ fireauth.IdToken.parseIdTokenClaims = function(tokenString) {
244245
jsonInfo += '.';
245246
}
246247
try {
247-
const token = JSON.parse(goog.crypt.base64.decodeString(jsonInfo, true));
248+
const decodedClaims = goog.crypt.utf8ByteArrayToString(
249+
goog.crypt.base64.decodeStringToByteArray(jsonInfo));
250+
const token = JSON.parse(decodedClaims);
248251
return /** @type {?Object} */ (token);
249252
} catch (e) {}
250253
return null;

packages/auth/test/idtoken_test.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,34 @@ var tokenCustomClaim = 'HEAD.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5j' +
147147
'bl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn19.SIGNATURE';
148148

149149

150+
// "iss": "https://securetoken.google.com/projectId",
151+
// "name": "John Doe",
152+
// "role": "Админ", // <---- Note non-ascii characters here
153+
// "aud": "projectId",
154+
// "auth_time": 1522715325,
155+
// "sub": "nep2uwNCK4PqjvoKjb0InVJHlGi1",
156+
// "iat": 1522776807,
157+
// "exp": 1522780575,
158+
// "email": "[email protected]",
159+
// "email_verified": true,
160+
// "firebase": {
161+
// "identities": {
162+
// "email": [
163+
164+
// ]
165+
// },
166+
// "sign_in_provider": "custom"
167+
// }
168+
var tokenCustomClaimWithUnicodeChar = 'HEAD.eyJpc3MiOiJodHRwczovL3NlY3VyZXRv' +
169+
'a2VuLmdvb2dsZS5jb20vcHJvamVjdElkIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6ItC' +
170+
'Q0LTQvNC40L0iLCJhdWQiOiJwcm9qZWN0SWQiLCJhdXRoX3RpbWUiOjE1MjI3MTUzMjUsIn' +
171+
'N1YiI6Im5lcDJ1d05DSzRQcWp2b0tqYjBJblZKSGxHaTEiLCJpYXQiOjE1MjI3NzY4MDcsI' +
172+
'mV4cCI6MTUyMjc4MDU3NSwiZW1haWwiOiJ0ZXN0dXNlckBnbWFpbC5jb20iLCJlbWFpbF92' +
173+
'ZXJpZmllZCI6dHJ1ZSwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6eyJlbWFpbCI6WyJ0ZXN' +
174+
'0dXNlckBnbWFpbC5jb20iXX0sInNpZ25faW5fcHJvdmlkZXIiOiJjdXN0b20ifX0=.SIGNA' +
175+
'TURE';
176+
177+
150178
// "iss": "https://securetoken.google.com/projectId",
151179
// "name": "John Doe",
152180
// "aud": "projectId",
@@ -405,3 +433,31 @@ function testParseIdTokenClaims_customClaims() {
405433
},
406434
tokenJSON);
407435
}
436+
437+
438+
function testParseIdTokenClaims_tokenCustomClaimWithUnicodeChar() {
439+
const tokenJSON = fireauth.IdToken.parseIdTokenClaims(
440+
tokenCustomClaimWithUnicodeChar);
441+
assertObjectEquals(
442+
{
443+
'iss': 'https://securetoken.google.com/projectId',
444+
'name': 'John Doe',
445+
'role': 'Админ',
446+
'aud': 'projectId',
447+
'auth_time': 1522715325,
448+
'sub': 'nep2uwNCK4PqjvoKjb0InVJHlGi1',
449+
'iat': 1522776807,
450+
'exp': 1522780575,
451+
'email': "[email protected]",
452+
'email_verified': true,
453+
'firebase': {
454+
'identities': {
455+
'email': [
456+
457+
]
458+
},
459+
'sign_in_provider': 'custom'
460+
}
461+
},
462+
tokenJSON);
463+
}

0 commit comments

Comments
 (0)