Skip to content

Commit

Permalink
fix export modules
Browse files Browse the repository at this point in the history
  • Loading branch information
trunges21 committed May 26, 2023
1 parent 2a722ee commit f7f9398
Show file tree
Hide file tree
Showing 74 changed files with 51 additions and 2,335 deletions.
65 changes: 9 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @kinde-oss/react-native-sdk
# @kinde-oss/react-native-sdk-0-6x

React Native Client for `@kinde-oss/react-native-sdk`
React Native Client for `@kinde-oss/react-native-sdk-0-6x`
Provides endpoints to manage your Kinde Businesses

> Functions/methods targeting the Management API can only be accessed with tokens generated by the Client Credentials Auth flow at the moment. Since this SDK does not support the Client Credential flow, Management API functions are not available for use. In the future, tokens obtained via other flows would also be able to access the management API functions/methods.
Expand All @@ -24,7 +24,7 @@ Follow [the installation instructions for your chosen OS](https://reactnative.de
The SDK can be installed with `npm` or `yarn` but we will use `npm` for code samples.

```shell
npm install @kinde-oss/react-native-sdk --save
npm install @kinde-oss/react-native-sdk-0-6x --save
```

### Android
Expand Down Expand Up @@ -302,7 +302,7 @@ You’ll need to create a new instance of the Kinde Auth client object. Please e

```javascript
...
import { KindeSDK } from '@kinde-oss/react-native-sdk';
import { KindeSDK } from '@kinde-oss/react-native-sdk-0-6x';
...

...
Expand Down Expand Up @@ -456,23 +456,12 @@ const handleLogout = () => {

### Get user information

**\*Note warning:** Before you call the API, please make sure that you've already authenticated. If not, errors will appear there.\*

To access the user information, use the `OAuthApi`, `ApiClient` classes exported from `@kinde-oss/react-native-sdk`, then call the `getUser` method of `OAuthApi` instance
To access the user information, use the `getUserDetails` helper function:

```javascript
...
import { ..., OAuthApi, ApiClient, ... } from '@kinde-oss/react-native-sdk';
...

const getUserProfile = () => {
const config = new ApiClient.Configuration({
basePath: KINDE_ISSUER_URL,
});
const apiInstance = new OAuthApi(config)
const data = await apiInstance.getUser();
console.log('API called successfully. Returned data: ' + data);
}
const userProfile = await client.getUserDetails();
console.log(userProfile);
// output: {"given_name":"Dave","id":"abcdef","family_name":"Smith","email":"[email protected]"}
```

### View users in Kinde
Expand Down Expand Up @@ -650,7 +639,7 @@ E.g., using the `getAccessToken` method of `the Storage` class to get an access

```javascript
...
import Storage from '@kinde-oss/react-native-sdk'
import Storage from '@kinde-oss/react-native-sdk-0-6x'
...


Expand Down Expand Up @@ -737,39 +726,3 @@ rm -rf Pods && rm Podfile.lock
3. Clean build folders on Xcode.

If you need any assistance with getting Kinde connected reach out to us at [email protected].

## How to run test

The simplest way to run the JavaScript test suite is by using the following command at the root of your React Native checkout:

```bash
npm run test

// or
yarn test
```

## Documentation for API Endpoints

All URIs are relative to *https://your_kinde_domain.kinde.com/api/v1*

| Class | Method | HTTP request | Description |
| -------------------------------------- | --------------------------------------------------------- | ------------------------------- | ----------------------------------------------------------- |
| _@kinde-oss/react-native-sdk.OAuthApi_ | [**getUser**](docs/OAuthApi.md#getUser) | **GET** /oauth2/user_profile | Returns the details of the currently logged in user |
| _@kinde-oss/react-native-sdk.OAuthApi_ | [**getUserProfileV2**](docs/OAuthApi.md#getUserProfileV2) | **GET** /oauth2/v2/user_profile | Returns the details of the currently logged in user |
| _@kinde-oss/react-native-sdk.UsersApi_ | [**createUser**](docs/UsersApi.md#createUser) | **POST** /user | Creates a user record |
| _@kinde-oss/react-native-sdk.UsersApi_ | [**getUsers**](docs/UsersApi.md#getUsers) | **GET** /users | Returns a paginated list of end-user records for a business |

## Documentation for Models

- [@kinde-oss/react-native-sdk.CreateUser200Response](docs/CreateUser200Response.md)
- [@kinde-oss/react-native-sdk.CreateUserRequest](docs/CreateUserRequest.md)
- [@kinde-oss/react-native-sdk.CreateUserRequestIdentitiesInner](docs/CreateUserRequestIdentitiesInner.md)
- [@kinde-oss/react-native-sdk.CreateUserRequestIdentitiesInnerDetails](docs/CreateUserRequestIdentitiesInnerDetails.md)
- [@kinde-oss/react-native-sdk.CreateUserRequestProfile](docs/CreateUserRequestProfile.md)
- [@kinde-oss/react-native-sdk.GetUsers200Response](docs/GetUsers200Response.md)
- [@kinde-oss/react-native-sdk.User](docs/User.md)
- [@kinde-oss/react-native-sdk.UserIdentity](docs/UserIdentity.md)
- [@kinde-oss/react-native-sdk.UserIdentityResult](docs/UserIdentityResult.md)
- [@kinde-oss/react-native-sdk.UserProfile](docs/UserProfile.md)
- [@kinde-oss/react-native-sdk.UserProfileV2](docs/UserProfileV2.md)
35 changes: 3 additions & 32 deletions __tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck

const { KindeSDK, ApiClient, OAuthApi } = require(process.cwd() + '/src/index');
const { KindeSDK } = require(process.cwd() + '/src/index');
import jwtDecode from 'jwt-decode';
import Url from 'url-parse';
import RNStorage from '../src/SDK/Storage/RNStorage';
Expand Down Expand Up @@ -63,19 +63,12 @@ const configuration = {
fakeCodeChallenge: '3Aqg8_tu8aNwnxPmhE1b1ONsThy-b6hppET0knva9Kc'
};

const fakeUserProfile = {
id: 'kp:58ece9f68a7c4c098efc1cf45c774e16',
last_name: 'test',
first_name: 'user',
provided_id: null,
preferred_email: '[email protected]'
};

const fakeUserDetail = {
id: 'kp:58ece9f68a7c4c098efc1cf45c774e16',
given_name: 'test',
family_name: 'user',
email: '[email protected]'
email: '[email protected]',
picture: ''
};

const fakePayloadFromDecodeToken = {
Expand Down Expand Up @@ -405,28 +398,6 @@ describe('KindeSDK', () => {
});
});

describe('Api', () => {
test('Get user profile', async () => {
const config = new ApiClient.Configuration({
basePath: configuration.issuer
});
const apiInstance = new OAuthApi(config);
jest.spyOn(apiInstance, 'getUserProfileV2').mockImplementation(
() => {
return {
id: 'kp:58ece9f68a7c4c098efc1cf45c774e16',
last_name: 'test',
first_name: 'user',
provided_id: null,
preferred_email: '[email protected]'
};
}
);
const data = await apiInstance.getUserProfileV2();
await expect(data).toEqual(fakeUserProfile);
});
});

describe('Payload', () => {
test('[RNStorage] Get claim via access token', async () => {
RNStorage.prototype.getItem = jest.fn().mockReturnValue({
Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@kinde-oss/react-native-sdk",
"displayName": "@kinde-oss/react-native-sdk"
"name": "@kinde-oss/react-native-sdk-0-6x",
"displayName": "@kinde-oss/react-native-sdk-0-6x"
}
7 changes: 1 addition & 6 deletions dist/SDK/KindeSDK.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,7 @@ declare class KindeSDK {
* It returns the user profile from session storage
* @returns The user profile object.
*/
getUserDetails(): Promise<{
id: string;
given_name: string;
family_name: string;
email: string;
}>;
getUserDetails(): Promise<import("../types/KindeSDK").UserProfile>;
/**
* It returns the claims of the token stored in Storage
* @param {TokenType} [tokenType=accessToken] - The type of token to get the claims from.
Expand Down
2 changes: 1 addition & 1 deletion dist/SDK/Storage/RNStorage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ import * as KeyChain from 'react-native-keychain';
*/
export default class RNStorage {
getItem(): Promise<false | KeyChain.UserCredentials>;
setItem<T>(value: T): Promise<false | KeyChain.Result>;
setItem<T>(value: T): Promise<boolean>;
clear(): Promise<boolean>;
}
2 changes: 1 addition & 1 deletion dist/SDK/Storage/RNStorage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions dist/SDK/Storage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
* Do not edit the class manually.
*
*/
/// <reference types="react-native-keychain" />
import { TokenResponse } from '../../types/KindeSDK';
import { TokenResponse, UserProfile } from '../../types/KindeSDK';
import { TokenType } from '../Enums/TokenType.enum';
import BaseStore from './Base';
/**
Expand All @@ -23,7 +22,7 @@ declare class Storage extends BaseStore {
constructor();
getStorage(): Promise<import("./ExpoStorage").default | import("./RNStorage").default>;
getToken(): Promise<TokenResponse | null>;
setToken(token: string): Promise<boolean | import("react-native-keychain").Result>;
setToken(token: string): Promise<boolean>;
getTokenType(type: TokenType): Promise<string | null>;
getAccessToken(): Promise<string | null>;
getIdToken(): Promise<string | null>;
Expand All @@ -33,12 +32,7 @@ declare class Storage extends BaseStore {
getCodeVerifier(): string | undefined;
setCodeVerifier(newCodeVerifier: string): void;
clearAll(): Promise<boolean>;
getUserProfile(): Promise<{
id: string;
given_name: string;
family_name: string;
email: string;
}>;
getUserProfile(): Promise<UserProfile>;
convertString(str: string | object): string;
}
declare const sessionStorage: Storage;
Expand Down
Loading

0 comments on commit f7f9398

Please sign in to comment.