@opencampus/ocid-connect-js 1.2.5 → 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 +2 -0
- package/dist/ocid-connect-js.js +145 -63
- 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/OCConnect.d.ts +7 -0
- 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 +1 -2
- 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/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/lib/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export class OCAuthCore {
|
|
2
|
+
constructor(loginEndpoint: any, redirectUri: any, transactionManager: any, tokenManager: any, referralCode: any, logoutEndPoint: any);
|
|
3
|
+
tokenManager: any;
|
|
4
|
+
authInfoManager: AuthInfoManager;
|
|
5
|
+
transactionManager: any;
|
|
6
|
+
redirectUri: any;
|
|
7
|
+
loginEndPoint: any;
|
|
8
|
+
logoutEndPoint: any;
|
|
9
|
+
referralCode: any;
|
|
10
|
+
clearStorage(): void;
|
|
11
|
+
logout(logoutReturnTo: any): Promise<void>;
|
|
12
|
+
signInWithRedirect(params: any): Promise<void>;
|
|
13
|
+
handleLoginRedirect(): Promise<any>;
|
|
14
|
+
isAuthenticated(): boolean;
|
|
15
|
+
syncAuthInfo(): void;
|
|
16
|
+
getAuthState(): any;
|
|
17
|
+
getStateParameter(): any;
|
|
18
|
+
getIdToken(): any;
|
|
19
|
+
getAccessToken(): any;
|
|
20
|
+
getParsedIdToken(): any;
|
|
21
|
+
getParsedAccessToken(): any;
|
|
22
|
+
get OCId(): any;
|
|
23
|
+
get ethAddress(): any;
|
|
24
|
+
}
|
|
25
|
+
export class OCAuthLive extends OCAuthCore {
|
|
26
|
+
constructor(opts?: {});
|
|
27
|
+
}
|
|
28
|
+
export class OCAuthSandbox extends OCAuthCore {
|
|
29
|
+
constructor(opts?: {});
|
|
30
|
+
}
|
|
31
|
+
import AuthInfoManager from './lib/AuthInfoManager';
|
package/lib/sdk/auth.js
CHANGED
|
@@ -267,8 +267,7 @@ var OCAuthSandbox = exports.OCAuthSandbox = /*#__PURE__*/function (_OCAuthCore3)
|
|
|
267
267
|
overrideLogoutEndpoint = opts.logoutEndPoint,
|
|
268
268
|
overridePublicKey = opts.publicKey,
|
|
269
269
|
redirectUri = opts.redirectUri,
|
|
270
|
-
referralCode = opts.referralCode
|
|
271
|
-
mode = opts.mode;
|
|
270
|
+
referralCode = opts.referralCode;
|
|
272
271
|
var tokenEndpoint = overrideTokenEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/token';
|
|
273
272
|
var loginEndpoint = overrideLoginEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/login';
|
|
274
273
|
var logoutEndpoint = overrideLogoutEndpoint || 'https://api.login.sandbox.opencampus.xyz/auth/logout';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function verifyToken(idToken: any, key: any): Promise<boolean>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
*
|
|
6
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
9
|
+
*/
|
|
10
|
+
declare function a(str: any): string;
|
|
11
|
+
declare function b(str: any): string;
|
|
12
|
+
declare const c: Crypto;
|
|
13
|
+
export { a as atob, b as btoa, c as webcrypto };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function buildAuthEndpointUrl(signInParams: any, loginEndPoint: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./buildAuthEndpointUrl";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default AuthInfoManager;
|
|
2
|
+
declare class AuthInfoManager {
|
|
3
|
+
_emmitter: any;
|
|
4
|
+
_authState: any;
|
|
5
|
+
_emitter: any;
|
|
6
|
+
setAuthState(accessToken: any, idToken: any, OCId: any, ethAddress: any, isAuthenticated: any): void;
|
|
7
|
+
getAuthState(): any;
|
|
8
|
+
clear(): void;
|
|
9
|
+
subscribe(handler: any): void;
|
|
10
|
+
unsubscribe(handler: any): void;
|
|
11
|
+
}
|
|
@@ -21,12 +21,14 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
21
21
|
*
|
|
22
22
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
// Wrapper to support Cookie based storage
|
|
25
24
|
var CookieStorageProvider = exports.CookieStorageProvider = /*#__PURE__*/function () {
|
|
26
|
-
function CookieStorageProvider(
|
|
25
|
+
function CookieStorageProvider() {
|
|
26
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
27
27
|
_classCallCheck(this, CookieStorageProvider);
|
|
28
28
|
_defineProperty(this, "domain", void 0);
|
|
29
|
-
this
|
|
29
|
+
_defineProperty(this, "sameSite", void 0);
|
|
30
|
+
this.domain = options.domain;
|
|
31
|
+
this.sameSite = options.sameSite;
|
|
30
32
|
}
|
|
31
33
|
return _createClass(CookieStorageProvider, [{
|
|
32
34
|
key: "getItem",
|
|
@@ -36,11 +38,20 @@ var CookieStorageProvider = exports.CookieStorageProvider = /*#__PURE__*/functio
|
|
|
36
38
|
}, {
|
|
37
39
|
key: "setItem",
|
|
38
40
|
value: function setItem(key, value) {
|
|
39
|
-
|
|
41
|
+
var cookieOptions = {
|
|
40
42
|
expires: 365,
|
|
41
43
|
path: '/',
|
|
42
44
|
domain: this.domain
|
|
43
|
-
}
|
|
45
|
+
};
|
|
46
|
+
if (this.sameSite === true) {
|
|
47
|
+
cookieOptions.sameSite = 'Strict';
|
|
48
|
+
} else if (this.sameSite === false) {
|
|
49
|
+
cookieOptions.sameSite = 'None';
|
|
50
|
+
cookieOptions.secure = true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// if sameSite is undefined or null, leave default browser behavior
|
|
54
|
+
return _jsCookie["default"].set(key, value, cookieOptions);
|
|
44
55
|
}
|
|
45
56
|
}, {
|
|
46
57
|
key: "removeItem",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class BaseStorageManager {
|
|
2
|
+
constructor(storageName: any, storageProvider: any);
|
|
3
|
+
storageProvider: any;
|
|
4
|
+
storageName: any;
|
|
5
|
+
getStorageObject(): SavedObject;
|
|
6
|
+
}
|
|
7
|
+
export class LocalStorageManager extends BaseStorageManager {
|
|
8
|
+
constructor(storageName: any);
|
|
9
|
+
}
|
|
10
|
+
export function getStorageClass(opts: any): typeof LocalStorageManager;
|
|
11
|
+
declare class SavedObject {
|
|
12
|
+
constructor(storageProvider: any, storageName: any);
|
|
13
|
+
storageProvider: any;
|
|
14
|
+
storageName: any;
|
|
15
|
+
getItem(key: any): any;
|
|
16
|
+
setItem(key: any, value: any): void;
|
|
17
|
+
removeItem(key: any): void;
|
|
18
|
+
getStorage(): any;
|
|
19
|
+
setStorage(obj: any): void;
|
|
20
|
+
clearStorage(key: any): void;
|
|
21
|
+
updateStorage(key: any, value: any): void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -122,7 +122,7 @@ var getStorageClass = exports.getStorageClass = function getStorageClass(opts) {
|
|
|
122
122
|
return /*#__PURE__*/function (_BaseStorageManager3) {
|
|
123
123
|
function CookieStorageManager(storageName) {
|
|
124
124
|
_classCallCheck(this, CookieStorageManager);
|
|
125
|
-
return _callSuper(this, CookieStorageManager, [storageName, new _CookieStorageProvider.CookieStorageProvider(opts
|
|
125
|
+
return _callSuper(this, CookieStorageManager, [storageName, new _CookieStorageProvider.CookieStorageProvider(opts)]);
|
|
126
126
|
}
|
|
127
127
|
_inherits(CookieStorageManager, _BaseStorageManager3);
|
|
128
128
|
return _createClass(CookieStorageManager);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default TokenManager;
|
|
2
|
+
declare class TokenManager {
|
|
3
|
+
constructor(StorageManagerClass: any, tokenEndPoint: any, publicKey: any);
|
|
4
|
+
storageManager: any;
|
|
5
|
+
tokenExpiredAt: any;
|
|
6
|
+
tokenEndPoint: any;
|
|
7
|
+
publicKey: any;
|
|
8
|
+
clear(): void;
|
|
9
|
+
exchangeTokenFromCode(accessCode: any, codeVerifier: any, state?: any): Promise<void>;
|
|
10
|
+
getStateParameter(): any;
|
|
11
|
+
getIdToken(): any;
|
|
12
|
+
getAccessToken(): any;
|
|
13
|
+
getExpiredAt(): any;
|
|
14
|
+
getPublicKey(): Promise<any>;
|
|
15
|
+
hasExpired(): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const MIN_VERIFIER_LENGTH: 43;
|
|
2
|
+
export const MAX_VERIFIER_LENGTH: 128;
|
|
3
|
+
export const DEFAULT_CODE_CHALLENGE_METHOD: "S256";
|
|
4
|
+
declare namespace _default {
|
|
5
|
+
export { DEFAULT_CODE_CHALLENGE_METHOD };
|
|
6
|
+
export { generateVerifier };
|
|
7
|
+
export { computeChallenge };
|
|
8
|
+
}
|
|
9
|
+
export default _default;
|
|
10
|
+
declare function generateVerifier(prefix: any): string;
|
|
11
|
+
declare function computeChallenge(str: any): Promise<any>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2024-Present Animoca Brands Corporation Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
*
|
|
6
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
9
|
+
*/
|
|
10
|
+
export class InternalError extends Error {
|
|
11
|
+
}
|
|
12
|
+
export class InvalidParamsError extends InternalError {
|
|
13
|
+
}
|
|
14
|
+
export class AuthError extends Error {
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function parseJwt(token: any): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencampus/ocid-connect-js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"author": "Animoca Brands",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "OCID Connector Library",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build-dev": "gulp clean && gulp copy && webpack",
|
|
14
|
-
"
|
|
14
|
+
"generate-types": "tsc --declaration --allowJs --emitDeclarationOnly",
|
|
15
|
+
"lib": "babel ./src --out-dir ./lib && yarn generate-types",
|
|
15
16
|
"build": "NODE_OPTIONS=--openssl-legacy-provider npm run lib && NODE_OPTIONS=--openssl-legacy-provider gulp dist",
|
|
16
17
|
"prepublishOnly": "npm run build",
|
|
17
18
|
"lint": "eslint src",
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"@babel/preset-react": "^7.0.0",
|
|
28
29
|
"@testing-library/react": "^13.3.0",
|
|
29
30
|
"@testing-library/user-event": "^14.3.0",
|
|
31
|
+
"@types/node": "^22.10.3",
|
|
30
32
|
"autoprefixer": "^7.1.2",
|
|
31
33
|
"babel-core": "^7.0.0-bridge.0",
|
|
32
34
|
"babel-loader": "^8.0.4",
|
|
@@ -50,6 +52,8 @@
|
|
|
50
52
|
"react-dom": "^18.0.0",
|
|
51
53
|
"sinon": "^2.1.0",
|
|
52
54
|
"style-loader": "^0.16.1",
|
|
55
|
+
"typescript": "^5.7.2",
|
|
56
|
+
"typescript-json-schema": "^0.65.1",
|
|
53
57
|
"uglifyjs-webpack-plugin": "^2.0.1",
|
|
54
58
|
"webpack": "^4.21.0",
|
|
55
59
|
"webpack-cli": "^3.1.2",
|