Skip to content

Commit

Permalink
Merge pull request #19 from trunges21/master
Browse files Browse the repository at this point in the history
Change type login and register
  • Loading branch information
DanielRivers authored Apr 9, 2024
2 parents 71ef7fb + 1631ac6 commit 8cda253
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 46 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: run-tests

on:
push:
branches: [master]
pull_request:
branches: [master]
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js

uses: actions/setup-node@v4
- name: Install dependencies
run: npm install # `npm ci` (won't work lock files are .gitignored)
uses: actions/setup-node@v4
- name: Install dependencies
run: npm install # `npm ci` (won't work lock files are .gitignored)

- name: Run tests
run: npm test
- name: Run tests
run: npm test
18 changes: 9 additions & 9 deletions dist/ApiClient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,24 @@ export declare const COLLECTION_FORMATS: {
tsv: string;
pipes: string;
};
export declare type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
export declare type Json = any;
export declare type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
export declare type HTTPHeaders = {
export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
export type Json = any;
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
export type HTTPHeaders = {
[key: string]: string;
};
export declare type HTTPQuery = {
export type HTTPQuery = {
[key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
};
export declare type HTTPBody = Json | FormData | URLSearchParams;
export declare type HTTPRequestInit = {
export type HTTPBody = Json | FormData | URLSearchParams;
export type HTTPRequestInit = {
headers?: HTTPHeaders;
method: HTTPMethod;
credentials?: RequestCredentials_;
body?: HTTPBody;
};
export declare type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
export declare type InitOverrideFunction = (requestContext: {
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
export type InitOverrideFunction = (requestContext: {
init: HTTPRequestInit;
context: RequestOpts;
}) => Promise<RequestInit>;
Expand Down
8 changes: 4 additions & 4 deletions dist/SDK/KindeSDK.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
import * as runtime from '../ApiClient';
import { AuthBrowserOptions } from '../types/Auth';
import { AdditionalParameters, FeatureFlag, OptionalFlag, OrgAdditionalParams, TokenResponse } from '../types/KindeSDK';
import { AdditionalParameters, FeatureFlag, LoginAdditionalParameters, OptionalFlag, OrgAdditionalParams, RegisterAdditionalParameters, TokenResponse } from '../types/KindeSDK';
import { TokenType } from './Enums';
/**
* The KindeSDK module.
Expand Down Expand Up @@ -44,11 +44,11 @@ declare class KindeSDK extends runtime.BaseAPI {
/**
* The function takes an object as an argument, and if the object is empty, it will use the default
* object
* @param {AdditionalParameters} additionalParameters - AdditionalParameters = {}
* @param {AdditionalParameters} additionalParameters - LoginAdditionalParameters = {}
* @param {AuthBrowserOptions} [authBrowserOptions] - Authentication browser options.
* @returns A promise that resolves to void.
*/
login(additionalParameters?: Omit<OrgAdditionalParams, 'is_create_org'>, authBrowserOptions?: AuthBrowserOptions): Promise<TokenResponse | null>;
login(additionalParameters?: LoginAdditionalParameters, authBrowserOptions?: AuthBrowserOptions): Promise<TokenResponse | null>;
/**
* This function registers an organization with additional parameters and authenticates it using an
* authorization code.
Expand All @@ -59,7 +59,7 @@ declare class KindeSDK extends runtime.BaseAPI {
* @param {AuthBrowserOptions} [authBrowserOptions] - Authentication browser options.
* @returns A Promise that resolves to void.
*/
register(additionalParameters?: OrgAdditionalParams, authBrowserOptions?: AuthBrowserOptions): Promise<TokenResponse | null>;
register(additionalParameters?: RegisterAdditionalParameters, authBrowserOptions?: AuthBrowserOptions): Promise<TokenResponse | null>;
/**
* This function creates an organization with additional parameters.
* @param additionalParameters
Expand Down
2 changes: 1 addition & 1 deletion dist/SDK/Utils.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/types/Auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { AuthSessionOpenOptions } from 'expo-web-browser';
import { InAppBrowserOptions } from 'react-native-inappbrowser-reborn';
export declare type AuthBrowserOptions = InAppBrowserOptions | AuthSessionOpenOptions;
export type AuthBrowserOptions = InAppBrowserOptions | AuthSessionOpenOptions;
26 changes: 16 additions & 10 deletions dist/types/KindeSDK.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
* @module SDK/Types
* @version 1.2.0
*/
export declare type AdditionalParameters = {
export type AdditionalParameters = {
audience?: string;
is_create_org?: boolean;
org_code?: string;
org_name?: string;
};
export declare type OrgAdditionalParams = Omit<AdditionalParameters, 'audience'>;
export declare type UserProfile = {
export type OrgAdditionalParams = Omit<AdditionalParameters, 'audience'>;
export type UserProfile = {
id: string;
given_name: string;
family_name: string;
email: string;
picture: string;
};
export declare type TokenResponse = {
export type TokenResponse = {
access_token: string;
refresh_token: string;
id_token: string;
scope: string;
token_type: string;
expires_in: number;
};
export declare type AccessTokenDecoded = {
export type AccessTokenDecoded = {
aud: string[];
azp: string;
exp: number;
Expand All @@ -47,19 +47,25 @@ export declare type AccessTokenDecoded = {
gty?: string[];
scp?: string[];
} & Record<string, any>;
export declare type IdTokenDecoded = {
export type IdTokenDecoded = {
sub: string;
given_name: string;
family_name: string;
email: string;
picture: string;
} & Record<string, any>;
export declare type OptionalFlag = {
export type OptionalFlag = {
defaultValue?: string | boolean | number;
};
export declare type FeatureFlagType = 's' | 'b' | 'i';
export declare type FeatureFlagValue = string | boolean | number;
export declare type FeatureFlag = {
export type FeatureFlagType = 's' | 'b' | 'i';
export type FeatureFlagValue = string | boolean | number;
export type FeatureFlag = {
v?: FeatureFlagValue;
t?: FeatureFlagType;
};
export type LoginAdditionalParameters = Omit<OrgAdditionalParams, 'is_create_org'> & {
[key: string]: unknown;
};
export type RegisterAdditionalParameters = OrgAdditionalParams & {
[key: string]: unknown;
};
8 changes: 5 additions & 3 deletions src/SDK/KindeSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import { AuthBrowserOptions } from '../types/Auth';
import {
AdditionalParameters,
FeatureFlag,
LoginAdditionalParameters,
OptionalFlag,
OrgAdditionalParams,
RegisterAdditionalParameters,
TokenResponse
} from '../types/KindeSDK';
import { TokenType } from './Enums';
Expand Down Expand Up @@ -101,12 +103,12 @@ class KindeSDK extends runtime.BaseAPI {
/**
* The function takes an object as an argument, and if the object is empty, it will use the default
* object
* @param {AdditionalParameters} additionalParameters - AdditionalParameters = {}
* @param {AdditionalParameters} additionalParameters - LoginAdditionalParameters = {}
* @param {AuthBrowserOptions} [authBrowserOptions] - Authentication browser options.
* @returns A promise that resolves to void.
*/
async login(
additionalParameters: Omit<OrgAdditionalParams, 'is_create_org'> = {},
additionalParameters: LoginAdditionalParameters = {},
authBrowserOptions?: AuthBrowserOptions
): Promise<TokenResponse | null> {
checkAdditionalParameters(additionalParameters);
Expand Down Expand Up @@ -137,7 +139,7 @@ class KindeSDK extends runtime.BaseAPI {
* @returns A Promise that resolves to void.
*/
register(
additionalParameters: OrgAdditionalParams = {},
additionalParameters: RegisterAdditionalParameters = {},
authBrowserOptions?: AuthBrowserOptions
): Promise<TokenResponse | null> {
checkAdditionalParameters(additionalParameters);
Expand Down
6 changes: 2 additions & 4 deletions src/SDK/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ export const checkAdditionalParameters = (
AdditionalParametersAllow
) as AdditionalParametersKeys[];
for (const key of keyExists) {
if (!keysAllow.includes(key)) {
throw new UnexpectedException(key);
}
if (
keysAllow.includes(key) &&
typeof additionalParameters[key] !==
AdditionalParametersAllow[key]
AdditionalParametersAllow[key]
) {
throw new InvalidTypeException(
key,
Expand Down
11 changes: 11 additions & 0 deletions src/types/KindeSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,14 @@ export type FeatureFlag = {
v?: FeatureFlagValue; // v -> value
t?: FeatureFlagType; // t -> type, s -> string, b -> boolean, i -> integer
};

export type LoginAdditionalParameters = Omit<
OrgAdditionalParams,
'is_create_org'
> & {
[key: string]: unknown;
};

export type RegisterAdditionalParameters = OrgAdditionalParams & {
[key: string]: unknown;
};

0 comments on commit 8cda253

Please sign in to comment.