@shware/security 2.5.3 → 2.6.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 +520 -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 +513 -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 +34 -59
  16. package/dist/core/index.cjs.map +1 -1
  17. package/dist/core/index.d.cts +23 -21
  18. package/dist/core/index.d.cts.map +1 -0
  19. package/dist/core/index.d.mts +34 -0
  20. package/dist/core/index.d.mts.map +1 -0
  21. package/dist/core/index.mjs +32 -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 +17 -54
  32. package/dist/index.d.cts +10 -15
  33. package/dist/index.d.mts +10 -0
  34. package/dist/index.mjs +4 -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 +13 -37
  112. package/dist/oauth2/types.cjs.map +1 -1
  113. package/dist/oauth2/types.d.cts +180 -178
  114. package/dist/oauth2/types.d.cts.map +1 -0
  115. package/dist/oauth2/types.d.mts +213 -0
  116. package/dist/oauth2/types.d.mts.map +1 -0
  117. package/dist/oauth2/types.mjs +13 -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,59 +0,0 @@
1
- import { OAuth2Token, Provider } from '../types.js';
2
-
3
- declare function createGithubProvider(): Provider;
4
- declare const github: Provider;
5
- interface GithubUserInfo {
6
- login: string;
7
- id: string;
8
- node_id: string;
9
- avatar_url: string;
10
- gravatar_id: string;
11
- url: string;
12
- html_url: string;
13
- followers_url: string;
14
- following_url: string;
15
- gists_url: string;
16
- starred_url: string;
17
- subscriptions_url: string;
18
- organizations_url: string;
19
- repos_url: string;
20
- events_url: string;
21
- received_events_url: string;
22
- type: string;
23
- site_admin: boolean;
24
- name: string;
25
- company: string;
26
- blog: string;
27
- location: string;
28
- email: string;
29
- hireable: boolean;
30
- bio: string;
31
- twitter_username: string;
32
- public_repos: string;
33
- public_gists: string;
34
- followers: string;
35
- following: string;
36
- created_at: string;
37
- updated_at: string;
38
- private_gists: string;
39
- total_private_repos: string;
40
- owned_private_repos: string;
41
- disk_usage: string;
42
- collaborators: string;
43
- two_factor_authentication: boolean;
44
- plan: {
45
- name: string;
46
- space: string;
47
- private_repos: string;
48
- collaborators: string;
49
- };
50
- }
51
- interface GithubToken extends OAuth2Token {
52
- access_token: string;
53
- token_type: string;
54
- scope: string;
55
- expires_in: number;
56
- refresh_token: string;
57
- }
58
-
59
- export { type GithubToken, type GithubUserInfo, createGithubProvider, github };
@@ -1,43 +0,0 @@
1
- import { NativeCredential, OAuth2Token, OneTapProvider } from '../types.js';
2
-
3
- declare function createGoogleProvider(): OneTapProvider;
4
- declare const google: OneTapProvider;
5
- interface GoogleUserInfo {
6
- aud: string;
7
- azp: string;
8
- email: string;
9
- email_verified: boolean;
10
- exp: number;
11
- family_name: string;
12
- given_name: string;
13
- hd?: string;
14
- iat: number;
15
- iss: string;
16
- jti?: string;
17
- locale?: string;
18
- name: string;
19
- nbf?: number;
20
- picture: string;
21
- sub: string;
22
- nonce?: string;
23
- }
24
- interface GoogleToken extends OAuth2Token {
25
- access_token: string;
26
- token_type: string;
27
- expires_in: number;
28
- refresh_token: string;
29
- id_token: string;
30
- scope: string;
31
- }
32
- interface GoogleAppCredential extends NativeCredential {
33
- state: string;
34
- code: string;
35
- client_id: string;
36
- redirect_uri: string;
37
- }
38
- interface GoogleErrorResponse {
39
- error: 'invalid_request' | 'invalid_client' | 'invalid_grant' | 'invalid_token' | 'invalid_scope' | 'unauthorized_client' | 'unsupported_grant_type' | 'access_denied' | 'server_error';
40
- error_description: string;
41
- }
42
-
43
- export { type GoogleAppCredential, type GoogleErrorResponse, type GoogleToken, type GoogleUserInfo, createGoogleProvider, google };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/oauth2/provider/index.ts"],"sourcesContent":["export { apple } from './apple';\nexport { facebook } from './facebook';\nexport { github } from './github';\nexport { google } from './google';\nexport { wechat } from './wechat';\nexport { x } from './x';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,sBAAyB;AACzB,oBAAuB;AACvB,oBAAuB;AACvB,oBAAuB;AACvB,eAAkB;","names":[]}
@@ -1,7 +0,0 @@
1
- export { apple } from './apple.js';
2
- export { facebook } from './facebook.js';
3
- export { github } from './github.js';
4
- export { google } from './google.js';
5
- export { wechat } from './wechat.js';
6
- export { x } from './x.js';
7
- import '../types.js';
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/oauth2/provider/index.ts"],"sourcesContent":["export { apple } from './apple';\nexport { facebook } from './facebook';\nexport { github } from './github';\nexport { google } from './google';\nexport { wechat } from './wechat';\nexport { x } from './x';\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,SAAS;","names":[]}
@@ -1,38 +0,0 @@
1
- import { Provider, OAuth2Token } from '../types.js';
2
-
3
- type Options = {
4
- isWechatBrowser: boolean;
5
- };
6
- /**
7
- * reference: https://developers.weixin.qq.com/doc/offiaccount/en/OA_Web_Apps/Wechat_webpage_authorization.html
8
- */
9
- declare function createWechatProvider(options?: Options): Provider;
10
- declare const wechat: Provider;
11
- interface WechatUserInfo {
12
- openid: string;
13
- nickname: string;
14
- sex: 0 | 1 | 2;
15
- province: string;
16
- city: string;
17
- country: string;
18
- /**
19
- * User's profile photo. The last numeric value represents the size of a square profile photo
20
- * (The value can be 0, 46, 64, 96, or 132. The value 0 represents a 640*640 square profile
21
- * photo). This parameter is left blank if a user has no profile photo. If the user changes the
22
- * profile photo, the URL of the original profile photo will expire.
23
- * e.g. http://thirdwx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46
24
- */
25
- headimgurl: string;
26
- privilege: string[];
27
- unionid?: string;
28
- }
29
- interface WechatToken extends OAuth2Token {
30
- access_token: string;
31
- expires_in: number;
32
- refresh_token: string;
33
- openid: string;
34
- scope: string;
35
- unionid?: string;
36
- }
37
-
38
- export { type Options, type WechatToken, type WechatUserInfo, createWechatProvider, wechat };
@@ -1,68 +0,0 @@
1
- import { Provider, OAuth2Token } from '../types.js';
2
-
3
- interface XOptions {
4
- userFields?: UserField[];
5
- }
6
- declare function createXProvider(options?: XOptions): Provider;
7
- declare const x: Provider;
8
- type UserField = 'affiliation' | 'connection_status' | 'created_at' | 'description' | 'entities' | 'id' | 'is_identity_verified' | 'location' | 'most_recent_tweet_id' | 'name' | 'parody' | 'pinned_tweet_id' | 'profile_banner_url' | 'profile_image_url' | 'protected' | 'public_metrics' | 'receives_your_dm' | 'subscription' | 'subscription_type' | 'url' | 'username' | 'verified' | 'verified_followers_count' | 'verified_type' | 'withheld';
9
- interface XUser {
10
- id: string;
11
- name: string;
12
- email?: string;
13
- username: string;
14
- location?: string;
15
- entities?: {
16
- url: {
17
- urls: UrlEntity[];
18
- };
19
- description: {
20
- hashtags: HashtagEntity[];
21
- cashtags: HashtagEntity[];
22
- mentions: MentionEntity[];
23
- };
24
- };
25
- verified?: boolean;
26
- description?: string;
27
- url?: string;
28
- profile_image_url?: string;
29
- protected?: boolean;
30
- pinned_tweet_id?: string;
31
- created_at?: string;
32
- }
33
- interface XUserInfo {
34
- data: XUser;
35
- includes?: {
36
- tweets?: {
37
- id: string;
38
- text: string;
39
- }[];
40
- users?: XUser[];
41
- };
42
- }
43
- type UrlEntity = {
44
- start: number;
45
- end: number;
46
- url: string;
47
- display_url: string;
48
- expanded_url: string;
49
- };
50
- type HashtagEntity = {
51
- start: number;
52
- end: number;
53
- tag: string;
54
- };
55
- type MentionEntity = {
56
- start: number;
57
- end: string;
58
- username: string;
59
- };
60
- interface XToken extends OAuth2Token {
61
- token_type: string;
62
- expires_in: number;
63
- access_token: string;
64
- scope: string;
65
- refresh_token: string;
66
- }
67
-
68
- export { type XOptions, type XToken, type XUser, type XUserInfo, createXProvider, x };
@@ -1,211 +0,0 @@
1
- interface PkceParameters {
2
- code_verifier: string;
3
- code_challenge: string;
4
- code_challenge_method: 'S256' | 'plain';
5
- }
6
- interface OAuth2AuthorizationRequest {
7
- state: string;
8
- registrationId: string;
9
- authorizationRequestUri: string;
10
- additionalParameters: PkceParameters;
11
- }
12
- interface CreateAuthorizationUriParams {
13
- state: string;
14
- clientId: string;
15
- redirectUri: string;
16
- scope: string[] | undefined;
17
- pkce?: Omit<PkceParameters, 'code_verifier'>;
18
- }
19
- interface ExchangeCodeParams {
20
- code: string;
21
- clientId: string;
22
- clientSecret: string;
23
- redirectUri: string;
24
- pkce?: Omit<PkceParameters, 'code_challenge' | 'code_challenge_method'>;
25
- }
26
- interface RefreshTokenParams {
27
- clientId: string;
28
- clientSecret: string;
29
- refreshToken: string;
30
- }
31
- interface RevokeTokenParams {
32
- token: string;
33
- clientId: string;
34
- clientSecret: string;
35
- }
36
- interface LoginOAuth2NativeParams {
37
- clientId: string;
38
- clientSecret: string;
39
- redirectUri: string;
40
- pkce?: PkceParameters;
41
- credentials: NativeCredential;
42
- }
43
- interface OAuth2Token {
44
- /**
45
- * REQUIRED.
46
- * The access token issued by the authorization server.
47
- */
48
- access_token: string;
49
- /**
50
- * REQUIRED.
51
- * The type of the token issued as described in Section 7.1. Value is case insensitive.
52
- */
53
- token_type: 'Bearer' | 'bearer' | 'mac' | (string & {});
54
- /**
55
- * RECOMMENDED.
56
- * The lifetime in seconds of the access token. For example, the value "3600" denotes that the
57
- * access token will expire in one hour from the time the response was generated. If omitted, the
58
- * authorization server SHOULD provide the expiration time via other means or document the default
59
- * value.
60
- */
61
- expires_in?: number;
62
- /**
63
- * OPTIONAL.
64
- * The refresh token, which can be used to obtain new access tokens using the same authorization
65
- * grant as described in Section 6.
66
- */
67
- refresh_token?: string;
68
- /**
69
- * OPTIONAL.
70
- * If identical to the scope requested by the client; otherwise, REQUIRED. The scope of the
71
- * access token as described by Section 3.3.
72
- */
73
- scope?: string;
74
- id_token?: string;
75
- [key: string]: unknown;
76
- }
77
- interface OidcToken extends OAuth2Token {
78
- id_token: string;
79
- }
80
- type NativeCredential = {
81
- state?: string;
82
- code?: string;
83
- client_id?: string;
84
- redirect_uri?: string;
85
- id_token?: string;
86
- access_token?: string;
87
- };
88
- declare enum OidcScopes {
89
- openid = "openid",
90
- profile = "profile",
91
- email = "email",
92
- phone = "phone",
93
- address = "address",
94
- offline_access = "offline_access"
95
- }
96
- interface StandardClaims {
97
- sub: string;
98
- name?: string;
99
- given_name?: string;
100
- family_name?: string;
101
- middle_name?: string;
102
- nickname?: string;
103
- preferred_username?: string;
104
- profile?: string;
105
- picture?: string;
106
- website?: string;
107
- email?: string;
108
- email_verified?: boolean;
109
- gender?: 'female' | 'male' | (string & {});
110
- birthdate?: string;
111
- zoneinfo?: string;
112
- locale?: string;
113
- phone_number?: string;
114
- phone_number_verified?: boolean;
115
- address?: {
116
- formatted: string;
117
- street_address: string;
118
- locality: string;
119
- region: string;
120
- postal_code: string;
121
- country: string;
122
- };
123
- updated_at?: number;
124
- }
125
- interface UserInfo<T = unknown> {
126
- claims: StandardClaims;
127
- data: T;
128
- }
129
- interface Provider {
130
- /** Authorization URI for the provider. */
131
- authorizationUri: string;
132
- /** Token URI for the provider. */
133
- tokenUri: string;
134
- /** Token revoke URI for the provider. */
135
- tokenRevokeUri?: string;
136
- /** Token refresh URI for the provider. */
137
- tokenRefreshUri?: string;
138
- /** User info URI for the provider. */
139
- userInfoUri?: string;
140
- /** User info authentication method for the provider. */
141
- userInfoAuthenticationMethod?: string;
142
- /**
143
- * Name of the attribute that will be used to extract the username from the call to 'userInfoUri'.
144
- * */
145
- userNameAttribute?: string;
146
- /** JWK set URI for the provider */
147
- jwkSetUri?: string;
148
- /**
149
- * URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0 Authorization
150
- * Server Metadata endpoint defined by RFC 8414.
151
- * */
152
- issuerUri?: string;
153
- /** Default scopes for the provider. */
154
- defaultScope: string[];
155
- /** step 1: generate authorization uri and redirect user to it */
156
- createAuthorizationUri: (params: CreateAuthorizationUriParams) => URL;
157
- /** step 2: exchange code for token */
158
- exchangeAuthorizationCode: (params: ExchangeCodeParams) => Promise<OAuth2Token>;
159
- /** step 3: get user info */
160
- getUserInfo: (token: OAuth2Token) => Promise<UserInfo>;
161
- /** others: refresh access token */
162
- refreshAccessToken?: (params: RefreshTokenParams) => Promise<OAuth2Token>;
163
- /** others: revoke token */
164
- revokeToken?: (params: RevokeTokenParams) => Promise<void>;
165
- loginOAuth2Native?: (params: LoginOAuth2NativeParams) => Promise<{
166
- token: OAuth2Token;
167
- userInfo: UserInfo;
168
- }>;
169
- }
170
- interface OneTapProvider extends Provider {
171
- getTokenInfo: (id_token: string) => Promise<{
172
- token: OAuth2Token;
173
- userInfo: UserInfo;
174
- }>;
175
- }
176
- interface Registration {
177
- /**
178
- * Reference to the OAuth 2.0 provider to use. May reference an element from the 'provider'
179
- * property or used one of the commonly used providers (google, github, facebook, okta).
180
- * */
181
- provider?: string;
182
- /** Client ID for the registration. */
183
- clientId: string;
184
- /** Client secret of the registration. */
185
- clientSecret: string;
186
- /** Client authentication method. May be left blank when using a pre-defined provider. */
187
- clientAuthenticationMethod?: string;
188
- /** Authorization grant type. May be left blank when using a pre-defined provider. */
189
- authorizationGrantType?: 'authorization_code' | 'client_credentials' | 'device_code' | 'jwt_bearer' | 'password' | 'refresh_token' | 'token_exchange';
190
- /** Redirect URI. May be left blank when using a pre-defined provider. */
191
- redirectUri?: string;
192
- /** Authorization scopes. When left blank the provider's default scopes, if any, will be used. */
193
- scope?: string[];
194
- /** Client name. May be left blank when using a pre-defined provider. */
195
- clientName?: string;
196
- }
197
- interface OAuth2ClientConfig {
198
- baseUri: string;
199
- errorUri: string;
200
- successUri: string;
201
- provider: {
202
- [name: string]: Provider | undefined;
203
- };
204
- registration: {
205
- [name: string]: Registration | undefined;
206
- } | (() => Promise<{
207
- [name: string]: Registration | undefined;
208
- }>);
209
- }
210
-
211
- export { type ExchangeCodeParams, type LoginOAuth2NativeParams, type NativeCredential, type OAuth2AuthorizationRequest, type OAuth2ClientConfig, type OAuth2Token, OidcScopes, type OidcToken, type OneTapProvider, type PkceParameters, type Provider, type RefreshTokenParams, type Registration, type RevokeTokenParams, type StandardClaims, type UserInfo };
@@ -1,247 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
-
28
- // ../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js
29
- var require_dist = __commonJS({
30
- "../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js"(exports2) {
31
- "use strict";
32
- var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o2, m2, k2, k22) {
33
- if (k22 === void 0) k22 = k2;
34
- var desc = Object.getOwnPropertyDescriptor(m2, k2);
35
- if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
36
- desc = { enumerable: true, get: function() {
37
- return m2[k2];
38
- } };
39
- }
40
- Object.defineProperty(o2, k22, desc);
41
- }) : (function(o2, m2, k2, k22) {
42
- if (k22 === void 0) k22 = k2;
43
- o2[k22] = m2[k2];
44
- }));
45
- var __exportStar = exports2 && exports2.__exportStar || function(m2, exports3) {
46
- for (var p2 in m2) if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p2)) __createBinding(exports3, m2, p2);
47
- };
48
- Object.defineProperty(exports2, "__esModule", { value: true });
49
- exports2.expectTypeOf = void 0;
50
- __exportStar(require("./branding.cjs"), exports2);
51
- __exportStar(require("./messages.cjs"), exports2);
52
- __exportStar(require("./overloads.cjs"), exports2);
53
- __exportStar(require("./utils.cjs"), exports2);
54
- var fn = () => true;
55
- var expectTypeOf2 = (_actual) => {
56
- const nonFunctionProperties = [
57
- "parameters",
58
- "returns",
59
- "resolves",
60
- "not",
61
- "items",
62
- "constructorParameters",
63
- "thisParameter",
64
- "instance",
65
- "guards",
66
- "asserts",
67
- "branded"
68
- ];
69
- const obj = {
70
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
71
- toBeAny: fn,
72
- toBeUnknown: fn,
73
- toBeNever: fn,
74
- toBeFunction: fn,
75
- toBeObject: fn,
76
- toBeArray: fn,
77
- toBeString: fn,
78
- toBeNumber: fn,
79
- toBeBoolean: fn,
80
- toBeVoid: fn,
81
- toBeSymbol: fn,
82
- toBeNull: fn,
83
- toBeUndefined: fn,
84
- toBeNullable: fn,
85
- toBeBigInt: fn,
86
- toMatchTypeOf: fn,
87
- toEqualTypeOf: fn,
88
- toBeConstructibleWith: fn,
89
- toMatchObjectType: fn,
90
- toExtend: fn,
91
- map: exports2.expectTypeOf,
92
- toBeCallableWith: exports2.expectTypeOf,
93
- extract: exports2.expectTypeOf,
94
- exclude: exports2.expectTypeOf,
95
- pick: exports2.expectTypeOf,
96
- omit: exports2.expectTypeOf,
97
- toHaveProperty: exports2.expectTypeOf,
98
- parameter: exports2.expectTypeOf
99
- };
100
- const getterProperties = nonFunctionProperties;
101
- getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports2.expectTypeOf)({}) }));
102
- return obj;
103
- };
104
- exports2.expectTypeOf = expectTypeOf2;
105
- }
106
- });
107
-
108
- // src/session/__tests__/redis.test.ts
109
- var import_ioredis = __toESM(require("ioredis"), 1);
110
-
111
- // ../../node_modules/.pnpm/vitest@4.1.9_@opentelemetry+api@1.9.1_@types+node@26.1.0_vite@8.0.14_@types+node@26.1.0_293c3eef4f0415b6417be6f1978e64fb/node_modules/vitest/dist/index.js
112
- var import_test_DNmyFkvJ = require("./chunks/test.DNmyFkvJ.js.cjs");
113
- var import_benchmark_CX_oY03V = require("./chunks/benchmark.CX_oY03V.js.cjs");
114
- var import_evaluatedModules_Dg1zASAC = require("./chunks/evaluatedModules.Dg1zASAC.js.cjs");
115
- var import_index_DdgEv5B1 = require("./chunks/index.DdgEv5B1.js.cjs");
116
- var import_expect_type = __toESM(require_dist(), 1);
117
-
118
- // ../../node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/index.js
119
- var import_chunk_artifact = require("./chunk-artifact.js.cjs");
120
-
121
- // ../../node_modules/.pnpm/vitest@4.1.9_@opentelemetry+api@1.9.1_@types+node@26.1.0_vite@8.0.14_@types+node@26.1.0_293c3eef4f0415b6417be6f1978e64fb/node_modules/vitest/dist/index.js
122
- var import_utils_BX5Fg8C4 = require("./chunks/utils.BX5Fg8C4.js.cjs");
123
-
124
- // ../../node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/utils.js
125
- var import_chunk_artifact2 = require("./chunk-artifact.js.cjs");
126
-
127
- // ../../node_modules/.pnpm/vitest@4.1.9_@opentelemetry+api@1.9.1_@types+node@26.1.0_vite@8.0.14_@types+node@26.1.0_293c3eef4f0415b6417be6f1978e64fb/node_modules/vitest/dist/index.js
128
- var import_commonjsHelpers_D26ty3Ew = require("./chunks/_commonjsHelpers.D26ty3Ew.js.cjs");
129
- var import_rpc_MzXet3jl = require("./chunks/rpc.MzXet3jl.js.cjs");
130
- var import_index_Chj8NDwU = require("./chunks/index.Chj8NDwU.js.cjs");
131
-
132
- // ../../node_modules/.pnpm/vite@8.0.14_@types+node@26.1.0_esbuild@0.27.7_jiti@2.6.1_terser@5.48.0_yaml@2.9.0/node_modules/vite/dist/node/module-runner.js
133
- var SOURCEMAPPING_URL = "sourceMa";
134
- SOURCEMAPPING_URL += "ppingURL";
135
- var isWindows = typeof process < "u" && process.platform === "win32";
136
- var AsyncFunction = async function() {
137
- }.constructor;
138
- var textDecoder = new TextDecoder();
139
- var decodeBase64 = typeof Buffer == "function" && typeof Buffer.from == "function" ? (base64) => Buffer.from(base64, "base64").toString("utf-8") : (base64) => textDecoder.decode(Uint8Array.from(atob(base64), (c3) => c3.charCodeAt(0)));
140
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
141
- var intToChar = new Uint8Array(64);
142
- var charToInt = new Uint8Array(128);
143
- for (let i3 = 0; i3 < chars.length; i3++) {
144
- let c3 = chars.charCodeAt(i3);
145
- intToChar[i3] = c3, charToInt[c3] = i3;
146
- }
147
- var MODULE_RUNNER_SOURCEMAPPING_REGEXP = RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
148
- var retrieveFileHandlers = /* @__PURE__ */ new Set();
149
- var retrieveSourceMapHandlers = /* @__PURE__ */ new Set();
150
- var createExecHandlers = (handlers) => ((...args) => {
151
- for (let handler of handlers) {
152
- let result = handler(...args);
153
- if (result) return result;
154
- }
155
- return null;
156
- });
157
- var retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers);
158
- var retrieveSourceMapFromHandlers = createExecHandlers(retrieveSourceMapHandlers);
159
- var originalPrepare = Error.prepareStackTrace;
160
- var customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/";
161
- var customizationHooksModule = `
162
-
163
- export async function resolve(specifier, context, nextResolve) {
164
- if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
165
- const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
166
- const [parsedSpecifier, parsedImporter] = JSON.parse(data)
167
- specifier = parsedSpecifier
168
- context.parentURL = parsedImporter
169
- }
170
- return nextResolve(specifier, context)
171
- }
172
-
173
- `;
174
- var envProxy = new Proxy({}, { get(_, p2) {
175
- throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p2)}" instead.`);
176
- } });
177
-
178
- // src/session/__tests__/redis.test.ts
179
- var import_common = require("../common.cjs");
180
- var import_redis = require("../redis.cjs");
181
- var redis = new import_ioredis.default("redis://default:123456@localhost:6379");
182
- var repository = new import_redis.RedisIndexedSessionRepository(redis, "myapp:session");
183
- (0, import_chunk_artifact.h)("redis session crud", () => {
184
- const principalName = "user_123456";
185
- (0, import_chunk_artifact.v)("should create a session", async () => {
186
- const session = repository.createSession();
187
- const sessionId = session.getId();
188
- session.setAttribute(import_common.PRINCIPAL_NAME_INDEX_NAME, principalName);
189
- await repository.save(session);
190
- const foundSession = await repository.findById(sessionId);
191
- (0, import_test_DNmyFkvJ.g)(foundSession?.getAttribute(import_common.PRINCIPAL_NAME_INDEX_NAME)).toBe(principalName);
192
- });
193
- (0, import_chunk_artifact.v)("should find a session by principal name", async () => {
194
- const sessions = await repository.findByPrincipalName(principalName);
195
- (0, import_test_DNmyFkvJ.g)(sessions.size).toBeGreaterThan(0);
196
- });
197
- (0, import_chunk_artifact.v)("should delete a session by id", async () => {
198
- const sessions = await repository.findByPrincipalName(principalName);
199
- for (const session of sessions.values()) {
200
- const sessionId = session.getId();
201
- await repository.deleteById(sessionId);
202
- const foundSession = await repository.findById(sessionId);
203
- (0, import_test_DNmyFkvJ.g)(foundSession).toBeNull();
204
- }
205
- });
206
- });
207
- (0, import_chunk_artifact.h)("redis session attributes", () => {
208
- (0, import_chunk_artifact.v)("should set and get attributes", async () => {
209
- const session = repository.createSession();
210
- session.setAttribute("test_key", "test_value");
211
- const sessionId = session.getId();
212
- await repository.save(session);
213
- const foundSession = await repository.findById(sessionId);
214
- (0, import_test_DNmyFkvJ.g)(foundSession).not.toBeNull();
215
- (0, import_test_DNmyFkvJ.g)(foundSession?.getAttribute("test_key")).toBe("test_value");
216
- foundSession?.removeAttribute("test_key");
217
- if (foundSession) await repository.save(foundSession);
218
- const foundSession2 = await repository.findById(sessionId);
219
- (0, import_test_DNmyFkvJ.g)(foundSession2?.getAttribute("test_key")).toBeNull();
220
- });
221
- (0, import_chunk_artifact.v)("should change session id", async () => {
222
- const session = repository.createSession();
223
- session.setAttribute("test_key", "test_value");
224
- session.setAttribute(import_common.PRINCIPAL_NAME_INDEX_NAME, "user_123");
225
- const oldSessionId = session.getId();
226
- await repository.save(session);
227
- const oldSession = await repository.findById(oldSessionId);
228
- (0, import_test_DNmyFkvJ.g)(oldSession).not.toBeNull();
229
- if (!oldSession) throw new Error("Not found session id");
230
- const newSessionId = oldSession.changeSessionId();
231
- await repository.save(oldSession);
232
- const foundSession1 = await repository.findById(oldSessionId);
233
- (0, import_test_DNmyFkvJ.g)(foundSession1).toBeNull();
234
- const foundSession2 = await repository.findById(newSessionId);
235
- (0, import_test_DNmyFkvJ.g)(foundSession2).not.toBeNull();
236
- });
237
- });
238
- (0, import_chunk_artifact.h)("redis session config", () => {
239
- const maxInactiveInterval = 24 * 60 * 60;
240
- repository.setDefaultMaxInactiveInterval(maxInactiveInterval);
241
- (0, import_chunk_artifact.v)("should set default max inactive interval", () => {
242
- const session = repository.createSession();
243
- (0, import_test_DNmyFkvJ.g)(session.isExpired()).toBe(false);
244
- (0, import_test_DNmyFkvJ.g)(session.getMaxInactiveInterval()).toBe(maxInactiveInterval);
245
- });
246
- });
247
- //# sourceMappingURL=redis.test.cjs.map