-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(add typescript support): - Update Dependencies
- Loading branch information
Abdulghani Akhras
authored and
Abdulghani Akhras
committed
Dec 15, 2022
1 parent
dea84d8
commit 585b140
Showing
8 changed files
with
141 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Author : Younes A <https://github.com/younes-io> | ||
|
||
export interface StrategyOptions { | ||
[key: string]: any; | ||
} | ||
|
||
export interface SelfServiceOptions { | ||
iamApiKey?: string; | ||
managementUrl?: string; | ||
tenantId?: string; | ||
oAuthServerUrl?: string; | ||
iamTokenUrl?: string; | ||
} | ||
|
||
export class Strategy { | ||
authenticate: () => void; | ||
} | ||
|
||
export interface ApplicationIdentityToken { | ||
accessToken: string; | ||
tokenType: string; | ||
expiresIn: number; | ||
} | ||
|
||
export interface CustomIdentityToken extends ApplicationIdentityToken { | ||
identityToken: string; | ||
} | ||
|
||
export interface UserSCIM { | ||
id: string; | ||
userName: string; | ||
[key: string]: any; | ||
} | ||
|
||
// tslint:disable-next-line:no-unnecessary-class | ||
export class APIStrategy extends Strategy { | ||
constructor(options: StrategyOptions); | ||
} | ||
|
||
// tslint:disable-next-line:no-unnecessary-class | ||
export class WebAppStrategy extends Strategy { | ||
constructor(options: StrategyOptions); | ||
} | ||
|
||
// tslint:disable-next-line:no-unnecessary-class | ||
export class TokenManager { | ||
constructor(options: StrategyOptions); | ||
getApplicationIdentityToken: () => Promise<ApplicationIdentityToken | Error>; | ||
getCustomIdentityTokens: () => Promise<CustomIdentityToken | Error>; | ||
} | ||
|
||
// tslint:disable-next-line:no-unnecessary-class | ||
export class SelfServiceManager { | ||
constructor(options: SelfServiceOptions); | ||
signUp: ( | ||
userData: unknown, | ||
language: string, | ||
iamToken: string | ||
) => Promise<UserSCIM>; | ||
} | ||
|
||
// tslint:disable-next-line:no-unnecessary-class | ||
export class UserProfileManager { | ||
constructor(); | ||
} | ||
|
||
// tslint:disable-next-line:no-unnecessary-class | ||
export class UnauthorizedException { | ||
constructor(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Author : Younes A <https://github.com/younes-io> | ||
import { | ||
APIStrategy, | ||
ApplicationIdentityToken, | ||
SelfServiceManager, | ||
Strategy, | ||
TokenManager, | ||
UserSCIM, | ||
WebAppStrategy, | ||
} from "./appid-sdk"; | ||
import { expectType } from "tsd"; | ||
|
||
expectType<Strategy>( | ||
new APIStrategy({ | ||
oauthServerUrl: "{oauth-server-url}", | ||
}) | ||
); | ||
|
||
expectType<Strategy>( | ||
new WebAppStrategy({ | ||
tenantId: "{tenant-id}", | ||
clientId: "{client-id}", | ||
secret: "{secret}", | ||
oauthServerUrl: "{oauth-server-url}", | ||
redirectUri: "{app-url}" + "CALLBACK_URL", | ||
}) | ||
); | ||
|
||
const config = { | ||
tenantId: "{tenant-id}", | ||
clientId: "{client-id}", | ||
secret: "{secret}", | ||
oauthServerUrl: "{oauth-server-url}", | ||
}; | ||
|
||
const tokenManager = new TokenManager(config); | ||
expectType<ApplicationIdentityToken | Error>( | ||
await tokenManager.getApplicationIdentityToken() | ||
); | ||
|
||
const selfServiceManager = new SelfServiceManager({ | ||
iamApiKey: "{iam-api-key}", | ||
managementUrl: "{management-url}", | ||
}); | ||
|
||
const userData = { | ||
id: "2819c223-7f76-453a-919d-413861904646", | ||
externalId: "701984", | ||
userName: "[email protected]", | ||
}; | ||
|
||
expectType<UserSCIM>( | ||
await selfServiceManager.signUp(userData, "en", "iamToken") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters