-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.js
250 lines (229 loc) · 17.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
const {
// default instance
frodo,
// default state
state,
} = require('@rockcarver/frodo-lib');
const host0 = 'https://openam-matrix.id.forgerock.io/am',
said0 = 'ecbfd81b-dadc-4b80-977e-260637fa2562',
jwk0 = '{"alg":"RS256","d":"NgdJ3qp8h3YvkWoWNGgu7bWvdh7WAi-22WIeOiSX83bPKzTmvy1tRX3UXjH8LCQqTpssL8TC3y3MvEd6ddZ-6Hic-xbmJ6wbw2TMan9nr1FNaV0TFIJzIdiQ_ze0jZDe2nVxlIeY9unjinCUT-BeBcdZgAfNNAiKP01MKiynYA2v8T42AO1ha5s8dphKf9SiZ5OAf15zTwc9JP35Wd_GWa-H8bD-ZAb8dnJZuCItOjepgken_WV5YttxMw_fuSUCOkVES0EA2mmdlPLj208Voo5o8UJAk9KKzSC96Ai5n_X059gjdm_TIj4O8poVRRt3bULKlhGdHbBHChS9lgrCsk-bBLfTrQrF6j8-F3Z5pZGQ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YzIDD6nLCBitCmTG9coS5k9mp193S7M82KPFwPo3QkZvLIjqn5K9aQQPtf2eLPpBySxqDcoDU4-4D032-yfEwzfWLv8Bu8OuR-6Fjdg19ieaeuxsQE4Et0uGQ-hv5X0qVYHx9mHbhymDlGY0cqjRl5UCJYxL7lzWKl3156YNmKV1C_NtntlIyhG-XDlZ4zxRgOvbT-T3A_nd2O8iwH4RJ8z_KHwfTyAOka_yUoU5IiLxSCpEZVtQp1wBqxAef9--2rHIz_SvNr_kkd71mWl9UqQxByMAFwn_Dl6uix-EC3nQVayCRLGNyoQYo-n99qV6bEL_w","qi":"3KP4T8V_u4xmJ2ERNkw2Y-ll1lmZjnLdZn9zDSQNc1hJcyKE9TEWBty1jOc_WFrv1xN1WpIliH5kiAQqxokClZNB6rLWME27_ygvBuxamCUk14OplrbNMwWoNTEcXv7DtWKtHDdd-P5RpX4b-yx7oUdcC2tjqQtYQqvWx6dAx6JDOhMO1rFO4FA0GWyUHtPp5cVdUT1OT9UR51QdhaJxcQWG7rAYpQJfQzyyi5YhF4MU8Xa7isMnS6KvrQX89NeVtNpz-z-7fCdPDUwFFpLaC3o1KnKEvQi33ORqR5ROiOb9bDddxU2TSXs5oc_ex2pXF6UU7fVCuneNfy3tE-amyw"}',
user0 = 'thomas.anderson@metacortex.com',
pass0 = 'Blu3P!ll3d',
host1 = 'https://openam-matrix.id.forgerock.io/am',
said1 = 'ecbfd81b-dadc-4b80-977e-260637fa2562',
jwk1 = '{"alg":"RS256","d":"NgdJ3qp8h3YvkWoWNGgu7bWvdh7WAi-22WIeOiSX83bPKzTmvy1tRX3UXjH8LCQqTpssL8TC3y3MvEd6ddZ-6Hic-xbmJ6wbw2TMan9nr1FNaV0TFIJzIdiQ_ze0jZDe2nVxlIeY9unjinCUT-BeBcdZgAfNNAiKP01MKiynYA2v8T42AO1ha5s8dphKf9SiZ5OAf15zTwc9JP35Wd_GWa-H8bD-ZAb8dnJZuCItOjepgken_WV5YttxMw_fuSUCOkVES0EA2m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KwHco4XWezbmUVu-BXiom_0EuDv5WQKm1yATgibHah2zECMdwXfL03eoDtovmGi-rrbfUDxuFqBbVmobww","q":"y5eMRV5bwIKDyCZt-YzIDD6nLCBitCmTG9coS5k9mp193S7M82KPFwPo3QkZvLIjqn5K9aQQPtf2eLPpBySxqDcoDU4-4D032-yfEwzfWLv8Bu8OuR-6Fjdg19ieaeuxsQE4Et0uGQ-hv5X0qVYHx9mHbhymDlGY0cqjRl5UCJYxL7lzWKl3156YNmKV1C_NtntlIyhG-XDlZ4zxRgOvbT-T3A_nd2O8iwH4RJ8z_KHwfTyAOka_yUoU5IiLxSCpEZVtQp1wBqxAef9--2rHIz_SvNr_kkd71mWl9UqQxByMAFwn_Dl6uix-EC3nQVayCRLGNyoQYo-n99qV6bEL_w","qi":"3KP4T8V_u4xmJ2ERNkw2Y-ll1lmZjnLdZn9zDSQNc1hJcyKE9TEWBty1jOc_WFrv1xN1WpIliH5kiAQqxokClZNB6rLWME27_ygvBuxamCUk14OplrbNMwWoNTEcXv7DtWKtHDdd-P5RpX4b-yx7oUdcC2tjqQtYQqvWx6dAx6JDOhMO1rFO4FA0GWyUHtPp5cVdUT1OT9UR51QdhaJxcQWG7rAYpQJfQzyyi5YhF4MU8Xa7isMnS6KvrQX89NeVtNpz-z-7fCdPDUwFFpLaC3o1KnKEvQi33ORqR5ROiOb9bDddxU2TSXs5oc_ex2pXF6UU7fVCuneNfy3tE-amyw"}',
user1 = 'thomas.anderson@metacortex.com',
pass1 = 'Blu3P!ll3d',
host2 = 'https://openam-matrix.id.forgerock.io/am',
said2 = 'ecbfd81b-dadc-4b80-977e-260637fa2562',
jwk2 = '{"alg":"RS256","d":"NgdJ3qp8h3YvkWoWNGgu7bWvdh7WAi-22WIeOiSX83bPKzTmvy1tRX3UXjH8LCQqTpssL8TC3y3MvEd6ddZ-6Hic-xbmJ6wbw2TMan9nr1FNaV0TFIJzIdiQ_ze0jZDe2nVxlIeY9unjinCUT-BeBcdZgAfNNAiKP01MKi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rICGH2iJ0HMQcYrRsGzPYsbJNsT52H3D2Yq7vv1Hqxzc4NQwarv1PDRbCP-pxTG6gHVaseH8dLrsOv17OCib8HeYc3pPFSIKwHco4XWezbmUVu-BXiom_0EuDv5WQKm1yATgibHah2zECMdwXfL03eoDtovmGi-rrbfUDxuFqBbVmobww","q":"y5eMRV5bwIKDyCZt-YzIDD6nLCBitCmTG9coS5k9mp193S7M82KPFwPo3QkZvLIjqn5K9aQQPtf2eLPpBySxqDcoDU4-4D032-yfEwzfWLv8Bu8OuR-6Fjdg19ieaeuxsQE4Et0uGQ-hv5X0qVYHx9mHbhymDlGY0cqjRl5UCJYxL7lzWKl3156YNmKV1C_NtntlIyhG-XDlZ4zxRgOvbT-T3A_nd2O8iwH4RJ8z_KHwfTyAOka_yUoU5IiLxSCpEZVtQp1wBqxAef9--2rHIz_SvNr_kkd71mWl9UqQxByMAFwn_Dl6uix-EC3nQVayCRLGNyoQYo-n99qV6bEL_w","qi":"3KP4T8V_u4xmJ2ERNkw2Y-ll1lmZjnLdZn9zDSQNc1hJcyKE9TEWBty1jOc_WFrv1xN1WpIliH5kiAQqxokClZNB6rLWME27_ygvBuxamCUk14OplrbNMwWoNTEcXv7DtWKtHDdd-P5RpX4b-yx7oUdcC2tjqQtYQqvWx6dAx6JDOhMO1rFO4FA0GWyUHtPp5cVdUT1OT9UR51QdhaJxcQWG7rAYpQJfQzyyi5YhF4MU8Xa7isMnS6KvrQX89NeVtNpz-z-7fCdPDUwFFpLaC3o1KnKEvQi33ORqR5ROiOb9bDddxU2TSXs5oc_ex2pXF6UU7fVCuneNfy3tE-amyw"}',
user2 = 'thomas.anderson@metacortex.com',
pass2 = 'Blu3P!ll3d';
/**
* create a new instance using factory helper function and login as service account
*/
async function newFactoryHelperServiceAccountLogin() {
console.log(
`\n********** BEGIN ********** newFactoryHelperServiceAccountLogin **********`
);
const myFrodo1 = frodo.createInstanceWithServiceAccount(
host1, // host base URL
said1, // service account id
jwk1 // service account jwk as a string
);
// destructure default instance for easier use of library functions
const { getTokens } = myFrodo1.login;
const { getInfo } = myFrodo1.info;
// login and obtain tokens
if (await getTokens()) {
// obtain and print information about the instance you are connected to
const info = await getInfo();
console.log(
`newFactoryHelperServiceAccountLogin: Logged in to: ${info.host}`
);
console.log(
`newFactoryHelperServiceAccountLogin: Logged in as: ${info.authenticatedSubject}`
);
console.log(
`newFactoryHelperServiceAccountLogin: Using bearer token: \n${info.bearerToken}`
);
} else {
console.log('error getting tokens');
}
console.log(
`********** END ************ newFactoryHelperServiceAccountLogin **********\n`
);
}
newFactoryHelperServiceAccountLogin();
/**
* create a new instance using factory helper function and login as admin user
*/
async function newFactoryHelperAdminLogin() {
console.log(
`\n********** BEGIN ********** newFactoryHelperAdminLogin **********`
);
const myFrodo1 = frodo.createInstanceWithAdminAccount(
host1, // host base URL
user1, // admin username
pass1 // admin password
);
// destructure default instance for easier use of library functions
const { getTokens } = myFrodo1.login;
const { getInfo } = myFrodo1.info;
// login and obtain tokens
if (await getTokens()) {
// obtain and print information about the instance you are connected to
const info = await getInfo();
console.log(`newFactoryHelperAdminLogin: Logged in to: ${info.host}`);
console.log(
`newFactoryHelperAdminLogin: Logged in as: ${info.authenticatedSubject}`
);
console.log(
`newFactoryHelperAdminLogin: Using bearer token: \n${info.bearerToken}`
);
} else {
console.log('error getting tokens');
}
console.log(
`********** END ************ newFactoryHelperAdminLogin **********\n`
);
}
newFactoryHelperAdminLogin();
/**
* create a new instance using factory function and login as service account
*/
async function newFactoryServiceAccountLogin() {
console.log(
`\n********** BEGIN ********** newFactoryServiceAccountLogin **********`
);
const myFrodo2 = frodo.createInstance({
host: host2, // host base URL
serviceAccountId: said2, // service account id
serviceAccountJwk: JSON.parse(jwk2), // service account jwk as a JwkRsa object
});
// destructure default instance for easier use of library functions
const { getTokens } = myFrodo2.login;
const { getInfo } = myFrodo2.info;
// login and obtain tokens
if (await getTokens()) {
// obtain and print information about the instance you are connected to
const info = await getInfo();
console.log(`newFactoryServiceAccountLogin: Logged in to: ${info.host}`);
console.log(
`newFactoryServiceAccountLogin: Logged in as: ${info.authenticatedSubject}`
);
console.log(
`newFactoryServiceAccountLogin: Using bearer token: \n${info.bearerToken}`
);
} else {
console.log('error getting tokens');
}
console.log(
`********** END ************ newFactoryServiceAccountLogin **********\n`
);
}
newFactoryServiceAccountLogin();
/**
* create a new instance using factory function and login as admin user
*/
async function newFactoryAdminLogin() {
console.log(`\n********** BEGIN ********** newFactoryAdminLogin **********`);
const myFrodo2 = frodo.createInstance({
host: host2, // host base URL
username: user2, // admin username
password: pass2, // admin password
});
// destructure default instance for easier use of library functions
const { getTokens } = myFrodo2.login;
const { getInfo } = myFrodo2.info;
// login and obtain tokens
if (await getTokens()) {
// obtain and print information about the instance you are connected to
const info = await getInfo();
console.log(`newFactoryAdminLogin: Logged in to: ${info.host}`);
console.log(
`newFactoryAdminLogin: Logged in as: ${info.authenticatedSubject}`
);
console.log(
`newFactoryAdminLogin: Using bearer token: \n${info.bearerToken}`
);
} else {
console.log('error getting tokens');
}
console.log(`********** END ************ newFactoryAdminLogin **********\n`);
}
newFactoryAdminLogin();
/**
* use default instance and state and login as service account
*/
async function defaultServiceAccountLogin() {
console.log(
`\n********** BEGIN ********** defaultServiceAccountLogin **********`
);
// destructure default instance for easier use of library functions
const { getTokens } = frodo.login;
const { getInfo } = frodo.info;
// The default state instance is a singleton. It is best to reset() the state before
// logging in to avoid interference. In this particular case no previous method in
// this file is using the default state but it is good practice to call reset() if
// you are not sure and need a clean state.
state.reset();
// host base URL
state.setHost(host0);
// service account id
state.setServiceAccountId(said0);
// service account jwk as a JwkRsa object
state.setServiceAccountJwk(JSON.parse(jwk0));
// login and obtain tokens
if (await getTokens()) {
// obtain and print information about the instance you are connected to
const info = await getInfo();
console.log(`defaultServiceAccountLogin: Logged in to: ${info.host}`);
console.log(
`defaultServiceAccountLogin: Logged in as: ${info.authenticatedSubject}`
);
console.log(
`defaultServiceAccountLogin: Using bearer token: \n${info.bearerToken}`
);
} else {
console.log('error getting tokens');
}
console.log(
`********** END ************ defaultServiceAccountLogin **********\n`
);
}
defaultServiceAccountLogin();
/**
* use default instance and state
*/
async function defaultAdminLogin() {
console.log(`\n********** BEGIN ********** defaultAdminLogin **********`);
// destructure default instance for easier use of library functions
const { getTokens } = frodo.login;
const { getInfo } = frodo.info;
// The default state instance is a singleton. It is best to reset() the state before
// logging in to avoid interference. In this particular case the previous method in
// this file is populating the state with a service account login and the admin login
// could possibly fail.
state.reset();
// host base URL
state.setHost(host0);
// username of an admin user
state.setUsername(user0);
// password of the admin user
state.setPassword(pass0);
// login and obtain tokens
if (await getTokens()) {
// obtain and print information about the instance you are connected to
const info = await getInfo();
console.log(`defaultAdminLogin: Logged in to: ${info.host}`);
console.log(
`defaultAdminLogin: Logged in as: ${info.authenticatedSubject}`
);
console.log(`defaultAdminLogin: Using bearer token: \n${info.bearerToken}`);
} else {
console.log('error getting tokens');
}
console.log(`********** END ************ defaultAdminLogin **********\n`);
}
defaultAdminLogin();