@opencampus/ocid-connect-js 1.2.3 → 1.2.6
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 +11 -7
- package/dist/ocid-connect-js.js +165 -74
- package/dist/ocid-connect-js.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/react/LoginButton.d.ts +6 -0
- package/lib/react/LoginCallBack.d.ts +7 -0
- package/lib/react/LoginCallBack.js +2 -1
- package/lib/react/OCConnect.d.ts +7 -0
- package/lib/react/OCConnect.js +12 -8
- package/lib/react/OCContext.d.ts +3 -0
- package/lib/react/index.d.ts +4 -0
- package/lib/sdk/auth.d.ts +31 -0
- package/lib/sdk/auth.js +3 -3
- package/lib/sdk/crypto/base64.d.ts +5 -0
- package/lib/sdk/crypto/index.d.ts +3 -0
- package/lib/sdk/crypto/verifyToken.d.ts +1 -0
- package/lib/sdk/crypto/webcrypto.d.ts +13 -0
- package/lib/sdk/endpoints/buildAuthEndpointUrl.d.ts +1 -0
- package/lib/sdk/endpoints/index.d.ts +1 -0
- package/lib/sdk/index.d.ts +2 -0
- package/lib/sdk/lib/AuthInfoManager.d.ts +11 -0
- package/lib/sdk/lib/AuthInfoManager.js +4 -1
- package/lib/sdk/lib/CookieStorageProvider.d.ts +8 -0
- package/lib/sdk/lib/CookieStorageProvider.js +16 -5
- package/lib/sdk/lib/StorageManager.d.ts +23 -0
- package/lib/sdk/lib/StorageManager.js +1 -1
- package/lib/sdk/lib/TokenManager.d.ts +16 -0
- package/lib/sdk/lib/TransactionManager.d.ts +9 -0
- package/lib/sdk/lib/index.d.ts +3 -0
- package/lib/sdk/lib/pkce.d.ts +11 -0
- package/lib/sdk/utils/createPkceMeta.d.ts +5 -0
- package/lib/sdk/utils/errors.d.ts +15 -0
- package/lib/sdk/utils/index.d.ts +4 -0
- package/lib/sdk/utils/jwtParser.d.ts +1 -0
- package/lib/sdk/utils/prepareTokenParams.d.ts +8 -0
- package/lib/sdk/utils/urlParser.d.ts +5 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -59,6 +59,8 @@ Opts Property
|
|
|
59
59
|
| --- | --- |
|
|
60
60
|
| redirectUri | URL to return after the login process is completed |
|
|
61
61
|
| referralCode | Unique identifiers assigned to partners for tracking during OCID account's registration. |
|
|
62
|
+
| domain | Domain to store cookie. Leave it blank to tell the browser to use the current domain |
|
|
63
|
+
| sameSite | Specify the SameSite behavior when using cookie as storage. When `true` - SameSite: strict; when `false` - SameSite: None, when not set - default SameSite behavior browser dependent |
|
|
62
64
|
|
|
63
65
|
Setup LoginCallBack to handle flow's result
|
|
64
66
|
|
|
@@ -104,15 +106,21 @@ export default function CustomLoadingComponent ()
|
|
|
104
106
|
/>
|
|
105
107
|
```
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
1. useOCAuth is a hook that provides credentials (authentication information)
|
|
110
|
+
2. Before using any information from this hook, we need to check isInitialized flag
|
|
111
|
+
3. This is because there's a setup/initialization period where the SDK (software development kit) is getting ready
|
|
112
|
+
|
|
113
|
+
Here's an example of how it would work:
|
|
108
114
|
|
|
109
115
|
```js
|
|
110
116
|
import { useOCAuth } from '@opencampus/ocid-connect-js';
|
|
111
117
|
|
|
112
118
|
const UserTokenPage = (props) => {
|
|
113
|
-
const { authState, ocAuth, OCId, ethAddress } = useOCAuth();
|
|
119
|
+
const { isInitialized, authState, ocAuth, OCId, ethAddress } = useOCAuth();
|
|
114
120
|
|
|
115
|
-
if (
|
|
121
|
+
if (!isInitialized) {
|
|
122
|
+
return <div>Loading...</div>;
|
|
123
|
+
} else if (authState.error !== undefined) {
|
|
116
124
|
return <div>Error: {authState.error.message}</div>;
|
|
117
125
|
} else {
|
|
118
126
|
return (
|
|
@@ -283,10 +291,6 @@ import { useOCAuth } from '@opencampus/ocid-connect-js';
|
|
|
283
291
|
export default function Home() {
|
|
284
292
|
const { authState, ocAuth } = useOCAuth();
|
|
285
293
|
|
|
286
|
-
useEffect(() => {
|
|
287
|
-
console.log(authState);
|
|
288
|
-
}, [authState]); // Now it will log whenever authState changes
|
|
289
|
-
|
|
290
294
|
if (authState.error) {
|
|
291
295
|
return <div>Error: {authState.error.message}</div>;
|
|
292
296
|
}
|