mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 06:29:40 +08:00
add types for discourse-sso
Signed-off-by: Arnav Gupta <arnav@codingblocks.com>
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)
|
||||
}
|
||||
30
types/discourse-sso/index.d.ts
vendored
Normal file
30
types/discourse-sso/index.d.ts
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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 {
|
||||
|
||||
export 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
|
||||
22
types/discourse-sso/tsconfig.json
Normal file
22
types/discourse-sso/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": 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