1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.IdToken = void 0;
|
8 | var ClientAuthError_1 = require("./error/ClientAuthError");
|
9 | var TokenUtils_1 = require("./utils/TokenUtils");
|
10 | var StringUtils_1 = require("./utils/StringUtils");
|
11 |
|
12 |
|
13 |
|
14 | var IdToken = (function () {
|
15 |
|
16 | function IdToken(rawIdToken) {
|
17 | if (StringUtils_1.StringUtils.isEmpty(rawIdToken)) {
|
18 | throw ClientAuthError_1.ClientAuthError.createIdTokenNullOrEmptyError(rawIdToken);
|
19 | }
|
20 | try {
|
21 | this.rawIdToken = rawIdToken;
|
22 | this.claims = TokenUtils_1.TokenUtils.extractIdToken(rawIdToken);
|
23 | if (this.claims) {
|
24 | if (this.claims.hasOwnProperty("iss")) {
|
25 | this.issuer = this.claims["iss"];
|
26 | }
|
27 | if (this.claims.hasOwnProperty("oid")) {
|
28 | this.objectId = this.claims["oid"];
|
29 | }
|
30 | if (this.claims.hasOwnProperty("sub")) {
|
31 | this.subject = this.claims["sub"];
|
32 | }
|
33 | if (this.claims.hasOwnProperty("tid")) {
|
34 | this.tenantId = this.claims["tid"];
|
35 | }
|
36 | if (this.claims.hasOwnProperty("ver")) {
|
37 | this.version = this.claims["ver"];
|
38 | }
|
39 | if (this.claims.hasOwnProperty("preferred_username")) {
|
40 | this.preferredName = this.claims["preferred_username"];
|
41 | }
|
42 | else if (this.claims.hasOwnProperty("upn")) {
|
43 | this.preferredName = this.claims["upn"];
|
44 | }
|
45 | if (this.claims.hasOwnProperty("name")) {
|
46 | this.name = this.claims["name"];
|
47 | }
|
48 | if (this.claims.hasOwnProperty("nonce")) {
|
49 | this.nonce = this.claims["nonce"];
|
50 | }
|
51 | if (this.claims.hasOwnProperty("exp")) {
|
52 | this.expiration = this.claims["exp"];
|
53 | }
|
54 | if (this.claims.hasOwnProperty("home_oid")) {
|
55 | this.homeObjectId = this.claims["home_oid"];
|
56 | }
|
57 | if (this.claims.hasOwnProperty("sid")) {
|
58 | this.sid = this.claims["sid"];
|
59 | }
|
60 | if (this.claims.hasOwnProperty("cloud_instance_host_name")) {
|
61 | this.cloudInstance = this.claims["cloud_instance_host_name"];
|
62 | }
|
63 |
|
64 | }
|
65 | }
|
66 | catch (e) {
|
67 | |
68 |
|
69 |
|
70 |
|
71 | throw ClientAuthError_1.ClientAuthError.createIdTokenParsingError(e);
|
72 | }
|
73 | }
|
74 | return IdToken;
|
75 | }());
|
76 | exports.IdToken = IdToken;
|
77 |
|
\ | No newline at end of file |