import { AppAuthManager } from "@normalized:N&&&authncenter/src/main/ets/components/AppAuthManager&1.1.0";
import type { AppAuthCallback } from "@normalized:N&&&authncenter/src/main/ets/components/AppAuthManager&1.1.0";
import { UTSObject } from "@normalized:N&&&@dcloudio/uni-app-runtime/Index&2.3.15";
class AppAuthOptions extends UTSObject {
    paramA!: boolean;
    success: ((res: string) => void) | null = null;
    fail: ((errCode: number, errMsg: string) => void) | null = null;
    complete: ((res: Object) => void) | null = null;
}
class MyApiOptions extends UTSObject {
    paramA!: boolean;
    success: ((res: string) => void) | null = null;
    fail: ((errCode: number, errMsg: string) => void) | null = null;
    complete: ((res: Object) => void) | null = null;
}
type getAuthorizationIntent = (appId: string, redirectUrl: string, discoveryUrl: string, scheme: string, bundleName: string, options: MyApiOptions) => void;
type endSession = (endSessionEndpoint: string, redirectUrl: string, scheme: string, bundleName: string, options: MyApiOptions) => void;
const TAG: string = "RJ-AppAuthnCenter";
export { AppAuthOptions as AppAuthOptions };
let myApiOptions: MyApiOptions | undefined;
class RJAppAuthCallback implements AppAuthCallback {
    OnSuccess(token: string): void {
        if (myApiOptions && myApiOptions.success) {
            myApiOptions.success(token);
        }
    }
    OnError(code: number, message: string): void {
        console.log("RJAppAuthCallback , error=" + message);
        if (myApiOptions && myApiOptions.fail) {
            myApiOptions.fail(code, message);
        }
    }
}
let appCallback: RJAppAuthCallback = new RJAppAuthCallback();
let appEndSessionCallback: RJAppAuthCallback = new RJAppAuthCallback();
const innerGetAuthorizationIntent: getAuthorizationIntent = (appId: string, redirectUrl: string, discoveryUrl: string, scheme: string, bundleName: string, options: MyApiOptions) => {
    console.log(TAG, "innerGetAuthorizationIntent redirectURl = " + redirectUrl + " discoveryUrl=" + discoveryUrl + ";scheme=" + scheme + ";bundleName" + bundleName);
    myApiOptions = options;
    AppAuthManager.getInstance().getAuthorizationIntentDirectly(appId, redirectUrl, "https://s10sso.ruishan.cc/cas/oidc/authorize", "https://s10sso.ruishan.cc/cas/oidc/accessToken", scheme, bundleName, appCallback);
};
const innerEndSession: endSession = (endSessionEndpoint: string, redirectUrl: string, scheme: string, bundleName: string, options: MyApiOptions) => {
    console.log(TAG, "innerEndSession redirectURl = " + redirectUrl + " endSessionEndpoint=" + endSessionEndpoint + ";scheme=" + scheme + ";bundleName" + bundleName);
    myApiOptions = options;
    AppAuthManager.getInstance().EndSession(endSessionEndpoint, redirectUrl, scheme, bundleName, appEndSessionCallback);
};
export { RJAppAuthCallback as RJAppAuthCallback };
export { innerGetAuthorizationIntent as innerGetAuthorizationIntent };
export { innerEndSession as innerEndSession };
