@strivacity/sdk-core 2.0.0-beta → 2.0.0-beta.3
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/CHANGELOG.md +10 -0
- package/README.md +63 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 2.0.0-beta.3 (2025-08-01)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- documentation updates ([3549d61](https://github.com/strivacity/sdk-js/commit/3549d61))
|
|
6
|
+
|
|
7
|
+
## 2.0.0-beta.2 (2025-07-24)
|
|
8
|
+
|
|
9
|
+
This was a version bump only for sdk-core to align it with other projects, there were no code changes.
|
|
10
|
+
|
|
1
11
|
## 2.0.0-beta (2025-07-24)
|
|
2
12
|
|
|
3
13
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -54,3 +54,66 @@ The `initFlow` function initializes and returns an instance of either `PopupFlow
|
|
|
54
54
|
- `popup`: Uses a popup window for authentication. Returns an instance of `PopupFlow`.
|
|
55
55
|
- `redirect`: Uses a full-page redirect for authentication. Returns an instance of `RedirectFlow`.
|
|
56
56
|
- `native`: Uses a native flow for authentication. Returns an instance of `NativeFlow`.
|
|
57
|
+
|
|
58
|
+
## Custom native flow
|
|
59
|
+
|
|
60
|
+
You can use the `NativeFlowHandler` class if there is no existing Strivacity implementation for your JavaScript framework, or if you want to build a fully custom authentication flow.
|
|
61
|
+
|
|
62
|
+
If you are looking for example implementations for different frameworks, visit [packages](https://github.com/Strivacity/sdk-js/tree/main/packages).
|
|
63
|
+
|
|
64
|
+
### Usage
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import { initFlow } from '@strivacity/sdk-core';
|
|
68
|
+
|
|
69
|
+
const sdk = initFlow({
|
|
70
|
+
mode: 'native',
|
|
71
|
+
issuer: 'https://<YOUR_DOMAIN>',
|
|
72
|
+
scopes: ['openid', 'profile'],
|
|
73
|
+
clientId: '<YOUR_CLIENT_ID>',
|
|
74
|
+
redirectUri: '<YOUR_REDIRECT_URI>',
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// This will return with a `NativeFlowHandler` instance
|
|
78
|
+
const handler = await sdk.login();
|
|
79
|
+
|
|
80
|
+
// Start a new session or resume an existing one
|
|
81
|
+
const state = await handler.startSession();
|
|
82
|
+
|
|
83
|
+
if (state.finalizeUrl) {
|
|
84
|
+
// If the response contains a finalize URL, you can finalize the session
|
|
85
|
+
await handler.finalizeSession(state.finalizeUrl);
|
|
86
|
+
} else {
|
|
87
|
+
// Handle the response as needed
|
|
88
|
+
console.log('Form submitted successfully:', state);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Submit a form in the native flow
|
|
92
|
+
const formState = await handler.submitForm('formId', {
|
|
93
|
+
// Your form data here
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (state.finalizeUrl) {
|
|
97
|
+
// If the response contains a finalize URL, you can finalize the session
|
|
98
|
+
await handler.finalizeSession(state.finalizeUrl);
|
|
99
|
+
} else {
|
|
100
|
+
// Handle the response as needed
|
|
101
|
+
console.log('Form submitted successfully:', state);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### API Documentation
|
|
108
|
+
|
|
109
|
+
#### `startSession(sessionId?: string | null): Promise<LoginFlowState | void>`
|
|
110
|
+
|
|
111
|
+
Starts a new authentication session. If a `sessionId` is provided, resumes the session; otherwise, initiates a new one.
|
|
112
|
+
|
|
113
|
+
#### `submitForm(formId?: string, body?: Record<string, unknown>): Promise<LoginFlowState>`
|
|
114
|
+
|
|
115
|
+
Submits a form in the native flow. Optionally specify a form ID and request body.
|
|
116
|
+
|
|
117
|
+
#### `finalizeSession(finalizeUrl: string): Promise<void>`
|
|
118
|
+
|
|
119
|
+
Finalizes the session using the provided URL. You can gather the finalize URL from the `LoginFlowState` returned by `startSession` or `submitForm`.
|