@sd-jwt/jwt-status-list 0.16.0 → 0.16.1-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.js +5 -17
- package/dist/index.mjs +5 -7
- package/package.json +4 -4
- package/src/status-list-jwt.ts +2 -2
- package/src/status-list.ts +3 -8
- package/src/test/status-list-jwt.spec.ts +4 -4
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -38,7 +28,7 @@ __export(index_exports, {
|
|
|
38
28
|
module.exports = __toCommonJS(index_exports);
|
|
39
29
|
|
|
40
30
|
// src/status-list.ts
|
|
41
|
-
var
|
|
31
|
+
var import_utils = require("@sd-jwt/utils");
|
|
42
32
|
var import_pako = require("pako");
|
|
43
33
|
var StatusList = class _StatusList {
|
|
44
34
|
/**
|
|
@@ -101,7 +91,7 @@ var StatusList = class _StatusList {
|
|
|
101
91
|
compressStatusList() {
|
|
102
92
|
const byteArray = this.encodeStatusList();
|
|
103
93
|
const compressed = (0, import_pako.deflate)(byteArray, { level: 9 });
|
|
104
|
-
return
|
|
94
|
+
return (0, import_utils.uint8ArrayToBase64Url)(compressed);
|
|
105
95
|
}
|
|
106
96
|
/**
|
|
107
97
|
* Decompress the compressed status list and return a new StatusList instance.
|
|
@@ -109,9 +99,7 @@ var StatusList = class _StatusList {
|
|
|
109
99
|
* @param bitsPerStatus
|
|
110
100
|
*/
|
|
111
101
|
static decompressStatusList(compressed, bitsPerStatus) {
|
|
112
|
-
const decoded =
|
|
113
|
-
import_base64url.default.decode(compressed, "binary").split("").map((c) => c.charCodeAt(0))
|
|
114
|
-
);
|
|
102
|
+
const decoded = (0, import_utils.base64UrlToUint8Array)(compressed);
|
|
115
103
|
try {
|
|
116
104
|
const decompressed = (0, import_pako.inflate)(decoded);
|
|
117
105
|
const statusList = _StatusList.decodeStatusList(
|
|
@@ -179,10 +167,10 @@ var StatusList = class _StatusList {
|
|
|
179
167
|
};
|
|
180
168
|
|
|
181
169
|
// src/status-list-jwt.ts
|
|
182
|
-
var
|
|
170
|
+
var import_utils2 = require("@sd-jwt/utils");
|
|
183
171
|
function decodeJwt(jwt) {
|
|
184
172
|
const parts = jwt.split(".");
|
|
185
|
-
return JSON.parse(
|
|
173
|
+
return JSON.parse((0, import_utils2.base64urlDecode)(parts[1]));
|
|
186
174
|
}
|
|
187
175
|
function createHeaderAndPayload(list, payload, header) {
|
|
188
176
|
if (!payload.iss) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/status-list.ts
|
|
2
|
-
import
|
|
2
|
+
import { base64UrlToUint8Array, uint8ArrayToBase64Url } from "@sd-jwt/utils";
|
|
3
3
|
import { deflate, inflate } from "pako";
|
|
4
4
|
var StatusList = class _StatusList {
|
|
5
5
|
/**
|
|
@@ -62,7 +62,7 @@ var StatusList = class _StatusList {
|
|
|
62
62
|
compressStatusList() {
|
|
63
63
|
const byteArray = this.encodeStatusList();
|
|
64
64
|
const compressed = deflate(byteArray, { level: 9 });
|
|
65
|
-
return
|
|
65
|
+
return uint8ArrayToBase64Url(compressed);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Decompress the compressed status list and return a new StatusList instance.
|
|
@@ -70,9 +70,7 @@ var StatusList = class _StatusList {
|
|
|
70
70
|
* @param bitsPerStatus
|
|
71
71
|
*/
|
|
72
72
|
static decompressStatusList(compressed, bitsPerStatus) {
|
|
73
|
-
const decoded =
|
|
74
|
-
base64Url.decode(compressed, "binary").split("").map((c) => c.charCodeAt(0))
|
|
75
|
-
);
|
|
73
|
+
const decoded = base64UrlToUint8Array(compressed);
|
|
76
74
|
try {
|
|
77
75
|
const decompressed = inflate(decoded);
|
|
78
76
|
const statusList = _StatusList.decodeStatusList(
|
|
@@ -140,10 +138,10 @@ var StatusList = class _StatusList {
|
|
|
140
138
|
};
|
|
141
139
|
|
|
142
140
|
// src/status-list-jwt.ts
|
|
143
|
-
import
|
|
141
|
+
import { base64urlDecode } from "@sd-jwt/utils";
|
|
144
142
|
function decodeJwt(jwt) {
|
|
145
143
|
const parts = jwt.split(".");
|
|
146
|
-
return JSON.parse(
|
|
144
|
+
return JSON.parse(base64urlDecode(parts[1]));
|
|
147
145
|
}
|
|
148
146
|
function createHeaderAndPayload(list, payload, header) {
|
|
149
147
|
if (!payload.iss) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/jwt-status-list",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1-next.1+09708e7",
|
|
4
4
|
"description": "Implementation based on https://datatracker.ietf.org/doc/draft-ietf-oauth-status-list/",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"jose": "^6.1.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@sd-jwt/types": "0.16.
|
|
45
|
-
"
|
|
44
|
+
"@sd-jwt/types": "0.16.1-next.1+09708e7",
|
|
45
|
+
"@sd-jwt/utils": "0.16.1-next.1+09708e7",
|
|
46
46
|
"pako": "^2.1.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"esm"
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "09708e7881c1e3e003444d7200af686eda4b8a55"
|
|
65
65
|
}
|
package/src/status-list-jwt.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JwtPayload } from '@sd-jwt/types';
|
|
2
|
-
import
|
|
2
|
+
import { base64urlDecode } from '@sd-jwt/utils';
|
|
3
3
|
import { StatusList } from './status-list';
|
|
4
4
|
import type {
|
|
5
5
|
JWTwithStatusListPayload,
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
*/
|
|
16
16
|
function decodeJwt<T>(jwt: string): T {
|
|
17
17
|
const parts = jwt.split('.');
|
|
18
|
-
return JSON.parse(
|
|
18
|
+
return JSON.parse(base64urlDecode(parts[1]));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
package/src/status-list.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { base64UrlToUint8Array, uint8ArrayToBase64Url } from '@sd-jwt/utils';
|
|
2
2
|
import { deflate, inflate } from 'pako';
|
|
3
3
|
import type { BitsPerStatus } from './types';
|
|
4
4
|
/**
|
|
@@ -75,7 +75,7 @@ export class StatusList {
|
|
|
75
75
|
compressStatusList(): string {
|
|
76
76
|
const byteArray = this.encodeStatusList();
|
|
77
77
|
const compressed = deflate(byteArray, { level: 9 });
|
|
78
|
-
return
|
|
78
|
+
return uint8ArrayToBase64Url(compressed);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -87,12 +87,7 @@ export class StatusList {
|
|
|
87
87
|
compressed: string,
|
|
88
88
|
bitsPerStatus: BitsPerStatus,
|
|
89
89
|
): StatusList {
|
|
90
|
-
const decoded =
|
|
91
|
-
base64Url
|
|
92
|
-
.decode(compressed, 'binary')
|
|
93
|
-
.split('')
|
|
94
|
-
.map((c) => c.charCodeAt(0)),
|
|
95
|
-
);
|
|
90
|
+
const decoded = base64UrlToUint8Array(compressed);
|
|
96
91
|
try {
|
|
97
92
|
const decompressed = inflate(decoded);
|
|
98
93
|
const statusList = StatusList.decodeStatusList(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { generateKeyPairSync } from 'node:crypto';
|
|
1
|
+
import { generateKeyPairSync, type KeyObject } from 'node:crypto';
|
|
2
2
|
import type { JwtPayload } from '@sd-jwt/types';
|
|
3
|
-
import { jwtVerify,
|
|
3
|
+
import { jwtVerify, SignJWT } from 'jose';
|
|
4
4
|
import { beforeAll, describe, expect, it } from 'vitest';
|
|
5
5
|
import { StatusList } from '../status-list';
|
|
6
6
|
import {
|
|
@@ -14,8 +14,8 @@ import type {
|
|
|
14
14
|
} from '../types';
|
|
15
15
|
|
|
16
16
|
describe('JWTStatusList', () => {
|
|
17
|
-
let publicKey:
|
|
18
|
-
let privateKey:
|
|
17
|
+
let publicKey: KeyObject;
|
|
18
|
+
let privateKey: KeyObject;
|
|
19
19
|
|
|
20
20
|
const header: StatusListJWTHeaderParameters = {
|
|
21
21
|
alg: 'ES256',
|