mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Add definitions for apple-signin-api (#42454)
* Add definitions for apple-signin-api * change signInResponse user to be optional apple returns user object only on first login * update to 1.4.1 version
This commit is contained in:
42
types/apple-signin-api/apple-signin-api-tests.ts
Normal file
42
types/apple-signin-api/apple-signin-api-tests.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
const ClientConfig: AppleSignInAPI.ClientConfigI = {
|
||||
clientId: '',
|
||||
redirectURI: '',
|
||||
scope: '',
|
||||
state: '',
|
||||
usePopup: false,
|
||||
};
|
||||
|
||||
const signInResponse: AppleSignInAPI.SignInResponseI = {
|
||||
authorization: {
|
||||
state: '[STATE]',
|
||||
code: '[CODE]',
|
||||
id_token: '[ID_TOKEN]',
|
||||
},
|
||||
user: {
|
||||
email: '[EMAIL]',
|
||||
name: {
|
||||
firstName: '[FIRST_NAME]',
|
||||
lastName: '[LAST_NAME]',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const signInError: AppleSignInAPI.SignInErrorI = {
|
||||
error: '[ERROR]',
|
||||
};
|
||||
|
||||
const AuthGood: AppleSignInAPI.AppleID = {
|
||||
auth: {
|
||||
init: () => new Promise(() => {}),
|
||||
signIn: () => new Promise(() => signInResponse),
|
||||
renderButton: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
const AuthBad: AppleSignInAPI.AppleID = {
|
||||
auth: {
|
||||
init: () => new Promise(() => {}),
|
||||
signIn: () => new Promise(() => signInError),
|
||||
renderButton: () => {},
|
||||
},
|
||||
};
|
||||
49
types/apple-signin-api/index.d.ts
vendored
Normal file
49
types/apple-signin-api/index.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Type definitions for non-npm package Apple Sign in API 1.4
|
||||
// Project: https://developer.apple.com/documentation/signinwithapplejs
|
||||
// Definitions by: Julius Lungys <https://github.com/voidpumpkin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace AppleSignInAPI {
|
||||
// https://developer.apple.com/documentation/signinwithapplejs/authorizationi
|
||||
interface AuthorizationI {
|
||||
code: string;
|
||||
id_token: string;
|
||||
state: string;
|
||||
}
|
||||
// https://developer.apple.com/documentation/signinwithapplejs/namei
|
||||
interface NameI {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
// https://developer.apple.com/documentation/signinwithapplejs/signinerrori
|
||||
interface SignInErrorI {
|
||||
error: string;
|
||||
}
|
||||
// https://developer.apple.com/documentation/signinwithapplejs/signinresponsei
|
||||
interface SignInResponseI {
|
||||
authorization: AuthorizationI;
|
||||
user?: UserI;
|
||||
}
|
||||
// https://developer.apple.com/documentation/signinwithapplejs/useri
|
||||
interface UserI {
|
||||
email: string;
|
||||
name: NameI;
|
||||
}
|
||||
// https://developer.apple.com/documentation/signinwithapplejs/authi
|
||||
interface AuthI {
|
||||
init: (config: ClientConfigI) => Promise<void>;
|
||||
signIn: (signInConfig?: ClientConfigI) => Promise<SignInResponseI | SignInErrorI>;
|
||||
renderButton: () => void;
|
||||
}
|
||||
// https://developer.apple.com/documentation/signinwithapplejs/clientconfigi
|
||||
interface ClientConfigI {
|
||||
clientId: string;
|
||||
redirectURI: string;
|
||||
scope: string;
|
||||
state: string;
|
||||
usePopup: boolean;
|
||||
}
|
||||
interface AppleID {
|
||||
auth: AuthI;
|
||||
}
|
||||
}
|
||||
23
types/apple-signin-api/tsconfig.json
Normal file
23
types/apple-signin-api/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"apple-signin-api-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/apple-signin-api/tslint.json
Normal file
1
types/apple-signin-api/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user