@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/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./react";
2
+ export * from "./sdk";
@@ -0,0 +1,6 @@
1
+ export default function LoginButton({ pill, disabled, theme, }: {
2
+ pill: any;
3
+ disabled: any;
4
+ theme: any;
5
+ }): React.JSX.Element;
6
+ import React from 'react';
@@ -0,0 +1,7 @@
1
+ export default LoginCallBack;
2
+ declare function LoginCallBack({ successCallback, errorCallback, customErrorComponent, customLoadingComponent }: {
3
+ successCallback: any;
4
+ errorCallback: any;
5
+ customErrorComponent: any;
6
+ customLoadingComponent: any;
7
+ }): any;
@@ -0,0 +1,7 @@
1
+ export default OCConnect;
2
+ declare function OCConnect({ children, opts, sandboxMode }: {
3
+ children: any;
4
+ opts: any;
5
+ sandboxMode: any;
6
+ }): React.JSX.Element;
7
+ import React from 'react';
@@ -0,0 +1,3 @@
1
+ export const OCContext: React.Context<any>;
2
+ export function useOCAuth(): any;
3
+ import * as React from 'react';
@@ -0,0 +1,4 @@
1
+ export { default as LoginButton } from "./LoginButton";
2
+ export { default as LoginCallBack } from "./LoginCallBack";
3
+ export { default as OCConnect } from "./OCConnect";
4
+ export * from "./OCContext";
@@ -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,5 @@
1
+ export function base64ToBase64Url(b64: any): any;
2
+ export function base64UrlToBase64(b64u: any): any;
3
+ export function stringToBase64Url(str: any): any;
4
+ export function stringToBuffer(str: any): Uint8Array<any>;
5
+ export function base64UrlDecode(str: any): string;
@@ -0,0 +1,3 @@
1
+ export * from "./webcrypto";
2
+ export * from "./base64";
3
+ export * from "./verifyToken";
@@ -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,2 @@
1
+ export * from "./lib";
2
+ export * from "./auth";
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ export class CookieStorageProvider {
2
+ constructor(options?: {});
3
+ domain: any;
4
+ sameSite: any;
5
+ getItem(key: any): any;
6
+ setItem(key: any, value: any): any;
7
+ removeItem(key: any): any;
8
+ }
@@ -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(domain) {
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.domain = domain;
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
- return _jsCookie["default"].set(key, value, {
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.cookieDomain)]);
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,9 @@
1
+ export default TransactionManager;
2
+ declare class TransactionManager {
3
+ constructor(StorageManagerClass: any);
4
+ storageManager: any;
5
+ clear(): void;
6
+ save(meta: any): void;
7
+ getTransactionMeta(): any;
8
+ hasActiveTransaction(): boolean;
9
+ }
@@ -0,0 +1,3 @@
1
+ export { default as TokenManager } from "./TokenManager";
2
+ export { default as TransactionManager } from "./TransactionManager";
3
+ export * from "./StorageManager";
@@ -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,5 @@
1
+ export function createPkceMeta(signinParams: any): {
2
+ codeChallenge: any;
3
+ codeVerifier: any;
4
+ codeChallengeMethod: any;
5
+ };
@@ -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,4 @@
1
+ export * from "./urlParser";
2
+ export * from "./prepareTokenParams";
3
+ export * from "./createPkceMeta";
4
+ export * from "./jwtParser";
@@ -0,0 +1 @@
1
+ export function parseJwt(token: any): any;
@@ -0,0 +1,8 @@
1
+ export function prepareTokenParams(params: any): Promise<{
2
+ redirectUri: any;
3
+ codeVerifier: string;
4
+ codeChallenge: any;
5
+ codeChallengeMethod: string;
6
+ scope: string;
7
+ responseType: string;
8
+ }>;
@@ -0,0 +1,5 @@
1
+ export function parseUrl(): {
2
+ id_token: string;
3
+ code: string;
4
+ state: string;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencampus/ocid-connect-js",
3
- "version": "1.2.5",
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
- "lib": "babel ./src --out-dir ./lib",
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",