mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Merge pull request #25726 from championswimmer/@types/discourse-sso
add types for discourse-sso
This commit is contained in:
16
types/discourse-sso/discourse-sso-tests.ts
Normal file
16
types/discourse-sso/discourse-sso-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as discourseSSO from 'discourse-sso';
|
||||
const sso = new discourseSSO('sso secret string');
|
||||
|
||||
if (sso.validate('payload', 'sig')) {
|
||||
const nonce = sso.getNonce('payload');
|
||||
|
||||
const userParams: discourseSSO.UserParams = {
|
||||
nonce,
|
||||
external_id: '1',
|
||||
email: 'omg@mail.com',
|
||||
username: 'myuser',
|
||||
name: 'This Guy'
|
||||
};
|
||||
|
||||
const loginString: string = sso.buildLoginString(userParams);
|
||||
}
|
||||
27
types/discourse-sso/index.d.ts
vendored
Normal file
27
types/discourse-sso/index.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for discourse-sso 1.0
|
||||
// Project: https://github.com/ArmedGuy/discourse_sso_node
|
||||
// Definitions by: Arnav Gupta <https://github.com/championswimmer>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare class DiscourseSSO {
|
||||
constructor(ssoSecret: string);
|
||||
validate(payload: string, sig: string): boolean;
|
||||
getNonce(payload: string): string;
|
||||
buildLoginString(params: DiscourseSSO.UserParams): string;
|
||||
}
|
||||
|
||||
declare namespace DiscourseSSO {
|
||||
interface UserParams {
|
||||
nonce: string;
|
||||
external_id: string;
|
||||
email: string;
|
||||
admin?: boolean;
|
||||
moderator?: boolean;
|
||||
username?: string;
|
||||
name?: string;
|
||||
avatar_url?: string;
|
||||
add_groups?: string[];
|
||||
remove_groups?: string[];
|
||||
}
|
||||
}
|
||||
export = DiscourseSSO;
|
||||
23
types/discourse-sso/tsconfig.json
Normal file
23
types/discourse-sso/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"discourse-sso-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/discourse-sso/tslint.json
Normal file
1
types/discourse-sso/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user