@luizleon/sf.prefeiturasp.vuecomponents 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,10 @@
1
- declare const _sfc_main: import("vue").DefineComponent<{}, {
2
- readonly ThemeToggleBase: {
3
- readonly storedTheme: "light" | "dark" | null;
4
- readonly IsDark: boolean;
5
- Toggle(): void;
6
- EnableDarkMode(): void;
7
- EnableLightMode(): void;
8
- SetInitialTheme(): void;
9
- };
10
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
11
- export default _sfc_main;
1
+ declare class ThemeToggle {
2
+ get storedTheme(): "light" | "dark" | null;
3
+ get IsDark(): boolean;
4
+ Toggle(): void;
5
+ EnableDarkMode(): void;
6
+ EnableLightMode(): void;
7
+ SetInitialTheme(): void;
8
+ }
9
+ export declare const ThemeToggleBase: ThemeToggle;
10
+ export {};
@@ -0,0 +1,671 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright 2017 Brett Epps <https://github.com/eppsilon>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
7
+ * associated documentation files (the "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
10
+ * following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
13
+ * portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16
+ * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ */
21
+ export type KeycloakOnLoad = "login-required" | "check-sso";
22
+ export type KeycloakResponseMode = "query" | "fragment";
23
+ export type KeycloakResponseType =
24
+ | "code"
25
+ | "id_token token"
26
+ | "code id_token token";
27
+ export type KeycloakFlow = "standard" | "implicit" | "hybrid";
28
+ export type KeycloakPkceMethod = "S256";
29
+
30
+ export interface KeycloakConfig {
31
+ /**
32
+ * URL to the Keycloak server, for example: http://keycloak-server/auth
33
+ */
34
+ url?: string;
35
+ /**
36
+ * Name of the realm, for example: 'myrealm'
37
+ */
38
+ realm: string;
39
+ /**
40
+ * Client identifier, example: 'myapp'
41
+ */
42
+ clientId: string;
43
+ }
44
+
45
+ export interface Acr {
46
+ /**
47
+ * Array of values, which will be used inside ID Token `acr` claim sent inside the `claims` parameter to Keycloak server during login.
48
+ * Values should correspond to the ACR levels defined in the ACR to Loa mapping for realm or client or to the numbers (levels) inside defined
49
+ * Keycloak authentication flow. See section 5.5.1 of OIDC 1.0 specification for the details.
50
+ */
51
+ values: string[];
52
+ /**
53
+ * This parameter specifies if ACR claims is considered essential or not.
54
+ */
55
+ essential: boolean;
56
+ }
57
+
58
+ export interface KeycloakInitOptions {
59
+ /**
60
+ * Adds a [cryptographic nonce](https://en.wikipedia.org/wiki/Cryptographic_nonce)
61
+ * to verify that the authentication response matches the request.
62
+ * @default true
63
+ */
64
+ useNonce?: boolean;
65
+
66
+ /**
67
+ *
68
+ * Allow usage of different types of adapters or a custom adapter to make Keycloak work in different environments.
69
+ *
70
+ * The following options are supported:
71
+ * - `default` - Use default APIs that are available in browsers.
72
+ * - `cordova` - Use a WebView in Cordova.
73
+ * - `cordova-native` - Use Cordova native APIs, this is recommended over `cordova`.
74
+ *
75
+ * It's also possible to pass in a custom adapter for the environment you are running Keycloak in. In order to do so extend the `KeycloakAdapter` interface and implement the methods that are defined there.
76
+ *
77
+ * For example:
78
+ *
79
+ * ```ts
80
+ * import Keycloak, { KeycloakAdapter } from 'keycloak-js';
81
+ *
82
+ * // Implement the 'KeycloakAdapter' interface so that all required methods are guaranteed to be present.
83
+ * const MyCustomAdapter: KeycloakAdapter = {
84
+ * login(options) {
85
+ * // Write your own implementation here.
86
+ * }
87
+ *
88
+ * // The other methods go here...
89
+ * };
90
+ *
91
+ * const keycloak = new Keycloak();
92
+ *
93
+ * keycloak.init({
94
+ * adapter: MyCustomAdapter,
95
+ * });
96
+ * ```
97
+ */
98
+ adapter?:
99
+ | "default"
100
+ | "cordova"
101
+ | "cordova-native"
102
+ | KeycloakAdapter;
103
+
104
+ /**
105
+ * Specifies an action to do on load.
106
+ */
107
+ onLoad?: KeycloakOnLoad;
108
+
109
+ /**
110
+ * Set an initial value for the token.
111
+ */
112
+ token?: string;
113
+
114
+ /**
115
+ * Set an initial value for the refresh token.
116
+ */
117
+ refreshToken?: string;
118
+
119
+ /**
120
+ * Set an initial value for the id token (only together with `token` or
121
+ * `refreshToken`).
122
+ */
123
+ idToken?: string;
124
+
125
+ /**
126
+ * Set an initial value for skew between local time and Keycloak server in
127
+ * seconds (only together with `token` or `refreshToken`).
128
+ */
129
+ timeSkew?: number;
130
+
131
+ /**
132
+ * Set to enable/disable monitoring login state.
133
+ * @default true
134
+ */
135
+ checkLoginIframe?: boolean;
136
+
137
+ /**
138
+ * Set the interval to check login state (in seconds).
139
+ * @default 5
140
+ */
141
+ checkLoginIframeInterval?: number;
142
+
143
+ /**
144
+ * Set the OpenID Connect response mode to send to Keycloak upon login.
145
+ * @default fragment After successful authentication Keycloak will redirect
146
+ * to JavaScript application with OpenID Connect parameters
147
+ * added in URL fragment. This is generally safer and
148
+ * recommended over query.
149
+ */
150
+ responseMode?: KeycloakResponseMode;
151
+
152
+ /**
153
+ * Specifies a default uri to redirect to after login or logout.
154
+ * This is currently supported for adapter 'cordova-native' and 'default'
155
+ */
156
+ redirectUri?: string;
157
+
158
+ /**
159
+ * Specifies an uri to redirect to after silent check-sso.
160
+ * Silent check-sso will only happen, when this redirect uri is given and
161
+ * the specified uri is available within the application.
162
+ */
163
+ silentCheckSsoRedirectUri?: string;
164
+
165
+ /**
166
+ * Specifies whether the silent check-sso should fallback to "non-silent"
167
+ * check-sso when 3rd party cookies are blocked by the browser. Defaults
168
+ * to true.
169
+ */
170
+ silentCheckSsoFallback?: boolean;
171
+
172
+ /**
173
+ * Set the OpenID Connect flow.
174
+ * @default standard
175
+ */
176
+ flow?: KeycloakFlow;
177
+
178
+ /**
179
+ * Configures the Proof Key for Code Exchange (PKCE) method to use.
180
+ * The currently allowed method is 'S256'.
181
+ * If not configured, PKCE will not be used.
182
+ */
183
+ pkceMethod?: KeycloakPkceMethod;
184
+
185
+ /**
186
+ * Configures the 'acr_values' query param in compliance with section 3.1.2.1
187
+ * of the OIDC 1.0 specification.
188
+ * Used to tell Keycloak what level of authentication the user needs.
189
+ */
190
+ acrValues?: string;
191
+
192
+ /**
193
+ * Enables logging messages from Keycloak to the console.
194
+ * @default false
195
+ */
196
+ enableLogging?: boolean;
197
+
198
+ /**
199
+ * Set the default scope parameter to the login endpoint. Use a space-delimited list of scopes.
200
+ * Note that the scope 'openid' will be always be added to the list of scopes by the adapter.
201
+ * Note that the default scope specified here is overwritten if the `login()` options specify scope explicitly.
202
+ */
203
+ scope?: string;
204
+
205
+ /**
206
+ * Configures how long will Keycloak adapter wait for receiving messages from server in ms. This is used,
207
+ * for example, when waiting for response of 3rd party cookies check.
208
+ *
209
+ * @default 10000
210
+ */
211
+ messageReceiveTimeout?: number;
212
+
213
+ /**
214
+ * When onLoad is 'login-required', sets the 'ui_locales' query param in compliance with section 3.1.2.1
215
+ * of the OIDC 1.0 specification.
216
+ */
217
+ locale?: string;
218
+ }
219
+
220
+ export interface KeycloakLoginOptions {
221
+ /**
222
+ * Specifies the scope parameter for the login url
223
+ * The scope 'openid' will be added to the scope if it is missing or undefined.
224
+ */
225
+ scope?: string;
226
+
227
+ /**
228
+ * Specifies the uri to redirect to after login.
229
+ */
230
+ redirectUri?: string;
231
+
232
+ /**
233
+ * By default the login screen is displayed if the user is not logged into
234
+ * Keycloak. To only authenticate to the application if the user is already
235
+ * logged in and not display the login page if the user is not logged in, set
236
+ * this option to `'none'`. To always require re-authentication and ignore
237
+ * SSO, set this option to `'login'`. To always prompt the user for consent,
238
+ * set this option to `'consent'`. This ensures that consent is requested,
239
+ * even if it has been given previously.
240
+ */
241
+ prompt?: "none" | "login" | "consent";
242
+
243
+ /**
244
+ * If value is `'register'` then user is redirected to registration page,
245
+ * otherwise to login page.
246
+ */
247
+ action?: string;
248
+
249
+ /**
250
+ * Used just if user is already authenticated. Specifies maximum time since
251
+ * the authentication of user happened. If user is already authenticated for
252
+ * longer time than `'maxAge'`, the SSO is ignored and he will need to
253
+ * authenticate again.
254
+ */
255
+ maxAge?: number;
256
+
257
+ /**
258
+ * Used to pre-fill the username/email field on the login form.
259
+ */
260
+ loginHint?: string;
261
+
262
+ /**
263
+ * Sets the `acr` claim of the ID token sent inside the `claims` parameter. See section 5.5.1 of the OIDC 1.0 specification.
264
+ */
265
+ acr?: Acr;
266
+
267
+ /**
268
+ * Configures the 'acr_values' query param in compliance with section 3.1.2.1
269
+ * of the OIDC 1.0 specification.
270
+ * Used to tell Keycloak what level of authentication the user needs.
271
+ */
272
+ acrValues?: string;
273
+
274
+ /**
275
+ * Used to tell Keycloak which IDP the user wants to authenticate with.
276
+ */
277
+ idpHint?: string;
278
+
279
+ /**
280
+ * Sets the 'ui_locales' query param in compliance with section 3.1.2.1
281
+ * of the OIDC 1.0 specification.
282
+ */
283
+ locale?: string;
284
+
285
+ /**
286
+ * Specifies arguments that are passed to the Cordova in-app-browser (if applicable).
287
+ * Options 'hidden' and 'location' are not affected by these arguments.
288
+ * All available options are defined at https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/.
289
+ * Example of use: { zoom: "no", hardwareback: "yes" }
290
+ */
291
+ cordovaOptions?: { [optionName: string]: string };
292
+ }
293
+
294
+ export interface KeycloakLogoutOptions {
295
+ /**
296
+ * Specifies the uri to redirect to after logout.
297
+ */
298
+ redirectUri?: string;
299
+ }
300
+
301
+ export interface KeycloakRegisterOptions
302
+ extends Omit<KeycloakLoginOptions, "action"> {}
303
+
304
+ export interface KeycloakAccountOptions {
305
+ /**
306
+ * Specifies the uri to redirect to when redirecting back to the application.
307
+ */
308
+ redirectUri?: string;
309
+ }
310
+ export interface KeycloakError {
311
+ error: string;
312
+ error_description: string;
313
+ }
314
+
315
+ export interface KeycloakAdapter {
316
+ login(options?: KeycloakLoginOptions): Promise<void>;
317
+ logout(options?: KeycloakLogoutOptions): Promise<void>;
318
+ register(options?: KeycloakRegisterOptions): Promise<void>;
319
+ accountManagement(): Promise<void>;
320
+ redirectUri(
321
+ options: { redirectUri: string },
322
+ encodeHash: boolean
323
+ ): string;
324
+ }
325
+
326
+ export interface KeycloakProfile {
327
+ id?: string;
328
+ username?: string;
329
+ email?: string;
330
+ firstName?: string;
331
+ lastName?: string;
332
+ enabled?: boolean;
333
+ emailVerified?: boolean;
334
+ totp?: boolean;
335
+ createdTimestamp?: number;
336
+ }
337
+
338
+ export interface KeycloakTokenParsed {
339
+ iss?: string;
340
+ sub?: string;
341
+ aud?: string;
342
+ exp?: number;
343
+ iat?: number;
344
+ auth_time?: number;
345
+ nonce?: string;
346
+ acr?: string;
347
+ amr?: string;
348
+ azp?: string;
349
+ session_state?: string;
350
+ realm_access?: KeycloakRoles;
351
+ resource_access?: KeycloakResourceAccess;
352
+ [key: string]: any; // Add other attributes here.
353
+ }
354
+
355
+ export interface KeycloakResourceAccess {
356
+ [key: string]: KeycloakRoles;
357
+ }
358
+
359
+ export interface KeycloakRoles {
360
+ roles: string[];
361
+ }
362
+
363
+ /**
364
+ * @deprecated Instead of importing 'KeycloakInstance' you can directly as a type.
365
+ */
366
+ export type KeycloakInstance = Keycloak;
367
+
368
+ /**
369
+ * A client for the Keycloak authentication server.
370
+ * @see {@link https://keycloak.gitbooks.io/securing-client-applications-guide/content/topics/oidc/javascript-adapter.html|Keycloak JS adapter documentation}
371
+ */
372
+ declare class Keycloak {
373
+ /**
374
+ * Creates a new Keycloak client instance.
375
+ * @param config A configuration object or path to a JSON config file.
376
+ */
377
+ constructor(config?: KeycloakConfig | string);
378
+
379
+ /**
380
+ * Is true if the user is authenticated, false otherwise.
381
+ */
382
+ authenticated?: boolean;
383
+
384
+ /**
385
+ * The user id.
386
+ */
387
+ subject?: string;
388
+
389
+ /**
390
+ * Response mode passed in init (default value is `'fragment'`).
391
+ */
392
+ responseMode?: KeycloakResponseMode;
393
+
394
+ /**
395
+ * Response type sent to Keycloak with login requests. This is determined
396
+ * based on the flow value used during initialization, but can be overridden
397
+ * by setting this value.
398
+ */
399
+ responseType?: KeycloakResponseType;
400
+
401
+ /**
402
+ * Flow passed in init.
403
+ */
404
+ flow?: KeycloakFlow;
405
+
406
+ /**
407
+ * The realm roles associated with the token.
408
+ */
409
+ realmAccess?: KeycloakRoles;
410
+
411
+ /**
412
+ * The resource roles associated with the token.
413
+ */
414
+ resourceAccess?: KeycloakResourceAccess;
415
+
416
+ /**
417
+ * The base64 encoded token that can be sent in the Authorization header in
418
+ * requests to services.
419
+ */
420
+ token?: string;
421
+
422
+ /**
423
+ * The parsed token as a JavaScript object.
424
+ */
425
+ tokenParsed?: KeycloakTokenParsed;
426
+
427
+ /**
428
+ * The base64 encoded refresh token that can be used to retrieve a new token.
429
+ */
430
+ refreshToken?: string;
431
+
432
+ /**
433
+ * The parsed refresh token as a JavaScript object.
434
+ */
435
+ refreshTokenParsed?: KeycloakTokenParsed;
436
+
437
+ /**
438
+ * The base64 encoded ID token.
439
+ */
440
+ idToken?: string;
441
+
442
+ /**
443
+ * The parsed id token as a JavaScript object.
444
+ */
445
+ idTokenParsed?: KeycloakTokenParsed;
446
+
447
+ /**
448
+ * The estimated time difference between the browser time and the Keycloak
449
+ * server in seconds. This value is just an estimation, but is accurate
450
+ * enough when determining if a token is expired or not.
451
+ */
452
+ timeSkew?: number;
453
+
454
+ /**
455
+ * @private Undocumented.
456
+ */
457
+ loginRequired?: boolean;
458
+
459
+ /**
460
+ * @private Undocumented.
461
+ */
462
+ authServerUrl?: string;
463
+
464
+ /**
465
+ * @private Undocumented.
466
+ */
467
+ realm?: string;
468
+
469
+ /**
470
+ * @private Undocumented.
471
+ */
472
+ clientId?: string;
473
+
474
+ /**
475
+ * @private Undocumented.
476
+ */
477
+ redirectUri?: string;
478
+
479
+ /**
480
+ * @private Undocumented.
481
+ */
482
+ sessionId?: string;
483
+
484
+ /**
485
+ * @private Undocumented.
486
+ */
487
+ profile?: KeycloakProfile;
488
+
489
+ /**
490
+ * @private Undocumented.
491
+ */
492
+ userInfo?: {}; // KeycloakUserInfo;
493
+
494
+ /**
495
+ * Called when the adapter is initialized.
496
+ */
497
+ onReady?(authenticated?: boolean): void;
498
+
499
+ /**
500
+ * Called when a user is successfully authenticated.
501
+ */
502
+ onAuthSuccess?(): void;
503
+
504
+ /**
505
+ * Called if there was an error during authentication.
506
+ */
507
+ onAuthError?(errorData: KeycloakError): void;
508
+
509
+ /**
510
+ * Called when the token is refreshed.
511
+ */
512
+ onAuthRefreshSuccess?(): void;
513
+
514
+ /**
515
+ * Called if there was an error while trying to refresh the token.
516
+ */
517
+ onAuthRefreshError?(): void;
518
+
519
+ /**
520
+ * Called if the user is logged out (will only be called if the session
521
+ * status iframe is enabled, or in Cordova mode).
522
+ */
523
+ onAuthLogout?(): void;
524
+
525
+ /**
526
+ * Called when the access token is expired. If a refresh token is available
527
+ * the token can be refreshed with Keycloak#updateToken, or in cases where
528
+ * it's not (ie. with implicit flow) you can redirect to login screen to
529
+ * obtain a new access token.
530
+ */
531
+ onTokenExpired?(): void;
532
+
533
+ /**
534
+ * Called when a AIA has been requested by the application.
535
+ */
536
+ onActionUpdate?(status: "success" | "cancelled" | "error"): void;
537
+
538
+ /**
539
+ * Called to initialize the adapter.
540
+ * @param initOptions Initialization options.
541
+ * @returns A promise to set functions to be invoked on success or error.
542
+ */
543
+ init(initOptions: KeycloakInitOptions): Promise<boolean>;
544
+
545
+ /**
546
+ * Redirects to login form.
547
+ * @param options Login options.
548
+ */
549
+ login(options?: KeycloakLoginOptions): Promise<void>;
550
+
551
+ /**
552
+ * Redirects to logout.
553
+ * @param options Logout options.
554
+ */
555
+ logout(options?: KeycloakLogoutOptions): Promise<void>;
556
+
557
+ /**
558
+ * Redirects to registration form.
559
+ * @param options The options used for the registration.
560
+ */
561
+ register(options?: KeycloakRegisterOptions): Promise<void>;
562
+
563
+ /**
564
+ * Redirects to the Account Management Console.
565
+ */
566
+ accountManagement(): Promise<void>;
567
+
568
+ /**
569
+ * Returns the URL to login form.
570
+ * @param options Supports same options as Keycloak#login.
571
+ */
572
+ createLoginUrl(options?: KeycloakLoginOptions): string;
573
+
574
+ /**
575
+ * Returns the URL to logout the user.
576
+ * @param options Logout options.
577
+ */
578
+ createLogoutUrl(options?: KeycloakLogoutOptions): string;
579
+
580
+ /**
581
+ * Returns the URL to registration page.
582
+ * @param options The options used for creating the registration URL.
583
+ */
584
+ createRegisterUrl(options?: KeycloakRegisterOptions): string;
585
+
586
+ /**
587
+ * Returns the URL to the Account Management Console.
588
+ * @param options The options used for creating the account URL.
589
+ */
590
+ createAccountUrl(options?: KeycloakAccountOptions): string;
591
+
592
+ /**
593
+ * Returns true if the token has less than `minValidity` seconds left before
594
+ * it expires.
595
+ * @param minValidity If not specified, `0` is used.
596
+ */
597
+ isTokenExpired(minValidity?: number): boolean;
598
+
599
+ /**
600
+ * If the token expires within `minValidity` seconds, the token is refreshed.
601
+ * If the session status iframe is enabled, the session status is also
602
+ * checked.
603
+ * @param minValidity If not specified, `5` is used.
604
+ * @returns A promise to set functions that can be invoked if the token is
605
+ * still valid, or if the token is no longer valid.
606
+ * @example
607
+ * ```js
608
+ * keycloak.updateToken(5).then(function(refreshed) {
609
+ * if (refreshed) {
610
+ * alert('Token was successfully refreshed');
611
+ * } else {
612
+ * alert('Token is still valid');
613
+ * }
614
+ * }).catch(function() {
615
+ * alert('Failed to refresh the token, or the session has expired');
616
+ * });
617
+ */
618
+ updateToken(minValidity?: number): Promise<boolean>;
619
+
620
+ /**
621
+ * Clears authentication state, including tokens. This can be useful if
622
+ * the application has detected the session was expired, for example if
623
+ * updating token fails. Invoking this results in Keycloak#onAuthLogout
624
+ * callback listener being invoked.
625
+ */
626
+ clearToken(): void;
627
+
628
+ /**
629
+ * Método para setar os tokens. Como o adaptador original não disponibiliza esta função,
630
+ * alteramos o código para permitir que seja chamada.
631
+ * @see keycloak.js
632
+ */
633
+
634
+ setToken(
635
+ token: any,
636
+ refreshToken: any,
637
+ idToken: any,
638
+ timeLocal?: number
639
+ ): void;
640
+
641
+ /**
642
+ * Returns true if the token has the given realm role.
643
+ * @param role A realm role name.
644
+ */
645
+ hasRealmRole(role: string): boolean;
646
+
647
+ /**
648
+ * Returns true if the token has the given role for the resource.
649
+ * @param role A role name.
650
+ * @param resource If not specified, `clientId` is used.
651
+ */
652
+ hasResourceRole(role: string, resource?: string): boolean;
653
+
654
+ /**
655
+ * Loads the user's profile.
656
+ * @returns A promise to set functions to be invoked on success or error.
657
+ */
658
+ loadUserProfile(): Promise<KeycloakProfile>;
659
+
660
+ /**
661
+ * @private Undocumented.
662
+ */
663
+ loadUserInfo(): Promise<{}>;
664
+ }
665
+
666
+ export default Keycloak;
667
+
668
+ /**
669
+ * @deprecated The 'Keycloak' namespace is deprecated, use named imports instead.
670
+ */
671
+ export as namespace Keycloak;