Skip to content

Commit 0887073

Browse files
author
Perki
committed
completed types
1 parent 23dec7c commit 0887073

File tree

1 file changed

+57
-12
lines changed

1 file changed

+57
-12
lines changed

components/pryv/src/index.d.ts

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ declare module 'pryv' {
575575
username(): Promise<string>;
576576
api<Calls extends APICall[] = APICall[]>(
577577
apiCalls: Calls,
578-
res?: APICallProgressHandler[],
578+
progress?: APICallProgressHandler,
579579
): Promise<Array<TypedAPICallResult>>;
580580
getEventsStreamed(
581581
queryParams: Partial<EventQueryParamsStreamQuery>,
@@ -598,9 +598,12 @@ declare module 'pryv' {
598598
id: Identifier,
599599
fields: string[],
600600
values: Array<string | number>,
601-
): Promise<void>;
601+
): Promise<any>;
602602
accessInfo(): Promise<AccessInfo>;
603603

604+
readonly deltaTime: number;
605+
readonly apiEndpoint: string;
606+
604607
post(
605608
path: string,
606609
data: Object | any[],
@@ -650,14 +653,27 @@ declare module 'pryv' {
650653
[key: string]: any;
651654
};
652655

656+
export class ServiceAssets {
657+
static setup(pryvServiceAssetsSourceUrl: string): Promise<ServiceAssets>;
658+
get(keyPath?: string): any;
659+
getUrl(keyPath?: string): string;
660+
relativeURL(url: string): string;
661+
setAllDefaults(): Promise<void>;
662+
setFavicon(): void;
663+
loadCSS(): Promise<void>;
664+
loginButtonLoadCSS(): Promise<void>;
665+
loginButtonGetHTML(): Promise<string>;
666+
loginButtonGetMessages(): Promise<KeyValue>;
667+
}
668+
653669
export class Service {
654670
constructor (
655671
serviceInfoUrl: string,
656672
serviceCustomizations?: serviceCustomizations,
657673
);
658674
info(forceFetch?: boolean): Promise<ServiceInfo>;
659-
setServiceInfo(serviceInfo: Partial<ServiceInfo>): Promise<void>;
660-
assets(forceFetch?: boolean): Promise<AssetsConfig>;
675+
setServiceInfo(serviceInfo: Partial<ServiceInfo>): void;
676+
assets(forceFetch?: boolean): Promise<ServiceAssets | null>;
661677
infoSync(): ServiceInfo | null;
662678
apiEndpointFor(username: string, token: string): Promise<string>;
663679
login(
@@ -666,6 +682,9 @@ declare module 'pryv' {
666682
appId: string,
667683
originHeader?: string,
668684
): Promise<Connection>;
685+
686+
supportsHF(): Promise<boolean>;
687+
isDnsLess(): Promise<boolean>;
669688
}
670689

671690
export type AuthRequestedPermission = {
@@ -755,12 +774,13 @@ declare module 'pryv' {
755774
};
756775

757776
export type CustomLoginButton = {
758-
init?: () => Promise<void>;
759-
getAuthorizationData(): string;
777+
init?: () => Promise<Service>;
778+
getAuthorizationData(): any;
760779
onStateChange(state: AuthStatePayload): Promise<void>;
761780
onClick(): void;
762-
saveAuthorizationData?: (authData: string) => void;
781+
saveAuthorizationData?: (authData: any) => void;
763782
deleteAuthorizationData?: () => Promise<void>;
783+
finishAuthProcessAfterRedirection?: (authController: AuthController) => Promise<void>;
764784
}
765785

766786
export class AuthController {
@@ -769,16 +789,15 @@ declare module 'pryv' {
769789
service: Service,
770790
loginButton: CustomLoginButton,
771791
);
772-
init(): Promise<void>;
792+
init(): Promise<Service>;
773793
stopAuthRequest(msg: string): void;
774794
handleClick(): Promise<void>;
775795
getReturnURL(
776796
returnURL: string,
777-
windowLocationForTest: string,
778-
navigatorForTests: string,
797+
windowLocationForTest?: string,
798+
navigatorForTests?: string,
779799
): string | boolean;
780800
startAuthRequest(): Promise<any>;
781-
doPolling(): Promise<void>;
782801
set state(newState: AuthStatePayload);
783802
get state(): AuthStatePayload;
784803
}
@@ -805,7 +824,7 @@ declare module 'pryv' {
805824

806825
export type TokenAndAPIEndpoint = {
807826
endpoint: string;
808-
token: string;
827+
token: string | null;
809828
};
810829

811830
export const utils: {
@@ -820,6 +839,32 @@ declare module 'pryv' {
820839
type version = string;
821840

822841
let pryv: {
842+
Service: typeof Service;
843+
Connection: typeof Connection;
844+
Auth: {
845+
setupAuth: SetupAuth;
846+
AuthStates: AuthStates;
847+
AuthController: typeof AuthController;
848+
};
849+
Browser: {
850+
LoginButton: CustomLoginButton;
851+
CookieUtils: {
852+
set(cookieKey: string, value: any, expireInDays: number): void;
853+
get(cookieKey: string): any;
854+
del(cookieKey: string): void;
855+
};
856+
AuthStates: AuthStates;
857+
setupAuth: SetupAuth;
858+
serviceInfoFromUrl: getServiceInfoFromURL;
859+
};
860+
utils: {
861+
isBrowser(): boolean;
862+
extractTokenAndAPIEndpoint(apiEndpoint: string): TokenAndAPIEndpoint;
863+
buildAPIEndpoint(tokenAndAPI: TokenAndAPIEndpoint): string;
864+
browserIsMobileOrTablet(navigator: string): boolean;
865+
cleanURLFromPrYvParams(url: string): string;
866+
getQueryParamsFromURL(url: string): KeyValue;
867+
};
823868
version: version;
824869
};
825870

0 commit comments

Comments
 (0)