oidc-spa 7.2.0-rc.1 → 7.2.0-rc.2

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 (282) hide show
  1. package/backend.js.map +1 -1
  2. package/core/AuthResponse.js.map +1 -1
  3. package/core/Oidc.js.map +1 -1
  4. package/core/OidcInitializationError.d.ts +0 -13
  5. package/core/OidcInitializationError.js +0 -243
  6. package/core/OidcInitializationError.js.map +1 -1
  7. package/core/OidcMetadata.js.map +1 -1
  8. package/core/StateData.js.map +1 -1
  9. package/core/configId.js.map +1 -1
  10. package/core/createOidc.js +38 -5
  11. package/core/createOidc.js.map +1 -1
  12. package/core/diagnostic.d.ts +14 -0
  13. package/core/diagnostic.js +214 -0
  14. package/core/diagnostic.js.map +1 -0
  15. package/core/evtIsUserActive.js.map +1 -1
  16. package/core/handleOidcCallback.js.map +1 -1
  17. package/core/iframeMessageProtection.js.map +1 -1
  18. package/core/index.js.map +1 -1
  19. package/core/initialLocationHref.js.map +1 -1
  20. package/core/isNewBrowserSession.js.map +1 -1
  21. package/core/loginOrGoToAuthServer.js.map +1 -1
  22. package/core/loginPropagationToOtherTabs.js.map +1 -1
  23. package/core/loginSilent.js.map +1 -1
  24. package/core/logoutPropagationToOtherTabs.js.map +1 -1
  25. package/core/oidcClientTsUserToTokens.js.map +1 -1
  26. package/core/ongoingLoginOrRefreshProcesses.js.map +1 -1
  27. package/core/persistedAuthState.js.map +1 -1
  28. package/entrypoint.js.map +1 -1
  29. package/esm/core/AuthResponse.d.ts +5 -0
  30. package/{src/core/AuthResponse.ts → esm/core/AuthResponse.js} +2 -10
  31. package/esm/core/AuthResponse.js.map +1 -0
  32. package/esm/core/Oidc.d.ts +126 -0
  33. package/esm/core/Oidc.js +2 -0
  34. package/esm/core/Oidc.js.map +1 -0
  35. package/esm/core/OidcInitializationError.d.ts +7 -0
  36. package/esm/core/OidcInitializationError.js +17 -0
  37. package/esm/core/OidcInitializationError.js.map +1 -0
  38. package/{src/core/OidcMetadata.ts → esm/core/OidcMetadata.d.ts} +0 -5
  39. package/esm/core/OidcMetadata.js +3 -0
  40. package/esm/core/OidcMetadata.js.map +1 -0
  41. package/esm/core/StateData.d.ts +42 -0
  42. package/esm/core/StateData.js +55 -0
  43. package/esm/core/StateData.js.map +1 -0
  44. package/esm/core/configId.d.ts +4 -0
  45. package/esm/core/configId.js +4 -0
  46. package/esm/core/configId.js.map +1 -0
  47. package/esm/core/createOidc.d.ts +132 -0
  48. package/{src/core/createOidc.ts → esm/core/createOidc.js} +269 -806
  49. package/esm/core/createOidc.js.map +1 -0
  50. package/esm/core/diagnostic.d.ts +14 -0
  51. package/{src/core/OidcInitializationError.ts → esm/core/diagnostic.js} +32 -109
  52. package/esm/core/diagnostic.js.map +1 -0
  53. package/esm/core/evtIsUserActive.d.ts +5 -0
  54. package/{src/core/evtIsUserActive.ts → esm/core/evtIsUserActive.js} +14 -46
  55. package/esm/core/evtIsUserActive.js.map +1 -0
  56. package/esm/core/handleOidcCallback.d.ts +13 -0
  57. package/{src/core/handleOidcCallback.ts → esm/core/handleOidcCallback.js} +25 -121
  58. package/esm/core/handleOidcCallback.js.map +1 -0
  59. package/esm/core/iframeMessageProtection.d.ts +20 -0
  60. package/{src/core/iframeMessageProtection.ts → esm/core/iframeMessageProtection.js} +10 -45
  61. package/esm/core/iframeMessageProtection.js.map +1 -0
  62. package/esm/core/index.js +4 -0
  63. package/esm/core/index.js.map +1 -0
  64. package/esm/core/initialLocationHref.d.ts +1 -0
  65. package/{src/core/initialLocationHref.ts → esm/core/initialLocationHref.js} +1 -1
  66. package/esm/core/initialLocationHref.js.map +1 -0
  67. package/esm/core/isNewBrowserSession.d.ts +9 -0
  68. package/{src/core/isNewBrowserSession.ts → esm/core/isNewBrowserSession.js} +3 -15
  69. package/esm/core/isNewBrowserSession.js.map +1 -0
  70. package/esm/core/loginOrGoToAuthServer.d.ts +40 -0
  71. package/{src/core/loginOrGoToAuthServer.ts → esm/core/loginOrGoToAuthServer.js} +60 -168
  72. package/esm/core/loginOrGoToAuthServer.js.map +1 -0
  73. package/esm/core/loginPropagationToOtherTabs.d.ts +8 -0
  74. package/{src/core/loginPropagationToOtherTabs.ts → esm/core/loginPropagationToOtherTabs.js} +7 -25
  75. package/esm/core/loginPropagationToOtherTabs.js.map +1 -0
  76. package/esm/core/loginSilent.d.ts +28 -0
  77. package/esm/core/loginSilent.js +125 -0
  78. package/esm/core/loginSilent.js.map +1 -0
  79. package/esm/core/logoutPropagationToOtherTabs.d.ts +10 -0
  80. package/{src/core/logoutPropagationToOtherTabs.ts → esm/core/logoutPropagationToOtherTabs.js} +8 -28
  81. package/esm/core/logoutPropagationToOtherTabs.js.map +1 -0
  82. package/esm/core/oidcClientTsUserToTokens.d.ts +11 -0
  83. package/esm/core/oidcClientTsUserToTokens.js +155 -0
  84. package/esm/core/oidcClientTsUserToTokens.js.map +1 -0
  85. package/esm/core/ongoingLoginOrRefreshProcesses.d.ts +6 -0
  86. package/{src/core/ongoingLoginOrRefreshProcesses.ts → esm/core/ongoingLoginOrRefreshProcesses.js} +6 -24
  87. package/esm/core/ongoingLoginOrRefreshProcesses.js.map +1 -0
  88. package/esm/core/persistedAuthState.d.ts +28 -0
  89. package/esm/core/persistedAuthState.js +64 -0
  90. package/esm/core/persistedAuthState.js.map +1 -0
  91. package/esm/entrypoint.d.ts +7 -0
  92. package/{src/entrypoint.ts → esm/entrypoint.js} +3 -26
  93. package/esm/entrypoint.js.map +1 -0
  94. package/esm/index.js +2 -0
  95. package/esm/index.js.map +1 -0
  96. package/esm/keycloak/index.d.ts +3 -0
  97. package/esm/keycloak/index.js +3 -0
  98. package/esm/keycloak/index.js.map +1 -0
  99. package/esm/keycloak/isKeycloak.d.ts +3 -0
  100. package/{src/keycloak/isKeycloak.ts → esm/keycloak/isKeycloak.js} +2 -8
  101. package/esm/keycloak/isKeycloak.js.map +1 -0
  102. package/esm/keycloak/keycloak-js/Keycloak.d.ts +284 -0
  103. package/{src/keycloak/keycloak-js/Keycloak.ts → esm/keycloak/keycloak-js/Keycloak.js} +116 -439
  104. package/esm/keycloak/keycloak-js/Keycloak.js.map +1 -0
  105. package/esm/keycloak/keycloak-js/index.js +2 -0
  106. package/esm/keycloak/keycloak-js/index.js.map +1 -0
  107. package/{src/keycloak/keycloak-js/types.ts → esm/keycloak/keycloak-js/types.d.ts} +3 -84
  108. package/esm/keycloak/keycloak-js/types.js +2 -0
  109. package/esm/keycloak/keycloak-js/types.js.map +1 -0
  110. package/esm/keycloak/keycloakIssuerUriParsed.d.ts +9 -0
  111. package/{src/keycloak/keycloakIssuerUriParsed.ts → esm/keycloak/keycloakIssuerUriParsed.js} +2 -15
  112. package/esm/keycloak/keycloakIssuerUriParsed.js.map +1 -0
  113. package/esm/keycloak/keycloakUtils.d.ts +37 -0
  114. package/esm/keycloak/keycloakUtils.js +44 -0
  115. package/esm/keycloak/keycloakUtils.js.map +1 -0
  116. package/esm/keycloak-js.js +2 -0
  117. package/esm/keycloak-js.js.map +1 -0
  118. package/esm/mock/index.js +2 -0
  119. package/esm/mock/index.js.map +1 -0
  120. package/esm/mock/oidc.d.ts +19 -0
  121. package/{src/mock/oidc.ts → esm/mock/oidc.js} +28 -88
  122. package/esm/mock/oidc.js.map +1 -0
  123. package/esm/mock/react.d.ts +58 -0
  124. package/esm/mock/react.js +7 -0
  125. package/esm/mock/react.js.map +1 -0
  126. package/esm/react/index.js +2 -0
  127. package/esm/react/index.js.map +1 -0
  128. package/esm/react/react.d.ts +102 -0
  129. package/esm/react/react.js +221 -0
  130. package/esm/react/react.js.map +1 -0
  131. package/esm/tools/Deferred.d.ts +14 -0
  132. package/esm/tools/Deferred.js +23 -0
  133. package/esm/tools/Deferred.js.map +1 -0
  134. package/esm/tools/EphemeralSessionStorage.d.ts +12 -0
  135. package/{src/tools/EphemeralSessionStorage.ts → esm/tools/EphemeralSessionStorage.js} +30 -112
  136. package/esm/tools/EphemeralSessionStorage.js.map +1 -0
  137. package/esm/tools/Evt.d.ts +11 -0
  138. package/{src/tools/Evt.ts → esm/tools/Evt.js} +7 -25
  139. package/esm/tools/Evt.js.map +1 -0
  140. package/esm/tools/StatefulEvt.d.ts +12 -0
  141. package/esm/tools/StatefulEvt.js +21 -0
  142. package/esm/tools/StatefulEvt.js.map +1 -0
  143. package/esm/tools/ValueOrAsyncGetter.js +2 -0
  144. package/esm/tools/ValueOrAsyncGetter.js.map +1 -0
  145. package/esm/tools/asymmetricEncryption.d.ts +18 -0
  146. package/esm/tools/asymmetricEncryption.js +85 -0
  147. package/esm/tools/asymmetricEncryption.js.map +1 -0
  148. package/esm/tools/base64.d.ts +2 -0
  149. package/{src/tools/base64.ts → esm/tools/base64.js} +3 -3
  150. package/esm/tools/base64.js.map +1 -0
  151. package/esm/tools/createObjectThatThrowsIfAccessed.d.ts +8 -0
  152. package/{src/tools/createObjectThatThrowsIfAccessed.ts → esm/tools/createObjectThatThrowsIfAccessed.js} +7 -18
  153. package/esm/tools/createObjectThatThrowsIfAccessed.js.map +1 -0
  154. package/esm/tools/decodeJwt.d.ts +25 -0
  155. package/esm/tools/decodeJwt.js +60 -0
  156. package/esm/tools/decodeJwt.js.map +1 -0
  157. package/esm/tools/generateUrlSafeRandom.d.ts +3 -0
  158. package/{src/tools/generateUrlSafeRandom.ts → esm/tools/generateUrlSafeRandom.js} +5 -8
  159. package/esm/tools/generateUrlSafeRandom.js.map +1 -0
  160. package/esm/tools/getDownlinkAndRtt.d.ts +4 -0
  161. package/{src/tools/getDownlinkAndRtt.ts → esm/tools/getDownlinkAndRtt.js} +6 -10
  162. package/esm/tools/getDownlinkAndRtt.js.map +1 -0
  163. package/esm/tools/getIsOnline.d.ts +7 -0
  164. package/{src/tools/getIsOnline.ts → esm/tools/getIsOnline.js} +3 -9
  165. package/esm/tools/getIsOnline.js.map +1 -0
  166. package/esm/tools/getIsValidRemoteJson.d.ts +1 -0
  167. package/esm/tools/getIsValidRemoteJson.js +15 -0
  168. package/esm/tools/getIsValidRemoteJson.js.map +1 -0
  169. package/esm/tools/getPrUserInteraction.d.ts +4 -0
  170. package/{src/tools/getPrUserInteraction.ts → esm/tools/getPrUserInteraction.js} +2 -6
  171. package/esm/tools/getPrUserInteraction.js.map +1 -0
  172. package/esm/tools/getUserEnvironmentInfo.d.ts +1 -0
  173. package/esm/tools/getUserEnvironmentInfo.js +50 -0
  174. package/esm/tools/getUserEnvironmentInfo.js.map +1 -0
  175. package/esm/tools/haveSharedParentDomain.d.ts +4 -0
  176. package/{src/tools/haveSharedParentDomain.ts → esm/tools/haveSharedParentDomain.js} +3 -5
  177. package/esm/tools/haveSharedParentDomain.js.map +1 -0
  178. package/esm/tools/isDev.d.ts +1 -0
  179. package/{src/tools/isDev.ts → esm/tools/isDev.js} +5 -12
  180. package/esm/tools/isDev.js.map +1 -0
  181. package/esm/tools/parseKeycloakIssuerUri.d.ts +30 -0
  182. package/{src/tools/parseKeycloakIssuerUri.ts → esm/tools/parseKeycloakIssuerUri.js} +2 -18
  183. package/esm/tools/parseKeycloakIssuerUri.js.map +1 -0
  184. package/esm/tools/readExpirationTimeInJwt.d.ts +1 -0
  185. package/{src/tools/readExpirationTimeInJwt.ts → esm/tools/readExpirationTimeInJwt.js} +6 -7
  186. package/esm/tools/readExpirationTimeInJwt.js.map +1 -0
  187. package/esm/tools/startCountdown.d.ts +11 -0
  188. package/{src/tools/startCountdown.ts → esm/tools/startCountdown.js} +6 -17
  189. package/esm/tools/startCountdown.js.map +1 -0
  190. package/esm/tools/subscribeToUserInteraction.d.ts +6 -0
  191. package/{src/tools/subscribeToUserInteraction.ts → esm/tools/subscribeToUserInteraction.js} +4 -13
  192. package/esm/tools/subscribeToUserInteraction.js.map +1 -0
  193. package/esm/tools/toFullyQualifiedUrl.d.ts +10 -0
  194. package/{src/tools/toFullyQualifiedUrl.ts → esm/tools/toFullyQualifiedUrl.js} +7 -25
  195. package/esm/tools/toFullyQualifiedUrl.js.map +1 -0
  196. package/esm/tools/toHumanReadableDuration.d.ts +1 -0
  197. package/{src/tools/toHumanReadableDuration.ts → esm/tools/toHumanReadableDuration.js} +8 -5
  198. package/esm/tools/toHumanReadableDuration.js.map +1 -0
  199. package/esm/tools/urlSearchParams.d.ts +19 -0
  200. package/{src/tools/urlSearchParams.ts → esm/tools/urlSearchParams.js} +24 -70
  201. package/esm/tools/urlSearchParams.js.map +1 -0
  202. package/esm/tools/workerTimers.d.ts +5 -0
  203. package/{src/tools/workerTimers.ts → esm/tools/workerTimers.js} +7 -27
  204. package/esm/tools/workerTimers.js.map +1 -0
  205. package/esm/vendor/frontend/oidc-client-ts.js +3636 -0
  206. package/esm/vendor/frontend/tsafe.js +1 -0
  207. package/esm/vendor/frontend/worker-timers.js +1 -0
  208. package/index.js.map +1 -1
  209. package/keycloak/index.js.map +1 -1
  210. package/keycloak/isKeycloak.js.map +1 -1
  211. package/keycloak/keycloak-js/Keycloak.js.map +1 -1
  212. package/keycloak/keycloak-js/index.js.map +1 -1
  213. package/keycloak/keycloak-js/types.js.map +1 -1
  214. package/keycloak/keycloakIssuerUriParsed.js.map +1 -1
  215. package/keycloak/keycloakUtils.js.map +1 -1
  216. package/keycloak-js.js.map +1 -1
  217. package/mock/index.js.map +1 -1
  218. package/mock/oidc.js.map +1 -1
  219. package/mock/react.js.map +1 -1
  220. package/package.json +74 -328
  221. package/react/index.js.map +1 -1
  222. package/react/react.js.map +1 -1
  223. package/tools/Deferred.js.map +1 -1
  224. package/tools/EphemeralSessionStorage.js.map +1 -1
  225. package/tools/Evt.js.map +1 -1
  226. package/tools/StatefulEvt.js.map +1 -1
  227. package/tools/ValueOrAsyncGetter.js.map +1 -1
  228. package/tools/asymmetricEncryption.js.map +1 -1
  229. package/tools/base64.js.map +1 -1
  230. package/tools/createObjectThatThrowsIfAccessed.js.map +1 -1
  231. package/tools/decodeJwt.js.map +1 -1
  232. package/tools/generateUrlSafeRandom.js.map +1 -1
  233. package/tools/getDownlinkAndRtt.js.map +1 -1
  234. package/tools/getIsOnline.js.map +1 -1
  235. package/tools/getIsValidRemoteJson.js.map +1 -1
  236. package/tools/getPrUserInteraction.js.map +1 -1
  237. package/tools/getUserEnvironmentInfo.js.map +1 -1
  238. package/tools/haveSharedParentDomain.js.map +1 -1
  239. package/tools/isDev.js.map +1 -1
  240. package/tools/parseKeycloakIssuerUri.js.map +1 -1
  241. package/tools/readExpirationTimeInJwt.js.map +1 -1
  242. package/tools/startCountdown.js.map +1 -1
  243. package/tools/subscribeToUserInteraction.js.map +1 -1
  244. package/tools/toFullyQualifiedUrl.js.map +1 -1
  245. package/tools/toHumanReadableDuration.js.map +1 -1
  246. package/tools/urlSearchParams.js.map +1 -1
  247. package/tools/workerTimers.js.map +1 -1
  248. package/LICENSE +0 -21
  249. package/README.md +0 -185
  250. package/src/backend.ts +0 -391
  251. package/src/core/Oidc.ts +0 -140
  252. package/src/core/StateData.ts +0 -118
  253. package/src/core/configId.ts +0 -3
  254. package/src/core/loginSilent.ts +0 -209
  255. package/src/core/oidcClientTsUserToTokens.ts +0 -229
  256. package/src/core/persistedAuthState.ts +0 -122
  257. package/src/keycloak/index.ts +0 -8
  258. package/src/keycloak/keycloakUtils.ts +0 -90
  259. package/src/mock/react.tsx +0 -11
  260. package/src/react/react.tsx +0 -476
  261. package/src/tools/Deferred.ts +0 -39
  262. package/src/tools/StatefulEvt.ts +0 -38
  263. package/src/tools/asymmetricEncryption.ts +0 -184
  264. package/src/tools/decodeJwt.ts +0 -95
  265. package/src/tools/getIsValidRemoteJson.ts +0 -18
  266. package/src/tools/getUserEnvironmentInfo.ts +0 -42
  267. package/src/vendor/backend/evt.ts +0 -2
  268. package/src/vendor/backend/jsonwebtoken.ts +0 -1
  269. package/src/vendor/backend/node-fetch.ts +0 -2
  270. package/src/vendor/backend/node-jose.ts +0 -1
  271. package/src/vendor/backend/tsafe.ts +0 -5
  272. package/src/vendor/backend/zod.ts +0 -1
  273. /package/{src/core/index.ts → esm/core/index.d.ts} +0 -0
  274. /package/{src/index.ts → esm/index.d.ts} +0 -0
  275. /package/{src/keycloak/keycloak-js/index.ts → esm/keycloak/keycloak-js/index.d.ts} +0 -0
  276. /package/{src/keycloak-js.ts → esm/keycloak-js.d.ts} +0 -0
  277. /package/{src/mock/index.ts → esm/mock/index.d.ts} +0 -0
  278. /package/{src/react/index.ts → esm/react/index.d.ts} +0 -0
  279. /package/{src/tools/ValueOrAsyncGetter.ts → esm/tools/ValueOrAsyncGetter.d.ts} +0 -0
  280. /package/{src/vendor/frontend/oidc-client-ts.ts → esm/vendor/frontend/oidc-client-ts.d.ts} +0 -0
  281. /package/{src/vendor/frontend/tsafe.ts → esm/vendor/frontend/tsafe.d.ts} +0 -0
  282. /package/{src/vendor/frontend/worker-timers.ts → esm/vendor/frontend/worker-timers.d.ts} +0 -0
@@ -1,184 +0,0 @@
1
- type AsymmetricKeys = {
2
- publicKey: string; // base64-encoded JSON export of CryptoKey
3
- privateKey: string; // base64-encoded JSON export of CryptoKey
4
- };
5
-
6
- const INFO_LABEL = "oidc-spa/tools/asymmetricEncryption";
7
-
8
- export async function generateKeys(): Promise<AsymmetricKeys> {
9
- const keyPair = await crypto.subtle.generateKey(
10
- {
11
- name: "ECDH",
12
- namedCurve: "P-256"
13
- },
14
- true,
15
- ["deriveKey", "deriveBits"]
16
- );
17
-
18
- const publicKeyRaw = await crypto.subtle.exportKey("jwk", keyPair.publicKey);
19
- const privateKeyRaw = await crypto.subtle.exportKey("jwk", keyPair.privateKey);
20
-
21
- return {
22
- publicKey: btoa(JSON.stringify(publicKeyRaw)),
23
- privateKey: btoa(JSON.stringify(privateKeyRaw))
24
- };
25
- }
26
-
27
- export async function asymmetricEncrypt(params: {
28
- publicKey: string;
29
- message: string;
30
- }): Promise<{ encryptedMessage: string }> {
31
- const { publicKey, message } = params;
32
-
33
- const importedPublicKey = await crypto.subtle.importKey(
34
- "jwk",
35
- JSON.parse(atob(publicKey)),
36
- {
37
- name: "ECDH",
38
- namedCurve: "P-256"
39
- },
40
- false,
41
- []
42
- );
43
-
44
- const ephemeralKeyPair = await crypto.subtle.generateKey(
45
- {
46
- name: "ECDH",
47
- namedCurve: "P-256"
48
- },
49
- true,
50
- ["deriveKey", "deriveBits"]
51
- );
52
-
53
- const sharedSecret = await crypto.subtle.deriveBits(
54
- {
55
- name: "ECDH",
56
- public: importedPublicKey
57
- },
58
- ephemeralKeyPair.privateKey,
59
- 256
60
- );
61
-
62
- const salt = crypto.getRandomValues(new Uint8Array(16));
63
- const infoBytes = new TextEncoder().encode(INFO_LABEL);
64
-
65
- const hkdfKey = await crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, ["deriveKey"]);
66
-
67
- const derivedKey = await crypto.subtle.deriveKey(
68
- {
69
- name: "HKDF",
70
- hash: "SHA-256",
71
- salt,
72
- info: infoBytes
73
- },
74
- hkdfKey,
75
- { name: "AES-GCM", length: 256 },
76
- false,
77
- ["encrypt"]
78
- );
79
-
80
- const iv = crypto.getRandomValues(new Uint8Array(12));
81
- const encodedMessage = new TextEncoder().encode(message);
82
-
83
- const ciphertext = await crypto.subtle.encrypt(
84
- {
85
- name: "AES-GCM",
86
- iv
87
- },
88
- derivedKey,
89
- encodedMessage
90
- );
91
-
92
- const ephemeralPubKeyRaw = await crypto.subtle.exportKey("jwk", ephemeralKeyPair.publicKey);
93
-
94
- const payload = {
95
- ephemeralPubKey: ephemeralPubKeyRaw,
96
- iv: Array.from(iv),
97
- salt: Array.from(salt),
98
- ciphertext: Array.from(new Uint8Array(ciphertext))
99
- };
100
-
101
- return {
102
- encryptedMessage: btoa(JSON.stringify(payload))
103
- };
104
- }
105
-
106
- export async function asymmetricDecrypt(params: {
107
- privateKey: string;
108
- encryptedMessage: string;
109
- }): Promise<{ message: string }> {
110
- const { privateKey, encryptedMessage } = params;
111
-
112
- const {
113
- ephemeralPubKey,
114
- iv,
115
- salt,
116
- ciphertext
117
- }: {
118
- ephemeralPubKey: JsonWebKey;
119
- iv: number[];
120
- salt: number[];
121
- ciphertext: number[];
122
- } = JSON.parse(atob(encryptedMessage));
123
-
124
- const importedPrivateKey = await crypto.subtle.importKey(
125
- "jwk",
126
- JSON.parse(atob(privateKey)),
127
- {
128
- name: "ECDH",
129
- namedCurve: "P-256"
130
- },
131
- false,
132
- ["deriveKey", "deriveBits"]
133
- );
134
-
135
- const importedEphemeralPubKey = await crypto.subtle.importKey(
136
- "jwk",
137
- ephemeralPubKey,
138
- {
139
- name: "ECDH",
140
- namedCurve: "P-256"
141
- },
142
- false,
143
- []
144
- );
145
-
146
- const sharedSecret = await crypto.subtle.deriveBits(
147
- {
148
- name: "ECDH",
149
- public: importedEphemeralPubKey
150
- },
151
- importedPrivateKey,
152
- 256
153
- );
154
-
155
- const infoBytes = new TextEncoder().encode(INFO_LABEL);
156
-
157
- const hkdfKey = await crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, ["deriveKey"]);
158
-
159
- const derivedKey = await crypto.subtle.deriveKey(
160
- {
161
- name: "HKDF",
162
- hash: "SHA-256",
163
- salt: new Uint8Array(salt),
164
- info: infoBytes
165
- },
166
- hkdfKey,
167
- { name: "AES-GCM", length: 256 },
168
- false,
169
- ["decrypt"]
170
- );
171
-
172
- const decryptedBuffer = await crypto.subtle.decrypt(
173
- {
174
- name: "AES-GCM",
175
- iv: new Uint8Array(iv)
176
- },
177
- derivedKey,
178
- new Uint8Array(ciphertext)
179
- );
180
-
181
- return {
182
- message: new TextDecoder().decode(decryptedBuffer)
183
- };
184
- }
@@ -1,95 +0,0 @@
1
- // Copy pasted jwt-decode v4.0.0
2
-
3
- export interface JwtDecodeOptions {
4
- header?: boolean;
5
- }
6
-
7
- export interface JwtHeader {
8
- typ?: string;
9
- alg?: string;
10
- kid?: string;
11
- }
12
-
13
- export interface JwtPayload {
14
- iss?: string;
15
- sub?: string;
16
- aud?: string[] | string;
17
- exp?: number;
18
- nbf?: number;
19
- iat?: number;
20
- jti?: string;
21
- }
22
-
23
- export class InvalidTokenError extends Error {}
24
-
25
- InvalidTokenError.prototype.name = "InvalidTokenError";
26
-
27
- function b64DecodeUnicode(str: string) {
28
- return decodeURIComponent(
29
- atob(str).replace(/(.)/g, (_m, p) => {
30
- let code = (p as string).charCodeAt(0).toString(16).toUpperCase();
31
- if (code.length < 2) {
32
- code = "0" + code;
33
- }
34
- return "%" + code;
35
- })
36
- );
37
- }
38
-
39
- function base64UrlDecode(str: string) {
40
- let output = str.replace(/-/g, "+").replace(/_/g, "/");
41
- switch (output.length % 4) {
42
- case 0:
43
- break;
44
- case 2:
45
- output += "==";
46
- break;
47
- case 3:
48
- output += "=";
49
- break;
50
- default:
51
- throw new Error("base64 string is not of the correct length");
52
- }
53
-
54
- try {
55
- return b64DecodeUnicode(output);
56
- } catch (err) {
57
- return atob(output);
58
- }
59
- }
60
-
61
- function jwtDecode<T = JwtHeader>(token: string, options: JwtDecodeOptions & { header: true }): T;
62
- function jwtDecode<T = JwtPayload>(token: string, options?: JwtDecodeOptions): T;
63
- function jwtDecode<T = JwtHeader | JwtPayload>(token: string, options?: JwtDecodeOptions): T {
64
- if (typeof token !== "string") {
65
- throw new InvalidTokenError("Invalid token specified: must be a string");
66
- }
67
-
68
- options ||= {};
69
-
70
- const pos = options.header === true ? 0 : 1;
71
- const part = token.split(".")[pos];
72
-
73
- if (typeof part !== "string") {
74
- throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
75
- }
76
-
77
- let decoded: string;
78
- try {
79
- decoded = base64UrlDecode(part);
80
- } catch (e) {
81
- throw new InvalidTokenError(
82
- `Invalid token specified: invalid base64 for part #${pos + 1} (${(e as Error).message})`
83
- );
84
- }
85
-
86
- try {
87
- return JSON.parse(decoded) as T;
88
- } catch (e) {
89
- throw new InvalidTokenError(
90
- `Invalid token specified: invalid json for part #${pos + 1} (${(e as Error).message})`
91
- );
92
- }
93
- }
94
-
95
- export const decodeJwt = jwtDecode;
@@ -1,18 +0,0 @@
1
- export function getIsValidRemoteJson(url: string): Promise<boolean> {
2
- return fetch(url).then(
3
- async response => {
4
- if (!response.ok) {
5
- return false;
6
- }
7
-
8
- try {
9
- await response.json();
10
- } catch {
11
- return false;
12
- }
13
-
14
- return true;
15
- },
16
- () => false
17
- );
18
- }
@@ -1,42 +0,0 @@
1
- export function getUserEnvironmentInfo(): string {
2
- function safeGet<T>(getter: () => T, fallback: string = "Unknown"): string {
3
- try {
4
- const value = getter();
5
- return value != null ? String(value) : fallback;
6
- } catch {
7
- return fallback;
8
- }
9
- }
10
-
11
- const ua = safeGet(() => navigator.userAgent);
12
- const platform = safeGet(() => navigator.platform);
13
- const language = safeGet(() => navigator.language || (navigator as any).userLanguage);
14
- const screenSize = safeGet(() => `${screen.width}x${screen.height}`);
15
- const timezone = safeGet(() => Intl.DateTimeFormat().resolvedOptions().timeZone);
16
-
17
- const browser: string = (() => {
18
- if (ua.includes("Firefox/")) return "Firefox";
19
- if (ua.includes("Edg/")) return "Edge";
20
- if (ua.includes("Chrome/") && !ua.includes("Edg/")) return "Chrome";
21
- if (ua.includes("Safari/") && !ua.includes("Chrome/")) return "Safari";
22
- if (ua.includes("OPR/") || ua.includes("Opera/")) return "Opera";
23
- return "Unknown";
24
- })();
25
-
26
- const os: string = (() => {
27
- if (platform.startsWith("Win")) return "Windows";
28
- if (platform.startsWith("Mac")) return "macOS";
29
- if (platform.startsWith("Linux")) return "Linux";
30
- if (/Android/.test(ua)) return "Android";
31
- if (/iPhone|iPad|iPod/.test(ua)) return "iOS";
32
- return "Unknown";
33
- })();
34
-
35
- return `Browser: ${browser}
36
- OS: ${os}
37
- Platform: ${platform}
38
- Language: ${language}
39
- Screen: ${screenSize}
40
- Timezone: ${timezone}
41
- User Agent: ${ua}`;
42
- }
@@ -1,2 +0,0 @@
1
- export { Evt } from "evt";
2
- export { throttleTime } from "evt/operators/throttleTime";
@@ -1 +0,0 @@
1
- export * from "jsonwebtoken";
@@ -1,2 +0,0 @@
1
- import fetch from "node-fetch";
2
- export { fetch };
@@ -1 +0,0 @@
1
- export * from "node-jose";
@@ -1,5 +0,0 @@
1
- export { assert, is } from "tsafe/assert";
2
- export { id } from "tsafe/id";
3
- export { isAmong } from "tsafe/isAmong";
4
- export type { Equals } from "tsafe";
5
- export { exclude } from "tsafe/exclude";
@@ -1 +0,0 @@
1
- export * from "zod";
File without changes
File without changes
File without changes
File without changes
File without changes