@rapidrest/auth 1.0.0-beta.1

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.
Files changed (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -0
  3. package/dist/lib/auth/BasicStrategy.js +82 -0
  4. package/dist/lib/auth/BasicStrategy.js.map +1 -0
  5. package/dist/lib/auth/FIDO2Strategy.js +179 -0
  6. package/dist/lib/auth/FIDO2Strategy.js.map +1 -0
  7. package/dist/lib/auth/MFAStrategy.js +219 -0
  8. package/dist/lib/auth/MFAStrategy.js.map +1 -0
  9. package/dist/lib/auth/OIDCStrategy.js +397 -0
  10. package/dist/lib/auth/OIDCStrategy.js.map +1 -0
  11. package/dist/lib/auth/OTPStrategy.js +143 -0
  12. package/dist/lib/auth/OTPStrategy.js.map +1 -0
  13. package/dist/lib/auth/PasskeyStrategy.js +185 -0
  14. package/dist/lib/auth/PasskeyStrategy.js.map +1 -0
  15. package/dist/lib/auth/TOTPStrategy.js +84 -0
  16. package/dist/lib/auth/TOTPStrategy.js.map +1 -0
  17. package/dist/lib/auth/index.js +10 -0
  18. package/dist/lib/auth/index.js.map +1 -0
  19. package/dist/lib/auth/shared.js +431 -0
  20. package/dist/lib/auth/shared.js.map +1 -0
  21. package/dist/lib/auth/types.js +12 -0
  22. package/dist/lib/auth/types.js.map +1 -0
  23. package/dist/lib/index.js +4 -0
  24. package/dist/lib/index.js.map +1 -0
  25. package/dist/lib/models/index.js +2 -0
  26. package/dist/lib/models/index.js.map +1 -0
  27. package/dist/lib/models/mongo/AliasMongo.js +77 -0
  28. package/dist/lib/models/mongo/AliasMongo.js.map +1 -0
  29. package/dist/lib/models/mongo/ProfileMongo.js +99 -0
  30. package/dist/lib/models/mongo/ProfileMongo.js.map +1 -0
  31. package/dist/lib/models/mongo/SecretMongo.js +71 -0
  32. package/dist/lib/models/mongo/SecretMongo.js.map +1 -0
  33. package/dist/lib/models/mongo/UserMongo.js +71 -0
  34. package/dist/lib/models/mongo/UserMongo.js.map +1 -0
  35. package/dist/lib/models/mongo/index.js +5 -0
  36. package/dist/lib/models/mongo/index.js.map +1 -0
  37. package/dist/lib/models/mongo.js +2 -0
  38. package/dist/lib/models/mongo.js.map +1 -0
  39. package/dist/lib/models/sql/AliasSQL.js +77 -0
  40. package/dist/lib/models/sql/AliasSQL.js.map +1 -0
  41. package/dist/lib/models/sql/ProfileSQL.js +99 -0
  42. package/dist/lib/models/sql/ProfileSQL.js.map +1 -0
  43. package/dist/lib/models/sql/SecretSQL.js +71 -0
  44. package/dist/lib/models/sql/SecretSQL.js.map +1 -0
  45. package/dist/lib/models/sql/UserSQL.js +68 -0
  46. package/dist/lib/models/sql/UserSQL.js.map +1 -0
  47. package/dist/lib/models/sql/index.js +5 -0
  48. package/dist/lib/models/sql/index.js.map +1 -0
  49. package/dist/lib/models/sql.js +2 -0
  50. package/dist/lib/models/sql.js.map +1 -0
  51. package/dist/lib/models/types.js +35 -0
  52. package/dist/lib/models/types.js.map +1 -0
  53. package/dist/lib/mongo.js +3 -0
  54. package/dist/lib/mongo.js.map +1 -0
  55. package/dist/lib/routes/BaseAliasRoute.js +10 -0
  56. package/dist/lib/routes/BaseAliasRoute.js.map +1 -0
  57. package/dist/lib/routes/BaseAuthBasicRoute.js +132 -0
  58. package/dist/lib/routes/BaseAuthBasicRoute.js.map +1 -0
  59. package/dist/lib/routes/BaseAuthFIDO2Route.js +191 -0
  60. package/dist/lib/routes/BaseAuthFIDO2Route.js.map +1 -0
  61. package/dist/lib/routes/BaseAuthMFARoute.js +310 -0
  62. package/dist/lib/routes/BaseAuthMFARoute.js.map +1 -0
  63. package/dist/lib/routes/BaseAuthOIDCRoute.js +231 -0
  64. package/dist/lib/routes/BaseAuthOIDCRoute.js.map +1 -0
  65. package/dist/lib/routes/BaseAuthOTPRoute.js +214 -0
  66. package/dist/lib/routes/BaseAuthOTPRoute.js.map +1 -0
  67. package/dist/lib/routes/BaseAuthPasskeyRoute.js +182 -0
  68. package/dist/lib/routes/BaseAuthPasskeyRoute.js.map +1 -0
  69. package/dist/lib/routes/BaseAuthTOTPRoute.js +133 -0
  70. package/dist/lib/routes/BaseAuthTOTPRoute.js.map +1 -0
  71. package/dist/lib/routes/BaseProfileRoute.js +10 -0
  72. package/dist/lib/routes/BaseProfileRoute.js.map +1 -0
  73. package/dist/lib/routes/BaseSecretRoute.js +399 -0
  74. package/dist/lib/routes/BaseSecretRoute.js.map +1 -0
  75. package/dist/lib/routes/BaseUserRoute.js +10 -0
  76. package/dist/lib/routes/BaseUserRoute.js.map +1 -0
  77. package/dist/lib/routes/UserUtils.js +78 -0
  78. package/dist/lib/routes/UserUtils.js.map +1 -0
  79. package/dist/lib/routes/index.js +13 -0
  80. package/dist/lib/routes/index.js.map +1 -0
  81. package/dist/lib/routes/mongo/BaseAliasRouteMongo.js +20 -0
  82. package/dist/lib/routes/mongo/BaseAliasRouteMongo.js.map +1 -0
  83. package/dist/lib/routes/mongo/BaseAuthBasicRouteMongo.js +14 -0
  84. package/dist/lib/routes/mongo/BaseAuthBasicRouteMongo.js.map +1 -0
  85. package/dist/lib/routes/mongo/BaseAuthFIDO2RouteMongo.js +14 -0
  86. package/dist/lib/routes/mongo/BaseAuthFIDO2RouteMongo.js.map +1 -0
  87. package/dist/lib/routes/mongo/BaseAuthMFARouteMongo.js +14 -0
  88. package/dist/lib/routes/mongo/BaseAuthMFARouteMongo.js.map +1 -0
  89. package/dist/lib/routes/mongo/BaseAuthOIDCRouteMongo.js +11 -0
  90. package/dist/lib/routes/mongo/BaseAuthOIDCRouteMongo.js.map +1 -0
  91. package/dist/lib/routes/mongo/BaseAuthOTPRouteMongo.js +14 -0
  92. package/dist/lib/routes/mongo/BaseAuthOTPRouteMongo.js.map +1 -0
  93. package/dist/lib/routes/mongo/BaseAuthPasskeyRouteMongo.js +14 -0
  94. package/dist/lib/routes/mongo/BaseAuthPasskeyRouteMongo.js.map +1 -0
  95. package/dist/lib/routes/mongo/BaseAuthTOTPRouteMongo.js +14 -0
  96. package/dist/lib/routes/mongo/BaseAuthTOTPRouteMongo.js.map +1 -0
  97. package/dist/lib/routes/mongo/BaseProfileRouteMongo.js +20 -0
  98. package/dist/lib/routes/mongo/BaseProfileRouteMongo.js.map +1 -0
  99. package/dist/lib/routes/mongo/BaseSecretRouteMongo.js +20 -0
  100. package/dist/lib/routes/mongo/BaseSecretRouteMongo.js.map +1 -0
  101. package/dist/lib/routes/mongo/BaseUserRouteMongo.js +20 -0
  102. package/dist/lib/routes/mongo/BaseUserRouteMongo.js.map +1 -0
  103. package/dist/lib/routes/mongo/index.js +12 -0
  104. package/dist/lib/routes/mongo/index.js.map +1 -0
  105. package/dist/lib/routes/mongo.js +2 -0
  106. package/dist/lib/routes/mongo.js.map +1 -0
  107. package/dist/lib/routes/sql/BaseAliasRouteSQL.js +20 -0
  108. package/dist/lib/routes/sql/BaseAliasRouteSQL.js.map +1 -0
  109. package/dist/lib/routes/sql/BaseAuthBasicRouteSQL.js +14 -0
  110. package/dist/lib/routes/sql/BaseAuthBasicRouteSQL.js.map +1 -0
  111. package/dist/lib/routes/sql/BaseAuthFIDO2RouteSQL.js +14 -0
  112. package/dist/lib/routes/sql/BaseAuthFIDO2RouteSQL.js.map +1 -0
  113. package/dist/lib/routes/sql/BaseAuthMFARouteSQL.js +14 -0
  114. package/dist/lib/routes/sql/BaseAuthMFARouteSQL.js.map +1 -0
  115. package/dist/lib/routes/sql/BaseAuthOIDCRouteSQL.js +11 -0
  116. package/dist/lib/routes/sql/BaseAuthOIDCRouteSQL.js.map +1 -0
  117. package/dist/lib/routes/sql/BaseAuthOTPRouteSQL.js +14 -0
  118. package/dist/lib/routes/sql/BaseAuthOTPRouteSQL.js.map +1 -0
  119. package/dist/lib/routes/sql/BaseAuthPasskeyRouteSQL.js +14 -0
  120. package/dist/lib/routes/sql/BaseAuthPasskeyRouteSQL.js.map +1 -0
  121. package/dist/lib/routes/sql/BaseAuthTOTPRouteSQL.js +14 -0
  122. package/dist/lib/routes/sql/BaseAuthTOTPRouteSQL.js.map +1 -0
  123. package/dist/lib/routes/sql/BaseProfileRouteSQL.js +20 -0
  124. package/dist/lib/routes/sql/BaseProfileRouteSQL.js.map +1 -0
  125. package/dist/lib/routes/sql/BaseSecretRouteSQL.js +20 -0
  126. package/dist/lib/routes/sql/BaseSecretRouteSQL.js.map +1 -0
  127. package/dist/lib/routes/sql/BaseUserRouteSQL.js +20 -0
  128. package/dist/lib/routes/sql/BaseUserRouteSQL.js.map +1 -0
  129. package/dist/lib/routes/sql/index.js +12 -0
  130. package/dist/lib/routes/sql/index.js.map +1 -0
  131. package/dist/lib/routes/sql.js +2 -0
  132. package/dist/lib/routes/sql.js.map +1 -0
  133. package/dist/lib/sql.js +3 -0
  134. package/dist/lib/sql.js.map +1 -0
  135. package/dist/types/auth/BasicStrategy.d.ts +39 -0
  136. package/dist/types/auth/FIDO2Strategy.d.ts +85 -0
  137. package/dist/types/auth/MFAStrategy.d.ts +110 -0
  138. package/dist/types/auth/OIDCStrategy.d.ts +188 -0
  139. package/dist/types/auth/OTPStrategy.d.ts +88 -0
  140. package/dist/types/auth/PasskeyStrategy.d.ts +81 -0
  141. package/dist/types/auth/TOTPStrategy.d.ts +49 -0
  142. package/dist/types/auth/index.d.ts +9 -0
  143. package/dist/types/auth/shared.d.ts +136 -0
  144. package/dist/types/auth/types.d.ts +127 -0
  145. package/dist/types/index.d.ts +3 -0
  146. package/dist/types/models/index.d.ts +1 -0
  147. package/dist/types/models/mongo/AliasMongo.d.ts +15 -0
  148. package/dist/types/models/mongo/ProfileMongo.d.ts +17 -0
  149. package/dist/types/models/mongo/SecretMongo.d.ts +14 -0
  150. package/dist/types/models/mongo/UserMongo.d.ts +14 -0
  151. package/dist/types/models/mongo/index.d.ts +4 -0
  152. package/dist/types/models/mongo.d.ts +1 -0
  153. package/dist/types/models/sql/AliasSQL.d.ts +15 -0
  154. package/dist/types/models/sql/ProfileSQL.d.ts +17 -0
  155. package/dist/types/models/sql/SecretSQL.d.ts +14 -0
  156. package/dist/types/models/sql/UserSQL.d.ts +14 -0
  157. package/dist/types/models/sql/index.d.ts +4 -0
  158. package/dist/types/models/sql.d.ts +1 -0
  159. package/dist/types/models/types.d.ts +136 -0
  160. package/dist/types/mongo.d.ts +2 -0
  161. package/dist/types/routes/BaseAliasRoute.d.ts +7 -0
  162. package/dist/types/routes/BaseAuthBasicRoute.d.ts +27 -0
  163. package/dist/types/routes/BaseAuthFIDO2Route.d.ts +50 -0
  164. package/dist/types/routes/BaseAuthMFARoute.d.ts +61 -0
  165. package/dist/types/routes/BaseAuthOIDCRoute.d.ts +33 -0
  166. package/dist/types/routes/BaseAuthOTPRoute.d.ts +53 -0
  167. package/dist/types/routes/BaseAuthPasskeyRoute.d.ts +41 -0
  168. package/dist/types/routes/BaseAuthTOTPRoute.d.ts +38 -0
  169. package/dist/types/routes/BaseProfileRoute.d.ts +7 -0
  170. package/dist/types/routes/BaseSecretRoute.d.ts +89 -0
  171. package/dist/types/routes/BaseUserRoute.d.ts +7 -0
  172. package/dist/types/routes/UserUtils.d.ts +21 -0
  173. package/dist/types/routes/index.d.ts +12 -0
  174. package/dist/types/routes/mongo/BaseAliasRouteMongo.d.ts +4 -0
  175. package/dist/types/routes/mongo/BaseAuthBasicRouteMongo.d.ts +7 -0
  176. package/dist/types/routes/mongo/BaseAuthFIDO2RouteMongo.d.ts +7 -0
  177. package/dist/types/routes/mongo/BaseAuthMFARouteMongo.d.ts +7 -0
  178. package/dist/types/routes/mongo/BaseAuthOIDCRouteMongo.d.ts +7 -0
  179. package/dist/types/routes/mongo/BaseAuthOTPRouteMongo.d.ts +7 -0
  180. package/dist/types/routes/mongo/BaseAuthPasskeyRouteMongo.d.ts +7 -0
  181. package/dist/types/routes/mongo/BaseAuthTOTPRouteMongo.d.ts +7 -0
  182. package/dist/types/routes/mongo/BaseProfileRouteMongo.d.ts +4 -0
  183. package/dist/types/routes/mongo/BaseSecretRouteMongo.d.ts +4 -0
  184. package/dist/types/routes/mongo/BaseUserRouteMongo.d.ts +4 -0
  185. package/dist/types/routes/mongo/index.d.ts +11 -0
  186. package/dist/types/routes/mongo.d.ts +1 -0
  187. package/dist/types/routes/sql/BaseAliasRouteSQL.d.ts +4 -0
  188. package/dist/types/routes/sql/BaseAuthBasicRouteSQL.d.ts +7 -0
  189. package/dist/types/routes/sql/BaseAuthFIDO2RouteSQL.d.ts +7 -0
  190. package/dist/types/routes/sql/BaseAuthMFARouteSQL.d.ts +7 -0
  191. package/dist/types/routes/sql/BaseAuthOIDCRouteSQL.d.ts +7 -0
  192. package/dist/types/routes/sql/BaseAuthOTPRouteSQL.d.ts +7 -0
  193. package/dist/types/routes/sql/BaseAuthPasskeyRouteSQL.d.ts +7 -0
  194. package/dist/types/routes/sql/BaseAuthTOTPRouteSQL.d.ts +7 -0
  195. package/dist/types/routes/sql/BaseProfileRouteSQL.d.ts +4 -0
  196. package/dist/types/routes/sql/BaseSecretRouteSQL.d.ts +4 -0
  197. package/dist/types/routes/sql/BaseUserRouteSQL.d.ts +4 -0
  198. package/dist/types/routes/sql/index.d.ts +11 -0
  199. package/dist/types/routes/sql.d.ts +1 -0
  200. package/dist/types/sql.d.ts +2 -0
  201. package/package.json +138 -0
@@ -0,0 +1,110 @@
1
+ import type { JWTUser } from "@rapidrest/core";
2
+ import { AuthStrategy, HttpRequest, HttpResponse, AuthResult } from "@rapidrest/service-core";
3
+ import { OTPContact, PasskeyConfig } from "./types.js";
4
+ /**
5
+ * The different types of secondary authentication methods.
6
+ */
7
+ export declare enum MFAMethodType {
8
+ FIDO2 = "fido2",
9
+ OTP = "otp",
10
+ TOTP = "totp"
11
+ }
12
+ /**
13
+ * Describes a method for performing the secondary authentication.
14
+ */
15
+ export interface MFAMethod {
16
+ /** The unique id of the secondary authentication method. */
17
+ id: string;
18
+ /** The method specific data required to perform secondary authentication. */
19
+ data: any;
20
+ /** The method type of contact (e.g. email, fido2, sms). */
21
+ type: MFAMethodType;
22
+ }
23
+ /**
24
+ * Describes the configuration options that can be used to initialize MFAStrategy.
25
+ *
26
+ * @author Jean-Philippe Steinmetz
27
+ */
28
+ export declare class MFAStrategyOptions {
29
+ /** The name of the header to look for when performing header based authentication. Default value is `Authorization`. */
30
+ headerKey: string;
31
+ /** The authorization scheme type when using header based authentication. Default value is `basic`. */
32
+ headerScheme: string;
33
+ /**
34
+ * The FIDO2/Passkey configuration to use when a FIDO2 secondary auth is used.
35
+ */
36
+ fidoConfig?: PasskeyConfig;
37
+ /**
38
+ * Set to `true` to require that user's must provide secondary authentication to succeed, otherwise set to
39
+ * `false`. Default is `true`.
40
+ */
41
+ require2FA: boolean;
42
+ /**
43
+ * Retrieves the user's secondary authentication method for a given id.
44
+ * NOTE: You must override this function when using this strategy.
45
+ * @param id The unique id of the secondary auth method to retrieve.
46
+ */
47
+ getMethod(id: string): Promise<MFAMethod | undefined>;
48
+ /**
49
+ * Retrieves the list of secondary authentication methods for the user with the given id.
50
+ * NOTE: You must override this function when using this strategy.
51
+ * @param id The unique id of the user.
52
+ */
53
+ getMethods(id: string): Promise<MFAMethod[]>;
54
+ /**
55
+ * Retrieves the user data for the given unique identifier after authentication has completed successfully.
56
+ * NOTE: You must override this function when using this strategy.
57
+ * @param id The unique identifier of the user that has been successfully authenticated.
58
+ */
59
+ getUser(uid: string): Promise<JWTUser | undefined>;
60
+ /**
61
+ * Sends a notification to the specified contact with the provided MFA code.
62
+ * NOTE: You must override this function when using this strategy.
63
+ * @param contact The contact to send the MFA code to.
64
+ * @param totp The MFA code to send to the user.
65
+ */
66
+ notifyContact(contact: OTPContact, totp: string): Promise<void>;
67
+ /**
68
+ * Called to verify the provided user's id and password.
69
+ * NOTE: You must override this function when using this strategy.
70
+ * @param id The unique id of the user whose password must be verified.
71
+ * @param password The password of the user to verify.
72
+ * @returns The successfully verified user data, otherwise `undefined`.
73
+ */
74
+ verify(id: string, password: string): Promise<JWTUser | undefined>;
75
+ }
76
+ /**
77
+ * Implements a multi-factory authentication (MFA) strategy that performs basic id and password verification, followed
78
+ * by a secondary authentication. This strategy requires an existing user account to have already registered a valid
79
+ * password that will be validated as well as at least one secondary authentication method.
80
+ *
81
+ * Supported secondary authentication (2FA) methods:
82
+ *
83
+ * * `FIDO2` - A hardware-based key challenge exchange that the user has access to (e.g. Yubikey, Passkey, etc).
84
+ * * `OTP` - A One Time Password (OTP) sent to one of the user's verified contacts.
85
+ * * `TOTP` - A Time-Based One Time Password (TOTP) configured on a device the user owns or has access to.
86
+ *
87
+ * The login flow has three phases:
88
+ *
89
+ * 1. Verify Basic - The client sends a request with `Authorization` header containing the user's id and password. The
90
+ * server returns with a list of available secondary authentication methods.
91
+ * 2. Challenge - The client requests a selected 2FA challenge. If a `TOTP` 2FA method is chosen, the request is
92
+ * processed as phase 3. For all others, a challenge is generated and stored in the session. If `OTP` is selected,
93
+ * a notification containing the challenge token is sent to the selected verified contact.
94
+ * 3. Verify - The client submits the completed 2FA challenge. The challenge is verified against the one stored in the
95
+ * session, and the associated user is resolved using the `getUser()` callback.
96
+ *
97
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
98
+ */
99
+ export declare class MFAStrategy implements AuthStrategy {
100
+ readonly name: string;
101
+ private options;
102
+ constructor(options: MFAStrategyOptions);
103
+ authenticate(req: HttpRequest, res: HttpResponse, required?: boolean): Promise<AuthResult | undefined>;
104
+ authenticateSync(req: HttpRequest, res: HttpResponse, required?: boolean): AuthResult | undefined;
105
+ protected challenge(payload: any, req: HttpRequest, res: HttpResponse): Promise<void>;
106
+ protected verifyBasic(req: HttpRequest, res: HttpResponse): Promise<JWTUser | undefined>;
107
+ protected verifyFIDO(payload: any, req: HttpRequest, res: HttpResponse): Promise<JWTUser | undefined>;
108
+ protected verifyOTP(payload: any, req: HttpRequest, res: HttpResponse): Promise<JWTUser | undefined>;
109
+ protected verifyTOTP(payload: any, req: HttpRequest, res: HttpResponse): Promise<JWTUser | undefined>;
110
+ }
@@ -0,0 +1,188 @@
1
+ import type { JWTUser } from "@rapidrest/core";
2
+ import { AuthStrategy, HttpRequest, HttpResponse, AuthResult } from "@rapidrest/service-core";
3
+ export declare const Protocol: {
4
+ readonly OAUTH2: "oauth2";
5
+ readonly OPENID: "openid";
6
+ };
7
+ /**
8
+ * Describes an authenticated user profile as converted by an OAuth/OpenID provider that is ready to be
9
+ * used by the system to create a local User and/or Profile.
10
+ */
11
+ export interface OIDCProfile {
12
+ /** The unique identifier of the user as registered with the provider. */
13
+ id: string;
14
+ /** The unique name of the provider. */
15
+ provider: string;
16
+ /** The alias or display name of the user. */
17
+ alias?: string;
18
+ /** The URL of the user's avatar image. */
19
+ avatar?: string;
20
+ /** The birthdate of the user. */
21
+ birthdate?: string;
22
+ /** The email address that the user registered their account with the provider. */
23
+ email?: string;
24
+ /** Indicates if the user email address has been verified by the provider. */
25
+ email_verified?: boolean;
26
+ /** The real surname name of the user. */
27
+ familyName?: string;
28
+ /** The real given name of the user. */
29
+ givenName?: string;
30
+ /** The user's chosen language option. */
31
+ locale?: string;
32
+ /** The phone number that the user registered their account with the provider. */
33
+ phone?: string;
34
+ /** Indicates if the user phone number has been verified by the provider. */
35
+ phone_verified?: boolean;
36
+ /** The unique name of the user. */
37
+ username?: string;
38
+ }
39
+ /** The two PKCE code challenge methods registered by RFC 7636 / the IANA PKCE registry. */
40
+ export type PkceMethod = "S256" | "plain";
41
+ export interface OIDCProvider {
42
+ /** The unique name of the provider that can be used for authentication. */
43
+ name: string;
44
+ /** The URL of the provider's API that will be used to perform authorization requests. */
45
+ authorizationURL: string;
46
+ /** The unique identifier that has been provided by the OIDC provider. */
47
+ clientID: string;
48
+ /** The shared secret that has been provided by the OIDC provider. */
49
+ clientSecret: string;
50
+ /**
51
+ * Indicates whether PKCE is required by the OIDC provider. Set to `true` to allow either
52
+ * `S256` or `plain` (the client may choose), or set to `"S256"`/`"plain"` to require that
53
+ * specific method regardless of what the client requests.
54
+ */
55
+ pkce?: boolean | PkceMethod;
56
+ /**
57
+ * The default transformation map to use to convert the third-party profile data to an `OIDCProfile`.
58
+ * Default is `DEFAULT_PROFILE_MAP`.
59
+ * */
60
+ profileMap?: any;
61
+ /** The URL of the provider's API that the user profile can be retrieved from. */
62
+ profileURL?: string;
63
+ /** The authentication protocol to use (e.g. OIDC 2.0 or Open ID). */
64
+ protocol: string;
65
+ /**
66
+ * The callback URI (or list of allowed callback URIs) that have been registered with the OIDC
67
+ * provider. A caller may request a specific `redirect_uri` via query parameter, but only a value
68
+ * that exactly matches one of these is honored — anything else is rejected.
69
+ */
70
+ redirectURI: string | string[];
71
+ /** The list of scopes to request during the authentication process. Default is `none`. */
72
+ scope?: string[];
73
+ /** The URL of the provider's API that will perform token exchange. */
74
+ tokenURL: string;
75
+ /**
76
+ * The provider's JWKS endpoint, used to verify ID token signatures. Required when `protocol`
77
+ * is `openid` and the provider returns an `id_token`.
78
+ */
79
+ jwksURI?: string;
80
+ /**
81
+ * The expected `iss` claim of ID tokens from this provider. Required when `protocol` is
82
+ * `openid` and the provider returns an `id_token`.
83
+ */
84
+ issuer?: string;
85
+ }
86
+ /**
87
+ * Describes the configuration options that can be used to initialize OIDCStrategy.
88
+ *
89
+ * @author Jean-Philippe Steinmetz
90
+ */
91
+ export declare class OIDCStrategyOptions {
92
+ /** The unique name of the auth strategy instance. */
93
+ name: string;
94
+ /**
95
+ * The configuration of the OIDC/OpenID provider.
96
+ */
97
+ provider: OIDCProvider;
98
+ /**
99
+ * Retrieves the user data for the given unique identifier after authentication has completed successfully.
100
+ * NOTE: You must override this function when using this strategy.
101
+ * @param token The user's authenticated access token to the third-party provider.
102
+ * @param profile The user's profile data associated with the third-party provider.
103
+ */
104
+ getUser(token: string, profile: OIDCProfile): Promise<JWTUser | undefined>;
105
+ constructor(name: string, provider: OIDCProvider);
106
+ }
107
+ export declare const DEFAULT_PROFILE_MAP: any;
108
+ /**
109
+ * Implements an authentication strategy for performing OIDC 2.0 or OpenID Connect (OIDC) authorization with a
110
+ * third-party provider. This strategy does not require that require an account already be registered. When using
111
+ * this strategy, ensure to allow for account creation to occur after a successful login.
112
+ *
113
+ * The authorization flow has the following steps:
114
+ *
115
+ * 1. Client initiates a request for an Authorization Request URI. Builds the Authorization Request URI and returns it
116
+ * to the client.
117
+ * 2. The client should automatically redirect the user to the Authorization Request URI obtained in step 1.
118
+ * 3. Once the user has approved the authorization request with the third-party provider the client will be
119
+ * redirected to the application's registered callback URL with a single query parameter containing an
120
+ * Authorization Code. The client initiates a request to a route handler, containing the code, and then
121
+ * calls `authenticate()`.
122
+ *
123
+ * NOTE: Requires session support!
124
+ *
125
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
126
+ */
127
+ export declare class OIDCStrategy implements AuthStrategy {
128
+ readonly name: string;
129
+ private options;
130
+ /** Cached `jwks-rsa` clients, keyed by JWKS URI, so keys are cached across requests. */
131
+ private jwksClients;
132
+ constructor(options: OIDCStrategyOptions);
133
+ /**
134
+ * Resolves the effective PKCE code challenge method to use, given what the provider requires
135
+ * (if anything specific) and what the client requested. Throws if the client requests an
136
+ * invalid value, or a value that conflicts with a provider-mandated method.
137
+ *
138
+ * @param clientMethod The `code_challenge_method` requested by the client, if any.
139
+ */
140
+ protected resolvePkceMethod(clientMethod?: string): PkceMethod;
141
+ /**
142
+ * Creates and returns the Authorization Request URI for the configured OIDC provider.
143
+ *
144
+ * @param req The source HTTP request.
145
+ * @param redirectURI The source URI to redirect the user to once authentication is complete.
146
+ */
147
+ protected buildAuthorizationURI(req: HttpRequest, redirectURI?: string): string;
148
+ authenticate(req: HttpRequest, res: HttpResponse, required?: boolean): Promise<AuthResult | undefined>;
149
+ authenticateSync(req: HttpRequest, res: HttpResponse, required?: boolean): AuthResult | undefined;
150
+ /**
151
+ * Performs a request against the OIDC provider to exchange the given authorization code for an access token.
152
+ *
153
+ * @param req The request data to use in the exchange exchange.
154
+ * @param provider The OIDC provider to perform the exchange with.
155
+ */
156
+ protected exchangeOIDCCode(req: HttpRequest): Promise<any>;
157
+ /**
158
+ * Converts the given user profile obtained from the specified OAuth provider into an OIDCProfile object.
159
+ *
160
+ * @param profile The profile to convert.
161
+ * @param provider The OAuth provider that the profile was obtained from.
162
+ */
163
+ protected convertProfile(profile: any): OIDCProfile;
164
+ /**
165
+ * Retrieves the user profile from the specified OIDC provider using the given access token.
166
+ * @param token The access token to use to retrieve the user profile.
167
+ * @param req The source HTTP request, used to validate the id_token's nonce claim.
168
+ */
169
+ protected retrieveUserProfile(token: any, req: HttpRequest): Promise<OIDCProfile | undefined>;
170
+ /**
171
+ * Dynamically imports the given optional peer dependency, throwing a helpful error if it is not installed.
172
+ *
173
+ * @param pkg The name of the package to import.
174
+ */
175
+ private importOptionalDependency;
176
+ /**
177
+ * Returns a (cached) `jwks-rsa` client for the given JWKS URI.
178
+ * @param jwksURI The JWKS endpoint to fetch signing keys from.
179
+ */
180
+ private getJwksClient;
181
+ /**
182
+ * Verifies the signature, issuer, audience, and nonce of the given ID token.
183
+ *
184
+ * @param idToken The compact JWT id_token to verify.
185
+ * @param req The source HTTP request, used to validate the nonce against the stored session value.
186
+ */
187
+ private verifyIdToken;
188
+ }
@@ -0,0 +1,88 @@
1
+ import type { JWTUser } from "@rapidrest/core";
2
+ import { AuthStrategy, HttpRequest, HttpResponse, AuthResult } from "@rapidrest/service-core";
3
+ import { OTPContact } from "./types.js";
4
+ /**
5
+ * Describes the configuration options that can be used to initialize OTPStrategy.
6
+ *
7
+ * @author Jean-Philippe Steinmetz
8
+ */
9
+ export declare class OTPStrategyOptions {
10
+ /**
11
+ * Set to `true` to enable discovery of a user's aliases. Default is `false`.
12
+ *
13
+ * Be careful enabling this as it can be used as a way for an attacker to discover sensitive information.
14
+ */
15
+ allowDiscovery?: boolean;
16
+ /** The name of the header to look for when performing header based authentication. Default value is `Authorization`. */
17
+ headerKey: string;
18
+ /** The authorization scheme type when using header based authentication. Default value is `otp`. */
19
+ headerScheme: string;
20
+ /**
21
+ * Retrieves the user's contact information for a given id.
22
+ * NOTE: You must override this function when using this strategy.
23
+ * @param id The unique id of the contact to retrieve.
24
+ */
25
+ getContact(id: string): Promise<OTPContact | undefined>;
26
+ /**
27
+ * Retrieves the list of available contacts for the user with the given id.
28
+ * NOTE: You must override this function when using this strategy.
29
+ * @param id The unique id of the user.
30
+ */
31
+ getContacts(id: string): Promise<OTPContact[]>;
32
+ /**
33
+ * Retrieves the user data for the given unique identifier after authentication has completed successfully.
34
+ * NOTE: You must override this function when using this strategy.
35
+ * @param id The unique identifier of the user that has been successfully authenticated.
36
+ */
37
+ getUser(uid: string): Promise<JWTUser | undefined>;
38
+ /**
39
+ * Sends a notification to the specified contact with the provided OTP token.
40
+ * NOTE: You must override this function when using this strategy.
41
+ * @param contact The contact to send the OTP token to.
42
+ * @param token The OTP token to send to the user.
43
+ */
44
+ notifyContact(contact: OTPContact, token: string): Promise<void>;
45
+ }
46
+ /**
47
+ * Implements an strategy for authenticating a user with a One Time Password (OTP) that is sent to one of the user's
48
+ * verified contact methods. This allows for implementation of a password-less login flow. This strategy requires that
49
+ * an existing user account has already been registered with at least one verified contact method.
50
+ *
51
+ * This strategy should not to be confused with Time-Based One Time Password (TOTP) authentication which uses a
52
+ * pre-shared security key, often stored on the user's device (e.g. authenticator app) or digital vault (e.g. 1Password,
53
+ * Bitwarden, etc.). For TOTP authentication, see `TOTPStrategy`.
54
+ *
55
+ * The login flow has three phases:
56
+ *
57
+ * 1. Discovery - The client requests a list of contacts for a given user id. The `getContacts()` callback is used to
58
+ * return the list of contacts.
59
+ * 2. Challenge - The client requests a OTP token to be sent to the contact with a specified id. The
60
+ * OTP token is generated and sent to the contact using the `notify()` callback and stored in the session.
61
+ * 3. Verify - The client submits the OTP token and contact id. The OTP token is verified against the one stored in the
62
+ * session, and the associated user is resolved using the `getUser()` callback.
63
+ *
64
+ * The client sends request data either in the `Authorization` header or the request body in standard form-data format
65
+ * (e.g. `id=<id>&token=<otp>`). For example, the initial challenge request (step 2) can be sent as
66
+ * `Authorization: otp id=<contact_id>`. The final verification request (step 3) is then sent as
67
+ * `Authorization: otp id=<contact_id>&token=<otp>`.
68
+ *
69
+ * WARNING: Allowing discovery (setting `OTPStrategyOptions.allowDiscovery` to `true`) is a potential side-channel
70
+ * attack allowing anyone to discover or gather partial contact information about a given user. For improved security,
71
+ * the returned list of contacts is partially obfuscated. However, enough information is still provided that an
72
+ * attacker may be able to harvest information anyway. For example, a phone number will be obfuscated from
73
+ * `818-867-5309` to `****5309`. An email address will be obfuscated from `john.smith@gmail.com` to
74
+ * `j****th@gmail.com`.
75
+ *
76
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
77
+ */
78
+ export declare class OTPStrategy implements AuthStrategy {
79
+ readonly name: string;
80
+ private options;
81
+ private regexHeaderScheme;
82
+ constructor(options: OTPStrategyOptions);
83
+ authenticate(req: HttpRequest, res: HttpResponse, required?: boolean): Promise<AuthResult | undefined>;
84
+ authenticateSync(req: HttpRequest, res: HttpResponse, required?: boolean): AuthResult | undefined;
85
+ protected discovery(req: HttpRequest, res: HttpResponse): Promise<any>;
86
+ protected challenge(payload: any, req: HttpRequest, res: HttpResponse): Promise<any>;
87
+ protected verify(payload: any, req: HttpRequest, res: HttpResponse): Promise<JWTUser | undefined>;
88
+ }
@@ -0,0 +1,81 @@
1
+ import type { JWTUser } from "@rapidrest/core";
2
+ import { AuthResult, AuthStrategy, HttpRequest, HttpResponse } from "@rapidrest/service-core";
3
+ import { PasskeyConfig, StoredPasskeyCredential } from "./types.js";
4
+ /**
5
+ * Describes the configuration options that can be used to initialize PasskeyStrategy.
6
+ *
7
+ * @author Jean-Philippe Steinmetz
8
+ */
9
+ export declare class PasskeyStrategyOptions {
10
+ /**
11
+ * The relying party configuration to use for this strategy.
12
+ */
13
+ config: PasskeyConfig;
14
+ constructor(config: PasskeyConfig);
15
+ /**
16
+ * Retrieves a previously-registered credential by its ID. Returns `undefined` if no credential
17
+ * with that ID is known.
18
+ * NOTE: You must override this function when using this strategy.
19
+ */
20
+ getCredentialById(credentialId: string): Promise<StoredPasskeyCredential | undefined>;
21
+ /**
22
+ * Retrieves all credentials registered for the given user. Used to build the `allowCredentials`
23
+ * list when a login ceremony is started with a known user hint.
24
+ * NOTE: You must override this function when using this strategy.
25
+ * @param id The unique identifier of the user or alias.
26
+ */
27
+ getCredentials(id: string): Promise<StoredPasskeyCredential[]>;
28
+ /**
29
+ * Persists the updated signature counter for the given credential after a successful
30
+ * authentication. Must be called on every successful login to guard against cloned authenticators.
31
+ * NOTE: You must override this function when using this strategy.
32
+ */
33
+ updateCredentialCounter(credentialId: string, newCounter: number): Promise<void>;
34
+ /**
35
+ * Retrieves the user data for the given unique identifier after authentication has completed successfully.
36
+ * NOTE: You must override this function when using this strategy.
37
+ * @param id The unique identifier of the user that has been successfully authenticated.
38
+ */
39
+ getUser(uid: string): Promise<JWTUser | undefined>;
40
+ }
41
+ /**
42
+ * Implements an authentication strategy for performing WebAuthn/Passkey (FIDO2) login.
43
+ *
44
+ * The login flow has two phases:
45
+ *
46
+ * 1. Challenge - The client requests a challenge. A random challenge is generated and stored in the
47
+ * session, and the resulting options are returned for use with
48
+ * `navigator.credentials.get()`.
49
+ * 2. Verify - The client submits the signed assertion response. The response is verified against the
50
+ * stored challenge and the credential's public key, the credential's signature counter is updated,
51
+ * and the associated user is resolved via `verify()`.
52
+ *
53
+ * NOTE: Requires session support!
54
+ *
55
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
56
+ */
57
+ export declare class PasskeyStrategy implements AuthStrategy {
58
+ readonly name: string;
59
+ private options;
60
+ constructor(options: PasskeyStrategyOptions);
61
+ authenticate(req: HttpRequest, res: HttpResponse, required?: boolean): Promise<AuthResult | undefined>;
62
+ authenticateSync(req: HttpRequest, res: HttpResponse, required?: boolean): AuthResult | undefined;
63
+ /**
64
+ * Begins a login ceremony: generates a challenge, stores it in the session, and writes the
65
+ * resulting options directly to the response for the client to pass to `navigator.credentials.get()`.
66
+ *
67
+ * @param req The source HTTP request. May optionally carry a `uid` query parameter to scope the
68
+ * allowed credentials to a known user; omitted entirely for a discoverable/"usernameless" flow.
69
+ * @param res The response to write the generated options to.
70
+ */
71
+ protected challenge(req: HttpRequest, res: HttpResponse): Promise<undefined>;
72
+ /**
73
+ * Finishes a login ceremony: verifies the client-submitted assertion response against the
74
+ * stored challenge and credential, updates the credential's signature counter, and resolves the
75
+ * associated user.
76
+ *
77
+ * @param req The source HTTP request, carrying the assertion response in its body.
78
+ * @param required Set to `true` if authentication is required to pass, otherwise set to `false`.
79
+ */
80
+ protected verify(req: HttpRequest, required?: boolean): Promise<AuthResult | undefined>;
81
+ }
@@ -0,0 +1,49 @@
1
+ import type { JWTUser } from "@rapidrest/core";
2
+ import { AuthResult, AuthStrategy, HttpRequest, HttpResponse } from "@rapidrest/service-core";
3
+ import { TOTPSecret } from "./types.js";
4
+ /**
5
+ * Describes the configuration options that can be used to initialize TOTPStrategy.
6
+ *
7
+ * @author Jean-Philippe Steinmetz
8
+ */
9
+ export declare class TOTPStrategyOptions {
10
+ /** The name of the header to look for when performing header based authentication. Default value is `Authorization`. */
11
+ headerKey: string;
12
+ /** The authorization scheme type when using header based authentication. Default value is `jwt`. */
13
+ headerScheme: string;
14
+ /** The name of the request query parameter to retrieve the token from when using query based authentication. Default value is `auth_totp`. */
15
+ queryKey: string;
16
+ /**
17
+ * Set to `true` to allow credentials to be supplied via the `queryKey` URL parameter.
18
+ * Disabled by default — query parameters appear in server logs, browser history, and
19
+ * Referer headers, which permanently exposes credentials outside the application.
20
+ */
21
+ allowQueryParam: boolean;
22
+ /**
23
+ * Retrieves the stored TOTP secrets for the user with the given unique identifier.
24
+ * NOTE: You must override this function when using this strategy.
25
+ * @param id The unique identifier of the user.
26
+ */
27
+ getSecrets(uid: string): Promise<TOTPSecret[]>;
28
+ /**
29
+ * Retrieves the user data for the given unique identifier.
30
+ * NOTE: You must override this function when using this strategy.
31
+ * @param id The unique id of the user that has been successfully authenticated.
32
+ */
33
+ getUser(id: string): Promise<JWTUser | undefined>;
34
+ }
35
+ /**
36
+ * Implements an authentication strategy that performs Time-Based One Time Password authentication. This strategy
37
+ * requires an existing user account to have already registered a TOTP secret that will be validated. The strategy does
38
+ * not implement how that secret is to be stored.
39
+ *
40
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
41
+ */
42
+ export declare class TOTPStrategy implements AuthStrategy {
43
+ readonly name: string;
44
+ private options;
45
+ constructor(options?: TOTPStrategyOptions);
46
+ authenticate(req: HttpRequest, res: HttpResponse, required?: boolean): Promise<AuthResult | undefined>;
47
+ authenticateSync(req: HttpRequest, res: HttpResponse, required?: boolean): AuthResult | undefined;
48
+ protected verify(payload: any): Promise<JWTUser | undefined>;
49
+ }
@@ -0,0 +1,9 @@
1
+ export * from "./shared.js";
2
+ export * from "./types.js";
3
+ export * from "./BasicStrategy.js";
4
+ export * from "./FIDO2Strategy.js";
5
+ export * from "./MFAStrategy.js";
6
+ export * from "./OIDCStrategy.js";
7
+ export * from "./OTPStrategy.js";
8
+ export * from "./PasskeyStrategy.js";
9
+ export * from "./TOTPStrategy.js";
@@ -0,0 +1,136 @@
1
+ import { HttpRequest } from "@rapidrest/service-core";
2
+ import { OTPContactType, PasskeyConfig, PasskeyTransport, StoredPasskeyCredential, TOTPConfig, TOTPSecret } from "./types.js";
3
+ /**
4
+ * Attempts to decode the request for authentication Basic request data
5
+ * (e.g. `Authorization: basic base64("<id>:<password>")).
6
+ *
7
+ * @param req The request to return auth request data for.
8
+ * @param headerKey The name of a header to look for request data in. Set to an empty string to skip
9
+ * the header search entirely — passing `undefined` has no effect, since that just triggers the
10
+ * default value. Default is 'Authorization'.
11
+ * @param headerScheme The header scheme to look for. Default is 'basic'.
12
+ * @returns An object with format `{id: <username>, password: <password> }, otherwise `undefined`.
13
+ */
14
+ export declare const getBasicData: (req: HttpRequest, headerKey?: string, headerScheme?: string) => any;
15
+ /**
16
+ * Attempts to decode the request for authentication request data. The auth request data may be in a header, a query
17
+ * parameter or the request body itself. It may either be JSON encoded or form-data encoded. We want to return a
18
+ * regular object.
19
+ *
20
+ * @param req The request to return auth request data for.
21
+ * @param headerKey The name of a header to look for request data in. Set to an empty string to skip
22
+ * the header search entirely — passing `undefined` has no effect, since that just triggers the
23
+ * default value. Default is 'Authorization'.
24
+ * @param headerScheme The header scheme to look for. Default is 'basic'.
25
+ * @returns The found request data and its decoded payload object.
26
+ */
27
+ export declare const getRequestData: (req: HttpRequest, headerKey?: string | undefined, headerScheme?: string) => {
28
+ data: any;
29
+ payload: any;
30
+ };
31
+ export declare const isOTPResponse: (response: any) => boolean;
32
+ export declare const isPasskeyResponse: (response: any) => boolean;
33
+ /**
34
+ * Determines if the given value has the shape of a WebAuthn `RegistrationResponseJSON`, as produced by
35
+ * `navigator.credentials.create()` and submitted to finish a passkey registration ceremony.
36
+ *
37
+ * @param response The value to check.
38
+ */
39
+ export declare const isPasskeyRegistrationResponse: (response: any) => boolean;
40
+ /**
41
+ * Obfuscates the given contact and returns the obfuscated value.
42
+ * @param contact The contact to obfuscate.
43
+ */
44
+ export declare const obfuscateContact: (contact: string, type: OTPContactType) => string;
45
+ /**
46
+ * Generates and returns a new OTP token for authentication. This function stores relevant data for
47
+ * validation of the OTP token in the request's session.
48
+ * @param req The HTTP request to use for storing session data.
49
+ * @returns The generated OTP token.
50
+ */
51
+ export declare const generateOTP: (req: HttpRequest, requestData?: any) => Promise<string>;
52
+ /**
53
+ * Validates the provided token against the data stored in the request session.
54
+ * @param token The OTP token to validate.
55
+ * @param req The HTTP request with OTP session data.
56
+ */
57
+ export declare const verifyOTP: (req: HttpRequest, payload?: any) => Promise<boolean>;
58
+ export declare const generatePasskeyChallenge: (config: PasskeyConfig, req: HttpRequest, allowCredentials?: any) => Promise<any>;
59
+ export declare const verifyPasskeyChallenge: (credential: StoredPasskeyCredential, config: PasskeyConfig, expectedChallenge: string, payload: any) => Promise<any>;
60
+ /**
61
+ * Begins a registration ceremony: generates a set of `PublicKeyCredentialCreationOptions` and stores the
62
+ * challenge in the session for later verification. The result is meant to be returned directly to the
63
+ * client for use with `navigator.credentials.create()`.
64
+ *
65
+ * @param config The relying party configuration to use for this ceremony.
66
+ * @param req The source HTTP request. Used to persist the generated challenge in the session.
67
+ * @param user The user the new credential will be associated with.
68
+ * @param excludeCredentials The user's already-registered credentials, if any, so that the authenticator
69
+ * can avoid creating a duplicate credential for one it already holds.
70
+ */
71
+ export declare const generatePasskeyRegistrationOptions: (config: PasskeyConfig, req: HttpRequest, user: {
72
+ id: string;
73
+ name: string;
74
+ displayName?: string;
75
+ }, excludeCredentials?: {
76
+ id: string;
77
+ transports?: PasskeyTransport[];
78
+ }[]) => Promise<any>;
79
+ /**
80
+ * Finishes a registration ceremony: verifies the client-submitted attestation response against the
81
+ * stored challenge and relying party configuration.
82
+ *
83
+ * @param config The relying party configuration to verify the response against.
84
+ * @param expectedChallenge The challenge previously stored in the session by
85
+ * `generatePasskeyRegistrationOptions()`.
86
+ * @param payload The client-submitted `RegistrationResponseJSON`.
87
+ */
88
+ export declare const verifyPasskeyRegistrationResponse: (config: PasskeyConfig, expectedChallenge: string, payload: any) => Promise<any>;
89
+ /**
90
+ * Generates and returns a new OTP token for authentication. This function stores relevant data for
91
+ * validation of the OTP token in the request's session.
92
+ * @param req The HTTP request to use for storing session data.
93
+ * @returns The generated OTP token.
94
+ */
95
+ export declare const generateTOTP: (req: HttpRequest, requestData?: any) => Promise<string>;
96
+ /**
97
+ * Validates the provided token against the specified TOTP secret.
98
+ * @param token The OTP token to validate.
99
+ * @param secret The stored TOTP secret to validate the token against.
100
+ * @returns The otplib verification result if successful, otherwise `undefined`.
101
+ */
102
+ export declare const verifyTOTP: (token: string, secret: TOTPSecret | TOTPSecret[]) => Promise<any>;
103
+ /**
104
+ * Determines if the given value is usable as a TOTP secret: a Base32-encoded string decoding to at
105
+ * least 128 bits, the minimum shared secret length mandated by RFC 4226 §4 (R6) (which RFC 6238
106
+ * TOTP secrets must also satisfy, per RFC 6238 §5.1).
107
+ *
108
+ * @param secret The value to check.
109
+ */
110
+ export declare const isValidTOTPSecret: (secret: any) => Promise<boolean>;
111
+ /**
112
+ * Generates an `otpauth://` provisioning URI for the given TOTP secret — the "Key URI Format"
113
+ * convention (https://github.com/google/google-authenticator/wiki/Key-Uri-Format) that, while not
114
+ * itself an RFC, is the de facto standard virtually every TOTP authenticator app (Google
115
+ * Authenticator, Authy, 1Password, etc.) relies on to enroll a secret via QR code or manual entry.
116
+ *
117
+ * @param config The relying party configuration to generate the URI for.
118
+ * @param label The account label to embed in the URI (typically a username or email).
119
+ * @param secret The TOTP secret to encode into the URI.
120
+ */
121
+ export declare const generateTOTPURI: (config: TOTPConfig, label: string, secret: TOTPSecret) => Promise<string>;
122
+ /**
123
+ * Dynamically imports the optional peer dependency `argon2`, throwing a helpful
124
+ * error if it is not installed.
125
+ */
126
+ export declare const importArgon2: () => Promise<any>;
127
+ /**
128
+ * Dynamically imports the optional peer dependency `otplib`, throwing a helpful
129
+ * error if it is not installed.
130
+ */
131
+ export declare const importOTPLib: () => Promise<any>;
132
+ /**
133
+ * Dynamically imports the optional peer dependency `@simplewebauthn/server`, throwing a helpful
134
+ * error if it is not installed.
135
+ */
136
+ export declare const importSimpleWebAuthn: () => Promise<any>;