@leancodepl/kratos 9.6.6 → 9.7.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/index.cjs.js +29 -54
- package/index.esm.js +29 -54
- package/package.json +3 -3
- package/src/lib/utils/passkeys/guards.d.ts +3 -0
package/index.cjs.js
CHANGED
|
@@ -144,6 +144,16 @@ var useFlowManager = function(param) {
|
|
|
144
144
|
|
|
145
145
|
var traitPrefix = "traits.";
|
|
146
146
|
|
|
147
|
+
function isPublicKeyCredential(credential) {
|
|
148
|
+
return "type" in credential && credential.type === "public-key" && "id" in credential && "rawId" in credential && "response" in credential;
|
|
149
|
+
}
|
|
150
|
+
function isAttestationResponse(response) {
|
|
151
|
+
return "attestationObject" in response && "clientDataJSON" in response;
|
|
152
|
+
}
|
|
153
|
+
function isAssertionResponse(response) {
|
|
154
|
+
return "authenticatorData" in response && "clientDataJSON" in response && "signature" in response;
|
|
155
|
+
}
|
|
156
|
+
|
|
147
157
|
function _array_like_to_array$a(arr, len) {
|
|
148
158
|
if (len == null || len > arr.length) len = arr.length;
|
|
149
159
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -208,13 +218,6 @@ function _async_to_generator$B(fn) {
|
|
|
208
218
|
});
|
|
209
219
|
};
|
|
210
220
|
}
|
|
211
|
-
function _instanceof$5(left, right) {
|
|
212
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
213
|
-
return !!right[Symbol.hasInstance](left);
|
|
214
|
-
} else {
|
|
215
|
-
return left instanceof right;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
221
|
function _ts_generator$B(thisArg, body) {
|
|
219
222
|
var f, y, t, g, _ = {
|
|
220
223
|
label: 0,
|
|
@@ -311,16 +314,16 @@ function _ts_generator$B(thisArg, body) {
|
|
|
311
314
|
}
|
|
312
315
|
}
|
|
313
316
|
function trySafeStringifyNewCredential(credential) {
|
|
314
|
-
if (!credential) return undefined;
|
|
315
|
-
|
|
316
|
-
if (!
|
|
317
|
+
if (!credential || !isPublicKeyCredential(credential)) return undefined;
|
|
318
|
+
var response = credential.response;
|
|
319
|
+
if (!isAttestationResponse(response)) return undefined;
|
|
317
320
|
return JSON.stringify({
|
|
318
321
|
id: credential.id,
|
|
319
322
|
rawId: base64urlEncode(credential.rawId),
|
|
320
323
|
type: credential.type,
|
|
321
324
|
response: {
|
|
322
|
-
attestationObject: base64urlEncode(
|
|
323
|
-
clientDataJSON: base64urlEncode(
|
|
325
|
+
attestationObject: base64urlEncode(response.attestationObject),
|
|
326
|
+
clientDataJSON: base64urlEncode(response.clientDataJSON)
|
|
324
327
|
}
|
|
325
328
|
});
|
|
326
329
|
}
|
|
@@ -365,18 +368,19 @@ function _createCredential() {
|
|
|
365
368
|
return _createCredential.apply(this, arguments);
|
|
366
369
|
}
|
|
367
370
|
function trySafeStringifyExistingCredential(credential) {
|
|
368
|
-
if (!credential) return undefined;
|
|
369
|
-
|
|
370
|
-
if (!
|
|
371
|
+
if (!credential || !isPublicKeyCredential(credential)) return undefined;
|
|
372
|
+
var response = credential.response;
|
|
373
|
+
if (!isAssertionResponse(response)) return undefined;
|
|
374
|
+
var userHandle = response.userHandle;
|
|
371
375
|
return JSON.stringify({
|
|
372
376
|
id: credential.id,
|
|
373
377
|
rawId: base64urlEncode(credential.rawId),
|
|
374
378
|
type: credential.type,
|
|
375
379
|
response: {
|
|
376
|
-
authenticatorData: base64urlEncode(
|
|
377
|
-
clientDataJSON: base64urlEncode(
|
|
378
|
-
signature: base64urlEncode(
|
|
379
|
-
userHandle:
|
|
380
|
+
authenticatorData: base64urlEncode(response.authenticatorData),
|
|
381
|
+
clientDataJSON: base64urlEncode(response.clientDataJSON),
|
|
382
|
+
signature: base64urlEncode(response.signature),
|
|
383
|
+
userHandle: userHandle ? base64urlEncode(userHandle) : undefined
|
|
380
384
|
}
|
|
381
385
|
});
|
|
382
386
|
}
|
|
@@ -442,13 +446,6 @@ function _async_to_generator$A(fn) {
|
|
|
442
446
|
});
|
|
443
447
|
};
|
|
444
448
|
}
|
|
445
|
-
function _instanceof$4(left, right) {
|
|
446
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
447
|
-
return !!right[Symbol.hasInstance](left);
|
|
448
|
-
} else {
|
|
449
|
-
return left instanceof right;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
449
|
function _ts_generator$A(thisArg, body) {
|
|
453
450
|
var f, y, t, g, _ = {
|
|
454
451
|
label: 0,
|
|
@@ -597,31 +594,9 @@ function _passkeyLoginInit() {
|
|
|
597
594
|
];
|
|
598
595
|
case 3:
|
|
599
596
|
credential = _state.sent();
|
|
600
|
-
if (!credential) return [
|
|
601
|
-
2,
|
|
602
|
-
undefined
|
|
603
|
-
];
|
|
604
|
-
if (!_instanceof$4(credential, PublicKeyCredential)) return [
|
|
605
|
-
2,
|
|
606
|
-
undefined
|
|
607
|
-
];
|
|
608
|
-
if (!_instanceof$4(credential.response, AuthenticatorAssertionResponse)) return [
|
|
609
|
-
2,
|
|
610
|
-
undefined
|
|
611
|
-
];
|
|
612
597
|
return [
|
|
613
598
|
2,
|
|
614
|
-
|
|
615
|
-
id: credential.id,
|
|
616
|
-
rawId: base64urlEncode(credential.rawId),
|
|
617
|
-
type: credential.type,
|
|
618
|
-
response: {
|
|
619
|
-
authenticatorData: base64urlEncode(credential.response.authenticatorData),
|
|
620
|
-
clientDataJSON: base64urlEncode(credential.response.clientDataJSON),
|
|
621
|
-
signature: base64urlEncode(credential.response.signature),
|
|
622
|
-
userHandle: credential.response.userHandle ? base64urlEncode(credential.response.userHandle) : undefined
|
|
623
|
-
}
|
|
624
|
-
})
|
|
599
|
+
trySafeStringifyExistingCredential(credential)
|
|
625
600
|
];
|
|
626
601
|
case 4:
|
|
627
602
|
_state.sent();
|
|
@@ -6431,7 +6406,7 @@ function toBody(response) {
|
|
|
6431
6406
|
}
|
|
6432
6407
|
function _toBody() {
|
|
6433
6408
|
_toBody = _async_to_generator$x(function(response) {
|
|
6434
|
-
var
|
|
6409
|
+
var _1, _tmp, _2;
|
|
6435
6410
|
return _ts_generator$x(this, function(_state) {
|
|
6436
6411
|
switch(_state.label){
|
|
6437
6412
|
case 0:
|
|
@@ -6452,19 +6427,19 @@ function _toBody() {
|
|
|
6452
6427
|
];
|
|
6453
6428
|
case 2:
|
|
6454
6429
|
_state.sent();
|
|
6455
|
-
|
|
6430
|
+
_1 = ResponseError.bind;
|
|
6456
6431
|
_tmp = [
|
|
6457
6432
|
void 0,
|
|
6458
6433
|
response
|
|
6459
6434
|
];
|
|
6460
|
-
|
|
6435
|
+
_2 = "The Ory API endpoint returned a response the SDK does not know how to handle:";
|
|
6461
6436
|
return [
|
|
6462
6437
|
4,
|
|
6463
6438
|
response.text()
|
|
6464
6439
|
];
|
|
6465
6440
|
case 3:
|
|
6466
|
-
throw new (
|
|
6467
|
-
|
|
6441
|
+
throw new (_1.apply(ResponseError, _tmp.concat([
|
|
6442
|
+
_2 + _state.sent()
|
|
6468
6443
|
])));
|
|
6469
6444
|
case 4:
|
|
6470
6445
|
return [
|
package/index.esm.js
CHANGED
|
@@ -123,6 +123,16 @@ var useFlowManager = function(param) {
|
|
|
123
123
|
|
|
124
124
|
var traitPrefix = "traits.";
|
|
125
125
|
|
|
126
|
+
function isPublicKeyCredential(credential) {
|
|
127
|
+
return "type" in credential && credential.type === "public-key" && "id" in credential && "rawId" in credential && "response" in credential;
|
|
128
|
+
}
|
|
129
|
+
function isAttestationResponse(response) {
|
|
130
|
+
return "attestationObject" in response && "clientDataJSON" in response;
|
|
131
|
+
}
|
|
132
|
+
function isAssertionResponse(response) {
|
|
133
|
+
return "authenticatorData" in response && "clientDataJSON" in response && "signature" in response;
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
function _array_like_to_array$a(arr, len) {
|
|
127
137
|
if (len == null || len > arr.length) len = arr.length;
|
|
128
138
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -187,13 +197,6 @@ function _async_to_generator$B(fn) {
|
|
|
187
197
|
});
|
|
188
198
|
};
|
|
189
199
|
}
|
|
190
|
-
function _instanceof$5(left, right) {
|
|
191
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
192
|
-
return !!right[Symbol.hasInstance](left);
|
|
193
|
-
} else {
|
|
194
|
-
return left instanceof right;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
200
|
function _ts_generator$B(thisArg, body) {
|
|
198
201
|
var f, y, t, g, _ = {
|
|
199
202
|
label: 0,
|
|
@@ -290,16 +293,16 @@ function _ts_generator$B(thisArg, body) {
|
|
|
290
293
|
}
|
|
291
294
|
}
|
|
292
295
|
function trySafeStringifyNewCredential(credential) {
|
|
293
|
-
if (!credential) return undefined;
|
|
294
|
-
|
|
295
|
-
if (!
|
|
296
|
+
if (!credential || !isPublicKeyCredential(credential)) return undefined;
|
|
297
|
+
var response = credential.response;
|
|
298
|
+
if (!isAttestationResponse(response)) return undefined;
|
|
296
299
|
return JSON.stringify({
|
|
297
300
|
id: credential.id,
|
|
298
301
|
rawId: base64urlEncode(credential.rawId),
|
|
299
302
|
type: credential.type,
|
|
300
303
|
response: {
|
|
301
|
-
attestationObject: base64urlEncode(
|
|
302
|
-
clientDataJSON: base64urlEncode(
|
|
304
|
+
attestationObject: base64urlEncode(response.attestationObject),
|
|
305
|
+
clientDataJSON: base64urlEncode(response.clientDataJSON)
|
|
303
306
|
}
|
|
304
307
|
});
|
|
305
308
|
}
|
|
@@ -344,18 +347,19 @@ function _createCredential() {
|
|
|
344
347
|
return _createCredential.apply(this, arguments);
|
|
345
348
|
}
|
|
346
349
|
function trySafeStringifyExistingCredential(credential) {
|
|
347
|
-
if (!credential) return undefined;
|
|
348
|
-
|
|
349
|
-
if (!
|
|
350
|
+
if (!credential || !isPublicKeyCredential(credential)) return undefined;
|
|
351
|
+
var response = credential.response;
|
|
352
|
+
if (!isAssertionResponse(response)) return undefined;
|
|
353
|
+
var userHandle = response.userHandle;
|
|
350
354
|
return JSON.stringify({
|
|
351
355
|
id: credential.id,
|
|
352
356
|
rawId: base64urlEncode(credential.rawId),
|
|
353
357
|
type: credential.type,
|
|
354
358
|
response: {
|
|
355
|
-
authenticatorData: base64urlEncode(
|
|
356
|
-
clientDataJSON: base64urlEncode(
|
|
357
|
-
signature: base64urlEncode(
|
|
358
|
-
userHandle:
|
|
359
|
+
authenticatorData: base64urlEncode(response.authenticatorData),
|
|
360
|
+
clientDataJSON: base64urlEncode(response.clientDataJSON),
|
|
361
|
+
signature: base64urlEncode(response.signature),
|
|
362
|
+
userHandle: userHandle ? base64urlEncode(userHandle) : undefined
|
|
359
363
|
}
|
|
360
364
|
});
|
|
361
365
|
}
|
|
@@ -421,13 +425,6 @@ function _async_to_generator$A(fn) {
|
|
|
421
425
|
});
|
|
422
426
|
};
|
|
423
427
|
}
|
|
424
|
-
function _instanceof$4(left, right) {
|
|
425
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
426
|
-
return !!right[Symbol.hasInstance](left);
|
|
427
|
-
} else {
|
|
428
|
-
return left instanceof right;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
428
|
function _ts_generator$A(thisArg, body) {
|
|
432
429
|
var f, y, t, g, _ = {
|
|
433
430
|
label: 0,
|
|
@@ -576,31 +573,9 @@ function _passkeyLoginInit() {
|
|
|
576
573
|
];
|
|
577
574
|
case 3:
|
|
578
575
|
credential = _state.sent();
|
|
579
|
-
if (!credential) return [
|
|
580
|
-
2,
|
|
581
|
-
undefined
|
|
582
|
-
];
|
|
583
|
-
if (!_instanceof$4(credential, PublicKeyCredential)) return [
|
|
584
|
-
2,
|
|
585
|
-
undefined
|
|
586
|
-
];
|
|
587
|
-
if (!_instanceof$4(credential.response, AuthenticatorAssertionResponse)) return [
|
|
588
|
-
2,
|
|
589
|
-
undefined
|
|
590
|
-
];
|
|
591
576
|
return [
|
|
592
577
|
2,
|
|
593
|
-
|
|
594
|
-
id: credential.id,
|
|
595
|
-
rawId: base64urlEncode(credential.rawId),
|
|
596
|
-
type: credential.type,
|
|
597
|
-
response: {
|
|
598
|
-
authenticatorData: base64urlEncode(credential.response.authenticatorData),
|
|
599
|
-
clientDataJSON: base64urlEncode(credential.response.clientDataJSON),
|
|
600
|
-
signature: base64urlEncode(credential.response.signature),
|
|
601
|
-
userHandle: credential.response.userHandle ? base64urlEncode(credential.response.userHandle) : undefined
|
|
602
|
-
}
|
|
603
|
-
})
|
|
578
|
+
trySafeStringifyExistingCredential(credential)
|
|
604
579
|
];
|
|
605
580
|
case 4:
|
|
606
581
|
_state.sent();
|
|
@@ -6410,7 +6385,7 @@ function toBody(response) {
|
|
|
6410
6385
|
}
|
|
6411
6386
|
function _toBody() {
|
|
6412
6387
|
_toBody = _async_to_generator$x(function(response) {
|
|
6413
|
-
var
|
|
6388
|
+
var _1, _tmp, _2;
|
|
6414
6389
|
return _ts_generator$x(this, function(_state) {
|
|
6415
6390
|
switch(_state.label){
|
|
6416
6391
|
case 0:
|
|
@@ -6431,19 +6406,19 @@ function _toBody() {
|
|
|
6431
6406
|
];
|
|
6432
6407
|
case 2:
|
|
6433
6408
|
_state.sent();
|
|
6434
|
-
|
|
6409
|
+
_1 = ResponseError.bind;
|
|
6435
6410
|
_tmp = [
|
|
6436
6411
|
void 0,
|
|
6437
6412
|
response
|
|
6438
6413
|
];
|
|
6439
|
-
|
|
6414
|
+
_2 = "The Ory API endpoint returned a response the SDK does not know how to handle:";
|
|
6440
6415
|
return [
|
|
6441
6416
|
4,
|
|
6442
6417
|
response.text()
|
|
6443
6418
|
];
|
|
6444
6419
|
case 3:
|
|
6445
|
-
throw new (
|
|
6446
|
-
|
|
6420
|
+
throw new (_1.apply(ResponseError, _tmp.concat([
|
|
6421
|
+
_2 + _state.sent()
|
|
6447
6422
|
])));
|
|
6448
6423
|
case 4:
|
|
6449
6424
|
return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/kratos",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"node": ">=18.0.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@leancodepl/utils": "9.
|
|
13
|
+
"@leancodepl/utils": "9.7.0",
|
|
14
14
|
"@radix-ui/react-slot": ">=1.0.0",
|
|
15
|
-
"@tanstack/react-form": ">=1.
|
|
15
|
+
"@tanstack/react-form": ">=1.23.0",
|
|
16
16
|
"@tanstack/react-query": ">=5.0.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function isPublicKeyCredential(credential: Credential): credential is PublicKeyCredential;
|
|
2
|
+
export declare function isAttestationResponse(response: AuthenticatorResponse): response is AuthenticatorAttestationResponse;
|
|
3
|
+
export declare function isAssertionResponse(response: AuthenticatorResponse): response is AuthenticatorAssertionResponse;
|