@sd-jwt/sd-jwt-vc 0.7.1 → 0.7.2-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as _sd_jwt_types from '@sd-jwt/types';
1
2
  import { SDJWTConfig, DisclosureFrame } from '@sd-jwt/types';
2
3
  import { SdJwtPayload, SDJwtInstance } from '@sd-jwt/core';
3
4
 
@@ -57,6 +58,10 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
57
58
  verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean): Promise<{
58
59
  payload: SdJwtVcPayload;
59
60
  header: Record<string, unknown> | undefined;
61
+ kb: {
62
+ payload: _sd_jwt_types.kbPayload;
63
+ header: _sd_jwt_types.kbHeader;
64
+ } | undefined;
60
65
  }>;
61
66
  }
62
67
 
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as _sd_jwt_types from '@sd-jwt/types';
1
2
  import { SDJWTConfig, DisclosureFrame } from '@sd-jwt/types';
2
3
  import { SdJwtPayload, SDJwtInstance } from '@sd-jwt/core';
3
4
 
@@ -57,6 +58,10 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
57
58
  verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean): Promise<{
58
59
  payload: SdJwtVcPayload;
59
60
  header: Record<string, unknown> | undefined;
61
+ kb: {
62
+ payload: _sd_jwt_types.kbPayload;
63
+ header: _sd_jwt_types.kbHeader;
64
+ } | undefined;
60
65
  }>;
61
66
  }
62
67
 
package/dist/index.js CHANGED
@@ -86,12 +86,18 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
86
86
  const controller = new AbortController();
87
87
  const timeoutId = setTimeout(() => controller.abort(), 1e4);
88
88
  try {
89
- const response = yield fetch(uri, { signal: controller.signal });
89
+ const response = yield fetch(uri, {
90
+ signal: controller.signal,
91
+ headers: { Accept: "application/statuslist+jwt" }
92
+ });
90
93
  if (!response.ok) {
91
94
  throw new Error(
92
95
  `Error fetching status list: ${response.status} ${yield response.text()}`
93
96
  );
94
97
  }
98
+ if (response.headers.get("content-type") !== "application/statuslist+jwt") {
99
+ throw new Error("Invalid content type");
100
+ }
95
101
  return response.text();
96
102
  } finally {
97
103
  clearTimeout(timeoutId);
@@ -117,7 +123,11 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
117
123
  return __async(this, null, function* () {
118
124
  var _a, _b, _c;
119
125
  const result = yield __superGet(_SDJwtVcInstance.prototype, this, "verify").call(this, encodedSDJwt, requiredClaimKeys, requireKeyBindings).then((res) => {
120
- return { payload: res.payload, header: res.header };
126
+ return {
127
+ payload: res.payload,
128
+ header: res.header,
129
+ kb: res.kb
130
+ };
121
131
  });
122
132
  if (result.payload.status) {
123
133
  if (result.payload.status.status_list) {
package/dist/index.mjs CHANGED
@@ -63,12 +63,18 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
63
63
  const controller = new AbortController();
64
64
  const timeoutId = setTimeout(() => controller.abort(), 1e4);
65
65
  try {
66
- const response = yield fetch(uri, { signal: controller.signal });
66
+ const response = yield fetch(uri, {
67
+ signal: controller.signal,
68
+ headers: { Accept: "application/statuslist+jwt" }
69
+ });
67
70
  if (!response.ok) {
68
71
  throw new Error(
69
72
  `Error fetching status list: ${response.status} ${yield response.text()}`
70
73
  );
71
74
  }
75
+ if (response.headers.get("content-type") !== "application/statuslist+jwt") {
76
+ throw new Error("Invalid content type");
77
+ }
72
78
  return response.text();
73
79
  } finally {
74
80
  clearTimeout(timeoutId);
@@ -94,7 +100,11 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
94
100
  return __async(this, null, function* () {
95
101
  var _a, _b, _c;
96
102
  const result = yield __superGet(_SDJwtVcInstance.prototype, this, "verify").call(this, encodedSDJwt, requiredClaimKeys, requireKeyBindings).then((res) => {
97
- return { payload: res.payload, header: res.header };
103
+ return {
104
+ payload: res.payload,
105
+ header: res.header,
106
+ kb: res.kb
107
+ };
98
108
  });
99
109
  if (result.payload.status) {
100
110
  if (result.payload.status.status_list) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/sd-jwt-vc",
3
- "version": "0.7.1",
3
+ "version": "0.7.2-next.1+6747319",
4
4
  "description": "sd-jwt draft 7 implementation in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -39,13 +39,13 @@
39
39
  },
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
- "@sd-jwt/core": "0.7.1",
43
- "@sd-jwt/jwt-status-list": "0.7.1",
44
- "@sd-jwt/utils": "0.7.1"
42
+ "@sd-jwt/core": "0.7.2-next.1+6747319",
43
+ "@sd-jwt/jwt-status-list": "0.7.2-next.1+6747319",
44
+ "@sd-jwt/utils": "0.7.2-next.1+6747319"
45
45
  },
46
46
  "devDependencies": {
47
- "@sd-jwt/crypto-nodejs": "0.7.1",
48
- "@sd-jwt/types": "0.7.1",
47
+ "@sd-jwt/crypto-nodejs": "0.7.2-next.1+6747319",
48
+ "@sd-jwt/types": "0.7.2-next.1+6747319",
49
49
  "jose": "^5.2.2"
50
50
  },
51
51
  "publishConfig": {
@@ -64,5 +64,5 @@
64
64
  "esm"
65
65
  ]
66
66
  },
67
- "gitHead": "0c36bb0d6ee3a7cf3edbe56e266514a29e816fb4"
67
+ "gitHead": "6747319c6f8ee748d84d1cb6ced43fcaec5f4fca"
68
68
  }
@@ -57,7 +57,10 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
57
57
  const timeoutId = setTimeout(() => controller.abort(), 10000);
58
58
 
59
59
  try {
60
- const response = await fetch(uri, { signal: controller.signal });
60
+ const response = await fetch(uri, {
61
+ signal: controller.signal,
62
+ headers: { Accept: 'application/statuslist+jwt' },
63
+ });
61
64
  if (!response.ok) {
62
65
  throw new Error(
63
66
  `Error fetching status list: ${
@@ -66,6 +69,13 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
66
69
  );
67
70
  }
68
71
 
72
+ // according to the spec the content type should be application/statuslist+jwt
73
+ if (
74
+ response.headers.get('content-type') !== 'application/statuslist+jwt'
75
+ ) {
76
+ throw new Error('Invalid content type');
77
+ }
78
+
69
79
  return response.text();
70
80
  } finally {
71
81
  clearTimeout(timeoutId);
@@ -94,7 +104,11 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
94
104
  const result = await super
95
105
  .verify(encodedSDJwt, requiredClaimKeys, requireKeyBindings)
96
106
  .then((res) => {
97
- return { payload: res.payload as SdJwtVcPayload, header: res.header };
107
+ return {
108
+ payload: res.payload as SdJwtVcPayload,
109
+ header: res.header,
110
+ kb: res.kb,
111
+ };
98
112
  });
99
113
 
100
114
  if (result.payload.status) {
@@ -260,6 +260,7 @@ async function JSONtest(filename: string) {
260
260
  expect(verified).toBeDefined();
261
261
  expect(verified).toStrictEqual({
262
262
  header: { alg: 'EdDSA', typ: 'vc+sd-jwt' },
263
+ kb: undefined,
263
264
  payload,
264
265
  });
265
266
  }