@shware/security 2.5.3 → 3.0.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.
Files changed (225) hide show
  1. package/dist/auth/index.cjs +519 -561
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.d.cts +104 -106
  4. package/dist/auth/index.d.cts.map +1 -0
  5. package/dist/auth/index.d.mts +109 -0
  6. package/dist/auth/index.d.mts.map +1 -0
  7. package/dist/auth/index.mjs +512 -536
  8. package/dist/auth/index.mjs.map +1 -1
  9. package/dist/auth/types.cjs +0 -19
  10. package/dist/auth/types.d.cts +44 -44
  11. package/dist/auth/types.d.cts.map +1 -0
  12. package/dist/auth/types.d.mts +50 -0
  13. package/dist/auth/types.d.mts.map +1 -0
  14. package/dist/auth/types.mjs +1 -1
  15. package/dist/core/index.cjs +18 -59
  16. package/dist/core/index.cjs.map +1 -1
  17. package/dist/core/index.d.cts +13 -24
  18. package/dist/core/index.d.cts.map +1 -0
  19. package/dist/core/index.d.mts +21 -0
  20. package/dist/core/index.d.mts.map +1 -0
  21. package/dist/core/index.mjs +17 -33
  22. package/dist/core/index.mjs.map +1 -1
  23. package/dist/email/schema.cjs +13 -38
  24. package/dist/email/schema.cjs.map +1 -1
  25. package/dist/email/schema.d.cts +11 -12
  26. package/dist/email/schema.d.cts.map +1 -0
  27. package/dist/email/schema.d.mts +12 -0
  28. package/dist/email/schema.d.mts.map +1 -0
  29. package/dist/email/schema.mjs +10 -11
  30. package/dist/email/schema.mjs.map +1 -1
  31. package/dist/index.cjs +18 -54
  32. package/dist/index.d.cts +10 -15
  33. package/dist/index.d.mts +10 -0
  34. package/dist/index.mjs +5 -17
  35. package/dist/oauth2/client.cjs +109 -145
  36. package/dist/oauth2/client.cjs.map +1 -1
  37. package/dist/oauth2/client.d.cts +55 -56
  38. package/dist/oauth2/client.d.cts.map +1 -0
  39. package/dist/oauth2/client.d.mts +58 -0
  40. package/dist/oauth2/client.d.mts.map +1 -0
  41. package/dist/oauth2/client.mjs +104 -116
  42. package/dist/oauth2/client.mjs.map +1 -1
  43. package/dist/oauth2/error.cjs +19 -44
  44. package/dist/oauth2/error.cjs.map +1 -1
  45. package/dist/oauth2/error.d.cts +8 -6
  46. package/dist/oauth2/error.d.cts.map +1 -0
  47. package/dist/oauth2/{error.d.ts → error.d.mts} +8 -6
  48. package/dist/oauth2/error.d.mts.map +1 -0
  49. package/dist/oauth2/error.mjs +18 -19
  50. package/dist/oauth2/error.mjs.map +1 -1
  51. package/dist/oauth2/provider/apple.cjs +75 -88
  52. package/dist/oauth2/provider/apple.cjs.map +1 -1
  53. package/dist/oauth2/provider/apple.d.cts +31 -30
  54. package/dist/oauth2/provider/apple.d.cts.map +1 -0
  55. package/dist/oauth2/provider/apple.d.mts +42 -0
  56. package/dist/oauth2/provider/apple.d.mts.map +1 -0
  57. package/dist/oauth2/provider/apple.mjs +71 -60
  58. package/dist/oauth2/provider/apple.mjs.map +1 -1
  59. package/dist/oauth2/provider/common.cjs +86 -109
  60. package/dist/oauth2/provider/common.cjs.map +1 -1
  61. package/dist/oauth2/provider/common.d.cts +19 -18
  62. package/dist/oauth2/provider/common.d.cts.map +1 -0
  63. package/dist/oauth2/provider/common.d.mts +30 -0
  64. package/dist/oauth2/provider/common.d.mts.map +1 -0
  65. package/dist/oauth2/provider/common.mjs +80 -79
  66. package/dist/oauth2/provider/common.mjs.map +1 -1
  67. package/dist/oauth2/provider/facebook.cjs +93 -109
  68. package/dist/oauth2/provider/facebook.cjs.map +1 -1
  69. package/dist/oauth2/provider/facebook.d.cts +29 -28
  70. package/dist/oauth2/provider/facebook.d.cts.map +1 -0
  71. package/dist/oauth2/provider/facebook.d.mts +45 -0
  72. package/dist/oauth2/provider/facebook.d.mts.map +1 -0
  73. package/dist/oauth2/provider/facebook.mjs +89 -81
  74. package/dist/oauth2/provider/facebook.mjs.map +1 -1
  75. package/dist/oauth2/provider/github.cjs +64 -91
  76. package/dist/oauth2/provider/github.cjs.map +1 -1
  77. package/dist/oauth2/provider/github.d.cts +52 -51
  78. package/dist/oauth2/provider/github.d.cts.map +1 -0
  79. package/dist/oauth2/provider/github.d.mts +60 -0
  80. package/dist/oauth2/provider/github.d.mts.map +1 -0
  81. package/dist/oauth2/provider/github.mjs +60 -63
  82. package/dist/oauth2/provider/github.mjs.map +1 -1
  83. package/dist/oauth2/provider/google.cjs +105 -122
  84. package/dist/oauth2/provider/google.cjs.map +1 -1
  85. package/dist/oauth2/provider/google.d.cts +34 -33
  86. package/dist/oauth2/provider/google.d.cts.map +1 -0
  87. package/dist/oauth2/provider/google.d.mts +44 -0
  88. package/dist/oauth2/provider/google.d.mts.map +1 -0
  89. package/dist/oauth2/provider/google.mjs +101 -94
  90. package/dist/oauth2/provider/google.mjs.map +1 -1
  91. package/dist/oauth2/provider/index.cjs +13 -46
  92. package/dist/oauth2/provider/index.d.cts +7 -7
  93. package/dist/oauth2/provider/index.d.mts +7 -0
  94. package/dist/oauth2/provider/index.mjs +1 -10
  95. package/dist/oauth2/provider/wechat.cjs +77 -99
  96. package/dist/oauth2/provider/wechat.cjs.map +1 -1
  97. package/dist/oauth2/provider/wechat.d.cts +28 -27
  98. package/dist/oauth2/provider/wechat.d.cts.map +1 -0
  99. package/dist/oauth2/provider/wechat.d.mts +39 -0
  100. package/dist/oauth2/provider/wechat.d.mts.map +1 -0
  101. package/dist/oauth2/provider/wechat.mjs +74 -72
  102. package/dist/oauth2/provider/wechat.mjs.map +1 -1
  103. package/dist/oauth2/provider/x.cjs +102 -125
  104. package/dist/oauth2/provider/x.cjs.map +1 -1
  105. package/dist/oauth2/provider/x.d.cts +51 -50
  106. package/dist/oauth2/provider/x.d.cts.map +1 -0
  107. package/dist/oauth2/provider/x.d.mts +69 -0
  108. package/dist/oauth2/provider/x.d.mts.map +1 -0
  109. package/dist/oauth2/provider/x.mjs +99 -103
  110. package/dist/oauth2/provider/x.mjs.map +1 -1
  111. package/dist/oauth2/types.cjs +12 -37
  112. package/dist/oauth2/types.cjs.map +1 -1
  113. package/dist/oauth2/types.d.cts +176 -180
  114. package/dist/oauth2/types.d.cts.map +1 -0
  115. package/dist/oauth2/types.d.mts +207 -0
  116. package/dist/oauth2/types.d.mts.map +1 -0
  117. package/dist/oauth2/types.mjs +12 -13
  118. package/dist/oauth2/types.mjs.map +1 -1
  119. package/dist/session/common.cjs +17 -43
  120. package/dist/session/common.cjs.map +1 -1
  121. package/dist/session/common.d.cts +4 -4
  122. package/dist/session/common.d.cts.map +1 -0
  123. package/dist/session/{common.d.ts → common.d.mts} +4 -4
  124. package/dist/session/common.d.mts.map +1 -0
  125. package/dist/session/common.mjs +14 -16
  126. package/dist/session/common.mjs.map +1 -1
  127. package/dist/session/db.cjs +88 -123
  128. package/dist/session/db.cjs.map +1 -1
  129. package/dist/session/db.d.cts +36 -36
  130. package/dist/session/db.d.cts.map +1 -0
  131. package/dist/session/db.d.mts +44 -0
  132. package/dist/session/db.d.mts.map +1 -0
  133. package/dist/session/db.mjs +84 -95
  134. package/dist/session/db.mjs.map +1 -1
  135. package/dist/session/map-session.cjs +71 -103
  136. package/dist/session/map-session.cjs.map +1 -1
  137. package/dist/session/map-session.d.cts +24 -24
  138. package/dist/session/map-session.d.cts.map +1 -0
  139. package/dist/session/map-session.d.mts +27 -0
  140. package/dist/session/map-session.d.mts.map +1 -0
  141. package/dist/session/map-session.mjs +70 -78
  142. package/dist/session/map-session.mjs.map +1 -1
  143. package/dist/session/redis.cjs +270 -319
  144. package/dist/session/redis.cjs.map +1 -1
  145. package/dist/session/redis.d.cts +51 -51
  146. package/dist/session/redis.d.cts.map +1 -0
  147. package/dist/session/redis.d.mts +58 -0
  148. package/dist/session/redis.d.mts.map +1 -0
  149. package/dist/session/redis.mjs +266 -291
  150. package/dist/session/redis.mjs.map +1 -1
  151. package/dist/session/types.cjs +0 -19
  152. package/dist/session/types.d.cts +34 -33
  153. package/dist/session/types.d.cts.map +1 -0
  154. package/dist/session/types.d.mts +45 -0
  155. package/dist/session/types.d.mts.map +1 -0
  156. package/dist/session/types.mjs +1 -1
  157. package/dist/utils/http.cjs +31 -55
  158. package/dist/utils/http.cjs.map +1 -1
  159. package/dist/utils/http.d.cts +7 -10
  160. package/dist/utils/http.d.cts.map +1 -0
  161. package/dist/utils/{http.d.ts → http.d.mts} +7 -10
  162. package/dist/utils/http.d.mts.map +1 -0
  163. package/dist/utils/http.mjs +24 -24
  164. package/dist/utils/http.mjs.map +1 -1
  165. package/dist/utils/oauth2.cjs +6 -30
  166. package/dist/utils/oauth2.cjs.map +1 -1
  167. package/dist/utils/oauth2.d.cts +3 -1
  168. package/dist/utils/oauth2.d.cts.map +1 -0
  169. package/dist/utils/oauth2.d.mts +5 -0
  170. package/dist/utils/oauth2.d.mts.map +1 -0
  171. package/dist/utils/oauth2.mjs +5 -5
  172. package/dist/utils/oauth2.mjs.map +1 -1
  173. package/dist/utils/timing.cjs +49 -70
  174. package/dist/utils/timing.cjs.map +1 -1
  175. package/dist/utils/timing.d.cts +10 -8
  176. package/dist/utils/timing.d.cts.map +1 -0
  177. package/dist/utils/timing.d.mts +15 -0
  178. package/dist/utils/timing.d.mts.map +1 -0
  179. package/dist/utils/timing.mjs +48 -45
  180. package/dist/utils/timing.mjs.map +1 -1
  181. package/dist/utils/valid.cjs +50 -71
  182. package/dist/utils/valid.cjs.map +1 -1
  183. package/dist/utils/valid.d.cts +17 -16
  184. package/dist/utils/valid.d.cts.map +1 -0
  185. package/dist/utils/valid.d.mts +28 -0
  186. package/dist/utils/valid.d.mts.map +1 -0
  187. package/dist/utils/valid.mjs +47 -44
  188. package/dist/utils/valid.mjs.map +1 -1
  189. package/package.json +22 -12
  190. package/dist/auth/index.d.ts +0 -111
  191. package/dist/auth/types.cjs.map +0 -1
  192. package/dist/auth/types.d.ts +0 -50
  193. package/dist/auth/types.mjs.map +0 -1
  194. package/dist/core/index.d.ts +0 -32
  195. package/dist/email/schema.d.ts +0 -13
  196. package/dist/index.cjs.map +0 -1
  197. package/dist/index.d.ts +0 -15
  198. package/dist/index.mjs.map +0 -1
  199. package/dist/oauth2/client.d.ts +0 -59
  200. package/dist/oauth2/provider/apple.d.ts +0 -41
  201. package/dist/oauth2/provider/common.d.ts +0 -29
  202. package/dist/oauth2/provider/facebook.d.ts +0 -44
  203. package/dist/oauth2/provider/github.d.ts +0 -59
  204. package/dist/oauth2/provider/google.d.ts +0 -43
  205. package/dist/oauth2/provider/index.cjs.map +0 -1
  206. package/dist/oauth2/provider/index.d.ts +0 -7
  207. package/dist/oauth2/provider/index.mjs.map +0 -1
  208. package/dist/oauth2/provider/wechat.d.ts +0 -38
  209. package/dist/oauth2/provider/x.d.ts +0 -68
  210. package/dist/oauth2/types.d.ts +0 -211
  211. package/dist/session/__tests__/redis.test.cjs +0 -247
  212. package/dist/session/__tests__/redis.test.cjs.map +0 -1
  213. package/dist/session/__tests__/redis.test.d.cts +0 -2
  214. package/dist/session/__tests__/redis.test.d.ts +0 -2
  215. package/dist/session/__tests__/redis.test.mjs +0 -252
  216. package/dist/session/__tests__/redis.test.mjs.map +0 -1
  217. package/dist/session/db.d.ts +0 -44
  218. package/dist/session/map-session.d.ts +0 -27
  219. package/dist/session/redis.d.ts +0 -58
  220. package/dist/session/types.cjs.map +0 -1
  221. package/dist/session/types.d.ts +0 -44
  222. package/dist/session/types.mjs.map +0 -1
  223. package/dist/utils/oauth2.d.ts +0 -3
  224. package/dist/utils/timing.d.ts +0 -13
  225. package/dist/utils/valid.d.ts +0 -27
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/oauth2/types.ts"],"sourcesContent":["// reference: https://datatracker.ietf.org/doc/html/rfc7636\nexport interface PkceParameters {\n code_verifier: string;\n code_challenge: string;\n code_challenge_method: 'S256' | 'plain';\n}\n\nexport interface OAuth2AuthorizationRequest {\n state: string;\n registrationId: string;\n authorizationRequestUri: string;\n additionalParameters: PkceParameters;\n}\n\ninterface CreateAuthorizationUriParams {\n state: string;\n clientId: string;\n redirectUri: string;\n scope: string[] | undefined;\n pkce?: Omit<PkceParameters, 'code_verifier'>;\n}\n\nexport interface ExchangeCodeParams {\n code: string;\n clientId: string;\n clientSecret: string;\n redirectUri: string;\n pkce?: Omit<PkceParameters, 'code_challenge' | 'code_challenge_method'>;\n}\n\nexport interface RefreshTokenParams {\n clientId: string;\n clientSecret: string;\n refreshToken: string;\n}\n\nexport interface RevokeTokenParams {\n token: string;\n clientId: string;\n clientSecret: string;\n}\n\nexport interface LoginOAuth2NativeParams {\n clientId: string;\n clientSecret: string;\n redirectUri: string;\n pkce?: PkceParameters;\n credentials: NativeCredential;\n}\n\n// reference: https://datatracker.ietf.org/doc/html/rfc6749#section-5.1\nexport interface OAuth2Token {\n /**\n * REQUIRED.\n * The access token issued by the authorization server.\n */\n access_token: string;\n\n /**\n * REQUIRED.\n * The type of the token issued as described in Section 7.1. Value is case insensitive.\n */\n token_type: 'Bearer' | 'bearer' | 'mac' | (string & {});\n\n /**\n * RECOMMENDED.\n * The lifetime in seconds of the access token. For example, the value \"3600\" denotes that the\n * access token will expire in one hour from the time the response was generated. If omitted, the\n * authorization server SHOULD provide the expiration time via other means or document the default\n * value.\n */\n expires_in?: number;\n\n /**\n * OPTIONAL.\n * The refresh token, which can be used to obtain new access tokens using the same authorization\n * grant as described in Section 6.\n */\n refresh_token?: string;\n\n /**\n * OPTIONAL.\n * If identical to the scope requested by the client; otherwise, REQUIRED. The scope of the\n * access token as described by Section 3.3.\n */\n scope?: string;\n\n id_token?: string;\n\n [key: string]: unknown;\n}\n\nexport interface OidcToken extends OAuth2Token {\n id_token: string;\n}\n\nexport type NativeCredential = {\n state?: string;\n code?: string;\n client_id?: string;\n redirect_uri?: string;\n id_token?: string;\n access_token?: string;\n};\n\nexport enum OidcScopes {\n openid = 'openid',\n profile = 'profile',\n email = 'email',\n phone = 'phone',\n address = 'address',\n offline_access = 'offline_access',\n}\n\n// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims\nexport interface StandardClaims {\n sub: string;\n name?: string;\n given_name?: string;\n family_name?: string;\n middle_name?: string;\n nickname?: string;\n preferred_username?: string;\n profile?: string;\n picture?: string;\n website?: string;\n email?: string;\n email_verified?: boolean;\n gender?: 'female' | 'male' | (string & {});\n birthdate?: string; // ISO 8601-1 [ISO8601‑1] YYYY-MM-DD format.\n zoneinfo?: string; // IANA Time Zone Database [IANA.time‑zones]\n locale?: string; // BCP47 [RFC5646] language tag.\n phone_number?: string; // E.164\n phone_number_verified?: boolean;\n address?: {\n formatted: string;\n street_address: string;\n locality: string;\n region: string;\n postal_code: string;\n country: string;\n }; // [RFC8259] JSON object\n updated_at?: number;\n}\n\nexport interface UserInfo<T = unknown> {\n claims: StandardClaims;\n data: T;\n}\n\nexport interface Provider {\n /** Authorization URI for the provider. */\n authorizationUri: string;\n\n /** Token URI for the provider. */\n tokenUri: string;\n\n /** Token revoke URI for the provider. */\n tokenRevokeUri?: string;\n\n /** Token refresh URI for the provider. */\n tokenRefreshUri?: string;\n\n /** User info URI for the provider. */\n userInfoUri?: string;\n\n /** User info authentication method for the provider. */\n userInfoAuthenticationMethod?: string;\n\n /**\n * Name of the attribute that will be used to extract the username from the call to 'userInfoUri'.\n * */\n userNameAttribute?: string;\n\n /** JWK set URI for the provider */\n jwkSetUri?: string;\n\n /**\n * URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 Authorization\n * Server Metadata endpoint defined by RFC 8414.\n * */\n issuerUri?: string;\n\n /** Default scopes for the provider. */\n defaultScope: string[];\n\n /** step 1: generate authorization uri and redirect user to it */\n createAuthorizationUri: (params: CreateAuthorizationUriParams) => URL;\n\n /** step 2: exchange code for token */\n exchangeAuthorizationCode: (params: ExchangeCodeParams) => Promise<OAuth2Token>;\n\n /** step 3: get user info */\n getUserInfo: (token: OAuth2Token) => Promise<UserInfo>;\n\n /** others: refresh access token */\n refreshAccessToken?: (params: RefreshTokenParams) => Promise<OAuth2Token>;\n\n /** others: revoke token */\n revokeToken?: (params: RevokeTokenParams) => Promise<void>;\n\n loginOAuth2Native?: (\n params: LoginOAuth2NativeParams\n ) => Promise<{ token: OAuth2Token; userInfo: UserInfo }>;\n}\n\nexport interface OneTapProvider extends Provider {\n getTokenInfo: (id_token: string) => Promise<{ token: OAuth2Token; userInfo: UserInfo }>;\n}\n\nexport interface Registration {\n /**\n * Reference to the OAuth 2.0 provider to use. May reference an element from the 'provider'\n * property or used one of the commonly used providers (google, github, facebook, okta).\n * */\n provider?: string;\n\n /** Client ID for the registration. */\n clientId: string;\n\n /** Client secret of the registration. */\n clientSecret: string;\n\n /** Client authentication method. May be left blank when using a pre-defined provider. */\n clientAuthenticationMethod?: string;\n\n /** Authorization grant type. May be left blank when using a pre-defined provider. */\n authorizationGrantType?:\n | 'authorization_code' // default\n | 'client_credentials'\n | 'device_code'\n | 'jwt_bearer'\n // Deprecated. The latest OAuth 2.0 Security Best Current Practice disallows the use of the\n // Resource Owner Password Credentials grant.\n | 'password'\n | 'refresh_token'\n | 'token_exchange';\n\n /** Redirect URI. May be left blank when using a pre-defined provider. */\n redirectUri?: string;\n\n /** Authorization scopes. When left blank the provider's default scopes, if any, will be used. */\n scope?: string[];\n\n /** Client name. May be left blank when using a pre-defined provider. */\n clientName?: string;\n}\n\nexport interface OAuth2ClientConfig {\n baseUri: string;\n errorUri: string;\n successUri: string;\n provider: { [name: string]: Provider | undefined };\n registration:\n | { [name: string]: Registration | undefined }\n | (() => Promise<{ [name: string]: Registration | undefined }>);\n}\n"],"mappings":";AAyGO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,YAAS;AACT,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,oBAAiB;AANP,SAAAA;AAAA,GAAA;","names":["OidcScopes"]}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../../src/oauth2/types.ts"],"sourcesContent":["// reference: https://datatracker.ietf.org/doc/html/rfc7636\nexport interface PkceParameters {\n code_verifier: string;\n code_challenge: string;\n code_challenge_method: 'S256' | 'plain';\n}\n\nexport interface OAuth2AuthorizationRequest {\n state: string;\n registrationId: string;\n authorizationRequestUri: string;\n additionalParameters: PkceParameters;\n}\n\ninterface CreateAuthorizationUriParams {\n state: string;\n clientId: string;\n redirectUri: string;\n scope: string[] | undefined;\n pkce?: Omit<PkceParameters, 'code_verifier'>;\n}\n\nexport interface ExchangeCodeParams {\n code: string;\n clientId: string;\n clientSecret: string;\n redirectUri: string;\n pkce?: Omit<PkceParameters, 'code_challenge' | 'code_challenge_method'>;\n}\n\nexport interface RefreshTokenParams {\n clientId: string;\n clientSecret: string;\n refreshToken: string;\n}\n\nexport interface RevokeTokenParams {\n token: string;\n clientId: string;\n clientSecret: string;\n}\n\nexport interface LoginOAuth2NativeParams {\n clientId: string;\n clientSecret: string;\n redirectUri: string;\n pkce?: PkceParameters;\n credentials: NativeCredential;\n}\n\n// reference: https://datatracker.ietf.org/doc/html/rfc6749#section-5.1\nexport interface OAuth2Token {\n /**\n * REQUIRED.\n * The access token issued by the authorization server.\n */\n access_token: string;\n\n /**\n * REQUIRED.\n * The type of the token issued as described in Section 7.1. Value is case insensitive.\n */\n token_type: 'Bearer' | 'bearer' | 'mac' | (string & {});\n\n /**\n * RECOMMENDED.\n * The lifetime in seconds of the access token. For example, the value \"3600\" denotes that the\n * access token will expire in one hour from the time the response was generated. If omitted, the\n * authorization server SHOULD provide the expiration time via other means or document the default\n * value.\n */\n expires_in?: number;\n\n /**\n * OPTIONAL.\n * The refresh token, which can be used to obtain new access tokens using the same authorization\n * grant as described in Section 6.\n */\n refresh_token?: string;\n\n /**\n * OPTIONAL.\n * If identical to the scope requested by the client; otherwise, REQUIRED. The scope of the\n * access token as described by Section 3.3.\n */\n scope?: string;\n\n id_token?: string;\n\n [key: string]: unknown;\n}\n\nexport interface OidcToken extends OAuth2Token {\n id_token: string;\n}\n\nexport type NativeCredential = {\n state?: string;\n code?: string;\n client_id?: string;\n redirect_uri?: string;\n id_token?: string;\n access_token?: string;\n};\n\nexport const OIDC_SCOPES = [\n 'openid',\n 'profile',\n 'email',\n 'phone',\n 'address',\n 'offline_access',\n] as const;\n\nexport type OidcScope = (typeof OIDC_SCOPES)[number];\n\n// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims\nexport interface StandardClaims {\n sub: string;\n name?: string;\n given_name?: string;\n family_name?: string;\n middle_name?: string;\n nickname?: string;\n preferred_username?: string;\n profile?: string;\n picture?: string;\n website?: string;\n email?: string;\n email_verified?: boolean;\n gender?: 'female' | 'male' | (string & {});\n birthdate?: string; // ISO 8601-1 [ISO8601‑1] YYYY-MM-DD format.\n zoneinfo?: string; // IANA Time Zone Database [IANA.time‑zones]\n locale?: string; // BCP47 [RFC5646] language tag.\n phone_number?: string; // E.164\n phone_number_verified?: boolean;\n address?: {\n formatted: string;\n street_address: string;\n locality: string;\n region: string;\n postal_code: string;\n country: string;\n }; // [RFC8259] JSON object\n updated_at?: number;\n}\n\nexport interface UserInfo<T = unknown> {\n claims: StandardClaims;\n data: T;\n}\n\nexport interface Provider {\n /** Authorization URI for the provider. */\n authorizationUri: string;\n\n /** Token URI for the provider. */\n tokenUri: string;\n\n /** Token revoke URI for the provider. */\n tokenRevokeUri?: string;\n\n /** Token refresh URI for the provider. */\n tokenRefreshUri?: string;\n\n /** User info URI for the provider. */\n userInfoUri?: string;\n\n /** User info authentication method for the provider. */\n userInfoAuthenticationMethod?: string;\n\n /**\n * Name of the attribute that will be used to extract the username from the call to 'userInfoUri'.\n * */\n userNameAttribute?: string;\n\n /** JWK set URI for the provider */\n jwkSetUri?: string;\n\n /**\n * URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 Authorization\n * Server Metadata endpoint defined by RFC 8414.\n * */\n issuerUri?: string;\n\n /** Default scopes for the provider. */\n defaultScope: string[];\n\n /** step 1: generate authorization uri and redirect user to it */\n createAuthorizationUri: (params: CreateAuthorizationUriParams) => URL;\n\n /** step 2: exchange code for token */\n exchangeAuthorizationCode: (params: ExchangeCodeParams) => Promise<OAuth2Token>;\n\n /** step 3: get user info */\n getUserInfo: (token: OAuth2Token) => Promise<UserInfo>;\n\n /** others: refresh access token */\n refreshAccessToken?: (params: RefreshTokenParams) => Promise<OAuth2Token>;\n\n /** others: revoke token */\n revokeToken?: (params: RevokeTokenParams) => Promise<void>;\n\n loginOAuth2Native?: (\n params: LoginOAuth2NativeParams\n ) => Promise<{ token: OAuth2Token; userInfo: UserInfo }>;\n}\n\nexport interface OneTapProvider extends Provider {\n getTokenInfo: (id_token: string) => Promise<{ token: OAuth2Token; userInfo: UserInfo }>;\n}\n\nexport interface Registration {\n /**\n * Reference to the OAuth 2.0 provider to use. May reference an element from the 'provider'\n * property or used one of the commonly used providers (google, github, facebook, okta).\n * */\n provider?: string;\n\n /** Client ID for the registration. */\n clientId: string;\n\n /** Client secret of the registration. */\n clientSecret: string;\n\n /** Client authentication method. May be left blank when using a pre-defined provider. */\n clientAuthenticationMethod?: string;\n\n /** Authorization grant type. May be left blank when using a pre-defined provider. */\n authorizationGrantType?:\n | 'authorization_code' // default\n | 'client_credentials'\n | 'device_code'\n | 'jwt_bearer'\n // Deprecated. The latest OAuth 2.0 Security Best Current Practice disallows the use of the\n // Resource Owner Password Credentials grant.\n | 'password'\n | 'refresh_token'\n | 'token_exchange';\n\n /** Redirect URI. May be left blank when using a pre-defined provider. */\n redirectUri?: string;\n\n /** Authorization scopes. When left blank the provider's default scopes, if any, will be used. */\n scope?: string[];\n\n /** Client name. May be left blank when using a pre-defined provider. */\n clientName?: string;\n}\n\nexport interface OAuth2ClientConfig {\n baseUri: string;\n errorUri: string;\n successUri: string;\n provider: { [name: string]: Provider | undefined };\n registration:\n | { [name: string]: Registration | undefined }\n | (() => Promise<{ [name: string]: Registration | undefined }>);\n}\n"],"mappings":";AAyGA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -1,46 +1,20 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/session/common.ts
21
- var common_exports = {};
22
- __export(common_exports, {
23
- PRINCIPAL_NAME_INDEX_NAME: () => PRINCIPAL_NAME_INDEX_NAME,
24
- SPRING_SECURITY_CONTEXT: () => SPRING_SECURITY_CONTEXT,
25
- resolveIndexesFor: () => resolveIndexesFor
26
- });
27
- module.exports = __toCommonJS(common_exports);
28
- var SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
29
- var PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/session/common.ts
3
+ const SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
4
+ const PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;
30
5
  function resolveIndexesFor(session) {
31
- const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME);
32
- if (principalName !== null) return principalName;
33
- const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);
34
- if (typeof jsonString === "string") {
35
- const context = JSON.parse(jsonString);
36
- return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;
37
- }
38
- return null;
6
+ const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME);
7
+ if (principalName !== null) return principalName;
8
+ const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);
9
+ if (typeof jsonString === "string") {
10
+ const context = JSON.parse(jsonString);
11
+ return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;
12
+ }
13
+ return null;
39
14
  }
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- PRINCIPAL_NAME_INDEX_NAME,
43
- SPRING_SECURITY_CONTEXT,
44
- resolveIndexesFor
45
- });
15
+ //#endregion
16
+ exports.PRINCIPAL_NAME_INDEX_NAME = PRINCIPAL_NAME_INDEX_NAME;
17
+ exports.SPRING_SECURITY_CONTEXT = SPRING_SECURITY_CONTEXT;
18
+ exports.resolveIndexesFor = resolveIndexesFor;
19
+
46
20
  //# sourceMappingURL=common.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/session/common.ts"],"sourcesContent":["import type { SecurityContext, Session } from './types';\n\nexport const SPRING_SECURITY_CONTEXT = 'SPRING_SECURITY_CONTEXT';\nexport const PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;\n\nexport function resolveIndexesFor(session: Session): string | null {\n const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME) as string | null;\n if (principalName !== null) return principalName;\n\n const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);\n if (typeof jsonString === 'string') {\n const context = JSON.parse(jsonString) as SecurityContext;\n return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,0BAA0B;AAChC,IAAM,4BAA4B;AAElC,SAAS,kBAAkB,SAAiC;AACjE,QAAM,gBAAgB,QAAQ,aAAa,yBAAyB;AACpE,MAAI,kBAAkB,KAAM,QAAO;AAEnC,QAAM,aAAa,QAAQ,aAAa,uBAAuB;AAC/D,MAAI,OAAO,eAAe,UAAU;AAClC,UAAM,UAAU,KAAK,MAAM,UAAU;AACrC,WAAO,SAAS,gBAAgB,QAAQ,QAAQ,gBAAgB,WAAW,QAAQ;AAAA,EACrF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"common.cjs","names":[],"sources":["../../src/session/common.ts"],"sourcesContent":["import type { SecurityContext, Session } from './types';\n\nexport const SPRING_SECURITY_CONTEXT = 'SPRING_SECURITY_CONTEXT';\nexport const PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;\n\nexport function resolveIndexesFor(session: Session): string | null {\n const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME) as string | null;\n if (principalName !== null) return principalName;\n\n const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);\n if (typeof jsonString === 'string') {\n const context = JSON.parse(jsonString) as SecurityContext;\n return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;\n }\n return null;\n}\n"],"mappings":";;AAEA,MAAa,0BAA0B;AACvC,MAAa,4BAA4B;AAEzC,SAAgB,kBAAkB,SAAiC;CACjE,MAAM,gBAAgB,QAAQ,aAAa,yBAAyB;CACpE,IAAI,kBAAkB,MAAM,OAAO;CAEnC,MAAM,aAAa,QAAQ,aAAa,uBAAuB;CAC/D,IAAI,OAAO,eAAe,UAAU;EAClC,MAAM,UAAU,KAAK,MAAM,UAAU;EACrC,OAAO,SAAS,gBAAgB,QAAQ,QAAQ,gBAAgB,WAAW,QAAQ;CACrF;CACA,OAAO;AACT"}
@@ -1,8 +1,8 @@
1
- import { Session } from './types.cjs';
2
- import '../core/index.cjs';
3
-
1
+ import { Session } from "./types.cjs";
2
+ //#region src/session/common.d.ts
4
3
  declare const SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
5
4
  declare const PRINCIPAL_NAME_INDEX_NAME = "org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME";
6
5
  declare function resolveIndexesFor(session: Session): string | null;
7
-
6
+ //#endregion
8
7
  export { PRINCIPAL_NAME_INDEX_NAME, SPRING_SECURITY_CONTEXT, resolveIndexesFor };
8
+ //# sourceMappingURL=common.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.cts","names":[],"sources":["../../src/session/common.ts"],"mappings":";;cAEa;cACA;iBAEG,kBAAkB,SAAS"}
@@ -1,8 +1,8 @@
1
- import { Session } from './types.js';
2
- import '../core/index.js';
3
-
1
+ import { Session } from "./types.mjs";
2
+ //#region src/session/common.d.ts
4
3
  declare const SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
5
4
  declare const PRINCIPAL_NAME_INDEX_NAME = "org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME";
6
5
  declare function resolveIndexesFor(session: Session): string | null;
7
-
6
+ //#endregion
8
7
  export { PRINCIPAL_NAME_INDEX_NAME, SPRING_SECURITY_CONTEXT, resolveIndexesFor };
8
+ //# sourceMappingURL=common.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.mts","names":[],"sources":["../../src/session/common.ts"],"mappings":";;cAEa;cACA;iBAEG,kBAAkB,SAAS"}
@@ -1,19 +1,17 @@
1
- // src/session/common.ts
2
- var SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
3
- var PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;
1
+ //#region src/session/common.ts
2
+ const SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
3
+ const PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;
4
4
  function resolveIndexesFor(session) {
5
- const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME);
6
- if (principalName !== null) return principalName;
7
- const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);
8
- if (typeof jsonString === "string") {
9
- const context = JSON.parse(jsonString);
10
- return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;
11
- }
12
- return null;
5
+ const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME);
6
+ if (principalName !== null) return principalName;
7
+ const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);
8
+ if (typeof jsonString === "string") {
9
+ const context = JSON.parse(jsonString);
10
+ return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;
11
+ }
12
+ return null;
13
13
  }
14
- export {
15
- PRINCIPAL_NAME_INDEX_NAME,
16
- SPRING_SECURITY_CONTEXT,
17
- resolveIndexesFor
18
- };
14
+ //#endregion
15
+ export { PRINCIPAL_NAME_INDEX_NAME, SPRING_SECURITY_CONTEXT, resolveIndexesFor };
16
+
19
17
  //# sourceMappingURL=common.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/session/common.ts"],"sourcesContent":["import type { SecurityContext, Session } from './types';\n\nexport const SPRING_SECURITY_CONTEXT = 'SPRING_SECURITY_CONTEXT';\nexport const PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;\n\nexport function resolveIndexesFor(session: Session): string | null {\n const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME) as string | null;\n if (principalName !== null) return principalName;\n\n const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);\n if (typeof jsonString === 'string') {\n const context = JSON.parse(jsonString) as SecurityContext;\n return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;\n }\n return null;\n}\n"],"mappings":";AAEO,IAAM,0BAA0B;AAChC,IAAM,4BAA4B;AAElC,SAAS,kBAAkB,SAAiC;AACjE,QAAM,gBAAgB,QAAQ,aAAa,yBAAyB;AACpE,MAAI,kBAAkB,KAAM,QAAO;AAEnC,QAAM,aAAa,QAAQ,aAAa,uBAAuB;AAC/D,MAAI,OAAO,eAAe,UAAU;AAClC,UAAM,UAAU,KAAK,MAAM,UAAU;AACrC,WAAO,SAAS,gBAAgB,QAAQ,QAAQ,gBAAgB,WAAW,QAAQ;AAAA,EACrF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"common.mjs","names":[],"sources":["../../src/session/common.ts"],"sourcesContent":["import type { SecurityContext, Session } from './types';\n\nexport const SPRING_SECURITY_CONTEXT = 'SPRING_SECURITY_CONTEXT';\nexport const PRINCIPAL_NAME_INDEX_NAME = `org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME`;\n\nexport function resolveIndexesFor(session: Session): string | null {\n const principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME) as string | null;\n if (principalName !== null) return principalName;\n\n const jsonString = session.getAttribute(SPRING_SECURITY_CONTEXT);\n if (typeof jsonString === 'string') {\n const context = JSON.parse(jsonString) as SecurityContext;\n return context?.authentication?.name ?? context.authentication?.principal?.name ?? null;\n }\n return null;\n}\n"],"mappings":";AAEA,MAAa,0BAA0B;AACvC,MAAa,4BAA4B;AAEzC,SAAgB,kBAAkB,SAAiC;CACjE,MAAM,gBAAgB,QAAQ,aAAa,yBAAyB;CACpE,IAAI,kBAAkB,MAAM,OAAO;CAEnC,MAAM,aAAa,QAAQ,aAAa,uBAAuB;CAC/D,IAAI,OAAO,eAAe,UAAU;EAClC,MAAM,UAAU,KAAK,MAAM,UAAU;EACrC,OAAO,SAAS,gBAAgB,QAAQ,QAAQ,gBAAgB,WAAW,QAAQ;CACrF;CACA,OAAO;AACT"}
@@ -1,127 +1,92 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/session/db.ts
21
- var db_exports = {};
22
- __export(db_exports, {
23
- DBIndexedSessionRepository: () => DBIndexedSessionRepository
24
- });
25
- module.exports = __toCommonJS(db_exports);
26
- var import_node_crypto = require("crypto");
27
- var import_common = require("./common.cjs");
28
- var import_map_session = require("./map-session.cjs");
29
- var DBSession = class extends import_map_session.MapSession {
30
- isNew;
31
- primaryId;
32
- constructor(cached, isNew) {
33
- super(cached);
34
- this.isNew = isNew;
35
- this.primaryId = (0, import_node_crypto.randomUUID)();
36
- }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_session_common = require("./common.cjs");
3
+ const require_session_map_session = require("./map-session.cjs");
4
+ let node_crypto = require("node:crypto");
5
+ //#region src/session/db.ts
6
+ var DBSession = class extends require_session_map_session.MapSession {
7
+ isNew;
8
+ primaryId;
9
+ constructor(cached, isNew) {
10
+ super(cached);
11
+ this.isNew = isNew;
12
+ this.primaryId = (0, node_crypto.randomUUID)();
13
+ }
37
14
  };
38
15
  var DBIndexedSessionRepository = class {
39
- defaultMaxInactiveInterval = 1800;
40
- db;
41
- constructor(db) {
42
- this.db = db;
43
- }
44
- setDefaultMaxInactiveInterval(interval) {
45
- this.defaultMaxInactiveInterval = interval;
46
- }
47
- mapSessionToEntity(session) {
48
- const attributes = {};
49
- for (const name of session.getAttributeNames()) {
50
- attributes[name] = session.getAttribute(name);
51
- }
52
- const principalName = (0, import_common.resolveIndexesFor)(session);
53
- return {
54
- primaryId: session.primaryId,
55
- sessionId: session.getId(),
56
- creationTime: session.getCreationTime(),
57
- lastAccessTime: session.getLastAccessedTime(),
58
- maxInactiveInterval: session.getMaxInactiveInterval(),
59
- expiryTime: session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1e3,
60
- attributes,
61
- principalName
62
- };
63
- }
64
- mapEntityToSession(entity, allowExpired) {
65
- const loaded = new import_map_session.MapSession(entity.sessionId);
66
- loaded.setCreationTime(entity.creationTime);
67
- loaded.setLastAccessedTime(entity.lastAccessTime);
68
- loaded.setMaxInactiveInterval(entity.maxInactiveInterval);
69
- for (const [key, value] of Object.entries(entity.attributes)) {
70
- loaded.setAttribute(key, value);
71
- }
72
- if (!allowExpired && loaded.isExpired()) return null;
73
- const session = new DBSession(loaded, false);
74
- session.primaryId = entity.primaryId;
75
- return session;
76
- }
77
- async getSession(id, allowExpired) {
78
- const entity = await this.db.findById(id);
79
- if (!entity) return null;
80
- return this.mapEntityToSession(entity, allowExpired);
81
- }
82
- // override
83
- createSession() {
84
- const cached = new import_map_session.MapSession();
85
- cached.setMaxInactiveInterval(this.defaultMaxInactiveInterval);
86
- return new DBSession(cached, true);
87
- }
88
- async save(session) {
89
- const entity = this.mapSessionToEntity(session);
90
- await this.db.save(entity);
91
- session.isNew = false;
92
- }
93
- async findById(sessionId) {
94
- return this.getSession(sessionId, false);
95
- }
96
- async deleteById(sessionId) {
97
- await this.db.deleteById(sessionId);
98
- }
99
- async findByIndexNameAndIndexValue(indexName, indexValue) {
100
- if (indexName !== import_common.PRINCIPAL_NAME_INDEX_NAME) {
101
- return /* @__PURE__ */ new Map();
102
- }
103
- const entities = await this.db.findByPrincipalName(indexValue);
104
- if (entities.length === 0) {
105
- return /* @__PURE__ */ new Map();
106
- }
107
- const sessions = /* @__PURE__ */ new Map();
108
- for (const entity of entities) {
109
- const session = this.mapEntityToSession(entity, false);
110
- if (session) {
111
- sessions.set(session.getId(), session);
112
- }
113
- }
114
- return sessions;
115
- }
116
- async findByPrincipalName(principalName) {
117
- return this.findByIndexNameAndIndexValue(import_common.PRINCIPAL_NAME_INDEX_NAME, principalName);
118
- }
119
- async cleanupExpiredSessions(cleanupCount) {
120
- return this.db.cleanupExpiredSessions(cleanupCount);
121
- }
16
+ defaultMaxInactiveInterval = 1800;
17
+ db;
18
+ constructor(db) {
19
+ this.db = db;
20
+ }
21
+ setDefaultMaxInactiveInterval(interval) {
22
+ this.defaultMaxInactiveInterval = interval;
23
+ }
24
+ mapSessionToEntity(session) {
25
+ const attributes = {};
26
+ for (const name of session.getAttributeNames()) attributes[name] = session.getAttribute(name);
27
+ const principalName = require_session_common.resolveIndexesFor(session);
28
+ return {
29
+ primaryId: session.primaryId,
30
+ sessionId: session.getId(),
31
+ creationTime: session.getCreationTime(),
32
+ lastAccessTime: session.getLastAccessedTime(),
33
+ maxInactiveInterval: session.getMaxInactiveInterval(),
34
+ expiryTime: session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1e3,
35
+ attributes,
36
+ principalName
37
+ };
38
+ }
39
+ mapEntityToSession(entity, allowExpired) {
40
+ const loaded = new require_session_map_session.MapSession(entity.sessionId);
41
+ loaded.setCreationTime(entity.creationTime);
42
+ loaded.setLastAccessedTime(entity.lastAccessTime);
43
+ loaded.setMaxInactiveInterval(entity.maxInactiveInterval);
44
+ for (const [key, value] of Object.entries(entity.attributes)) loaded.setAttribute(key, value);
45
+ if (!allowExpired && loaded.isExpired()) return null;
46
+ const session = new DBSession(loaded, false);
47
+ session.primaryId = entity.primaryId;
48
+ return session;
49
+ }
50
+ async getSession(id, allowExpired) {
51
+ const entity = await this.db.findById(id);
52
+ if (!entity) return null;
53
+ return this.mapEntityToSession(entity, allowExpired);
54
+ }
55
+ createSession() {
56
+ const cached = new require_session_map_session.MapSession();
57
+ cached.setMaxInactiveInterval(this.defaultMaxInactiveInterval);
58
+ return new DBSession(cached, true);
59
+ }
60
+ async save(session) {
61
+ const entity = this.mapSessionToEntity(session);
62
+ await this.db.save(entity);
63
+ session.isNew = false;
64
+ }
65
+ async findById(sessionId) {
66
+ return this.getSession(sessionId, false);
67
+ }
68
+ async deleteById(sessionId) {
69
+ await this.db.deleteById(sessionId);
70
+ }
71
+ async findByIndexNameAndIndexValue(indexName, indexValue) {
72
+ if (indexName !== require_session_common.PRINCIPAL_NAME_INDEX_NAME) return /* @__PURE__ */ new Map();
73
+ const entities = await this.db.findByPrincipalName(indexValue);
74
+ if (entities.length === 0) return /* @__PURE__ */ new Map();
75
+ const sessions = /* @__PURE__ */ new Map();
76
+ for (const entity of entities) {
77
+ const session = this.mapEntityToSession(entity, false);
78
+ if (session) sessions.set(session.getId(), session);
79
+ }
80
+ return sessions;
81
+ }
82
+ async findByPrincipalName(principalName) {
83
+ return this.findByIndexNameAndIndexValue(require_session_common.PRINCIPAL_NAME_INDEX_NAME, principalName);
84
+ }
85
+ async cleanupExpiredSessions(cleanupCount) {
86
+ return this.db.cleanupExpiredSessions(cleanupCount);
87
+ }
122
88
  };
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- DBIndexedSessionRepository
126
- });
89
+ //#endregion
90
+ exports.DBIndexedSessionRepository = DBIndexedSessionRepository;
91
+
127
92
  //# sourceMappingURL=db.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/session/db.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { PRINCIPAL_NAME_INDEX_NAME, resolveIndexesFor } from './common';\nimport { MapSession } from './map-session';\nimport type { SessionRepository } from './types';\n\ninterface SessionEntity {\n primaryId: string;\n sessionId: string;\n creationTime: number;\n lastAccessTime: number;\n maxInactiveInterval: number;\n expiryTime: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n attributes: Record<string, any>;\n principalName?: string | null;\n}\n\nclass DBSession extends MapSession {\n public isNew: boolean;\n public primaryId: string;\n\n constructor(cached: MapSession, isNew: boolean) {\n super(cached);\n this.isNew = isNew;\n this.primaryId = randomUUID();\n }\n}\n\nexport interface DBAdapter {\n save(session: SessionEntity): Promise<void>;\n deleteById(sessionId: string): Promise<void>;\n findById(sessionId: string): Promise<SessionEntity | null>;\n findByPrincipalName(principalName: string): Promise<SessionEntity[]>;\n cleanupExpiredSessions(cleanupCount?: number): Promise<void>;\n}\n\nexport class DBIndexedSessionRepository implements SessionRepository<DBSession> {\n private defaultMaxInactiveInterval = 1800;\n private db: DBAdapter;\n\n constructor(db: DBAdapter) {\n this.db = db;\n }\n\n setDefaultMaxInactiveInterval(interval: number) {\n this.defaultMaxInactiveInterval = interval;\n }\n\n private mapSessionToEntity(session: DBSession): SessionEntity {\n const attributes: Record<string, string | number | null> = {};\n for (const name of session.getAttributeNames()) {\n attributes[name] = session.getAttribute(name);\n }\n const principalName = resolveIndexesFor(session);\n\n return {\n primaryId: session.primaryId,\n sessionId: session.getId(),\n creationTime: session.getCreationTime(),\n lastAccessTime: session.getLastAccessedTime(),\n maxInactiveInterval: session.getMaxInactiveInterval(),\n expiryTime: session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1000,\n attributes,\n principalName,\n };\n }\n\n private mapEntityToSession(entity: SessionEntity, allowExpired: boolean): DBSession | null {\n const loaded = new MapSession(entity.sessionId);\n loaded.setCreationTime(entity.creationTime);\n loaded.setLastAccessedTime(entity.lastAccessTime);\n loaded.setMaxInactiveInterval(entity.maxInactiveInterval);\n for (const [key, value] of Object.entries(entity.attributes)) {\n loaded.setAttribute(key, value);\n }\n\n if (!allowExpired && loaded.isExpired()) return null;\n const session = new DBSession(loaded, false);\n session.primaryId = entity.primaryId;\n return session;\n }\n\n private async getSession(id: string, allowExpired: boolean): Promise<DBSession | null> {\n const entity = await this.db.findById(id);\n if (!entity) return null;\n return this.mapEntityToSession(entity, allowExpired);\n }\n\n // override\n createSession() {\n const cached = new MapSession();\n cached.setMaxInactiveInterval(this.defaultMaxInactiveInterval);\n return new DBSession(cached, true);\n }\n\n async save(session: DBSession) {\n const entity = this.mapSessionToEntity(session);\n await this.db.save(entity);\n session.isNew = false;\n }\n\n async findById(sessionId: string): Promise<DBSession | null> {\n return this.getSession(sessionId, false);\n }\n\n async deleteById(sessionId: string) {\n await this.db.deleteById(sessionId);\n }\n\n async findByIndexNameAndIndexValue(\n indexName: string,\n indexValue: string\n ): Promise<Map<string, DBSession>> {\n if (indexName !== PRINCIPAL_NAME_INDEX_NAME) {\n return new Map<string, DBSession>();\n }\n const entities = await this.db.findByPrincipalName(indexValue);\n if (entities.length === 0) {\n return new Map<string, DBSession>();\n }\n const sessions = new Map<string, DBSession>();\n for (const entity of entities) {\n const session = this.mapEntityToSession(entity, false);\n if (session) {\n sessions.set(session.getId(), session);\n }\n }\n return sessions;\n }\n\n async findByPrincipalName(principalName: string): Promise<Map<string, DBSession>> {\n return this.findByIndexNameAndIndexValue(PRINCIPAL_NAME_INDEX_NAME, principalName);\n }\n\n async cleanupExpiredSessions(cleanupCount?: number): Promise<void> {\n return this.db.cleanupExpiredSessions(cleanupCount);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,oBAA6D;AAC7D,yBAA2B;AAe3B,IAAM,YAAN,cAAwB,8BAAW;AAAA,EAC1B;AAAA,EACA;AAAA,EAEP,YAAY,QAAoB,OAAgB;AAC9C,UAAM,MAAM;AACZ,SAAK,QAAQ;AACb,SAAK,gBAAY,+BAAW;AAAA,EAC9B;AACF;AAUO,IAAM,6BAAN,MAAyE;AAAA,EACtE,6BAA6B;AAAA,EAC7B;AAAA,EAER,YAAY,IAAe;AACzB,SAAK,KAAK;AAAA,EACZ;AAAA,EAEA,8BAA8B,UAAkB;AAC9C,SAAK,6BAA6B;AAAA,EACpC;AAAA,EAEQ,mBAAmB,SAAmC;AAC5D,UAAM,aAAqD,CAAC;AAC5D,eAAW,QAAQ,QAAQ,kBAAkB,GAAG;AAC9C,iBAAW,IAAI,IAAI,QAAQ,aAAa,IAAI;AAAA,IAC9C;AACA,UAAM,oBAAgB,iCAAkB,OAAO;AAE/C,WAAO;AAAA,MACL,WAAW,QAAQ;AAAA,MACnB,WAAW,QAAQ,MAAM;AAAA,MACzB,cAAc,QAAQ,gBAAgB;AAAA,MACtC,gBAAgB,QAAQ,oBAAoB;AAAA,MAC5C,qBAAqB,QAAQ,uBAAuB;AAAA,MACpD,YAAY,QAAQ,oBAAoB,IAAI,QAAQ,uBAAuB,IAAI;AAAA,MAC/E;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,mBAAmB,QAAuB,cAAyC;AACzF,UAAM,SAAS,IAAI,8BAAW,OAAO,SAAS;AAC9C,WAAO,gBAAgB,OAAO,YAAY;AAC1C,WAAO,oBAAoB,OAAO,cAAc;AAChD,WAAO,uBAAuB,OAAO,mBAAmB;AACxD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,UAAU,GAAG;AAC5D,aAAO,aAAa,KAAK,KAAK;AAAA,IAChC;AAEA,QAAI,CAAC,gBAAgB,OAAO,UAAU,EAAG,QAAO;AAChD,UAAM,UAAU,IAAI,UAAU,QAAQ,KAAK;AAC3C,YAAQ,YAAY,OAAO;AAC3B,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,WAAW,IAAY,cAAkD;AACrF,UAAM,SAAS,MAAM,KAAK,GAAG,SAAS,EAAE;AACxC,QAAI,CAAC,OAAQ,QAAO;AACpB,WAAO,KAAK,mBAAmB,QAAQ,YAAY;AAAA,EACrD;AAAA;AAAA,EAGA,gBAAgB;AACd,UAAM,SAAS,IAAI,8BAAW;AAC9B,WAAO,uBAAuB,KAAK,0BAA0B;AAC7D,WAAO,IAAI,UAAU,QAAQ,IAAI;AAAA,EACnC;AAAA,EAEA,MAAM,KAAK,SAAoB;AAC7B,UAAM,SAAS,KAAK,mBAAmB,OAAO;AAC9C,UAAM,KAAK,GAAG,KAAK,MAAM;AACzB,YAAQ,QAAQ;AAAA,EAClB;AAAA,EAEA,MAAM,SAAS,WAA8C;AAC3D,WAAO,KAAK,WAAW,WAAW,KAAK;AAAA,EACzC;AAAA,EAEA,MAAM,WAAW,WAAmB;AAClC,UAAM,KAAK,GAAG,WAAW,SAAS;AAAA,EACpC;AAAA,EAEA,MAAM,6BACJ,WACA,YACiC;AACjC,QAAI,cAAc,yCAA2B;AAC3C,aAAO,oBAAI,IAAuB;AAAA,IACpC;AACA,UAAM,WAAW,MAAM,KAAK,GAAG,oBAAoB,UAAU;AAC7D,QAAI,SAAS,WAAW,GAAG;AACzB,aAAO,oBAAI,IAAuB;AAAA,IACpC;AACA,UAAM,WAAW,oBAAI,IAAuB;AAC5C,eAAW,UAAU,UAAU;AAC7B,YAAM,UAAU,KAAK,mBAAmB,QAAQ,KAAK;AACrD,UAAI,SAAS;AACX,iBAAS,IAAI,QAAQ,MAAM,GAAG,OAAO;AAAA,MACvC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,oBAAoB,eAAwD;AAChF,WAAO,KAAK,6BAA6B,yCAA2B,aAAa;AAAA,EACnF;AAAA,EAEA,MAAM,uBAAuB,cAAsC;AACjE,WAAO,KAAK,GAAG,uBAAuB,YAAY;AAAA,EACpD;AACF;","names":[]}
1
+ {"version":3,"file":"db.cjs","names":["MapSession","resolveIndexesFor","PRINCIPAL_NAME_INDEX_NAME"],"sources":["../../src/session/db.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { PRINCIPAL_NAME_INDEX_NAME, resolveIndexesFor } from './common';\nimport { MapSession } from './map-session';\nimport type { SessionRepository } from './types';\n\ninterface SessionEntity {\n primaryId: string;\n sessionId: string;\n creationTime: number;\n lastAccessTime: number;\n maxInactiveInterval: number;\n expiryTime: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n attributes: Record<string, any>;\n principalName?: string | null;\n}\n\nclass DBSession extends MapSession {\n public isNew: boolean;\n public primaryId: string;\n\n constructor(cached: MapSession, isNew: boolean) {\n super(cached);\n this.isNew = isNew;\n this.primaryId = randomUUID();\n }\n}\n\nexport interface DBAdapter {\n save(session: SessionEntity): Promise<void>;\n deleteById(sessionId: string): Promise<void>;\n findById(sessionId: string): Promise<SessionEntity | null>;\n findByPrincipalName(principalName: string): Promise<SessionEntity[]>;\n cleanupExpiredSessions(cleanupCount?: number): Promise<void>;\n}\n\nexport class DBIndexedSessionRepository implements SessionRepository<DBSession> {\n private defaultMaxInactiveInterval = 1800;\n private db: DBAdapter;\n\n constructor(db: DBAdapter) {\n this.db = db;\n }\n\n setDefaultMaxInactiveInterval(interval: number) {\n this.defaultMaxInactiveInterval = interval;\n }\n\n private mapSessionToEntity(session: DBSession): SessionEntity {\n const attributes: Record<string, string | number | null> = {};\n for (const name of session.getAttributeNames()) {\n attributes[name] = session.getAttribute(name);\n }\n const principalName = resolveIndexesFor(session);\n\n return {\n primaryId: session.primaryId,\n sessionId: session.getId(),\n creationTime: session.getCreationTime(),\n lastAccessTime: session.getLastAccessedTime(),\n maxInactiveInterval: session.getMaxInactiveInterval(),\n expiryTime: session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1000,\n attributes,\n principalName,\n };\n }\n\n private mapEntityToSession(entity: SessionEntity, allowExpired: boolean): DBSession | null {\n const loaded = new MapSession(entity.sessionId);\n loaded.setCreationTime(entity.creationTime);\n loaded.setLastAccessedTime(entity.lastAccessTime);\n loaded.setMaxInactiveInterval(entity.maxInactiveInterval);\n for (const [key, value] of Object.entries(entity.attributes)) {\n loaded.setAttribute(key, value);\n }\n\n if (!allowExpired && loaded.isExpired()) return null;\n const session = new DBSession(loaded, false);\n session.primaryId = entity.primaryId;\n return session;\n }\n\n private async getSession(id: string, allowExpired: boolean): Promise<DBSession | null> {\n const entity = await this.db.findById(id);\n if (!entity) return null;\n return this.mapEntityToSession(entity, allowExpired);\n }\n\n // override\n createSession() {\n const cached = new MapSession();\n cached.setMaxInactiveInterval(this.defaultMaxInactiveInterval);\n return new DBSession(cached, true);\n }\n\n async save(session: DBSession) {\n const entity = this.mapSessionToEntity(session);\n await this.db.save(entity);\n session.isNew = false;\n }\n\n async findById(sessionId: string): Promise<DBSession | null> {\n return this.getSession(sessionId, false);\n }\n\n async deleteById(sessionId: string) {\n await this.db.deleteById(sessionId);\n }\n\n async findByIndexNameAndIndexValue(\n indexName: string,\n indexValue: string\n ): Promise<Map<string, DBSession>> {\n if (indexName !== PRINCIPAL_NAME_INDEX_NAME) {\n return new Map<string, DBSession>();\n }\n const entities = await this.db.findByPrincipalName(indexValue);\n if (entities.length === 0) {\n return new Map<string, DBSession>();\n }\n const sessions = new Map<string, DBSession>();\n for (const entity of entities) {\n const session = this.mapEntityToSession(entity, false);\n if (session) {\n sessions.set(session.getId(), session);\n }\n }\n return sessions;\n }\n\n async findByPrincipalName(principalName: string): Promise<Map<string, DBSession>> {\n return this.findByIndexNameAndIndexValue(PRINCIPAL_NAME_INDEX_NAME, principalName);\n }\n\n async cleanupExpiredSessions(cleanupCount?: number): Promise<void> {\n return this.db.cleanupExpiredSessions(cleanupCount);\n }\n}\n"],"mappings":";;;;;AAiBA,IAAM,YAAN,cAAwBA,4BAAAA,WAAW;CACjC;CACA;CAEA,YAAY,QAAoB,OAAgB;EAC9C,MAAM,MAAM;EACZ,KAAK,QAAQ;EACb,KAAK,aAAA,GAAA,YAAA,WAAA,CAAuB;CAC9B;AACF;AAUA,IAAa,6BAAb,MAAgF;CAC9E,6BAAqC;CACrC;CAEA,YAAY,IAAe;EACzB,KAAK,KAAK;CACZ;CAEA,8BAA8B,UAAkB;EAC9C,KAAK,6BAA6B;CACpC;CAEA,mBAA2B,SAAmC;EAC5D,MAAM,aAAqD,CAAC;EAC5D,KAAK,MAAM,QAAQ,QAAQ,kBAAkB,GAC3C,WAAW,QAAQ,QAAQ,aAAa,IAAI;EAE9C,MAAM,gBAAgBC,uBAAAA,kBAAkB,OAAO;EAE/C,OAAO;GACL,WAAW,QAAQ;GACnB,WAAW,QAAQ,MAAM;GACzB,cAAc,QAAQ,gBAAgB;GACtC,gBAAgB,QAAQ,oBAAoB;GAC5C,qBAAqB,QAAQ,uBAAuB;GACpD,YAAY,QAAQ,oBAAoB,IAAI,QAAQ,uBAAuB,IAAI;GAC/E;GACA;EACF;CACF;CAEA,mBAA2B,QAAuB,cAAyC;EACzF,MAAM,SAAS,IAAID,4BAAAA,WAAW,OAAO,SAAS;EAC9C,OAAO,gBAAgB,OAAO,YAAY;EAC1C,OAAO,oBAAoB,OAAO,cAAc;EAChD,OAAO,uBAAuB,OAAO,mBAAmB;EACxD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,UAAU,GACzD,OAAO,aAAa,KAAK,KAAK;EAGhC,IAAI,CAAC,gBAAgB,OAAO,UAAU,GAAG,OAAO;EAChD,MAAM,UAAU,IAAI,UAAU,QAAQ,KAAK;EAC3C,QAAQ,YAAY,OAAO;EAC3B,OAAO;CACT;CAEA,MAAc,WAAW,IAAY,cAAkD;EACrF,MAAM,SAAS,MAAM,KAAK,GAAG,SAAS,EAAE;EACxC,IAAI,CAAC,QAAQ,OAAO;EACpB,OAAO,KAAK,mBAAmB,QAAQ,YAAY;CACrD;CAGA,gBAAgB;EACd,MAAM,SAAS,IAAIA,4BAAAA,WAAW;EAC9B,OAAO,uBAAuB,KAAK,0BAA0B;EAC7D,OAAO,IAAI,UAAU,QAAQ,IAAI;CACnC;CAEA,MAAM,KAAK,SAAoB;EAC7B,MAAM,SAAS,KAAK,mBAAmB,OAAO;EAC9C,MAAM,KAAK,GAAG,KAAK,MAAM;EACzB,QAAQ,QAAQ;CAClB;CAEA,MAAM,SAAS,WAA8C;EAC3D,OAAO,KAAK,WAAW,WAAW,KAAK;CACzC;CAEA,MAAM,WAAW,WAAmB;EAClC,MAAM,KAAK,GAAG,WAAW,SAAS;CACpC;CAEA,MAAM,6BACJ,WACA,YACiC;EACjC,IAAI,cAAcE,uBAAAA,2BAChB,uBAAO,IAAI,IAAuB;EAEpC,MAAM,WAAW,MAAM,KAAK,GAAG,oBAAoB,UAAU;EAC7D,IAAI,SAAS,WAAW,GACtB,uBAAO,IAAI,IAAuB;EAEpC,MAAM,2BAAW,IAAI,IAAuB;EAC5C,KAAK,MAAM,UAAU,UAAU;GAC7B,MAAM,UAAU,KAAK,mBAAmB,QAAQ,KAAK;GACrD,IAAI,SACF,SAAS,IAAI,QAAQ,MAAM,GAAG,OAAO;EAEzC;EACA,OAAO;CACT;CAEA,MAAM,oBAAoB,eAAwD;EAChF,OAAO,KAAK,6BAA6BA,uBAAAA,2BAA2B,aAAa;CACnF;CAEA,MAAM,uBAAuB,cAAsC;EACjE,OAAO,KAAK,GAAG,uBAAuB,YAAY;CACpD;AACF"}
@@ -1,44 +1,44 @@
1
- import { MapSession } from './map-session.cjs';
2
- import { SessionRepository } from './types.cjs';
3
- import '../core/index.cjs';
4
-
1
+ import { SessionRepository } from "./types.cjs";
2
+ import { MapSession } from "./map-session.cjs";
3
+ //#region src/session/db.d.ts
5
4
  interface SessionEntity {
6
- primaryId: string;
7
- sessionId: string;
8
- creationTime: number;
9
- lastAccessTime: number;
10
- maxInactiveInterval: number;
11
- expiryTime: number;
12
- attributes: Record<string, any>;
13
- principalName?: string | null;
5
+ primaryId: string;
6
+ sessionId: string;
7
+ creationTime: number;
8
+ lastAccessTime: number;
9
+ maxInactiveInterval: number;
10
+ expiryTime: number;
11
+ attributes: Record<string, any>;
12
+ principalName?: string | null;
14
13
  }
15
14
  declare class DBSession extends MapSession {
16
- isNew: boolean;
17
- primaryId: string;
18
- constructor(cached: MapSession, isNew: boolean);
15
+ isNew: boolean;
16
+ primaryId: string;
17
+ constructor(cached: MapSession, isNew: boolean);
19
18
  }
20
19
  interface DBAdapter {
21
- save(session: SessionEntity): Promise<void>;
22
- deleteById(sessionId: string): Promise<void>;
23
- findById(sessionId: string): Promise<SessionEntity | null>;
24
- findByPrincipalName(principalName: string): Promise<SessionEntity[]>;
25
- cleanupExpiredSessions(cleanupCount?: number): Promise<void>;
20
+ save(session: SessionEntity): Promise<void>;
21
+ deleteById(sessionId: string): Promise<void>;
22
+ findById(sessionId: string): Promise<SessionEntity | null>;
23
+ findByPrincipalName(principalName: string): Promise<SessionEntity[]>;
24
+ cleanupExpiredSessions(cleanupCount?: number): Promise<void>;
26
25
  }
27
26
  declare class DBIndexedSessionRepository implements SessionRepository<DBSession> {
28
- private defaultMaxInactiveInterval;
29
- private db;
30
- constructor(db: DBAdapter);
31
- setDefaultMaxInactiveInterval(interval: number): void;
32
- private mapSessionToEntity;
33
- private mapEntityToSession;
34
- private getSession;
35
- createSession(): DBSession;
36
- save(session: DBSession): Promise<void>;
37
- findById(sessionId: string): Promise<DBSession | null>;
38
- deleteById(sessionId: string): Promise<void>;
39
- findByIndexNameAndIndexValue(indexName: string, indexValue: string): Promise<Map<string, DBSession>>;
40
- findByPrincipalName(principalName: string): Promise<Map<string, DBSession>>;
41
- cleanupExpiredSessions(cleanupCount?: number): Promise<void>;
27
+ private defaultMaxInactiveInterval;
28
+ private db;
29
+ constructor(db: DBAdapter);
30
+ setDefaultMaxInactiveInterval(interval: number): void;
31
+ private mapSessionToEntity;
32
+ private mapEntityToSession;
33
+ private getSession;
34
+ createSession(): DBSession;
35
+ save(session: DBSession): Promise<void>;
36
+ findById(sessionId: string): Promise<DBSession | null>;
37
+ deleteById(sessionId: string): Promise<void>;
38
+ findByIndexNameAndIndexValue(indexName: string, indexValue: string): Promise<Map<string, DBSession>>;
39
+ findByPrincipalName(principalName: string): Promise<Map<string, DBSession>>;
40
+ cleanupExpiredSessions(cleanupCount?: number): Promise<void>;
42
41
  }
43
-
44
- export { type DBAdapter, DBIndexedSessionRepository };
42
+ //#endregion
43
+ export { DBAdapter, DBIndexedSessionRepository };
44
+ //# sourceMappingURL=db.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.d.cts","names":[],"sources":["../../src/session/db.ts"],"mappings":";;;UAKU;EACR;EACA;EACA;EACA;EACA;EACA;EAEA,YAAY;EACZ;;cAGI,kBAAkB;EACf;EACA;EAEP,YAAY,QAAQ,YAAY;;UAOjB;EACf,KAAK,SAAS,gBAAgB;EAC9B,WAAW,oBAAoB;EAC/B,SAAS,oBAAoB,QAAQ;EACrC,oBAAoB,wBAAwB,QAAQ;EACpD,uBAAuB,wBAAwB;;cAGpC,sCAAsC,kBAAkB;UAC3D;UACA;EAER,YAAY,IAAI;EAIhB,8BAA8B;UAItB;UAmBA;UAeM;EAOd,iBAAa;EAMP,KAAK,SAAS,YAAS;EAMvB,SAAS,oBAAoB,QAAQ;EAIrC,WAAW,oBAAiB;EAI5B,6BACJ,mBACA,qBACC,QAAQ,YAAY;EAkBjB,oBAAoB,wBAAwB,QAAQ,YAAY;EAIhE,uBAAuB,wBAAwB"}
@@ -0,0 +1,44 @@
1
+ import { SessionRepository } from "./types.mjs";
2
+ import { MapSession } from "./map-session.mjs";
3
+ //#region src/session/db.d.ts
4
+ interface SessionEntity {
5
+ primaryId: string;
6
+ sessionId: string;
7
+ creationTime: number;
8
+ lastAccessTime: number;
9
+ maxInactiveInterval: number;
10
+ expiryTime: number;
11
+ attributes: Record<string, any>;
12
+ principalName?: string | null;
13
+ }
14
+ declare class DBSession extends MapSession {
15
+ isNew: boolean;
16
+ primaryId: string;
17
+ constructor(cached: MapSession, isNew: boolean);
18
+ }
19
+ interface DBAdapter {
20
+ save(session: SessionEntity): Promise<void>;
21
+ deleteById(sessionId: string): Promise<void>;
22
+ findById(sessionId: string): Promise<SessionEntity | null>;
23
+ findByPrincipalName(principalName: string): Promise<SessionEntity[]>;
24
+ cleanupExpiredSessions(cleanupCount?: number): Promise<void>;
25
+ }
26
+ declare class DBIndexedSessionRepository implements SessionRepository<DBSession> {
27
+ private defaultMaxInactiveInterval;
28
+ private db;
29
+ constructor(db: DBAdapter);
30
+ setDefaultMaxInactiveInterval(interval: number): void;
31
+ private mapSessionToEntity;
32
+ private mapEntityToSession;
33
+ private getSession;
34
+ createSession(): DBSession;
35
+ save(session: DBSession): Promise<void>;
36
+ findById(sessionId: string): Promise<DBSession | null>;
37
+ deleteById(sessionId: string): Promise<void>;
38
+ findByIndexNameAndIndexValue(indexName: string, indexValue: string): Promise<Map<string, DBSession>>;
39
+ findByPrincipalName(principalName: string): Promise<Map<string, DBSession>>;
40
+ cleanupExpiredSessions(cleanupCount?: number): Promise<void>;
41
+ }
42
+ //#endregion
43
+ export { DBAdapter, DBIndexedSessionRepository };
44
+ //# sourceMappingURL=db.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.d.mts","names":[],"sources":["../../src/session/db.ts"],"mappings":";;;UAKU;EACR;EACA;EACA;EACA;EACA;EACA;EAEA,YAAY;EACZ;;cAGI,kBAAkB;EACf;EACA;EAEP,YAAY,QAAQ,YAAY;;UAOjB;EACf,KAAK,SAAS,gBAAgB;EAC9B,WAAW,oBAAoB;EAC/B,SAAS,oBAAoB,QAAQ;EACrC,oBAAoB,wBAAwB,QAAQ;EACpD,uBAAuB,wBAAwB;;cAGpC,sCAAsC,kBAAkB;UAC3D;UACA;EAER,YAAY,IAAI;EAIhB,8BAA8B;UAItB;UAmBA;UAeM;EAOd,iBAAa;EAMP,KAAK,SAAS,YAAS;EAMvB,SAAS,oBAAoB,QAAQ;EAIrC,WAAW,oBAAiB;EAI5B,6BACJ,mBACA,qBACC,QAAQ,YAAY;EAkBjB,oBAAoB,wBAAwB,QAAQ,YAAY;EAIhE,uBAAuB,wBAAwB"}