@hxa-rn/rnaa 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +159 -0
- package/harmony/rnaa/LICENSE +21 -0
- package/harmony/rnaa/NOTICE +33 -0
- package/harmony/rnaa/OAT.xml +38 -0
- package/harmony/rnaa/build-profile.json5 +19 -0
- package/harmony/rnaa/hvigorfile.ts +2 -0
- package/harmony/rnaa/index.ets +1 -0
- package/harmony/rnaa/oh-package.json5 +14 -0
- package/harmony/rnaa/src/main/cpp/CMakeLists.txt +15 -0
- package/harmony/rnaa/src/main/cpp/RNAppAuthPackage.h +13 -0
- package/harmony/rnaa/src/main/cpp/generated/RNOH/generated/BaseRnaaPackage.h +72 -0
- package/harmony/rnaa/src/main/cpp/generated/RNOH/generated/turbo_modules/RNAppAuth.cpp +22 -0
- package/harmony/rnaa/src/main/cpp/generated/RNOH/generated/turbo_modules/RNAppAuth.h +16 -0
- package/harmony/rnaa/src/main/ets/DateUtil.ets +28 -0
- package/harmony/rnaa/src/main/ets/OAuthHttpClient.ets +293 -0
- package/harmony/rnaa/src/main/ets/OAuthProtocol.ets +293 -0
- package/harmony/rnaa/src/main/ets/PKCE.ets +105 -0
- package/harmony/rnaa/src/main/ets/RNAppAuthTurboModule.ets +713 -0
- package/harmony/rnaa/src/main/ets/RNAppAuthTurboModulesFactory.ets +18 -0
- package/harmony/rnaa/src/main/ets/Types.ets +98 -0
- package/harmony/rnaa/src/main/ets/generated/index.ets +5 -0
- package/harmony/rnaa/src/main/ets/generated/ts.ts +5 -0
- package/harmony/rnaa/src/main/ets/generated/turboModules/RNAppAuth.ts +38 -0
- package/harmony/rnaa/src/main/ets/generated/turboModules/ts.ts +5 -0
- package/harmony/rnaa/src/main/module.json5 +16 -0
- package/harmony/rnaa/src/main/resources/base/element/string.json +8 -0
- package/harmony/rnaa/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/rnaa/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/rnaa.har +0 -0
- package/package.json +69 -0
- package/src/index.d.ts +202 -0
- package/src/index.js +596 -0
- package/src/specs/v1/.gitkeep +1 -0
- package/src/specs/v1/NativeRNAppAuth.ts +138 -0
- package/src/specs/v2/.gitkeep +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RNOHPackage } from '@rnoh/react-native-openharmony/ets';
|
|
2
|
+
import type { UITurboModule, UITurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
3
|
+
import { RNAppAuthTurboModule } from './RNAppAuthTurboModule';
|
|
4
|
+
import { TM } from './generated/ts';
|
|
5
|
+
|
|
6
|
+
export class RNAppAuthPackage extends RNOHPackage {
|
|
7
|
+
getUITurboModuleFactoryByNameMap(): Map<string, (ctx: UITurboModuleContext) => UITurboModule | null> {
|
|
8
|
+
const map = new Map<string, (ctx: UITurboModuleContext) => UITurboModule | null>();
|
|
9
|
+
map.set(TM.RNAppAuth.NAME, (ctx: UITurboModuleContext) => new RNAppAuthTurboModule(ctx));
|
|
10
|
+
return map;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override async createEagerUITurboModuleByNameMap(ctx: UITurboModuleContext): Promise<Map<string, UITurboModule>> {
|
|
14
|
+
const module = new RNAppAuthTurboModule(ctx);
|
|
15
|
+
return new Map()
|
|
16
|
+
.set(TM.RNAppAuth.NAME, module)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal shared types for the RNAppAuth OAuth protocol stack (HarmonyOS).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Structured OAuth error surfaced to the JS layer.
|
|
7
|
+
* Mirrors the AppAuthError contract (code + message) from index.d.ts.
|
|
8
|
+
*
|
|
9
|
+
* Extends Error so `throw new OAuthError(...)` satisfies the ArkTS
|
|
10
|
+
* arkts-limited-throw rule (only Error or subclasses may be thrown).
|
|
11
|
+
*/
|
|
12
|
+
export class OAuthError extends Error {
|
|
13
|
+
public code: string = '';
|
|
14
|
+
|
|
15
|
+
constructor(code: string, message: string) {
|
|
16
|
+
// RNOH TurboModule only forwards Error.message to JS; embed code so the
|
|
17
|
+
// JS layer can reconstruct AppAuthError { code, message } (Android uses
|
|
18
|
+
// promise.reject(code, message) for the same contract).
|
|
19
|
+
super(`${code}::${message}`);
|
|
20
|
+
this.code = code;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A Promise whose resolve/reject can be invoked later by handleRedirect().
|
|
26
|
+
* Used to bridge the pending authorize/logout flow across the browser
|
|
27
|
+
* redirect boundary.
|
|
28
|
+
*/
|
|
29
|
+
export class Deferred<T> {
|
|
30
|
+
public promise: Promise<T>;
|
|
31
|
+
private resolveFn: (value: T) => void = (_value: T) => {
|
|
32
|
+
};
|
|
33
|
+
private rejectFn: (reason?: Object) => void = (_reason?: Object) => {
|
|
34
|
+
};
|
|
35
|
+
private settled: boolean = false;
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
this.promise = new Promise<T>((resolve: (value: T | PromiseLike<T>) => void,
|
|
39
|
+
reject: (reason?: Object) => void) => {
|
|
40
|
+
this.resolveFn = resolve as (value: T) => void;
|
|
41
|
+
this.rejectFn = reject;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
resolve(value: T | PromiseLike<T>): void {
|
|
46
|
+
if (!this.settled) {
|
|
47
|
+
this.settled = true;
|
|
48
|
+
this.resolveFn(value as T);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
reject(reason?: Object): void {
|
|
53
|
+
if (!this.settled) {
|
|
54
|
+
this.settled = true;
|
|
55
|
+
this.rejectFn(reason);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Raw token endpoint response (JSON fields from RFC 6749 / OIDC).
|
|
62
|
+
*/
|
|
63
|
+
export interface TokenResponse {
|
|
64
|
+
accessToken: string;
|
|
65
|
+
accessTokenExpirationDate: string;
|
|
66
|
+
additionalParameters: Record<string, string>;
|
|
67
|
+
idToken: string;
|
|
68
|
+
refreshToken: string;
|
|
69
|
+
tokenType: string;
|
|
70
|
+
scope: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Raw authorization response parsed from the redirect callback URL.
|
|
75
|
+
*/
|
|
76
|
+
export interface AuthorizationResponse {
|
|
77
|
+
state: string;
|
|
78
|
+
authorizationCode: string;
|
|
79
|
+
error: string;
|
|
80
|
+
errorDescription: string;
|
|
81
|
+
scope: string;
|
|
82
|
+
idToken: string;
|
|
83
|
+
accessToken: string;
|
|
84
|
+
tokenType: string;
|
|
85
|
+
accessTokenExpirationTime: number;
|
|
86
|
+
additionalParameters: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Parsed OpenID Connect discovery document fields.
|
|
91
|
+
*/
|
|
92
|
+
export interface DiscoveryDocument {
|
|
93
|
+
authorizationEndpoint: string;
|
|
94
|
+
tokenEndpoint: string;
|
|
95
|
+
registrationEndpoint: string;
|
|
96
|
+
revocationEndpoint: string;
|
|
97
|
+
endSessionEndpoint: string;
|
|
98
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
6
|
+
|
|
7
|
+
export namespace RNAppAuth {
|
|
8
|
+
export const NAME = 'RNAppAuth' as const
|
|
9
|
+
|
|
10
|
+
export type AuthorizeResult = {accessToken: string, accessTokenExpirationDate: string, authorizeAdditionalParameters?: Object, tokenAdditionalParameters?: Object, idToken: string, refreshToken: string, tokenType: string, scopes: string[], authorizationCode: string, codeVerifier?: string}
|
|
11
|
+
|
|
12
|
+
export type CustomHeaders = {token?: Object, authorize?: Object, register?: Object}
|
|
13
|
+
|
|
14
|
+
export type EndSessionResult = {idTokenHint: string, postLogoutRedirectUri: string, state: string}
|
|
15
|
+
|
|
16
|
+
export type RefreshResult = {accessToken: string, accessTokenExpirationDate: string, additionalParameters?: Object, idToken: string, refreshToken: null | string, tokenType: string}
|
|
17
|
+
|
|
18
|
+
export type RegistrationResponse = {clientId: string, additionalParameters?: Object, clientIdIssuedAt?: string, clientSecret?: string, clientSecretExpiresAt?: string, registrationAccessToken?: string, registrationClientUri?: string, tokenEndpointAuthMethod?: string}
|
|
19
|
+
|
|
20
|
+
export type ServiceConfiguration = {authorizationEndpoint?: string, tokenEndpoint?: string, revocationEndpoint?: string, registrationEndpoint?: string, endSessionEndpoint?: string}
|
|
21
|
+
|
|
22
|
+
export interface Spec {
|
|
23
|
+
prefetchConfiguration(warmAndPrefetchChrome: boolean, issuer: string, redirectUrl: string, clientId: string, scopes: string[], serviceConfiguration: ServiceConfiguration, dangerouslyAllowInsecureHttpRequests: boolean, customHeaders: CustomHeaders, connectionTimeoutMillis: number): Promise<void>;
|
|
24
|
+
|
|
25
|
+
register(issuer: string, redirectUrls: string[], responseTypes: string[], grantTypes: string[], subjectType: string, tokenEndpointAuthMethod: string, additionalParameters: Object, serviceConfiguration: ServiceConfiguration, connectionTimeoutMillis: number, dangerouslyAllowInsecureHttpRequests: boolean, customHeaders: CustomHeaders): Promise<RegistrationResponse>;
|
|
26
|
+
|
|
27
|
+
authorize(issuer: string, redirectUrl: string, clientId: string, clientSecret: string, scopes: string[], additionalParameters: Object, serviceConfiguration: ServiceConfiguration, skipCodeExchange: boolean, connectionTimeoutMillis: number, useNonce: boolean, usePKCE: boolean, clientAuthMethod: string, dangerouslyAllowInsecureHttpRequests: boolean, customHeaders: CustomHeaders): Promise<AuthorizeResult>;
|
|
28
|
+
|
|
29
|
+
refresh(issuer: string, redirectUrl: string, clientId: string, clientSecret: string, refreshToken: string, scopes: string[], additionalParameters: Object, serviceConfiguration: ServiceConfiguration, connectionTimeoutMillis: number, clientAuthMethod: string, dangerouslyAllowInsecureHttpRequests: boolean, customHeaders: CustomHeaders): Promise<RefreshResult>;
|
|
30
|
+
|
|
31
|
+
logout(issuer: string, idTokenHint: string, postLogoutRedirectUri: string, serviceConfiguration: ServiceConfiguration, additionalParameters: Object, dangerouslyAllowInsecureHttpRequests: boolean): Promise<EndSessionResult>;
|
|
32
|
+
|
|
33
|
+
handleRedirect(url: string): Promise<boolean>;
|
|
34
|
+
|
|
35
|
+
cancelPendingFlow(): Promise<boolean>;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
}
|
package/harmony/rnaa.har
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hxa-rn/rnaa",
|
|
3
|
+
"displayName": "react-native-app-auth",
|
|
4
|
+
"version": "8.1.0",
|
|
5
|
+
"description": "React Native bridge for AppAuth for supporting any OAuth 2 provider",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"module": "./src/index.js",
|
|
8
|
+
"react-native": "./src/index.js",
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"private": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/FormidableLabs/react-native-app-auth.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"harmony",
|
|
19
|
+
"harmonyos",
|
|
20
|
+
"auth",
|
|
21
|
+
"oauth",
|
|
22
|
+
"oauth2",
|
|
23
|
+
"appauth"
|
|
24
|
+
],
|
|
25
|
+
"homepage": "https://github.com/FormidableLabs/react-native-app-auth",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/",
|
|
31
|
+
"src/",
|
|
32
|
+
"harmony/",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name rnaa --cpp-output-path ./harmony/rnaa/src/main/cpp/generated --ets-output-path ./harmony/rnaa/src/main/ets/generated --turbo-modules-spec-paths ./src/specs/v1/NativeRNAppAuth.ts"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react-native": ">=0.72"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"invariant": "2.2.4",
|
|
44
|
+
"react-native-base64": "0.0.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"typescript": "5.0.4",
|
|
48
|
+
"@react-native/typescript-config": "0.79.5",
|
|
49
|
+
"react": "18.2.0",
|
|
50
|
+
"@types/react": "18.2.79",
|
|
51
|
+
"react-native": "0.72.5",
|
|
52
|
+
"jest": "^29.6.3",
|
|
53
|
+
"react-native-builder-bob": "^0.18.0",
|
|
54
|
+
"@react-native-oh/react-native-harmony-cli": "^0.77.50",
|
|
55
|
+
"metro": "^0.81.0"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=18"
|
|
59
|
+
},
|
|
60
|
+
"harmony": {
|
|
61
|
+
"alias": "react-native-app-auth",
|
|
62
|
+
"autolinking": {
|
|
63
|
+
"cmakeLibraryTargetName": "rnaa",
|
|
64
|
+
"ohPackageName": "@hxa-rn/rnaa",
|
|
65
|
+
"etsPackageClassName": "RNAppAuthPackage",
|
|
66
|
+
"cppPackageClassName": "RNAppAuthPackage"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
export interface ServiceConfiguration {
|
|
2
|
+
authorizationEndpoint: string;
|
|
3
|
+
tokenEndpoint: string;
|
|
4
|
+
revocationEndpoint?: string;
|
|
5
|
+
registrationEndpoint?: string;
|
|
6
|
+
endSessionEndpoint?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type BaseConfiguration =
|
|
10
|
+
| {
|
|
11
|
+
issuer?: string;
|
|
12
|
+
serviceConfiguration: ServiceConfiguration;
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
issuer: string;
|
|
16
|
+
serviceConfiguration?: ServiceConfiguration;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type CustomHeaders = {
|
|
20
|
+
authorize?: Record<string, string>;
|
|
21
|
+
token?: Record<string, string>;
|
|
22
|
+
register?: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type AdditionalHeaders = Record<string, string>;
|
|
26
|
+
|
|
27
|
+
interface BuiltInRegistrationParameters {
|
|
28
|
+
client_name?: string;
|
|
29
|
+
logo_uri?: string;
|
|
30
|
+
client_uri?: string;
|
|
31
|
+
policy_uri?: string;
|
|
32
|
+
tos_uri?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type RegistrationConfiguration = BaseConfiguration & {
|
|
36
|
+
redirectUrls: string[];
|
|
37
|
+
responseTypes?: string[];
|
|
38
|
+
grantTypes?: string[];
|
|
39
|
+
subjectType?: string;
|
|
40
|
+
tokenEndpointAuthMethod?: string;
|
|
41
|
+
additionalParameters?: BuiltInRegistrationParameters & { [name: string]: string };
|
|
42
|
+
dangerouslyAllowInsecureHttpRequests?: boolean;
|
|
43
|
+
customHeaders?: CustomHeaders;
|
|
44
|
+
additionalHeaders?: AdditionalHeaders;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export interface RegistrationResponse {
|
|
48
|
+
clientId: string;
|
|
49
|
+
additionalParameters?: { [name: string]: string };
|
|
50
|
+
clientIdIssuedAt?: string;
|
|
51
|
+
clientSecret?: string;
|
|
52
|
+
clientSecretExpiresAt?: string;
|
|
53
|
+
registrationAccessToken?: string;
|
|
54
|
+
registrationClientUri?: string;
|
|
55
|
+
tokenEndpointAuthMethod?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface BuiltInParameters {
|
|
59
|
+
display?: 'page' | 'popup' | 'touch' | 'wap';
|
|
60
|
+
login_prompt?: string;
|
|
61
|
+
prompt?: 'consent' | 'login' | 'none' | 'select_account';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type BaseAuthConfiguration = BaseConfiguration & {
|
|
65
|
+
clientId: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type AuthConfiguration = BaseAuthConfiguration & {
|
|
69
|
+
clientSecret?: string;
|
|
70
|
+
scopes: string[];
|
|
71
|
+
redirectUrl: string;
|
|
72
|
+
additionalParameters?: BuiltInParameters & { [name: string]: string };
|
|
73
|
+
clientAuthMethod?: 'basic' | 'post';
|
|
74
|
+
dangerouslyAllowInsecureHttpRequests?: boolean;
|
|
75
|
+
customHeaders?: CustomHeaders;
|
|
76
|
+
additionalHeaders?: AdditionalHeaders;
|
|
77
|
+
connectionTimeoutSeconds?: number;
|
|
78
|
+
useNonce?: boolean;
|
|
79
|
+
usePKCE?: boolean;
|
|
80
|
+
warmAndPrefetchChrome?: boolean;
|
|
81
|
+
skipCodeExchange?: boolean;
|
|
82
|
+
iosCustomBrowser?: 'safari' | 'chrome' | 'opera' | 'firefox';
|
|
83
|
+
androidAllowCustomBrowsers?: (
|
|
84
|
+
| 'chrome'
|
|
85
|
+
| 'chromeCustomTab'
|
|
86
|
+
| 'firefox'
|
|
87
|
+
| 'firefoxCustomTab'
|
|
88
|
+
| 'samsung'
|
|
89
|
+
| 'samsungCustomTab'
|
|
90
|
+
)[];
|
|
91
|
+
androidTrustedWebActivity?: boolean;
|
|
92
|
+
iosPrefersEphemeralSession?: boolean;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type EndSessionConfiguration = BaseAuthConfiguration & {
|
|
96
|
+
additionalParameters?: { [name: string]: string };
|
|
97
|
+
dangerouslyAllowInsecureHttpRequests?: boolean;
|
|
98
|
+
iosPrefersEphemeralSession?: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export interface AuthorizeResult {
|
|
102
|
+
accessToken: string;
|
|
103
|
+
accessTokenExpirationDate: string;
|
|
104
|
+
authorizeAdditionalParameters?: { [name: string]: string };
|
|
105
|
+
tokenAdditionalParameters?: { [name: string]: string };
|
|
106
|
+
idToken: string;
|
|
107
|
+
refreshToken: string;
|
|
108
|
+
tokenType: string;
|
|
109
|
+
scopes: string[];
|
|
110
|
+
authorizationCode: string;
|
|
111
|
+
codeVerifier?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface RefreshResult {
|
|
115
|
+
accessToken: string;
|
|
116
|
+
accessTokenExpirationDate: string;
|
|
117
|
+
additionalParameters?: { [name: string]: string };
|
|
118
|
+
idToken: string;
|
|
119
|
+
refreshToken: string | null;
|
|
120
|
+
tokenType: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface RevokeConfiguration {
|
|
124
|
+
tokenToRevoke: string;
|
|
125
|
+
sendClientId?: boolean;
|
|
126
|
+
includeBasicAuth?: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface RefreshConfiguration {
|
|
130
|
+
refreshToken: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface LogoutConfiguration {
|
|
134
|
+
idToken: string;
|
|
135
|
+
postLogoutRedirectUrl: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface EndSessionResult {
|
|
139
|
+
idTokenHint: string;
|
|
140
|
+
postLogoutRedirectUri: string;
|
|
141
|
+
state: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function prefetchConfiguration(config: AuthConfiguration): Promise<void>;
|
|
145
|
+
|
|
146
|
+
export function register(config: RegistrationConfiguration): Promise<RegistrationResponse>;
|
|
147
|
+
|
|
148
|
+
export function authorize(config: AuthConfiguration): Promise<AuthorizeResult>;
|
|
149
|
+
|
|
150
|
+
export function refresh(
|
|
151
|
+
config: AuthConfiguration,
|
|
152
|
+
refreshConfig: RefreshConfiguration
|
|
153
|
+
): Promise<RefreshResult>;
|
|
154
|
+
|
|
155
|
+
export function revoke(
|
|
156
|
+
config: BaseAuthConfiguration,
|
|
157
|
+
revokeConfig: RevokeConfiguration
|
|
158
|
+
): Promise<void>;
|
|
159
|
+
|
|
160
|
+
export function logout(
|
|
161
|
+
config: EndSessionConfiguration,
|
|
162
|
+
logoutConfig: LogoutConfiguration
|
|
163
|
+
): Promise<EndSessionResult>;
|
|
164
|
+
|
|
165
|
+
// https://tools.ietf.org/html/rfc6749#section-4.1.2.1
|
|
166
|
+
type OAuthAuthorizationErrorCode =
|
|
167
|
+
| 'unauthorized_client'
|
|
168
|
+
| 'access_denied'
|
|
169
|
+
| 'unsupported_response_type'
|
|
170
|
+
| 'invalid_scope'
|
|
171
|
+
| 'server_error'
|
|
172
|
+
| 'temporarily_unavailable';
|
|
173
|
+
// https://tools.ietf.org/html/rfc6749#section-5.2
|
|
174
|
+
type OAuthTokenErrorCode =
|
|
175
|
+
| 'invalid_request'
|
|
176
|
+
| 'invalid_client'
|
|
177
|
+
| 'invalid_grant'
|
|
178
|
+
| 'unauthorized_client'
|
|
179
|
+
| 'unsupported_grant_type'
|
|
180
|
+
| 'invalid_scope';
|
|
181
|
+
// https://openid.net/specs/openid-connect-registration-1_0.html#RegistrationError
|
|
182
|
+
type OICRegistrationErrorCode = 'invalid_redirect_uri' | 'invalid_client_metadata';
|
|
183
|
+
type AppAuthErrorCode =
|
|
184
|
+
| 'service_configuration_fetch_error'
|
|
185
|
+
| 'authentication_failed'
|
|
186
|
+
| 'token_refresh_failed'
|
|
187
|
+
| 'token_exchange_failed'
|
|
188
|
+
| 'registration_failed'
|
|
189
|
+
| 'end_session_failed'
|
|
190
|
+
| 'authentication_error'
|
|
191
|
+
| 'run_time_exception'
|
|
192
|
+
| 'configuration_error';
|
|
193
|
+
|
|
194
|
+
type ErrorCode =
|
|
195
|
+
| OAuthAuthorizationErrorCode
|
|
196
|
+
| OAuthTokenErrorCode
|
|
197
|
+
| OICRegistrationErrorCode
|
|
198
|
+
| AppAuthErrorCode;
|
|
199
|
+
|
|
200
|
+
export interface AppAuthError extends Error {
|
|
201
|
+
code: ErrorCode;
|
|
202
|
+
}
|