@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.
@@ -28,3 +28,7 @@ export declare enum QueryKey {
28
28
  State = "state",
29
29
  Token = "token"
30
30
  }
31
+ export declare enum Prompt {
32
+ Consent = "consent",
33
+ Login = "login"
34
+ }
@@ -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 = {}));
@@ -17,7 +17,7 @@ export declare type FetchTokenByRefreshTokenParameters = {
17
17
  };
18
18
  declare type SnakeCaseCodeTokenResponse = {
19
19
  access_token: string;
20
- refresh_token: string;
20
+ refresh_token?: string;
21
21
  id_token: string;
22
22
  scope: string;
23
23
  expires_in: number;
@@ -3,4 +3,3 @@ export * from './oidc-config';
3
3
  export * from './revoke';
4
4
  export * from './sign-in';
5
5
  export * from './sign-out';
6
- export * from './user-info';
package/lib/core/index.js CHANGED
@@ -15,4 +15,3 @@ __exportStar(require("./oidc-config"), exports);
15
15
  __exportStar(require("./revoke"), exports);
16
16
  __exportStar(require("./sign-in"), exports);
17
17
  __exportStar(require("./sign-out"), exports);
18
- __exportStar(require("./user-info"), exports);
@@ -3,7 +3,6 @@ import { Requester } from '../utils';
3
3
  declare type OidcConfigSnakeCaseResponse = {
4
4
  authorization_endpoint: string;
5
5
  token_endpoint: string;
6
- userinfo_endpoint: string;
7
6
  end_session_endpoint: string;
8
7
  revocation_endpoint: string;
9
8
  jwks_uri: string;
@@ -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;
@@ -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 ?? []) {
@@ -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>;
@@ -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.1.16",
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.15.3"
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": "b56e794cea7ba791c73cd2da6e4ea405223d6970"
60
+ "gitHead": "5166ae926de86816f29229f18bc756f3b17fb57b"
61
61
  }
@@ -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>;
@@ -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;