auth0-actions 0.1.0 → 0.2.0

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.
package/index.ts DELETED
@@ -1,842 +0,0 @@
1
-
2
- //#region Events
3
-
4
- /**
5
- *
6
- */
7
- export interface CredentialsExchangeEvent<TSecret, TClientMetadata, TRequest extends CredentialsExchangeRequestBody> {
8
-
9
- /** An object containing information describing the authorization granted to the user who is logging in. */
10
- accessToken?: AccessToken;
11
-
12
- /** */
13
- client?: Client<TClientMetadata>;
14
-
15
- /** */
16
- request?: RequestBase<TRequest>;
17
-
18
- /** */
19
- resource_server?: ResourceServer;
20
-
21
- /** */
22
- secrets?: TSecret;
23
-
24
- /** */
25
- tenant?: Tenant;
26
-
27
- /** */
28
- transaction?: TransactionBase;
29
-
30
- }
31
-
32
- /**
33
- *
34
- */
35
- export interface PostLoginEvent<TSecret, TClientMetadata, TAppMetadata, TUserMetadata> {
36
-
37
- /** Details about authentication signals obtained during the login flow. */
38
- authentication?: AuthenticationInfoWithRiskAssessment
39
-
40
- /** An object containing information describing the authorization granted to the user who is logging in. */
41
- authorization?: AuthorizationInfo;
42
-
43
- /** */
44
- client?: Client<TClientMetadata>;
45
-
46
- /** */
47
- configuration?: Configuration;
48
-
49
- /** */
50
- connection?: Connection;
51
-
52
- /** */
53
- organization?: Organization;
54
-
55
- /** */
56
- request?: Request<any>;
57
-
58
- /** */
59
- resource_server?: ResourceServer;
60
-
61
- /** */
62
- secrets?: TSecret;
63
-
64
- /** */
65
- stats?: Stats;
66
-
67
- /** */
68
- tenant?: Tenant;
69
-
70
- /** */
71
- transaction?: Transaction;
72
-
73
- /** */
74
- user?: UserBase<TAppMetadata, TUserMetadata>;
75
- }
76
-
77
- /**
78
- *
79
- */
80
- interface AccessToken {
81
-
82
- customClaims: any;
83
- scope: string[];
84
- }
85
-
86
- /**
87
- * Details about authentication signals obtained during the login flow.
88
- */
89
- interface AuthenticationInfoWithRiskAssessment {
90
-
91
- /** Contains the authentication methods a user has completed during their session. */
92
- methods: AuthenticationMethod[];
93
-
94
- riskAssessment?: RiskAssessmentSummary;
95
- }
96
-
97
- /**
98
- *
99
- */
100
- interface AuthenticationMethod {
101
- /**
102
- * The name of the first factor that was completed. Values include the following:
103
- */
104
- name: AuthenticationMethods | string;
105
-
106
- timestamp: string;
107
-
108
- /* A specific MFA factor. Only present when name is set to 'mfa'. */
109
- type: string;
110
- }
111
-
112
- /**
113
- *
114
- */
115
- enum AuthenticationMethods {
116
-
117
- /** A social or enterprise connection was used to authenticate the user as the first factor. */
118
- federated = 'federated',
119
-
120
- /** */
121
- passkey = 'passkey',
122
-
123
- /** A database connection was used to authenticate the user as the first factor. */
124
- pwd = 'pwd',
125
-
126
- /** A Passwordless SMS connection was used to authenticate the user as the first factor. */
127
- sms = 'sms',
128
-
129
- /** A Passwordless Email connection was used to authenticate the user as the first factor or verify email for password reset. */
130
- email = 'email',
131
-
132
- /** */
133
- mfa = 'mfa',
134
-
135
- /* "Used for internal testing. */
136
- mock = 'mock'
137
- }
138
-
139
- /**
140
- *
141
- */
142
- interface AuthorizationInfo {
143
- roles: string[];
144
- }
145
-
146
- /**
147
- *
148
- */
149
- interface Client<TMetadata> {
150
-
151
- /** The client id of the application the user is logging in to. */
152
- clientId: string;
153
-
154
- /** An object for holding other application properties. */
155
- metadata: TMetadata
156
-
157
- /** The name of the application (as defined in the Dashboard). */
158
- name: string;
159
-
160
- /** */
161
- strategy: string;
162
- }
163
-
164
- /**
165
- *
166
- */
167
- interface Configuration {
168
-
169
- }
170
-
171
- /**
172
- *
173
- */
174
- interface Connection {
175
-
176
- /**
177
- * The connection's identifier
178
- */
179
- id: string;
180
-
181
- /**
182
- * Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed.
183
- */
184
- metadata: { [key: string]: any };
185
-
186
- /**
187
- * The name of the connection
188
- */
189
- name: string;
190
-
191
- /**
192
- * The type of the connection, related to the identity provider
193
- */
194
- strategy: ConnectionStrategies;
195
-
196
- }
197
-
198
- /**
199
- *
200
- */
201
- enum ConnectionStrategies {
202
- ad = 'ad',
203
- adfs = 'adfs',
204
- amazon = 'amazon',
205
- apple = 'apple',
206
- dropbox = 'dropbox',
207
- bitbucket = 'bitbucket',
208
- aol = 'aol',
209
- auth0_oidc = 'auth0-oidc',
210
- auth0 = 'auth0',
211
- baidu = 'baidu',
212
- bitly = 'bitly',
213
- box = 'box',
214
- custom = 'custom',
215
- daccount = 'daccount',
216
- dwolla = 'dwolla',
217
- email = 'email',
218
- evernote_sandbox = 'evernote-sandbox',
219
- evernote = 'evernote',
220
- exact = 'exact',
221
- facebook = 'facebook',
222
- fitbit = 'fitbit',
223
- flickr = 'flickr',
224
- github = 'github',
225
- google_apps = 'google-apps',
226
- google_oauth2 = 'google-oauth2',
227
- instagram = 'instagram',
228
- ip = 'ip',
229
- line = 'line',
230
- linkedin = 'linkedin',
231
- miicard = 'miicard',
232
- oauth1 = 'oauth1',
233
- oauth2 = 'oauth2',
234
- office365 = 'office365',
235
- oidc = 'oidc',
236
- okta = 'okta',
237
- paypal = 'paypal',
238
- paypal_sandbox = 'paypal-sandbox',
239
- pingfederate = 'pingfederate',
240
- planningcenter = 'planningcenter',
241
- renren = 'renren',
242
- salesforce_community = 'salesforce-community',
243
- salesforce_sandbox = 'salesforce-sandbox',
244
- salesforce = 'salesforce',
245
- samlp = 'samlp',
246
- sharepoint = 'sharepoint',
247
- shopify = 'shopify',
248
- sms = 'sms',
249
- soundcloud = 'soundcloud',
250
- thecity_sandbox = 'thecity-sandbox',
251
- thecity = 'thecity',
252
- thirtysevensignals = 'thirtysevensignals',
253
- twitter = 'twitter',
254
- untappd = 'untappd',
255
- vkontakte = 'vkontakte',
256
- waad = 'waad',
257
- weibo = 'weibo',
258
- windowslive = 'windowslive',
259
- wordpress = 'wordpress',
260
- yahoo = 'yahoo',
261
- yammer = 'yammer',
262
- yandex = 'yandex',
263
- }
264
-
265
- /**
266
- *
267
- */
268
- interface CredentialsExchangeRequestBody {
269
- audience: string;
270
- client_id: string;
271
- client_secret: string;
272
- grant_type: string;
273
- }
274
-
275
- /**
276
- *
277
- */
278
- interface GeoIP {
279
- cityName: string
280
- continentCode: string
281
- countryCode3: string
282
- countryCode: string
283
- countryName: string
284
- latitude: number
285
- longitude: number
286
- subdivisionCode: string
287
- subdivisionName: string
288
- timeZone: string
289
- }
290
-
291
- /**
292
- *
293
- */
294
- interface Identity {
295
- connection: string
296
- isSocial: boolean
297
- provider: string
298
- userId: string
299
- user_id: string
300
- }
301
-
302
- /**
303
- *
304
- */
305
- interface IPAddressDetails {
306
- category: string;
307
- ip: string;
308
- matches: string;
309
- source: string;
310
- }
311
-
312
- /**
313
- *
314
- */
315
- interface NewDeviceDetails {
316
- device: string;
317
- useragent: string;
318
- }
319
-
320
- /**
321
- *
322
- */
323
- interface Organization {
324
-
325
- /* The friendly name of the Organization. */
326
- display_name: string;
327
-
328
- /**
329
- * The Organization's identifier.
330
- */
331
- id: string;
332
-
333
- /**
334
- * Metadata associated with the Organization.
335
- */
336
- metadata: { [key: string]: any };
337
-
338
- /**
339
- * The name of the Organization.
340
- */
341
- name: string;
342
-
343
- }
344
-
345
- /**
346
- *
347
- */
348
- interface Query {
349
- audience: string
350
- client_id: string
351
- code_challenge: string
352
- code_challenge_method: string
353
- prompt: string
354
- redirect_uri: string
355
- response_mode: string
356
- response_type: string
357
- scope: string
358
- state: string
359
- }
360
-
361
- /**
362
- *
363
- */
364
- interface Request<TBody> extends RequestBase<TBody> {
365
- query: Query;
366
- }
367
-
368
- /**
369
- *
370
- */
371
- interface RequestBase<TBody> {
372
- body: TBody;
373
- geoip: GeoIP;
374
- hostname: string;
375
- ip: string;
376
- method: string;
377
- user_agent: string;
378
- }
379
-
380
- /**
381
- *
382
- */
383
- interface ResourceServer {
384
- identifier: string
385
- }
386
-
387
- interface RiskAssessmentBase {
388
-
389
- code: string;
390
-
391
- confidence: string;
392
- }
393
-
394
- /**
395
- *
396
- */
397
- interface RiskAssessmentSummary {
398
- assessments: RiskAssessments;
399
- confidence: "low" | "medium" | "high" | "neutral";
400
- version: string;
401
- }
402
-
403
- /**
404
- *
405
- */
406
- interface RiskAssessments {
407
-
408
- ImpossibleTravel: RiskAssessmentBase;
409
-
410
- NewDevice: RiskAssessmentWithDetails<NewDeviceDetails>
411
-
412
- UntrustedIP: RiskAssessmentWithDetails<IPAddressDetails>
413
- }
414
-
415
- /**
416
- *
417
- */
418
- interface RiskAssessmentWithDetails<TDetails> {
419
-
420
- details: TDetails;
421
- }
422
-
423
- /**
424
- *
425
- */
426
- interface Stats {
427
- logins_count: number
428
- }
429
-
430
- /**
431
- *
432
- */
433
- interface Tenant {
434
- id: string
435
- }
436
-
437
- /**
438
- *
439
- */
440
- interface Transaction extends TransactionBase {
441
- acr_values: any[]
442
- linking_id?: string
443
- locale: string
444
- login_hint?: string
445
- prompt: string[]
446
- protocol?: TransactionProtocols
447
- redirect_uri?: string
448
- response_mode?: string
449
- response_type?: string[]
450
- state?: string
451
- ui_locales: string[]
452
- }
453
-
454
- /**
455
- *
456
- */
457
- interface TransactionBase {
458
- requested_scopes: string[]
459
- }
460
-
461
- /**
462
- *
463
- */
464
- enum TransactionProtocols {
465
- oidc_basic = 'oidc-basic-profile',
466
- /* Allows your application to have immediate access to an ID token while still providing for secure and safe retrieval of access and refresh tokens. */
467
- oidc_hybrid = 'oidc-hybrid',
468
- oidc_implicit = 'oidc-implicit-profile',
469
- samlp = 'samlp',
470
- wsfed = 'wsfed',
471
- wstrust_usernamemixed = 'wstrust-usernamemixed',
472
- oauth2_device_code = 'oauth2-device-code',
473
- oauth2_resource_owner = 'oauth2-resource-owner',
474
- oauth2_jwt_bearer = 'oauth2-resource-owner-jwt-bearer',
475
- oauth2_password = 'oauth2-password',
476
- oauth2_access_token = 'oauth2-access-token',
477
- oauth2_refresh_token = 'oauth2-refresh-token',
478
- oauth2_token_exchange = 'oauth2-token-exchange',
479
- }
480
-
481
- /**
482
- *
483
- */
484
- export interface UserBase<TAppMetadata, TUserMetadata> {
485
-
486
- /** Data that the user has read-only access to (e.g. roles, permissions, vip, etc) */
487
- app_metadata: TAppMetadata
488
-
489
- /** */
490
- created_at: string
491
-
492
- /** */
493
- email: string
494
-
495
- /** */
496
- email_verified: boolean
497
-
498
- /** */
499
- family_name: string
500
-
501
- /** */
502
- given_name: string
503
-
504
- /** */
505
- identities: Identity[]
506
-
507
- /** */
508
- last_password_reset?: string
509
-
510
- /** */
511
- multifactor?: string[]
512
-
513
- /** */
514
- name: string
515
-
516
- /** */
517
- nickname: string
518
-
519
- /** */
520
- phone_number?: string
521
-
522
- /** */
523
- phone_verified?: boolean
524
-
525
- /** */
526
- picture: string
527
-
528
- /** */
529
- updated_at: string
530
-
531
- /** */
532
- user_id: string
533
-
534
- /** Data that the user has read/write access to (e.g. color_preference, blog_url, etc.) */
535
- user_metadata: TUserMetadata
536
-
537
- /** */
538
- username?: string
539
- }
540
-
541
- //#endregion
542
-
543
- //#region Actions APIs
544
-
545
- export interface PostLoginApi extends ActionsApiBase<PostLoginApi> {
546
-
547
- /** Modify the user's login access, such as by rejecting the login attempt. */
548
- access: LoginAccessManager<PostLoginApi>;
549
-
550
- /** Request changes to the access token being issued. */
551
- accessToken: AccessTokenManager<PostLoginApi>;
552
-
553
- /** */
554
- authentication: AuthenticationManager;
555
-
556
- /** Store and retrieve data that persists across executions. */
557
- cache: CacheManager;
558
-
559
- /** Request changes to the ID token being issued. */
560
- idToken: IdTokenManager;
561
-
562
- /** */
563
- multifactor: MultifactorManager;
564
-
565
- /** */
566
- redirect: RedirectManager;
567
-
568
- /** */
569
- user: UserManager;
570
- }
571
-
572
- export interface AccessTokenManager<TApi extends ActionsApiBase<TApi>> extends AccessTokenManagerBase<TApi> {
573
-
574
- /**
575
- * Add a scope on the Access Token that will be issued upon completion of the login flow.
576
- * @param scope The scope to be added.
577
- */
578
- addScope(scope: string): TApi;
579
-
580
- /**
581
- * Remove a scope on the Access Token that will be issued upon completion of the login flow.
582
- * @param scope The scope to be removed.
583
- */
584
- removeScope(scope: string): TApi;
585
-
586
- }
587
-
588
- export interface AccessTokenManagerBase<TApi extends ActionsApiBase<TApi>> {
589
-
590
- /**
591
- * Set a custom claim on the Access Token that will be issued upon completion of the login flow.
592
- * @param name Name of the claim (note that this may need to be a fully-qualified URL).
593
- * @param value The value of the claim.
594
- */
595
- setCustomClaim(name: string, value: any): TApi;
596
- }
597
-
598
- export interface ActionsApiBase<TApi extends ActionsApiBase<TApi>> {
599
-
600
- /** Modify the user's login access, such as by rejecting the login attempt. */
601
- access: LoginAccessManager<TApi>;
602
-
603
- /** Request changes to the access token being issued. */
604
- accessToken: AccessTokenManagerBase<TApi>;
605
-
606
- /** Store and retrieve data that persists across executions. */
607
- cache: CacheManager;
608
-
609
- }
610
-
611
- export interface AuthenticationManager {
612
-
613
- /**
614
- * Indicate that a custom authentication method has been completed in the current session. This method will then be available in the
615
- * `event.authentication.methods` array in subsequent logins.
616
- *
617
- * Important: This API is only available from within the onContinuePostLogin function for PostLogin Actions. In other words, this may
618
- * be used to record the completion of a custom authentication method after redirecting the user via api.redirect.sendUserTo().
619
- *
620
- * @param provider_url
621
- */
622
- recordMethod(provider_url: string): PostLoginApi;
623
-
624
- /**
625
- * Challenge the user with one or more specified multifactor authentication factors. This method presents the default challenge first,
626
- * then allows the user to select a different option if additional factors have been supplied. If the user has not enrolled in any of
627
- * the factors supplied (including both the default and any additional factors), the command fails.
628
- *
629
- * Note: This method overrides existing policies and rules that enable or disable MFA in a tenant.
630
- * @param factor Used to specify the default MFA factor or factors used to challenge the user.
631
- * @param options An object containing the optional additionalFactors field.
632
- */
633
- challengeWith(factor: ChallengeFactor, options: ChallengeOptions): void
634
-
635
- /**
636
- * Trigger an MFA challenge and allow the user to select their preferred factor from the supplied list. This method presents a factor picker to the user rather than a specific challenge, in accordance with the following conditions:
637
- * - If two or more factors are specified, a factor picker displays to the user.
638
- * - If the user has only enrolled in one of the specified factors (or only one factor is specified), the factor picker is skipped.
639
- * - If the user has not enrolled in any of the specified factors, the challenge command fails.
640
- * Note: This method overrides existing policies and rules that enable or disable MFA in a tenant.
641
- * @param factors
642
- */
643
- challengeWithAny(factors: ChallengeFactor[]): void
644
- }
645
-
646
- export interface CacheManager {
647
-
648
- /**
649
- * Delete a record describing a cached value at the supplied key if it exists.
650
- * @param key
651
- */
652
- delete(key: string): CacheWriteResult;
653
-
654
- /**
655
- * Retrieve a record describing a cached value at the supplied key, if it exists. If a record is found, the cached value can be found at the value
656
- * property of the returned object.
657
- * @param key The key of the record stored in the cache.
658
- */
659
- get(key: string): CacheRecord
660
-
661
- /**
662
- *
663
- * @param key The value of the record to be stored.
664
- * @param value The value of the record to be stored.
665
- * @param options Options for adjusting cache behavior.
666
- */
667
- set(key: string, value: any, options?: CacheOptions): void
668
-
669
- }
670
-
671
- export interface CacheWriteResult {
672
-
673
- /** */
674
- type: 'success' | 'error'
675
-
676
- /** If @see type = 'error', then the error code will be populated here. */
677
- code: string
678
- }
679
-
680
- export interface CacheRecord {
681
-
682
- /** The object stored in the Cache. */
683
- value: any
684
-
685
- /** The maximum expiry of the record in milliseconds since the Unix epoch. */
686
- expires_at: number
687
- }
688
-
689
- export interface CacheOptions {
690
-
691
- /**
692
- * The absolute expiry time in milliseconds since the unix epoch. While cached records may be evicted earlier, they will never remain beyond the the supplied expires_at.
693
- * NOTE: This value should not be supplied if a value was also provided for ttl. If both options are supplied, the earlier expiry of the two will be used.
694
- */
695
- expires_at?: number
696
-
697
- /**
698
- * The time-to-live value of this cache entry in milliseconds. While cached values may be evicted earlier, they will never remain beyond the the supplied ttl.
699
- * NOTE: This value should not be supplied if a value was also provided for expires_at. If both options are supplied, the earlier expiry of the two will be used.
700
- */
701
- ttl?: number
702
- }
703
-
704
- export interface ChallengeFactor {
705
- type: ChallengeTypes
706
-
707
- /**
708
- * When set to true, the user cannot use the OTP fallback option of the push notification factor. (Developer's note: This makes no sense.)
709
- * Only used for @see ChallengeTypes.push_notification.
710
- */
711
- otpFallback?: boolean
712
-
713
- /**
714
- * Only used for @see ChallengeTypes.phone.
715
- */
716
- preferredMethod?: 'voice' | 'phone' | 'both'
717
- }
718
-
719
- export interface ChallengeOptions {
720
- additionalFactors: ChallengeFactor[]
721
- }
722
-
723
- export enum ChallengeTypes {
724
- otp = 'otp',
725
- email = 'email',
726
- phone = 'phone',
727
- push_notification = 'push-notification',
728
- webauthn_platform = 'webauthn-platform',
729
- webauthn_roaming = 'webauthn-roaming'
730
- }
731
-
732
- export interface CredentialsExchangeApi extends ActionsApiBase<CredentialsExchangeApi> {
733
-
734
- /** Control availability to the access token. */
735
- access: LoginAccessManager<CredentialsExchangeApi>;
736
-
737
- /** Request changes to the access token being issued. */
738
- accessToken: AccessTokenManagerBase<CredentialsExchangeApi>;
739
-
740
- /** Store and retrieve data that persists across executions. */
741
- cache: CacheManager;
742
-
743
- }
744
-
745
- export interface DuoMultifactorOptions {
746
- host: string
747
- ikey: string
748
- skey: string
749
- }
750
-
751
- export interface EncodeTokenOptions {
752
- expiresInSeconds: number
753
- payload: any;
754
-
755
- /**
756
- * A secret that will be used to sign a JWT that is shared with the redirect target.
757
- * The secret value should be stored as a secret and retrieved using event.secrets['SECRET_NAME']
758
- */
759
- secret: string;
760
- }
761
-
762
- export interface IdTokenManager {
763
-
764
- /**
765
- * Set a custom claim on the ID token that will be issued upon completion of the login flow.
766
- * @param name Name of the claim (note that this may need to be a fully-qualified URL).
767
- * @param value The value of the claim.
768
- */
769
- setCustomClaim(name: string, value: any): PostLoginApi
770
- }
771
-
772
- export interface LoginAccessManager<TApi extends ActionsApiBase<TApi>> {
773
-
774
- /**
775
- * Mark the current login attempt as denied. This will prevent the end-user from completing the login flow. This will NOT cancel other user-related
776
- * side effects (such as metadata changes) requested by this Action. The login flow will immediately stop following the completion of this action
777
- * and no further Actions will be executed.
778
- * @param reason A human-readable explanation for rejecting the login. This may be presented directly in end-user interfaces.
779
- */
780
- deny(reason: string): TApi;
781
- }
782
-
783
- export interface MultifactorManager {
784
-
785
- /**
786
- *
787
- * @param provider
788
- * @param options
789
- */
790
- enable(provider: 'any' | 'duo' | 'google-authenticator' | 'guardian' | 'none', options: MultifactorOptions): PostLoginApi
791
- }
792
-
793
- export interface MultifactorOptions {
794
- allowRememberBrowser?: boolean
795
- providerOptions?: DuoMultifactorOptions
796
- }
797
-
798
- export interface RedirectManager {
799
-
800
- /**
801
- *
802
- * @param options
803
- */
804
- encodeToken(options: EncodeTokenOptions): string
805
-
806
- /**
807
- *
808
- * @param url
809
- * @param options
810
- */
811
- sendUserTo(url: string, options: { query: string }): PostLoginApi
812
-
813
- /**
814
- *
815
- * @param options
816
- */
817
- validateToken(options: ValidateTokenOptions): string
818
- }
819
-
820
- export interface UserManager {
821
-
822
- /**
823
- *
824
- * @param name
825
- * @param value
826
- */
827
- setAppMetadata(name: string, value: any): PostLoginApi
828
-
829
- /**
830
- *
831
- * @param name
832
- * @param value
833
- */
834
- setUserMetadata(name: string, value: any): PostLoginApi
835
- }
836
-
837
- export interface ValidateTokenOptions {
838
- secret: string;
839
- tokenParameterName: string;
840
- }
841
-
842
- //#endregion