1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.Account = void 0;
|
8 | var CryptoUtils_1 = require("./utils/CryptoUtils");
|
9 | var StringUtils_1 = require("./utils/StringUtils");
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | var Account = (function () {
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | function Account(accountIdentifier, homeAccountIdentifier, userName, name, idTokenClaims, sid, environment) {
|
31 | this.accountIdentifier = accountIdentifier;
|
32 | this.homeAccountIdentifier = homeAccountIdentifier;
|
33 | this.userName = userName;
|
34 | this.name = name;
|
35 |
|
36 | this.idToken = idTokenClaims;
|
37 | this.idTokenClaims = idTokenClaims;
|
38 | this.sid = sid;
|
39 | this.environment = environment;
|
40 | }
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 | Account.createAccount = function (idToken, clientInfo) {
|
47 |
|
48 | var accountIdentifier = idToken.objectId || idToken.subject;
|
49 |
|
50 | var uid = clientInfo ? clientInfo.uid : "";
|
51 | var utid = clientInfo ? clientInfo.utid : "";
|
52 | var homeAccountIdentifier;
|
53 | if (!StringUtils_1.StringUtils.isEmpty(uid)) {
|
54 | homeAccountIdentifier = StringUtils_1.StringUtils.isEmpty(utid) ? CryptoUtils_1.CryptoUtils.base64Encode(uid) : CryptoUtils_1.CryptoUtils.base64Encode(uid) + "." + CryptoUtils_1.CryptoUtils.base64Encode(utid);
|
55 | }
|
56 | return new Account(accountIdentifier, homeAccountIdentifier, idToken.preferredName, idToken.name, idToken.claims, idToken.sid, idToken.issuer);
|
57 | };
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | Account.compareAccounts = function (a1, a2) {
|
65 | if (!a1 || !a2) {
|
66 | return false;
|
67 | }
|
68 | if (a1.homeAccountIdentifier && a2.homeAccountIdentifier) {
|
69 | if (a1.homeAccountIdentifier === a2.homeAccountIdentifier) {
|
70 | return true;
|
71 | }
|
72 | }
|
73 | return false;
|
74 | };
|
75 | return Account;
|
76 | }());
|
77 | exports.Account = Account;
|
78 |
|
\ | No newline at end of file |