@orangecheck/me-client 0.32.4 → 0.34.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.
- package/README.md +33 -6
- package/dist/{identity-6pjtyKYh.d.mts → identity-DfxCvxuH.d.mts} +1 -0
- package/dist/{identity-6pjtyKYh.d.ts → identity-DfxCvxuH.d.ts} +1 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +270 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +270 -189
- package/dist/index.mjs.map +1 -1
- package/dist/popup.js.map +1 -1
- package/dist/popup.mjs.map +1 -1
- package/dist/server.d.mts +14 -5
- package/dist/server.d.ts +14 -5
- package/dist/server.js +290 -178
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +291 -180
- package/dist/server.mjs.map +1 -1
- package/package.json +2 -2
package/dist/server.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getOcSession as getOcSession$1, bondMeets, readBondClaim } from '@orangecheck/auth-core';
|
|
1
|
+
import { getOcSession as getOcSession$1, integratorRevocationCheck, bondMeets, readBondClaim } from '@orangecheck/auth-core';
|
|
2
2
|
export { bondMeets, readBondClaim, verifyOcToken } from '@orangecheck/auth-core';
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -8,46 +8,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
8
8
|
// node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
9
9
|
new TextEncoder();
|
|
10
10
|
var decoder = new TextDecoder();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
new TextDecoder("utf-8", { fatal: true });
|
|
12
|
+
function decodeBase64(encoded, url = false) {
|
|
13
|
+
if (Uint8Array.fromBase64)
|
|
14
|
+
return Uint8Array.fromBase64(encoded, { alphabet: url ? "base64url" : "base64" });
|
|
15
|
+
if (url) {
|
|
16
|
+
if (encoded.includes("+") || encoded.includes("/"))
|
|
17
|
+
throw new TypeError("Invalid base64url");
|
|
18
|
+
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
16
19
|
}
|
|
17
|
-
const binary = atob(encoded);
|
|
18
|
-
|
|
19
|
-
for (let i = 0; i < binary.length; i++) {
|
|
20
|
+
const binary = atob(encoded), bytes = new Uint8Array(binary.length);
|
|
21
|
+
for (let i = 0; i < binary.length; i++)
|
|
20
22
|
bytes[i] = binary.charCodeAt(i);
|
|
21
|
-
}
|
|
22
23
|
return bytes;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
// node_modules/jose/dist/webapi/util/base64url.js
|
|
26
|
-
function decode(input) {
|
|
27
|
-
if (Uint8Array.fromBase64) {
|
|
28
|
-
return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
|
|
29
|
-
alphabet: "base64url"
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
let encoded = input;
|
|
33
|
-
if (encoded instanceof Uint8Array) {
|
|
34
|
-
encoded = decoder.decode(encoded);
|
|
35
|
-
}
|
|
36
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
37
|
-
try {
|
|
38
|
-
return decodeBase64(encoded);
|
|
39
|
-
} catch {
|
|
40
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
26
|
// node_modules/jose/dist/webapi/util/errors.js
|
|
45
27
|
var JOSEError = class extends Error {
|
|
46
28
|
constructor(message, options) {
|
|
47
29
|
super(message, options);
|
|
48
30
|
__publicField(this, "code", "ERR_JOSE_GENERIC");
|
|
49
|
-
this.name = this.constructor.name;
|
|
50
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
31
|
+
this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
|
|
51
32
|
}
|
|
52
33
|
};
|
|
53
34
|
__publicField(JOSEError, "code", "ERR_JOSE_GENERIC");
|
|
@@ -62,166 +43,258 @@ var _a, _b;
|
|
|
62
43
|
var JWKSMultipleMatchingKeys = class extends (_b = JOSEError, _a = Symbol.asyncIterator, _b) {
|
|
63
44
|
constructor(message = "multiple matching keys found in the JSON Web Key Set", options) {
|
|
64
45
|
super(message, options);
|
|
65
|
-
__publicField(this, _a)
|
|
46
|
+
__publicField(this, _a, async function* () {
|
|
47
|
+
});
|
|
66
48
|
__publicField(this, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
|
|
67
49
|
}
|
|
68
50
|
};
|
|
69
51
|
__publicField(JWKSMultipleMatchingKeys, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
|
|
70
52
|
|
|
71
|
-
// node_modules/jose/dist/webapi/
|
|
72
|
-
var
|
|
53
|
+
// node_modules/jose/dist/webapi/util/base64url.js
|
|
54
|
+
var invalid = "The input to be decoded is not correctly encoded.";
|
|
55
|
+
function decode(input) {
|
|
56
|
+
try {
|
|
57
|
+
return decodeBase64(typeof input == "string" ? input : decoder.decode(input), true);
|
|
58
|
+
} catch (cause) {
|
|
59
|
+
throw new TypeError(invalid, { cause });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// node_modules/jose/dist/webapi/lib/validate.js
|
|
73
64
|
function isObject(input) {
|
|
74
|
-
if (
|
|
65
|
+
if (typeof input != "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]")
|
|
75
66
|
return false;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
let proto = input;
|
|
81
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
82
|
-
proto = Object.getPrototypeOf(proto);
|
|
83
|
-
}
|
|
84
|
-
return Object.getPrototypeOf(input) === proto;
|
|
67
|
+
const prototype = Object.getPrototypeOf(input);
|
|
68
|
+
return prototype === null || Object.getPrototypeOf(prototype) === null;
|
|
85
69
|
}
|
|
86
70
|
|
|
87
|
-
// node_modules/jose/dist/webapi/lib/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let algorithm;
|
|
91
|
-
let keyUsages;
|
|
92
|
-
switch (jwk.kty) {
|
|
93
|
-
case "AKP": {
|
|
94
|
-
switch (jwk.alg) {
|
|
95
|
-
case "ML-DSA-44":
|
|
96
|
-
case "ML-DSA-65":
|
|
97
|
-
case "ML-DSA-87":
|
|
98
|
-
algorithm = { name: jwk.alg };
|
|
99
|
-
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case "RSA": {
|
|
107
|
-
switch (jwk.alg) {
|
|
108
|
-
case "PS256":
|
|
109
|
-
case "PS384":
|
|
110
|
-
case "PS512":
|
|
111
|
-
algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
112
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
113
|
-
break;
|
|
114
|
-
case "RS256":
|
|
115
|
-
case "RS384":
|
|
116
|
-
case "RS512":
|
|
117
|
-
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
118
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
119
|
-
break;
|
|
120
|
-
case "RSA-OAEP":
|
|
121
|
-
case "RSA-OAEP-256":
|
|
122
|
-
case "RSA-OAEP-384":
|
|
123
|
-
case "RSA-OAEP-512":
|
|
124
|
-
algorithm = {
|
|
125
|
-
name: "RSA-OAEP",
|
|
126
|
-
hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
|
|
127
|
-
};
|
|
128
|
-
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
129
|
-
break;
|
|
130
|
-
default:
|
|
131
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
132
|
-
}
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
case "EC": {
|
|
136
|
-
switch (jwk.alg) {
|
|
137
|
-
case "ES256":
|
|
138
|
-
case "ES384":
|
|
139
|
-
case "ES512":
|
|
140
|
-
algorithm = {
|
|
141
|
-
name: "ECDSA",
|
|
142
|
-
namedCurve: { ES256: "P-256", ES384: "P-384", ES512: "P-521" }[jwk.alg]
|
|
143
|
-
};
|
|
144
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
145
|
-
break;
|
|
146
|
-
case "ECDH-ES":
|
|
147
|
-
case "ECDH-ES+A128KW":
|
|
148
|
-
case "ECDH-ES+A192KW":
|
|
149
|
-
case "ECDH-ES+A256KW":
|
|
150
|
-
algorithm = { name: "ECDH", namedCurve: jwk.crv };
|
|
151
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
152
|
-
break;
|
|
153
|
-
default:
|
|
154
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
case "OKP": {
|
|
159
|
-
switch (jwk.alg) {
|
|
160
|
-
case "Ed25519":
|
|
161
|
-
case "EdDSA":
|
|
162
|
-
algorithm = { name: "Ed25519" };
|
|
163
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
164
|
-
break;
|
|
165
|
-
case "ECDH-ES":
|
|
166
|
-
case "ECDH-ES+A128KW":
|
|
167
|
-
case "ECDH-ES+A192KW":
|
|
168
|
-
case "ECDH-ES+A256KW":
|
|
169
|
-
algorithm = { name: jwk.crv };
|
|
170
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
171
|
-
break;
|
|
172
|
-
default:
|
|
173
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
default:
|
|
178
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
179
|
-
}
|
|
180
|
-
return { algorithm, keyUsages };
|
|
71
|
+
// node_modules/jose/dist/webapi/lib/key.js
|
|
72
|
+
function snapshotJwk(jwk) {
|
|
73
|
+
return { __proto__: null, ...jwk };
|
|
181
74
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
75
|
+
function normalizeJwk(jwk) {
|
|
76
|
+
const normalized = snapshotJwk(jwk);
|
|
77
|
+
if (normalized.ext !== void 0 && typeof normalized.ext != "boolean")
|
|
78
|
+
throw new TypeError('"ext" (Extractable) Parameter must be a boolean');
|
|
79
|
+
if (normalized.key_ops !== void 0) {
|
|
80
|
+
const value = normalized.key_ops, keyOps = Array.isArray(value) ? [...value] : void 0;
|
|
81
|
+
if (!keyOps || keyOps.some((operation) => typeof operation != "string") || new Set(keyOps).size !== keyOps.length)
|
|
82
|
+
throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');
|
|
83
|
+
normalized.key_ops = keyOps;
|
|
190
84
|
}
|
|
191
|
-
|
|
192
|
-
|
|
85
|
+
return normalized;
|
|
86
|
+
}
|
|
87
|
+
async function jwkToKey(entry, jwk, extractable) {
|
|
88
|
+
if (!entry.kty.includes(jwk.kty))
|
|
89
|
+
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
90
|
+
const algorithm = entry.resolve?.({ kty: jwk.kty, crv: jwk.crv }) ?? entry.subtle, isPrivate = !!(jwk.d || jwk.priv), keyData = { ...jwk, ext: jwk.ext };
|
|
91
|
+
return keyData.kty !== "AKP" && delete keyData.alg, delete keyData.use, crypto.subtle.importKey("jwk", keyData, algorithm, keyData.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// node_modules/jose/dist/webapi/lib/key_descriptor.js
|
|
95
|
+
function table(entries) {
|
|
96
|
+
const out = { __proto__: null };
|
|
97
|
+
for (const alg in entries)
|
|
98
|
+
out[alg] = { ...entries[alg], alg };
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// node_modules/jose/dist/webapi/lib/jwe_algorithms.js
|
|
103
|
+
var wrap = [
|
|
104
|
+
["encrypt", "wrapKey"],
|
|
105
|
+
["decrypt", "unwrapKey"]
|
|
106
|
+
];
|
|
107
|
+
var derive = [[], ["deriveBits"]];
|
|
108
|
+
var none = [[], []];
|
|
109
|
+
function rsaes(bits) {
|
|
110
|
+
return {
|
|
111
|
+
kty: ["RSA"],
|
|
112
|
+
mode: "key-encryption",
|
|
113
|
+
subtle: { name: "RSA-OAEP", hash: `SHA-${bits}` },
|
|
114
|
+
usages: wrap,
|
|
115
|
+
ops: ["wrapKey", "unwrapKey"]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function ecdh(mode) {
|
|
119
|
+
return {
|
|
120
|
+
kty: ["EC", "OKP"],
|
|
121
|
+
mode,
|
|
122
|
+
subtle: { name: "ECDH" },
|
|
123
|
+
resolve: ({ kty, crv, asymmetricKeyType }) => {
|
|
124
|
+
if (crv === "X25519" || asymmetricKeyType === "x25519")
|
|
125
|
+
return { name: "X25519" };
|
|
126
|
+
if (kty === "OKP")
|
|
127
|
+
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
128
|
+
return { name: "ECDH", namedCurve: crv };
|
|
129
|
+
},
|
|
130
|
+
usages: derive,
|
|
131
|
+
ops: [void 0, "deriveBits"]
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function aeskw(bits, gcm = false) {
|
|
135
|
+
return {
|
|
136
|
+
kty: ["oct"],
|
|
137
|
+
mode: "key-wrapping",
|
|
138
|
+
secret: true,
|
|
139
|
+
subtle: { name: gcm ? "AES-GCM" : "AES-KW", length: bits },
|
|
140
|
+
usages: none,
|
|
141
|
+
ops: gcm ? ["encrypt", "decrypt"] : ["wrapKey", "unwrapKey"]
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function pbes2() {
|
|
145
|
+
return {
|
|
146
|
+
kty: ["oct"],
|
|
147
|
+
mode: "key-wrapping",
|
|
148
|
+
secret: true,
|
|
149
|
+
subtle: { name: "PBKDF2" },
|
|
150
|
+
usages: none,
|
|
151
|
+
ops: ["deriveBits", "deriveBits"]
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
var JWE = table({
|
|
155
|
+
dir: {
|
|
156
|
+
kty: ["oct"],
|
|
157
|
+
mode: "direct-encryption",
|
|
158
|
+
secret: true,
|
|
159
|
+
subtle: { name: "AES-GCM" },
|
|
160
|
+
usages: none,
|
|
161
|
+
ops: ["encrypt", "decrypt"]
|
|
162
|
+
},
|
|
163
|
+
"RSA-OAEP": rsaes(1),
|
|
164
|
+
"RSA-OAEP-256": rsaes(256),
|
|
165
|
+
"RSA-OAEP-384": rsaes(384),
|
|
166
|
+
"RSA-OAEP-512": rsaes(512),
|
|
167
|
+
"ECDH-ES": ecdh("direct-key-agreement"),
|
|
168
|
+
"ECDH-ES+A128KW": ecdh("key-agreement-with-key-wrapping"),
|
|
169
|
+
"ECDH-ES+A192KW": ecdh("key-agreement-with-key-wrapping"),
|
|
170
|
+
"ECDH-ES+A256KW": ecdh("key-agreement-with-key-wrapping"),
|
|
171
|
+
A128KW: aeskw(128),
|
|
172
|
+
A192KW: aeskw(192),
|
|
173
|
+
A256KW: aeskw(256),
|
|
174
|
+
A128GCMKW: aeskw(128, true),
|
|
175
|
+
A192GCMKW: aeskw(192, true),
|
|
176
|
+
A256GCMKW: aeskw(256, true),
|
|
177
|
+
"PBES2-HS256+A128KW": pbes2(),
|
|
178
|
+
"PBES2-HS384+A192KW": pbes2(),
|
|
179
|
+
"PBES2-HS512+A256KW": pbes2()
|
|
180
|
+
});
|
|
181
|
+
var contentOps = ["encrypt", "decrypt"];
|
|
182
|
+
function contentEncryption(bits, cbc = false) {
|
|
183
|
+
return {
|
|
184
|
+
kty: ["oct"],
|
|
185
|
+
secret: true,
|
|
186
|
+
subtle: { name: cbc ? "AES-CBC" : "AES-GCM", length: bits },
|
|
187
|
+
usages: none,
|
|
188
|
+
ops: contentOps,
|
|
189
|
+
cekBits: bits,
|
|
190
|
+
ivBits: cbc ? 128 : 96,
|
|
191
|
+
cbc
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
table({
|
|
195
|
+
A128GCM: contentEncryption(128),
|
|
196
|
+
A192GCM: contentEncryption(192),
|
|
197
|
+
A256GCM: contentEncryption(256),
|
|
198
|
+
"A128CBC-HS256": contentEncryption(256, true),
|
|
199
|
+
"A192CBC-HS384": contentEncryption(384, true),
|
|
200
|
+
"A256CBC-HS512": contentEncryption(512, true)
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// node_modules/jose/dist/webapi/lib/jws_algorithms.js
|
|
204
|
+
var sig = [["verify"], ["sign"]];
|
|
205
|
+
function hmac(bits) {
|
|
206
|
+
const subtle = { name: "HMAC", hash: `SHA-${bits}` };
|
|
207
|
+
return { kty: ["oct"], secret: true, subtle, signing: subtle, usages: sig };
|
|
208
|
+
}
|
|
209
|
+
function rsa(bits, saltLength) {
|
|
210
|
+
const subtle = { name: saltLength ? "RSA-PSS" : "RSASSA-PKCS1-v1_5", hash: `SHA-${bits}` };
|
|
211
|
+
return {
|
|
212
|
+
kty: ["RSA"],
|
|
213
|
+
subtle,
|
|
214
|
+
signing: saltLength ? { ...subtle, saltLength } : subtle,
|
|
215
|
+
usages: sig,
|
|
216
|
+
minRsaBits: 2048
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function ecdsa(crv, bits) {
|
|
220
|
+
return {
|
|
221
|
+
kty: ["EC"],
|
|
222
|
+
crv,
|
|
223
|
+
subtle: { name: "ECDSA", namedCurve: crv },
|
|
224
|
+
signing: { name: "ECDSA", hash: `SHA-${bits}` },
|
|
225
|
+
usages: sig
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function eddsa() {
|
|
229
|
+
const subtle = { name: "Ed25519" };
|
|
230
|
+
return {
|
|
231
|
+
kty: ["OKP"],
|
|
232
|
+
crv: "Ed25519",
|
|
233
|
+
subtle,
|
|
234
|
+
signing: subtle,
|
|
235
|
+
usages: sig
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function mldsa(parameterSet) {
|
|
239
|
+
const subtle = { name: `ML-DSA-${parameterSet}` };
|
|
240
|
+
return {
|
|
241
|
+
kty: ["AKP"],
|
|
242
|
+
subtle,
|
|
243
|
+
signing: subtle,
|
|
244
|
+
usages: sig
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
var JWS = table({
|
|
248
|
+
HS256: hmac(256),
|
|
249
|
+
HS384: hmac(384),
|
|
250
|
+
HS512: hmac(512),
|
|
251
|
+
RS256: rsa(256),
|
|
252
|
+
RS384: rsa(384),
|
|
253
|
+
RS512: rsa(512),
|
|
254
|
+
PS256: rsa(256, 32),
|
|
255
|
+
PS384: rsa(384, 48),
|
|
256
|
+
PS512: rsa(512, 64),
|
|
257
|
+
ES256: ecdsa("P-256", 256),
|
|
258
|
+
ES384: ecdsa("P-384", 384),
|
|
259
|
+
ES512: ecdsa("P-521", 512),
|
|
260
|
+
EdDSA: eddsa(),
|
|
261
|
+
Ed25519: eddsa(),
|
|
262
|
+
"ML-DSA-44": mldsa(44),
|
|
263
|
+
"ML-DSA-65": mldsa(65),
|
|
264
|
+
"ML-DSA-87": mldsa(87)
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// node_modules/jose/dist/webapi/lib/key_algorithm.js
|
|
268
|
+
function unsupportedAlg(source = 'JWK "alg" (Algorithm) Parameter') {
|
|
269
|
+
throw new JOSENotSupported(`Invalid or unsupported ${source} value`);
|
|
270
|
+
}
|
|
271
|
+
function keyAlgorithm(alg, source) {
|
|
272
|
+
return (typeof alg == "string" ? JWS[alg] ?? JWE[alg] : void 0) ?? unsupportedAlg(source);
|
|
193
273
|
}
|
|
194
274
|
|
|
195
275
|
// node_modules/jose/dist/webapi/key/import.js
|
|
196
276
|
async function importJWK(jwk, alg, options) {
|
|
197
|
-
if (!isObject(jwk))
|
|
277
|
+
if (!isObject(jwk))
|
|
198
278
|
throw new TypeError("JWK must be an object");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
switch (
|
|
279
|
+
const normalized = normalizeJwk(jwk), { alg: jwkAlg } = normalized;
|
|
280
|
+
if (normalized.kty !== "oct" && !alg)
|
|
281
|
+
;
|
|
282
|
+
switch (normalized.kty) {
|
|
203
283
|
case "oct":
|
|
204
|
-
if (typeof
|
|
284
|
+
if (typeof normalized.k != "string")
|
|
205
285
|
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
206
|
-
|
|
207
|
-
return decode(jwk.k);
|
|
208
|
-
case "RSA":
|
|
209
|
-
if ("oth" in jwk && jwk.oth !== void 0) {
|
|
210
|
-
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
211
|
-
}
|
|
212
|
-
return jwkToKey({ ...jwk, alg, ext });
|
|
286
|
+
return decode(normalized.k);
|
|
213
287
|
case "AKP": {
|
|
214
|
-
if (typeof
|
|
288
|
+
if (typeof jwkAlg != "string" || !jwkAlg)
|
|
215
289
|
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
216
|
-
|
|
217
|
-
if (alg !== jwk.alg) {
|
|
290
|
+
if (alg !== jwkAlg)
|
|
218
291
|
throw new TypeError("JWK alg and alg option value mismatch");
|
|
219
|
-
|
|
220
|
-
return jwkToKey({ ...jwk, ext });
|
|
292
|
+
return jwkToKey(keyAlgorithm(alg), normalized);
|
|
221
293
|
}
|
|
294
|
+
case "RSA":
|
|
222
295
|
case "EC":
|
|
223
296
|
case "OKP":
|
|
224
|
-
return jwkToKey(
|
|
297
|
+
return jwkToKey(keyAlgorithm(alg), normalized);
|
|
225
298
|
default:
|
|
226
299
|
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
227
300
|
}
|
|
@@ -230,10 +303,13 @@ async function importJWK(jwk, alg, options) {
|
|
|
230
303
|
// src/identity.ts
|
|
231
304
|
var DEFAULT_ISSUER = "https://me.ochk.io";
|
|
232
305
|
var DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
306
|
+
var DEFAULT_MAX_STALE_MS = 6 * 60 * 60 * 1e3;
|
|
307
|
+
var FORCED_REFRESH_MIN_INTERVAL_MS = 6e4;
|
|
233
308
|
var ENVELOPE_JWKS_PATH = "/.well-known/oc-envelope-jwks.json";
|
|
234
309
|
var jwksCache = /* @__PURE__ */ new Map();
|
|
235
310
|
var inflight = /* @__PURE__ */ new Map();
|
|
236
|
-
|
|
311
|
+
var lastForcedRefresh = /* @__PURE__ */ new Map();
|
|
312
|
+
async function fetchEnvelopeJwks(issuer, ttlMs, maxStaleMs = DEFAULT_MAX_STALE_MS) {
|
|
237
313
|
const cached = jwksCache.get(issuer);
|
|
238
314
|
if (cached && Date.now() - cached.fetchedAt < ttlMs) return cached;
|
|
239
315
|
const existing = inflight.get(issuer);
|
|
@@ -260,7 +336,7 @@ async function fetchEnvelopeJwks(issuer, ttlMs) {
|
|
|
260
336
|
return entry;
|
|
261
337
|
} catch (err) {
|
|
262
338
|
const stale = jwksCache.get(issuer);
|
|
263
|
-
if (stale) return stale;
|
|
339
|
+
if (stale && Date.now() - stale.fetchedAt < maxStaleMs) return stale;
|
|
264
340
|
throw err;
|
|
265
341
|
}
|
|
266
342
|
})().finally(() => {
|
|
@@ -309,14 +385,14 @@ function toArrayBuffer(view) {
|
|
|
309
385
|
new Uint8Array(buf).set(view);
|
|
310
386
|
return buf;
|
|
311
387
|
}
|
|
312
|
-
async function verifyEd25519(key,
|
|
388
|
+
async function verifyEd25519(key, sig2, msg) {
|
|
313
389
|
const subtle = typeof globalThis.crypto !== "undefined" && globalThis.crypto.subtle ? globalThis.crypto.subtle : null;
|
|
314
390
|
if (!subtle) return false;
|
|
315
391
|
try {
|
|
316
392
|
return await subtle.verify(
|
|
317
393
|
"Ed25519",
|
|
318
394
|
key,
|
|
319
|
-
toArrayBuffer(
|
|
395
|
+
toArrayBuffer(sig2),
|
|
320
396
|
toArrayBuffer(msg)
|
|
321
397
|
);
|
|
322
398
|
} catch {
|
|
@@ -426,12 +502,13 @@ async function verifyActivityAttestation(bundle, options = {}) {
|
|
|
426
502
|
} else {
|
|
427
503
|
const issuer = options.issuer ?? DEFAULT_ISSUER;
|
|
428
504
|
const ttl = options.jwksCacheTtlMs ?? DEFAULT_TTL_MS;
|
|
505
|
+
const maxStale = options.jwksMaxStaleMs ?? DEFAULT_MAX_STALE_MS;
|
|
429
506
|
try {
|
|
430
|
-
let entry = await fetchEnvelopeJwks(issuer, ttl);
|
|
507
|
+
let entry = await fetchEnvelopeJwks(issuer, ttl, maxStale);
|
|
431
508
|
key = entry.keys[bundle.kid] ?? null;
|
|
432
|
-
if (!key) {
|
|
433
|
-
|
|
434
|
-
entry = await fetchEnvelopeJwks(issuer,
|
|
509
|
+
if (!key && Date.now() - (lastForcedRefresh.get(issuer) ?? 0) >= FORCED_REFRESH_MIN_INTERVAL_MS) {
|
|
510
|
+
lastForcedRefresh.set(issuer, Date.now());
|
|
511
|
+
entry = await fetchEnvelopeJwks(issuer, 0, maxStale);
|
|
435
512
|
key = entry.keys[bundle.kid] ?? null;
|
|
436
513
|
}
|
|
437
514
|
checks.push({
|
|
@@ -492,9 +569,40 @@ var identity = {
|
|
|
492
569
|
};
|
|
493
570
|
|
|
494
571
|
// src/server.ts
|
|
572
|
+
var sessionChecks = /* @__PURE__ */ new Map();
|
|
573
|
+
var warnedUnchecked = false;
|
|
574
|
+
function revocationFor(options) {
|
|
575
|
+
if (options.revocation === false) return null;
|
|
576
|
+
if (options.revocation) return options.revocation;
|
|
577
|
+
const key = options.projectKey ?? "";
|
|
578
|
+
if (!sessionChecks.has(key)) {
|
|
579
|
+
sessionChecks.set(
|
|
580
|
+
key,
|
|
581
|
+
integratorRevocationCheck(options.projectKey ? { projectKey: options.projectKey } : {})
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
const check = sessionChecks.get(key);
|
|
585
|
+
const production = typeof process !== "undefined" && process.env?.NODE_ENV === "production";
|
|
586
|
+
if (!check && !warnedUnchecked && production) {
|
|
587
|
+
warnedUnchecked = true;
|
|
588
|
+
console.warn(
|
|
589
|
+
"[@orangecheck/me-client] sessions are checked by signature only, so one the person ended everywhere stays valid here until it expires. Set OC_PROJECT_KEY and OC_SIGNING_SECRET to refuse it."
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
return check;
|
|
593
|
+
}
|
|
594
|
+
function _resetSessionChecksForTests() {
|
|
595
|
+
sessionChecks.clear();
|
|
596
|
+
warnedUnchecked = false;
|
|
597
|
+
}
|
|
495
598
|
async function getOcSession(headers, options = {}) {
|
|
496
599
|
const session = await getOcSession$1(headers, options);
|
|
497
|
-
if (!session
|
|
600
|
+
if (!session) {
|
|
601
|
+
if (options.audience === void 0) warnIfAudienceMissing(headers);
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
const check = revocationFor(options);
|
|
605
|
+
if (check && await check.refuses(session, options.method)) return null;
|
|
498
606
|
return session;
|
|
499
607
|
}
|
|
500
608
|
var warnedAudience = false;
|
|
@@ -608,7 +716,7 @@ function withOcAuth(handler, options = {}) {
|
|
|
608
716
|
cookie: typeof req.headers.cookie === "string" ? req.headers.cookie : null,
|
|
609
717
|
authorization: typeof req.headers.authorization === "string" ? req.headers.authorization : null
|
|
610
718
|
},
|
|
611
|
-
options
|
|
719
|
+
{ ...options, method: req.method }
|
|
612
720
|
);
|
|
613
721
|
const withSession = req;
|
|
614
722
|
withSession.ocSession = session;
|
|
@@ -627,7 +735,7 @@ function ocAuthExpress(options = {}) {
|
|
|
627
735
|
cookie: typeof req.headers.cookie === "string" ? req.headers.cookie : null,
|
|
628
736
|
authorization: typeof req.headers.authorization === "string" ? req.headers.authorization : null
|
|
629
737
|
},
|
|
630
|
-
options
|
|
738
|
+
{ ...options, method: req.method }
|
|
631
739
|
);
|
|
632
740
|
req.ocSession = session;
|
|
633
741
|
const refused = await refusal(session, options);
|
|
@@ -645,7 +753,10 @@ function ocAuthHono(options = {}) {
|
|
|
645
753
|
return async (c, next) => {
|
|
646
754
|
c.header("Cache-Control", "no-store, private");
|
|
647
755
|
c.header("Vary", "Cookie, Authorization");
|
|
648
|
-
const session = await getOcSession(c.req.raw.headers,
|
|
756
|
+
const session = await getOcSession(c.req.raw.headers, {
|
|
757
|
+
...options,
|
|
758
|
+
method: c.req.raw.method
|
|
759
|
+
});
|
|
649
760
|
c.set("ocSession", session);
|
|
650
761
|
const refused = await refusal(session, options);
|
|
651
762
|
if (refused) return c.json(refused.body, refused.status);
|
|
@@ -653,6 +764,6 @@ function ocAuthHono(options = {}) {
|
|
|
653
764
|
};
|
|
654
765
|
}
|
|
655
766
|
|
|
656
|
-
export { BACK_ACCOUNT_URL, getOcSession, identity, ocAuthExpress, ocAuthHono, refreshEnvelopeJwks, verifyActivityAttestation, withOcAuth };
|
|
767
|
+
export { BACK_ACCOUNT_URL, _resetSessionChecksForTests, getOcSession, identity, ocAuthExpress, ocAuthHono, refreshEnvelopeJwks, verifyActivityAttestation, withOcAuth };
|
|
657
768
|
//# sourceMappingURL=server.mjs.map
|
|
658
769
|
//# sourceMappingURL=server.mjs.map
|