@logto/js 0.1.16 → 0.2.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/lib/consts/index.d.ts +4 -0
- package/lib/consts/index.js +6 -1
- package/lib/core/fetch-token.d.ts +1 -1
- package/lib/core/index.d.ts +0 -1
- package/lib/core/index.js +0 -1
- package/lib/core/oidc-config.d.ts +0 -1
- package/lib/core/sign-in.d.ts +3 -1
- package/lib/core/sign-in.js +2 -3
- package/lib/utils/id-token.d.ts +10 -2
- package/lib/utils/id-token.js +5 -1
- package/package.json +3 -3
- package/lib/core/user-info.d.ts +0 -9
- package/lib/core/user-info.js +0 -7
package/lib/consts/index.d.ts
CHANGED
package/lib/consts/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryKey = exports.TokenGrantType = exports.ContentType = void 0;
|
|
3
|
+
exports.Prompt = exports.QueryKey = exports.TokenGrantType = exports.ContentType = void 0;
|
|
4
4
|
exports.ContentType = {
|
|
5
5
|
formUrlEncoded: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
6
6
|
};
|
|
@@ -31,3 +31,8 @@ var QueryKey;
|
|
|
31
31
|
QueryKey["State"] = "state";
|
|
32
32
|
QueryKey["Token"] = "token";
|
|
33
33
|
})(QueryKey = exports.QueryKey || (exports.QueryKey = {}));
|
|
34
|
+
var Prompt;
|
|
35
|
+
(function (Prompt) {
|
|
36
|
+
Prompt["Consent"] = "consent";
|
|
37
|
+
Prompt["Login"] = "login";
|
|
38
|
+
})(Prompt = exports.Prompt || (exports.Prompt = {}));
|
package/lib/core/index.d.ts
CHANGED
package/lib/core/index.js
CHANGED
package/lib/core/sign-in.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Prompt } from '../consts';
|
|
1
2
|
export declare type SignInUriParameters = {
|
|
2
3
|
authorizationEndpoint: string;
|
|
3
4
|
clientId: string;
|
|
@@ -6,5 +7,6 @@ export declare type SignInUriParameters = {
|
|
|
6
7
|
state: string;
|
|
7
8
|
scopes?: string[];
|
|
8
9
|
resources?: string[];
|
|
10
|
+
prompt?: Prompt;
|
|
9
11
|
};
|
|
10
|
-
export declare const generateSignInUri: ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes, resources, }: SignInUriParameters) => string;
|
|
12
|
+
export declare const generateSignInUri: ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes, resources, prompt, }: SignInUriParameters) => string;
|
package/lib/core/sign-in.js
CHANGED
|
@@ -4,9 +4,8 @@ exports.generateSignInUri = void 0;
|
|
|
4
4
|
const consts_1 = require("../consts");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const codeChallengeMethod = 'S256';
|
|
7
|
-
const prompt = 'consent';
|
|
8
7
|
const responseType = 'code';
|
|
9
|
-
const generateSignInUri = ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes, resources, }) => {
|
|
8
|
+
const generateSignInUri = ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes, resources, prompt, }) => {
|
|
10
9
|
const urlSearchParameters = new URLSearchParams({
|
|
11
10
|
[consts_1.QueryKey.ClientId]: clientId,
|
|
12
11
|
[consts_1.QueryKey.RedirectUri]: redirectUri,
|
|
@@ -14,7 +13,7 @@ const generateSignInUri = ({ authorizationEndpoint, clientId, redirectUri, codeC
|
|
|
14
13
|
[consts_1.QueryKey.CodeChallengeMethod]: codeChallengeMethod,
|
|
15
14
|
[consts_1.QueryKey.State]: state,
|
|
16
15
|
[consts_1.QueryKey.ResponseType]: responseType,
|
|
17
|
-
[consts_1.QueryKey.Prompt]: prompt,
|
|
16
|
+
[consts_1.QueryKey.Prompt]: prompt ?? consts_1.Prompt.Consent,
|
|
18
17
|
[consts_1.QueryKey.Scope]: (0, utils_1.withReservedScopes)(scopes),
|
|
19
18
|
});
|
|
20
19
|
for (const resource of resources ?? []) {
|
package/lib/utils/id-token.d.ts
CHANGED
|
@@ -9,14 +9,22 @@ declare const IdTokenClaimsSchema: s.Struct<{
|
|
|
9
9
|
aud: string;
|
|
10
10
|
exp: number;
|
|
11
11
|
iat: number;
|
|
12
|
-
at_hash?: string | undefined;
|
|
12
|
+
at_hash?: string | null | undefined;
|
|
13
|
+
name?: string | null | undefined;
|
|
14
|
+
username?: string | null | undefined;
|
|
15
|
+
avatar?: string | null | undefined;
|
|
16
|
+
role_names?: string[] | null | undefined;
|
|
13
17
|
}, {
|
|
14
18
|
iss: s.Struct<string, null>;
|
|
15
19
|
sub: s.Struct<string, null>;
|
|
16
20
|
aud: s.Struct<string, null>;
|
|
17
21
|
exp: s.Struct<number, null>;
|
|
18
22
|
iat: s.Struct<number, null>;
|
|
19
|
-
at_hash: s.Struct<string | undefined, null>;
|
|
23
|
+
at_hash: s.Struct<string | null | undefined, null>;
|
|
24
|
+
name: s.Struct<string | null | undefined, null>;
|
|
25
|
+
username: s.Struct<string | null | undefined, null>;
|
|
26
|
+
avatar: s.Struct<string | null | undefined, null>;
|
|
27
|
+
role_names: s.Struct<string[] | null | undefined, s.Struct<string, null>>;
|
|
20
28
|
}>;
|
|
21
29
|
export declare type IdTokenClaims = s.Infer<typeof IdTokenClaimsSchema>;
|
|
22
30
|
export declare const verifyIdToken: (idToken: string, clientId: string, issuer: string, jwks: JWTVerifyGetKey) => Promise<void>;
|
package/lib/utils/id-token.js
CHANGED
|
@@ -34,7 +34,11 @@ const IdTokenClaimsSchema = s.type({
|
|
|
34
34
|
aud: s.string(),
|
|
35
35
|
exp: s.number(),
|
|
36
36
|
iat: s.number(),
|
|
37
|
-
at_hash: s.optional(s.string()),
|
|
37
|
+
at_hash: s.nullable(s.optional(s.string())),
|
|
38
|
+
name: s.nullable(s.optional(s.string())),
|
|
39
|
+
username: s.nullable(s.optional(s.string())),
|
|
40
|
+
avatar: s.nullable(s.optional(s.string())),
|
|
41
|
+
role_names: s.nullable(s.optional(s.array(s.string()))),
|
|
38
42
|
});
|
|
39
43
|
const verifyIdToken = async (idToken, clientId, issuer, jwks) => {
|
|
40
44
|
const result = await (0, jose_1.jwtVerify)(idToken, jwks, { audience: clientId, issuer });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"exports": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"jose": "^4.3.8",
|
|
29
29
|
"js-base64": "^3.7.2",
|
|
30
30
|
"lodash.get": "^4.4.2",
|
|
31
|
-
"superstruct": "^0.
|
|
31
|
+
"superstruct": "^0.16.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@jest/types": "^27.5.1",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "5166ae926de86816f29229f18bc756f3b17fb57b"
|
|
61
61
|
}
|
package/lib/core/user-info.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Requester } from '../utils';
|
|
2
|
-
export declare type UserInfoResponse = {
|
|
3
|
-
sub: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
username?: string;
|
|
6
|
-
avatar?: string;
|
|
7
|
-
role_names?: string[];
|
|
8
|
-
};
|
|
9
|
-
export declare const fetchUserInfo: (userInfoEndpoint: string, accessToken: string, requester: Requester) => Promise<UserInfoResponse>;
|
package/lib/core/user-info.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchUserInfo = void 0;
|
|
4
|
-
const fetchUserInfo = async (userInfoEndpoint, accessToken, requester) => requester(userInfoEndpoint, {
|
|
5
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
6
|
-
});
|
|
7
|
-
exports.fetchUserInfo = fetchUserInfo;
|