Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-3870] Typescript Migration #628

Merged
merged 39 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
730142b
Edit tsconfig.json to support the root project
poovamraj May 23, 2023
dd7e5ec
Update tsconfig.json
poovamraj May 24, 2023
b624d91
Convert js files to ts
poovamraj May 24, 2023
2678921
Add more ts support in mocks and tests
poovamraj May 24, 2023
524a895
Rename tsx files
poovamraj May 24, 2023
80266e5
Ignore dist in gitignore
poovamraj May 24, 2023
20a14a1
ignore dist being build repeatedly
poovamraj May 24, 2023
50fcb65
Part 1 - TS syntax migration
poovamraj May 25, 2023
e26c762
Part 2 - TS Syntax migration
poovamraj May 25, 2023
0132d81
Fix telemetry export - TS Syntax
poovamraj May 25, 2023
c50ef96
Migrating tests back to JS
poovamraj May 25, 2023
9d02c51
Fix broken tests
poovamraj May 28, 2023
0de32f8
Stricter typescript configuration
poovamraj May 29, 2023
ac5f0cf
Changed entry point in package.json
poovamraj May 30, 2023
69f9c0d
Update src/networking/index.ts
poovamraj May 30, 2023
c8ca4ac
Use unknown instead of any
poovamraj May 30, 2023
2354a48
Use PropsWithChildren
poovamraj May 30, 2023
019a0a8
Implement type interface for methods
poovamraj May 30, 2023
1836442
Add types to reducer and actions
poovamraj May 30, 2023
70fe756
Improved Types and reduced amount of any used
poovamraj Jun 2, 2023
750596f
Update src/hooks/auth0-provider.tsx
poovamraj Jun 2, 2023
17f7ebf
Update src/jwt/signatureVerifier.ts
poovamraj Jun 2, 2023
c5cd8e8
Implement proper naming convention
poovamraj Jun 2, 2023
fc81e34
Implement PR review changes
poovamraj Jun 2, 2023
0d849a5
Fix TS Syntax issue
poovamraj Jun 2, 2023
ce91883
Return types implemented for rest APIs
poovamraj Jun 4, 2023
e1cd16e
Breaking change: revoke token and change password return type
poovamraj Jun 4, 2023
d80b423
Return user object in camel case
poovamraj Jun 4, 2023
be4604d
Change tests to provide return user object in camel case
poovamraj Jun 4, 2023
ee3c6ba
Change tests to provide return user object in camel case
poovamraj Jun 4, 2023
e76d5dd
Error types handling
poovamraj Jun 4, 2023
4592ace
Replace any with unknown in whitelist.ts
poovamraj Jun 4, 2023
8b4c2ef
Provide type support for auth0.ts
poovamraj Jun 4, 2023
cfa904c
Some additional improvements to add more type-safety (#634)
frederikprijck Jun 5, 2023
d898a58
Convert user object to camel case
poovamraj Jun 5, 2023
48b8af9
Simplify user conversion
poovamraj Jun 5, 2023
932dcac
Implement return type for user conversion
poovamraj Jun 5, 2023
ad74f1d
Better types for JwtPayload
poovamraj Jun 5, 2023
bbe53fc
Fix convertUser parameter type
frederikprijck Jun 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ coverage/
# Temp files
out/

plugin/build
plugin/build

dist
4 changes: 2 additions & 2 deletions .babelrc.js → babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
sourceMaps: true
};
sourceMaps: true,
};
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "React Native Auth0",
"version": "2.17.2",
"description": "React Native toolkit for Auth0 API",
"main": "index.js",
"main": "dist/index.js",
"scripts": {
"test": "jest",
"test:ci": "jest --coverage",
Expand Down Expand Up @@ -37,7 +37,6 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^28.1.6",
"babel-jest": "^28.1.3",
"expo-module-scripts": "^2.0.0",
"faker": "^4.1.0",
Expand All @@ -53,15 +52,23 @@
"pretty-quick": "^1.11.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-native": "^0.65.0",
"react-native": "^0.71.8",
"@tsconfig/react-native": "^2.0.2",
"@types/jest": "^29.2.1",
"@types/react": "^18.0.24",
"@types/react-test-renderer": "^18.0.0",
"@types/base-64": "^1.0.0",
"@types/crypto-js": "^4.0.0",
"@types/jsbn": "^1.1.0",
"typescript": "4.8.4",
"semver": "^6.3.0"
},
"dependencies": {
"@expo/config-plugins": "^4.1.5",
"base-64": "^0.1.0",
"crypto-js": "^4.0.0",
"jsbn": "^1.1.0",
"jwt-decode": "^2.2.0",
"jwt-decode": "^3.1.2",
"prop-types": "^15.8.1",
"url": "^0.11.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/auth/__tests__/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ Object {

exports[`auth Recovery Code flow when user does not have Recovery Code 1`] = `[unsupported_challenge_type: User does not have a recovery-code.]`;

exports[`auth authorizeUrl should return default authorize url 1`] = `"https://samples.auth0.com/authorize?response_type=code&redirect_uri=https%3A%2F%2Fmysite.com%2Fcallback&state=a_random_state&client_id=A_CLIENT_ID_OF_YOUR_ACCOUNT&auth0Client=eyJuYW1lIjoicmVhY3QtbmF0aXZlLWF1dGgwIiwidmVyc2lvbiI6IjEuMC4wIn0%3D"`;
exports[`auth authorizeUrl should return default authorize url 1`] = `"https://samples.auth0.com/authorize?response_type=code&redirect_uri=https%3A%2F%2Fmysite.com%2Fcallback&state=a_random_state&auth0Client=eyJuYW1lIjoicmVhY3QtbmF0aXZlLWF1dGgwIiwidmVyc2lvbiI6IjEuMC4wIn0%3D"`;

exports[`auth authorizeUrl should return default authorize url with extra parameters 1`] = `"https://samples.auth0.com/authorize?response_type=code&redirect_uri=https%3A%2F%2Fmysite.com%2Fcallback&state=a_random_state&connection=facebook&client_id=A_CLIENT_ID_OF_YOUR_ACCOUNT&auth0Client=eyJuYW1lIjoicmVhY3QtbmF0aXZlLWF1dGgwIiwidmVyc2lvbiI6IjEuMC4wIn0%3D"`;
exports[`auth authorizeUrl should return default authorize url with extra parameters 1`] = `"https://samples.auth0.com/authorize?response_type=code&redirect_uri=https%3A%2F%2Fmysite.com%2Fcallback&state=a_random_state&connection=facebook&auth0Client=eyJuYW1lIjoicmVhY3QtbmF0aXZlLWF1dGgwIiwidmVyc2lvbiI6IjEuMC4wIn0%3D"`;

exports[`auth change password should handle oauth error 1`] = `[invalid_request: Invalid grant]`;

Expand Down
15 changes: 0 additions & 15 deletions src/auth/auth0Error.js

This file was deleted.

19 changes: 19 additions & 0 deletions src/auth/auth0Error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import BaseError from '../utils/baseError';

export default class Auth0Error extends BaseError {
public json;
public status;
public code;

constructor(response: {status: string; json: any; text?: string}) {
const {status, json = {}, text} = response;
const {name, description, code} = json;
super(
name || 'a0.response.invalid',
description || text || 'unknown error',
);
this.json = json;
this.status = status;
this.code = code;
}
}
7 changes: 5 additions & 2 deletions src/auth/authError.js → src/auth/authError.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import BaseError from '../utils/baseError';

export default class AuthError extends BaseError {
constructor(response) {
public json;
public status;

constructor(response: {status: number; json: any; text?: string}) {
const {status, json = {}, text} = response;
const {error, error_description: description} = json;
super(
Expand All @@ -13,7 +16,7 @@ export default class AuthError extends BaseError {
}
}

const handleInvalidToken = response =>
export const handleInvalidToken = (response: any) =>
response?.headers?.get('www-authenticate')?.match(/error="invalid_token"/g)
? 'invalid_token'
: null;
Loading