@sphereon/oid4vc-common 0.17.0 → 0.17.1-feature.esm.cjs.24

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 (81) hide show
  1. package/dist/index.cjs +485 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +297 -0
  4. package/dist/index.d.ts +296 -8
  5. package/dist/index.js +425 -26
  6. package/dist/index.js.map +1 -1
  7. package/package.json +22 -13
  8. package/dist/dpop/DPoP.d.ts +0 -60
  9. package/dist/dpop/DPoP.d.ts.map +0 -1
  10. package/dist/dpop/DPoP.js +0 -184
  11. package/dist/dpop/DPoP.js.map +0 -1
  12. package/dist/dpop/index.d.ts +0 -2
  13. package/dist/dpop/index.d.ts.map +0 -1
  14. package/dist/dpop/index.js +0 -18
  15. package/dist/dpop/index.js.map +0 -1
  16. package/dist/hasher.d.ts +0 -3
  17. package/dist/hasher.d.ts.map +0 -1
  18. package/dist/hasher.js +0 -19
  19. package/dist/hasher.js.map +0 -1
  20. package/dist/index.d.ts.map +0 -1
  21. package/dist/jwt/Jwk.types.d.ts +0 -36
  22. package/dist/jwt/Jwk.types.d.ts.map +0 -1
  23. package/dist/jwt/Jwk.types.js +0 -3
  24. package/dist/jwt/Jwk.types.js.map +0 -1
  25. package/dist/jwt/JwkThumbprint.d.ts +0 -6
  26. package/dist/jwt/JwkThumbprint.d.ts.map +0 -1
  27. package/dist/jwt/JwkThumbprint.js +0 -102
  28. package/dist/jwt/JwkThumbprint.js.map +0 -1
  29. package/dist/jwt/Jwt.types.d.ts +0 -23
  30. package/dist/jwt/Jwt.types.d.ts.map +0 -1
  31. package/dist/jwt/Jwt.types.js +0 -12
  32. package/dist/jwt/Jwt.types.js.map +0 -1
  33. package/dist/jwt/JwtIssuer.d.ts +0 -51
  34. package/dist/jwt/JwtIssuer.d.ts.map +0 -1
  35. package/dist/jwt/JwtIssuer.js +0 -3
  36. package/dist/jwt/JwtIssuer.js.map +0 -1
  37. package/dist/jwt/JwtVerifier.d.ts +0 -72
  38. package/dist/jwt/JwtVerifier.d.ts.map +0 -1
  39. package/dist/jwt/JwtVerifier.js +0 -80
  40. package/dist/jwt/JwtVerifier.js.map +0 -1
  41. package/dist/jwt/index.d.ts +0 -7
  42. package/dist/jwt/index.d.ts.map +0 -1
  43. package/dist/jwt/index.js +0 -23
  44. package/dist/jwt/index.js.map +0 -1
  45. package/dist/jwt/jwtUtils.d.ts +0 -26
  46. package/dist/jwt/jwtUtils.d.ts.map +0 -1
  47. package/dist/jwt/jwtUtils.js +0 -62
  48. package/dist/jwt/jwtUtils.js.map +0 -1
  49. package/dist/oauth/DynamicClientRegistration.types.d.ts +0 -19
  50. package/dist/oauth/DynamicClientRegistration.types.d.ts.map +0 -1
  51. package/dist/oauth/DynamicClientRegistration.types.js +0 -3
  52. package/dist/oauth/DynamicClientRegistration.types.js.map +0 -1
  53. package/dist/oauth/index.d.ts +0 -2
  54. package/dist/oauth/index.d.ts.map +0 -1
  55. package/dist/oauth/index.js +0 -18
  56. package/dist/oauth/index.js.map +0 -1
  57. package/dist/types/digest.types.d.ts +0 -2
  58. package/dist/types/digest.types.d.ts.map +0 -1
  59. package/dist/types/digest.types.js +0 -3
  60. package/dist/types/digest.types.js.map +0 -1
  61. package/dist/types/index.d.ts +0 -2
  62. package/dist/types/index.d.ts.map +0 -1
  63. package/dist/types/index.js +0 -18
  64. package/dist/types/index.js.map +0 -1
  65. package/lib/__tests__/dpop.spec.ts +0 -124
  66. package/lib/dpop/DPoP.ts +0 -242
  67. package/lib/dpop/index.ts +0 -1
  68. package/lib/hasher.ts +0 -18
  69. package/lib/index.ts +0 -11
  70. package/lib/jwt/Jwk.types.ts +0 -38
  71. package/lib/jwt/JwkThumbprint.ts +0 -65
  72. package/lib/jwt/Jwt.types.ts +0 -26
  73. package/lib/jwt/JwtIssuer.ts +0 -60
  74. package/lib/jwt/JwtVerifier.ts +0 -130
  75. package/lib/jwt/__tests__/JwkThumbprint.spec.ts +0 -16
  76. package/lib/jwt/index.ts +0 -6
  77. package/lib/jwt/jwtUtils.ts +0 -71
  78. package/lib/oauth/DynamicClientRegistration.types.ts +0 -20
  79. package/lib/oauth/index.ts +0 -1
  80. package/lib/types/digest.types.ts +0 -1
  81. package/lib/types/index.ts +0 -1
@@ -1,71 +0,0 @@
1
- import { jwtDecode } from 'jwt-decode';
2
-
3
- import { JwtHeader, JwtPayload } from '..';
4
-
5
- export type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop';
6
-
7
- export type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom';
8
-
9
- export function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {
10
- const header = jwtDecode<Header>(jwt, { header: true });
11
- const payload = jwtDecode<Payload>(jwt, { header: false });
12
-
13
- if (!payload || !header) {
14
- throw new Error('Jwt Payload and/or Header could not be parsed');
15
- }
16
- return { header, payload };
17
- }
18
-
19
- /**
20
- * The maximum allowed clock skew time in seconds. If an time based validation
21
- * is performed against current time (`now`), the validation can be of by the skew
22
- * time.
23
- *
24
- * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5
25
- */
26
- const DEFAULT_SKEW_TIME = 60;
27
-
28
- export function getNowSkewed(now?: number, skewTime?: number) {
29
- const _now = now ? now : epochTime();
30
- const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME;
31
-
32
- return {
33
- nowSkewedPast: _now - _skewTime,
34
- nowSkewedFuture: _now + _skewTime,
35
- };
36
- }
37
-
38
- /**
39
- * Returns the current unix timestamp in seconds.
40
- */
41
- export function epochTime() {
42
- return Math.floor(Date.now() / 1000);
43
- }
44
-
45
- export const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
46
-
47
- export const isJws = (jws: string) => {
48
- const jwsParts = jws.split('.');
49
- return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part));
50
- };
51
- export const isJwe = (jwe: string) => {
52
- const jweParts = jwe.split('.');
53
- return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part));
54
- };
55
-
56
- export const decodeProtectedHeader = (jwt: string) => {
57
- return jwtDecode(jwt, { header: true });
58
- };
59
-
60
- export const decodeJwt = (jwt: string): JwtPayload => {
61
- return jwtDecode(jwt, { header: false });
62
- };
63
-
64
- export const checkExp = (input: {
65
- exp: number;
66
- now?: number; // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
67
- clockSkew?: number;
68
- }) => {
69
- const { exp, now, clockSkew } = input;
70
- return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120);
71
- };
@@ -1,20 +0,0 @@
1
- import { JWKS } from '../jwt';
2
-
3
- // https://www.rfc-editor.org/rfc/rfc7591.html#section-2
4
- export interface DynamicRegistrationClientMetadata {
5
- redirect_uris?: string[];
6
- token_endpoint_auth_method?: string;
7
- grant_types?: string;
8
- response_types?: string;
9
- client_name?: string;
10
- client_uri?: string;
11
- logo_uri?: string;
12
- scope?: string;
13
- contacts?: string[];
14
- tos_uri?: string;
15
- policy_uri?: string;
16
- jwks_uri?: string;
17
- jwks?: JWKS;
18
- software_id?: string;
19
- software_version?: string;
20
- }
@@ -1 +0,0 @@
1
- export * from './DynamicClientRegistration.types';
@@ -1 +0,0 @@
1
- export type DigestAlgorithm = 'sha256' | 'sha384' | 'sha512';
@@ -1 +0,0 @@
1
- export * from './digest.types';