@leancodepl/kratos 9.6.5 → 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 +115 -140
- package/index.esm.js +102 -127
- package/package.json +3 -3
- package/src/lib/utils/passkeys/guards.d.ts +3 -0
package/index.cjs.js
CHANGED
|
@@ -8,20 +8,20 @@ var reactForm = require('@tanstack/react-form');
|
|
|
8
8
|
var utils = require('@leancodepl/utils');
|
|
9
9
|
|
|
10
10
|
function _interopNamespaceDefault(e) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
}
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
21
19
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
var Slot__namespace = /*#__PURE__*/_interopNamespaceDefault(Slot);
|
|
@@ -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 [
|
|
@@ -8533,11 +8508,11 @@ function VerificationFlowWrapper(param) {
|
|
|
8533
8508
|
}
|
|
8534
8509
|
|
|
8535
8510
|
var index$5 = /*#__PURE__*/Object.freeze({
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8511
|
+
__proto__: null,
|
|
8512
|
+
VerificationFlow: VerificationFlow,
|
|
8513
|
+
VerificationFlowProvider: VerificationFlowProvider,
|
|
8514
|
+
VerificationFlowWrapper: VerificationFlowWrapper,
|
|
8515
|
+
useVerificationFlowContext: useVerificationFlowContext
|
|
8541
8516
|
});
|
|
8542
8517
|
|
|
8543
8518
|
var baseKey$3 = withQueryKeyPrefix("login_flow");
|
|
@@ -10771,8 +10746,8 @@ function LoginFlowWrapper(param) {
|
|
|
10771
10746
|
}
|
|
10772
10747
|
|
|
10773
10748
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
10774
|
-
|
|
10775
|
-
|
|
10749
|
+
__proto__: null,
|
|
10750
|
+
LoginFlow: LoginFlow
|
|
10776
10751
|
});
|
|
10777
10752
|
|
|
10778
10753
|
function asyncGeneratorStep$k(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -11048,8 +11023,8 @@ var useLogout = function() {
|
|
|
11048
11023
|
};
|
|
11049
11024
|
|
|
11050
11025
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
11051
|
-
|
|
11052
|
-
|
|
11026
|
+
__proto__: null,
|
|
11027
|
+
useLogout: useLogout
|
|
11053
11028
|
});
|
|
11054
11029
|
|
|
11055
11030
|
var chooseMethodFormContext = /*#__PURE__*/ react.createContext(undefined);
|
|
@@ -13078,8 +13053,8 @@ function RegistrationFlowWrapper(param) {
|
|
|
13078
13053
|
}
|
|
13079
13054
|
|
|
13080
13055
|
var index$2 = /*#__PURE__*/Object.freeze({
|
|
13081
|
-
|
|
13082
|
-
|
|
13056
|
+
__proto__: null,
|
|
13057
|
+
RegistrationFlow: RegistrationFlow
|
|
13083
13058
|
});
|
|
13084
13059
|
|
|
13085
13060
|
var baseKey$1 = withQueryKeyPrefix("settings_flow");
|
|
@@ -15577,11 +15552,11 @@ function SettingsFlowWrapper(param) {
|
|
|
15577
15552
|
}
|
|
15578
15553
|
|
|
15579
15554
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15555
|
+
__proto__: null,
|
|
15556
|
+
SettingsFlow: SettingsFlow,
|
|
15557
|
+
SettingsFlowProvider: SettingsFlowProvider,
|
|
15558
|
+
SettingsFlowWrapper: SettingsFlowWrapper,
|
|
15559
|
+
useSettingsFlowContext: useSettingsFlowContext
|
|
15585
15560
|
});
|
|
15586
15561
|
|
|
15587
15562
|
var codeFormContext = /*#__PURE__*/ react.createContext(undefined);
|
|
@@ -16962,8 +16937,8 @@ function RecoveryFlowWrapper(param) {
|
|
|
16962
16937
|
}
|
|
16963
16938
|
|
|
16964
16939
|
var index = /*#__PURE__*/Object.freeze({
|
|
16965
|
-
|
|
16966
|
-
|
|
16940
|
+
__proto__: null,
|
|
16941
|
+
RecoveryFlow: RecoveryFlow
|
|
16967
16942
|
});
|
|
16968
16943
|
|
|
16969
16944
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -17508,30 +17483,30 @@ function _object_spread(target) {
|
|
|
17508
17483
|
};
|
|
17509
17484
|
var providers = {
|
|
17510
17485
|
/**
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
|
|
17533
|
-
|
|
17534
|
-
|
|
17486
|
+
* Provides React context for Kratos authentication flows and session management.
|
|
17487
|
+
*
|
|
17488
|
+
* Combines `KratosClientProvider` for API access and `KratosSessionProvider` for session management
|
|
17489
|
+
* to enable authentication flows and session management throughout your component tree.
|
|
17490
|
+
* Must wrap your application or the parts that use Kratos functionality.
|
|
17491
|
+
*
|
|
17492
|
+
* @param children - React children components that will have access to Kratos context
|
|
17493
|
+
* @returns JSX element that provides Kratos context to child components
|
|
17494
|
+
* @example
|
|
17495
|
+
* ```tsx
|
|
17496
|
+
* function App() {
|
|
17497
|
+
* return (
|
|
17498
|
+
* <KratosProviders>
|
|
17499
|
+
* <Router>
|
|
17500
|
+
* <Routes>
|
|
17501
|
+
* <Route path="/login" element={<LoginPage />} />
|
|
17502
|
+
* <Route path="/profile" element={<ProfilePage />} />
|
|
17503
|
+
* </Routes>
|
|
17504
|
+
* </Router>
|
|
17505
|
+
* </KratosProviders>
|
|
17506
|
+
* );
|
|
17507
|
+
* }
|
|
17508
|
+
* ```
|
|
17509
|
+
*/ KratosProviders: function(param) {
|
|
17535
17510
|
var children = param.children;
|
|
17536
17511
|
return /*#__PURE__*/ jsxRuntime.jsx(KratosClientProvider, {
|
|
17537
17512
|
api: api,
|
|
@@ -17544,37 +17519,37 @@ function _object_spread(target) {
|
|
|
17544
17519
|
};
|
|
17545
17520
|
var session = {
|
|
17546
17521
|
/**
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
|
|
17565
|
-
|
|
17566
|
-
|
|
17567
|
-
|
|
17568
|
-
|
|
17569
|
-
|
|
17570
|
-
|
|
17571
|
-
|
|
17572
|
-
|
|
17573
|
-
|
|
17574
|
-
|
|
17575
|
-
|
|
17576
|
-
|
|
17577
|
-
|
|
17522
|
+
* Manages Ory Kratos session and identity state with React Query integration.
|
|
17523
|
+
*
|
|
17524
|
+
* Provides both async methods and React hooks for session management, identity access,
|
|
17525
|
+
* and authentication state. Can be extended with custom trait-specific methods when using
|
|
17526
|
+
* a custom SessionManager class.
|
|
17527
|
+
*
|
|
17528
|
+
* Available methods:
|
|
17529
|
+
* - Session management: `getSession()`, `useSession()`, `checkIfLoggedIn()`
|
|
17530
|
+
* - Identity access: `getIdentity()`, `useIdentity()`, `getUserId()`, `useUserId()`
|
|
17531
|
+
* - Authentication state: `isLoggedIn()`, `useIsLoggedIn()`, `useIsAal2Required()`
|
|
17532
|
+
*
|
|
17533
|
+
* @example
|
|
17534
|
+
* ```tsx
|
|
17535
|
+
* // Using hooks in components
|
|
17536
|
+
* function UserProfile() {
|
|
17537
|
+
* const { isLoggedIn, isLoading } = session.sessionManager.useIsLoggedIn();
|
|
17538
|
+
* const { userId } = session.sessionManager.useUserId();
|
|
17539
|
+
*
|
|
17540
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
17541
|
+
* if (!isLoggedIn) return <div>Please log in</div>;
|
|
17542
|
+
*
|
|
17543
|
+
* return <div>Welcome, User ID: {userId}</div>;
|
|
17544
|
+
* }
|
|
17545
|
+
*
|
|
17546
|
+
* // Using async methods
|
|
17547
|
+
* const checkAuth = async () => {
|
|
17548
|
+
* const isLoggedIn = await session.sessionManager.isLoggedIn();
|
|
17549
|
+
* const userId = await session.sessionManager.getUserId();
|
|
17550
|
+
* };
|
|
17551
|
+
* ```
|
|
17552
|
+
*/ sessionManager: sessionManager
|
|
17578
17553
|
};
|
|
17579
17554
|
return {
|
|
17580
17555
|
flows: flows,
|
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 [
|
|
@@ -8512,11 +8487,11 @@ function VerificationFlowWrapper(param) {
|
|
|
8512
8487
|
}
|
|
8513
8488
|
|
|
8514
8489
|
var index$5 = /*#__PURE__*/Object.freeze({
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8490
|
+
__proto__: null,
|
|
8491
|
+
VerificationFlow: VerificationFlow,
|
|
8492
|
+
VerificationFlowProvider: VerificationFlowProvider,
|
|
8493
|
+
VerificationFlowWrapper: VerificationFlowWrapper,
|
|
8494
|
+
useVerificationFlowContext: useVerificationFlowContext
|
|
8520
8495
|
});
|
|
8521
8496
|
|
|
8522
8497
|
var baseKey$3 = withQueryKeyPrefix("login_flow");
|
|
@@ -10750,8 +10725,8 @@ function LoginFlowWrapper(param) {
|
|
|
10750
10725
|
}
|
|
10751
10726
|
|
|
10752
10727
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
10753
|
-
|
|
10754
|
-
|
|
10728
|
+
__proto__: null,
|
|
10729
|
+
LoginFlow: LoginFlow
|
|
10755
10730
|
});
|
|
10756
10731
|
|
|
10757
10732
|
function asyncGeneratorStep$k(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -11027,8 +11002,8 @@ var useLogout = function() {
|
|
|
11027
11002
|
};
|
|
11028
11003
|
|
|
11029
11004
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
11030
|
-
|
|
11031
|
-
|
|
11005
|
+
__proto__: null,
|
|
11006
|
+
useLogout: useLogout
|
|
11032
11007
|
});
|
|
11033
11008
|
|
|
11034
11009
|
var chooseMethodFormContext = /*#__PURE__*/ createContext(undefined);
|
|
@@ -13057,8 +13032,8 @@ function RegistrationFlowWrapper(param) {
|
|
|
13057
13032
|
}
|
|
13058
13033
|
|
|
13059
13034
|
var index$2 = /*#__PURE__*/Object.freeze({
|
|
13060
|
-
|
|
13061
|
-
|
|
13035
|
+
__proto__: null,
|
|
13036
|
+
RegistrationFlow: RegistrationFlow
|
|
13062
13037
|
});
|
|
13063
13038
|
|
|
13064
13039
|
var baseKey$1 = withQueryKeyPrefix("settings_flow");
|
|
@@ -15556,11 +15531,11 @@ function SettingsFlowWrapper(param) {
|
|
|
15556
15531
|
}
|
|
15557
15532
|
|
|
15558
15533
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
|
|
15562
|
-
|
|
15563
|
-
|
|
15534
|
+
__proto__: null,
|
|
15535
|
+
SettingsFlow: SettingsFlow,
|
|
15536
|
+
SettingsFlowProvider: SettingsFlowProvider,
|
|
15537
|
+
SettingsFlowWrapper: SettingsFlowWrapper,
|
|
15538
|
+
useSettingsFlowContext: useSettingsFlowContext
|
|
15564
15539
|
});
|
|
15565
15540
|
|
|
15566
15541
|
var codeFormContext = /*#__PURE__*/ createContext(undefined);
|
|
@@ -16941,8 +16916,8 @@ function RecoveryFlowWrapper(param) {
|
|
|
16941
16916
|
}
|
|
16942
16917
|
|
|
16943
16918
|
var index = /*#__PURE__*/Object.freeze({
|
|
16944
|
-
|
|
16945
|
-
|
|
16919
|
+
__proto__: null,
|
|
16920
|
+
RecoveryFlow: RecoveryFlow
|
|
16946
16921
|
});
|
|
16947
16922
|
|
|
16948
16923
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -17487,30 +17462,30 @@ function _object_spread(target) {
|
|
|
17487
17462
|
};
|
|
17488
17463
|
var providers = {
|
|
17489
17464
|
/**
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17493
|
-
|
|
17494
|
-
|
|
17495
|
-
|
|
17496
|
-
|
|
17497
|
-
|
|
17498
|
-
|
|
17499
|
-
|
|
17500
|
-
|
|
17501
|
-
|
|
17502
|
-
|
|
17503
|
-
|
|
17504
|
-
|
|
17505
|
-
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17465
|
+
* Provides React context for Kratos authentication flows and session management.
|
|
17466
|
+
*
|
|
17467
|
+
* Combines `KratosClientProvider` for API access and `KratosSessionProvider` for session management
|
|
17468
|
+
* to enable authentication flows and session management throughout your component tree.
|
|
17469
|
+
* Must wrap your application or the parts that use Kratos functionality.
|
|
17470
|
+
*
|
|
17471
|
+
* @param children - React children components that will have access to Kratos context
|
|
17472
|
+
* @returns JSX element that provides Kratos context to child components
|
|
17473
|
+
* @example
|
|
17474
|
+
* ```tsx
|
|
17475
|
+
* function App() {
|
|
17476
|
+
* return (
|
|
17477
|
+
* <KratosProviders>
|
|
17478
|
+
* <Router>
|
|
17479
|
+
* <Routes>
|
|
17480
|
+
* <Route path="/login" element={<LoginPage />} />
|
|
17481
|
+
* <Route path="/profile" element={<ProfilePage />} />
|
|
17482
|
+
* </Routes>
|
|
17483
|
+
* </Router>
|
|
17484
|
+
* </KratosProviders>
|
|
17485
|
+
* );
|
|
17486
|
+
* }
|
|
17487
|
+
* ```
|
|
17488
|
+
*/ KratosProviders: function(param) {
|
|
17514
17489
|
var children = param.children;
|
|
17515
17490
|
return /*#__PURE__*/ jsx(KratosClientProvider, {
|
|
17516
17491
|
api: api,
|
|
@@ -17523,37 +17498,37 @@ function _object_spread(target) {
|
|
|
17523
17498
|
};
|
|
17524
17499
|
var session = {
|
|
17525
17500
|
/**
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
|
|
17533
|
-
|
|
17534
|
-
|
|
17535
|
-
|
|
17536
|
-
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17501
|
+
* Manages Ory Kratos session and identity state with React Query integration.
|
|
17502
|
+
*
|
|
17503
|
+
* Provides both async methods and React hooks for session management, identity access,
|
|
17504
|
+
* and authentication state. Can be extended with custom trait-specific methods when using
|
|
17505
|
+
* a custom SessionManager class.
|
|
17506
|
+
*
|
|
17507
|
+
* Available methods:
|
|
17508
|
+
* - Session management: `getSession()`, `useSession()`, `checkIfLoggedIn()`
|
|
17509
|
+
* - Identity access: `getIdentity()`, `useIdentity()`, `getUserId()`, `useUserId()`
|
|
17510
|
+
* - Authentication state: `isLoggedIn()`, `useIsLoggedIn()`, `useIsAal2Required()`
|
|
17511
|
+
*
|
|
17512
|
+
* @example
|
|
17513
|
+
* ```tsx
|
|
17514
|
+
* // Using hooks in components
|
|
17515
|
+
* function UserProfile() {
|
|
17516
|
+
* const { isLoggedIn, isLoading } = session.sessionManager.useIsLoggedIn();
|
|
17517
|
+
* const { userId } = session.sessionManager.useUserId();
|
|
17518
|
+
*
|
|
17519
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
17520
|
+
* if (!isLoggedIn) return <div>Please log in</div>;
|
|
17521
|
+
*
|
|
17522
|
+
* return <div>Welcome, User ID: {userId}</div>;
|
|
17523
|
+
* }
|
|
17524
|
+
*
|
|
17525
|
+
* // Using async methods
|
|
17526
|
+
* const checkAuth = async () => {
|
|
17527
|
+
* const isLoggedIn = await session.sessionManager.isLoggedIn();
|
|
17528
|
+
* const userId = await session.sessionManager.getUserId();
|
|
17529
|
+
* };
|
|
17530
|
+
* ```
|
|
17531
|
+
*/ sessionManager: sessionManager
|
|
17557
17532
|
};
|
|
17558
17533
|
return {
|
|
17559
17534
|
flows: flows,
|
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;
|