@scalekit-sdk/node 1.0.2 → 1.0.4

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.
Files changed (64) hide show
  1. package/.github/dependabot.yml +10 -0
  2. package/README.md +82 -12
  3. package/lib/connect.js +5 -4
  4. package/lib/connect.js.map +1 -1
  5. package/lib/connection.d.ts +17 -3
  6. package/lib/connection.js +36 -2
  7. package/lib/connection.js.map +1 -1
  8. package/lib/constants/user.d.ts +1 -1
  9. package/lib/core.d.ts +9 -5
  10. package/lib/core.js +27 -23
  11. package/lib/core.js.map +1 -1
  12. package/lib/domain.d.ts +1 -12
  13. package/lib/domain.js +0 -19
  14. package/lib/domain.js.map +1 -1
  15. package/lib/index.d.ts +4 -4
  16. package/lib/index.js +3 -3
  17. package/lib/index.js.map +1 -1
  18. package/lib/organization.d.ts +26 -8
  19. package/lib/organization.js +50 -14
  20. package/lib/organization.js.map +1 -1
  21. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +1 -1
  22. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +3 -3
  23. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +2 -2
  24. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
  25. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +19 -55
  26. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +26 -63
  27. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
  28. package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +1 -1
  29. package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +1 -1
  30. package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +1 -1
  31. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +15 -19
  32. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +14 -18
  33. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js.map +1 -1
  34. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +58 -24
  35. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +94 -32
  36. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -1
  37. package/lib/scalekit.d.ts +11 -14
  38. package/lib/scalekit.js +17 -14
  39. package/lib/scalekit.js.map +1 -1
  40. package/lib/types/{user.d.ts → auth.d.ts} +5 -0
  41. package/lib/types/{user.js → auth.js} +1 -1
  42. package/lib/types/auth.js.map +1 -0
  43. package/lib/types/scalekit.d.ts +9 -9
  44. package/lib/types/scalekit.js.map +1 -1
  45. package/package.json +1 -1
  46. package/src/connect.ts +5 -5
  47. package/src/connection.ts +41 -3
  48. package/src/constants/user.ts +1 -1
  49. package/src/core.ts +32 -25
  50. package/src/domain.ts +0 -21
  51. package/src/index.ts +4 -4
  52. package/src/organization.ts +59 -12
  53. package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +1 -1
  54. package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +3 -3
  55. package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +33 -89
  56. package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +1 -1
  57. package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +1 -1
  58. package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +1 -1
  59. package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +15 -19
  60. package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +117 -43
  61. package/src/scalekit.ts +26 -17
  62. package/src/types/{user.ts → auth.ts} +6 -0
  63. package/src/types/scalekit.ts +11 -11
  64. package/lib/types/user.js.map +0 -1
@@ -1,4 +1,4 @@
1
- // @generated by protoc-gen-es v1.8.0 with parameter "target=ts"
1
+ // @generated by protoc-gen-es v1.9.0 with parameter "target=ts"
2
2
  // @generated from file scalekit/v1/organizations/organizations.proto (package scalekit.v1.organizations, syntax proto3)
3
3
  /* eslint-disable */
4
4
  // @ts-nocheck
@@ -95,7 +95,7 @@ export class CreateOrganization extends Message<CreateOrganization> {
95
95
  displayName = "";
96
96
 
97
97
  /**
98
- * Optional regioncode
98
+ * Optional regioncode
99
99
  *
100
100
  * @generated from field: scalekit.v1.commons.RegionCode region_code = 5;
101
101
  */
@@ -109,7 +109,7 @@ export class CreateOrganization extends Message<CreateOrganization> {
109
109
  externalId?: string;
110
110
 
111
111
  /**
112
- * Key value pairs extension attributes.
112
+ * Key value pairs extension attributes.
113
113
  *
114
114
  * @generated from field: map<string, string> metadata = 7;
115
115
  */
@@ -151,14 +151,14 @@ export class CreateOrganization extends Message<CreateOrganization> {
151
151
  */
152
152
  export class Organization extends Message<Organization> {
153
153
  /**
154
- * Id
154
+ * Id
155
155
  *
156
156
  * @generated from field: string id = 1;
157
157
  */
158
158
  id = "";
159
159
 
160
160
  /**
161
- * Created Time
161
+ * Created Time
162
162
  *
163
163
  * @generated from field: google.protobuf.Timestamp create_time = 2;
164
164
  */
@@ -179,7 +179,7 @@ export class Organization extends Message<Organization> {
179
179
  displayName = "";
180
180
 
181
181
  /**
182
- * Optional regioncode
182
+ * Optional regioncode
183
183
  *
184
184
  * @generated from field: scalekit.v1.commons.RegionCode region_code = 5;
185
185
  */
@@ -193,7 +193,7 @@ export class Organization extends Message<Organization> {
193
193
  externalId?: string;
194
194
 
195
195
  /**
196
- * Key value pairs extension attributes.
196
+ * Key value pairs extension attributes.
197
197
  *
198
198
  * @generated from field: map<string, string> metadata = 7;
199
199
  */
@@ -613,39 +613,113 @@ export class DeleteOrganizationRequest extends Message<DeleteOrganizationRequest
613
613
  }
614
614
 
615
615
  /**
616
- * @generated from message scalekit.v1.organizations.CustomerPortalLinkRequest
616
+ * @generated from message scalekit.v1.organizations.GeneratePortalLinkRequest
617
617
  */
618
- export class CustomerPortalLinkRequest extends Message<CustomerPortalLinkRequest> {
618
+ export class GeneratePortalLinkRequest extends Message<GeneratePortalLinkRequest> {
619
619
  /**
620
620
  * @generated from field: string id = 1;
621
621
  */
622
622
  id = "";
623
623
 
624
- constructor(data?: PartialMessage<CustomerPortalLinkRequest>) {
624
+ constructor(data?: PartialMessage<GeneratePortalLinkRequest>) {
625
625
  super();
626
626
  proto3.util.initPartial(data, this);
627
627
  }
628
628
 
629
629
  static readonly runtime: typeof proto3 = proto3;
630
- static readonly typeName = "scalekit.v1.organizations.CustomerPortalLinkRequest";
630
+ static readonly typeName = "scalekit.v1.organizations.GeneratePortalLinkRequest";
631
631
  static readonly fields: FieldList = proto3.util.newFieldList(() => [
632
632
  { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
633
633
  ]);
634
634
 
635
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CustomerPortalLinkRequest {
636
- return new CustomerPortalLinkRequest().fromBinary(bytes, options);
635
+ static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GeneratePortalLinkRequest {
636
+ return new GeneratePortalLinkRequest().fromBinary(bytes, options);
637
637
  }
638
638
 
639
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CustomerPortalLinkRequest {
640
- return new CustomerPortalLinkRequest().fromJson(jsonValue, options);
639
+ static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GeneratePortalLinkRequest {
640
+ return new GeneratePortalLinkRequest().fromJson(jsonValue, options);
641
641
  }
642
642
 
643
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CustomerPortalLinkRequest {
644
- return new CustomerPortalLinkRequest().fromJsonString(jsonString, options);
643
+ static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GeneratePortalLinkRequest {
644
+ return new GeneratePortalLinkRequest().fromJsonString(jsonString, options);
645
645
  }
646
646
 
647
- static equals(a: CustomerPortalLinkRequest | PlainMessage<CustomerPortalLinkRequest> | undefined, b: CustomerPortalLinkRequest | PlainMessage<CustomerPortalLinkRequest> | undefined): boolean {
648
- return proto3.util.equals(CustomerPortalLinkRequest, a, b);
647
+ static equals(a: GeneratePortalLinkRequest | PlainMessage<GeneratePortalLinkRequest> | undefined, b: GeneratePortalLinkRequest | PlainMessage<GeneratePortalLinkRequest> | undefined): boolean {
648
+ return proto3.util.equals(GeneratePortalLinkRequest, a, b);
649
+ }
650
+ }
651
+
652
+ /**
653
+ * @generated from message scalekit.v1.organizations.GetPortalLinkRequest
654
+ */
655
+ export class GetPortalLinkRequest extends Message<GetPortalLinkRequest> {
656
+ /**
657
+ * @generated from field: string id = 1;
658
+ */
659
+ id = "";
660
+
661
+ constructor(data?: PartialMessage<GetPortalLinkRequest>) {
662
+ super();
663
+ proto3.util.initPartial(data, this);
664
+ }
665
+
666
+ static readonly runtime: typeof proto3 = proto3;
667
+ static readonly typeName = "scalekit.v1.organizations.GetPortalLinkRequest";
668
+ static readonly fields: FieldList = proto3.util.newFieldList(() => [
669
+ { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
670
+ ]);
671
+
672
+ static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetPortalLinkRequest {
673
+ return new GetPortalLinkRequest().fromBinary(bytes, options);
674
+ }
675
+
676
+ static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetPortalLinkRequest {
677
+ return new GetPortalLinkRequest().fromJson(jsonValue, options);
678
+ }
679
+
680
+ static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetPortalLinkRequest {
681
+ return new GetPortalLinkRequest().fromJsonString(jsonString, options);
682
+ }
683
+
684
+ static equals(a: GetPortalLinkRequest | PlainMessage<GetPortalLinkRequest> | undefined, b: GetPortalLinkRequest | PlainMessage<GetPortalLinkRequest> | undefined): boolean {
685
+ return proto3.util.equals(GetPortalLinkRequest, a, b);
686
+ }
687
+ }
688
+
689
+ /**
690
+ * @generated from message scalekit.v1.organizations.DeletePortalLinkRequest
691
+ */
692
+ export class DeletePortalLinkRequest extends Message<DeletePortalLinkRequest> {
693
+ /**
694
+ * @generated from field: string id = 1;
695
+ */
696
+ id = "";
697
+
698
+ constructor(data?: PartialMessage<DeletePortalLinkRequest>) {
699
+ super();
700
+ proto3.util.initPartial(data, this);
701
+ }
702
+
703
+ static readonly runtime: typeof proto3 = proto3;
704
+ static readonly typeName = "scalekit.v1.organizations.DeletePortalLinkRequest";
705
+ static readonly fields: FieldList = proto3.util.newFieldList(() => [
706
+ { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
707
+ ]);
708
+
709
+ static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DeletePortalLinkRequest {
710
+ return new DeletePortalLinkRequest().fromBinary(bytes, options);
711
+ }
712
+
713
+ static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DeletePortalLinkRequest {
714
+ return new DeletePortalLinkRequest().fromJson(jsonValue, options);
715
+ }
716
+
717
+ static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DeletePortalLinkRequest {
718
+ return new DeletePortalLinkRequest().fromJsonString(jsonString, options);
719
+ }
720
+
721
+ static equals(a: DeletePortalLinkRequest | PlainMessage<DeletePortalLinkRequest> | undefined, b: DeletePortalLinkRequest | PlainMessage<DeletePortalLinkRequest> | undefined): boolean {
722
+ return proto3.util.equals(DeletePortalLinkRequest, a, b);
649
723
  }
650
724
  }
651
725
 
@@ -699,76 +773,76 @@ export class Link extends Message<Link> {
699
773
  }
700
774
 
701
775
  /**
702
- * @generated from message scalekit.v1.organizations.GenerateCustomerPortalLinkResponse
776
+ * @generated from message scalekit.v1.organizations.GeneratePortalLinkResponse
703
777
  */
704
- export class GenerateCustomerPortalLinkResponse extends Message<GenerateCustomerPortalLinkResponse> {
778
+ export class GeneratePortalLinkResponse extends Message<GeneratePortalLinkResponse> {
705
779
  /**
706
780
  * @generated from field: scalekit.v1.organizations.Link link = 1;
707
781
  */
708
782
  link?: Link;
709
783
 
710
- constructor(data?: PartialMessage<GenerateCustomerPortalLinkResponse>) {
784
+ constructor(data?: PartialMessage<GeneratePortalLinkResponse>) {
711
785
  super();
712
786
  proto3.util.initPartial(data, this);
713
787
  }
714
788
 
715
789
  static readonly runtime: typeof proto3 = proto3;
716
- static readonly typeName = "scalekit.v1.organizations.GenerateCustomerPortalLinkResponse";
790
+ static readonly typeName = "scalekit.v1.organizations.GeneratePortalLinkResponse";
717
791
  static readonly fields: FieldList = proto3.util.newFieldList(() => [
718
792
  { no: 1, name: "link", kind: "message", T: Link },
719
793
  ]);
720
794
 
721
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenerateCustomerPortalLinkResponse {
722
- return new GenerateCustomerPortalLinkResponse().fromBinary(bytes, options);
795
+ static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GeneratePortalLinkResponse {
796
+ return new GeneratePortalLinkResponse().fromBinary(bytes, options);
723
797
  }
724
798
 
725
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenerateCustomerPortalLinkResponse {
726
- return new GenerateCustomerPortalLinkResponse().fromJson(jsonValue, options);
799
+ static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GeneratePortalLinkResponse {
800
+ return new GeneratePortalLinkResponse().fromJson(jsonValue, options);
727
801
  }
728
802
 
729
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenerateCustomerPortalLinkResponse {
730
- return new GenerateCustomerPortalLinkResponse().fromJsonString(jsonString, options);
803
+ static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GeneratePortalLinkResponse {
804
+ return new GeneratePortalLinkResponse().fromJsonString(jsonString, options);
731
805
  }
732
806
 
733
- static equals(a: GenerateCustomerPortalLinkResponse | PlainMessage<GenerateCustomerPortalLinkResponse> | undefined, b: GenerateCustomerPortalLinkResponse | PlainMessage<GenerateCustomerPortalLinkResponse> | undefined): boolean {
734
- return proto3.util.equals(GenerateCustomerPortalLinkResponse, a, b);
807
+ static equals(a: GeneratePortalLinkResponse | PlainMessage<GeneratePortalLinkResponse> | undefined, b: GeneratePortalLinkResponse | PlainMessage<GeneratePortalLinkResponse> | undefined): boolean {
808
+ return proto3.util.equals(GeneratePortalLinkResponse, a, b);
735
809
  }
736
810
  }
737
811
 
738
812
  /**
739
- * @generated from message scalekit.v1.organizations.CustomerPortalLinksResponse
813
+ * @generated from message scalekit.v1.organizations.GetPortalLinksResponse
740
814
  */
741
- export class CustomerPortalLinksResponse extends Message<CustomerPortalLinksResponse> {
815
+ export class GetPortalLinksResponse extends Message<GetPortalLinksResponse> {
742
816
  /**
743
817
  * @generated from field: repeated scalekit.v1.organizations.Link links = 1;
744
818
  */
745
819
  links: Link[] = [];
746
820
 
747
- constructor(data?: PartialMessage<CustomerPortalLinksResponse>) {
821
+ constructor(data?: PartialMessage<GetPortalLinksResponse>) {
748
822
  super();
749
823
  proto3.util.initPartial(data, this);
750
824
  }
751
825
 
752
826
  static readonly runtime: typeof proto3 = proto3;
753
- static readonly typeName = "scalekit.v1.organizations.CustomerPortalLinksResponse";
827
+ static readonly typeName = "scalekit.v1.organizations.GetPortalLinksResponse";
754
828
  static readonly fields: FieldList = proto3.util.newFieldList(() => [
755
829
  { no: 1, name: "links", kind: "message", T: Link, repeated: true },
756
830
  ]);
757
831
 
758
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CustomerPortalLinksResponse {
759
- return new CustomerPortalLinksResponse().fromBinary(bytes, options);
832
+ static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetPortalLinksResponse {
833
+ return new GetPortalLinksResponse().fromBinary(bytes, options);
760
834
  }
761
835
 
762
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CustomerPortalLinksResponse {
763
- return new CustomerPortalLinksResponse().fromJson(jsonValue, options);
836
+ static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetPortalLinksResponse {
837
+ return new GetPortalLinksResponse().fromJson(jsonValue, options);
764
838
  }
765
839
 
766
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CustomerPortalLinksResponse {
767
- return new CustomerPortalLinksResponse().fromJsonString(jsonString, options);
840
+ static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetPortalLinksResponse {
841
+ return new GetPortalLinksResponse().fromJsonString(jsonString, options);
768
842
  }
769
843
 
770
- static equals(a: CustomerPortalLinksResponse | PlainMessage<CustomerPortalLinksResponse> | undefined, b: CustomerPortalLinksResponse | PlainMessage<CustomerPortalLinksResponse> | undefined): boolean {
771
- return proto3.util.equals(CustomerPortalLinksResponse, a, b);
844
+ static equals(a: GetPortalLinksResponse | PlainMessage<GetPortalLinksResponse> | undefined, b: GetPortalLinksResponse | PlainMessage<GetPortalLinksResponse> | undefined): boolean {
845
+ return proto3.util.equals(GetPortalLinksResponse, a, b);
772
846
  }
773
847
  }
774
848
 
package/src/scalekit.ts CHANGED
@@ -6,8 +6,8 @@ import { IdTokenClaimToUserMap } from './constants/user';
6
6
  import CoreClient from './core';
7
7
  import DomainClient from './domain';
8
8
  import OrganizationClient from './organization';
9
- import { AuthorizationUrlOptions, CodeAuthenticationOptions, GrantType } from './types/scalekit';
10
- import { IdTokenClaim, User } from './types/user';
9
+ import { AuthorizationUrlOptions, AuthenticationOptions, GrantType, AuthenticationResponse } from './types/scalekit';
10
+ import { IdTokenClaim, User } from './types/auth';
11
11
 
12
12
  const authorizeEndpoint = "oauth/authorize";
13
13
 
@@ -16,11 +16,11 @@ const authorizeEndpoint = "oauth/authorize";
16
16
  * @param {string} envUrl The environment url
17
17
  * @param {string} clientId The client id
18
18
  * @param {string} clientSecret The client secret
19
- * @returns {Scalekit} Returns the scalekit instance
19
+ * @returns {ScalekitClient} Returns the scalekit instance
20
20
  * @example
21
21
  * const scalekit = new Scalekit(envUrl, clientId, clientSecret);
22
22
  */
23
- export default class Scalekit {
23
+ export default class ScalekitClient {
24
24
  private readonly coreClient: CoreClient;
25
25
  private readonly grpcConnect: GrpcConnect;
26
26
  readonly organization: OrganizationClient;
@@ -65,6 +65,8 @@ export default class Scalekit {
65
65
  * @param {string} options.domainHint Domain hint parameter
66
66
  * @param {string} options.connectionId Connection id parameter
67
67
  * @param {string} options.organizationId Organization id parameter
68
+ * @param {string} options.codeChallenge Code challenge parameter in case of PKCE
69
+ * @param {string} options.codeChallengeMethod Code challenge method parameter in case of PKCE
68
70
  *
69
71
  * @example
70
72
  * const scalekit = new Scalekit(envUrl, clientId, clientSecret);
@@ -76,7 +78,7 @@ export default class Scalekit {
76
78
  options?: AuthorizationUrlOptions
77
79
  ): string {
78
80
  const defaultOptions: AuthorizationUrlOptions = {
79
- scopes: ['openid', 'profile']
81
+ scopes: ['openid', 'profile', 'email']
80
82
  }
81
83
  options = {
82
84
  ...defaultOptions,
@@ -94,6 +96,8 @@ export default class Scalekit {
94
96
  ...(options.domainHint && { domain: options.domainHint }),
95
97
  ...(options.connectionId && { connection_id: options.connectionId }),
96
98
  ...(options.organizationId && { organization_id: options.organizationId }),
99
+ ...(options.codeChallenge && { code_challenge: options.codeChallenge }),
100
+ ...(options.codeChallengeMethod && { code_challenge_method: options.codeChallengeMethod })
97
101
  })
98
102
 
99
103
  return `${this.coreClient.envUrl}/${authorizeEndpoint}?${qs}`
@@ -101,24 +105,28 @@ export default class Scalekit {
101
105
 
102
106
  /**
103
107
  * Authenticate with the code
104
- * @param {CodeAuthenticationOptions} options Code authentication options
105
- * @param {string} options.code Code
106
- * @param {string} options.redirectUri Redirect uri
107
- * @param {string} options.codeVerifier Code verifier
108
- * @returns {Promise<{ user: Partial<User>, idToken: string, accessToken: string }>} Returns user, id token and access token
108
+ * @param {string} code Code
109
+ * @param {string} redirectUri Redirect uri
110
+ * @param {AuthenticationOptions} options Code authentication options
111
+ * @param {string} options.codeVerifier Code verifier in case of PKCE
112
+ * @returns {Promise<AuthenticationResponse>} Returns user, id token and access token
109
113
  */
110
- async authenticateWithCode(options: CodeAuthenticationOptions): Promise<{ user: Partial<User>; idToken: string; accessToken: string; }> {
114
+ async authenticateWithCode(
115
+ code: string,
116
+ redirectUri: string,
117
+ options?: AuthenticationOptions,
118
+ ): Promise<AuthenticationResponse> {
111
119
  const res = await this.coreClient.authenticate(QueryString.stringify({
112
- code: options.code,
113
- redirect_uri: options.redirectUri,
120
+ code: code,
121
+ redirect_uri: redirectUri,
114
122
  grant_type: GrantType.AuthorizationCode,
115
123
  client_id: this.coreClient.clientId,
116
124
  client_secret: this.coreClient.clientSecret,
117
- ...(options.codeVerifier && { code_verifier: options.codeVerifier })
125
+ ...(options?.codeVerifier && { code_verifier: options.codeVerifier })
118
126
  }))
119
- const { id_token, access_token } = res.data;
127
+ const { id_token, access_token, expires_in } = res.data;
120
128
  const claims = jose.decodeJwt<IdTokenClaim>(id_token);
121
- const user: Partial<User> = {};
129
+ const user = <User>{};
122
130
  for (const [k, v] of Object.entries(claims)) {
123
131
  if (IdTokenClaimToUserMap[k]) {
124
132
  user[IdTokenClaimToUserMap[k]] = v;
@@ -128,7 +136,8 @@ export default class Scalekit {
128
136
  return {
129
137
  user,
130
138
  idToken: id_token,
131
- accessToken: access_token
139
+ accessToken: access_token,
140
+ expiresIn: expires_in
132
141
  }
133
142
  }
134
143
 
@@ -56,4 +56,10 @@ export type IdTokenClaim = {
56
56
  updated_at: string | undefined;
57
57
  identities: IdTokenClaimIdentity[];
58
58
  metadata: string | undefined;
59
+ }
60
+
61
+ export type TokenResponse = {
62
+ access_token: string;
63
+ id_token: string;
64
+ expires_in: number;
59
65
  }
@@ -1,3 +1,5 @@
1
+ import { User } from './auth';
2
+
1
3
  export enum GrantType {
2
4
  AuthorizationCode = 'authorization_code',
3
5
  RefreshToken = 'refresh_token',
@@ -12,19 +14,17 @@ export type AuthorizationUrlOptions = {
12
14
  nonce?: string;
13
15
  domainHint?: string;
14
16
  loginHint?: string;
17
+ codeChallenge?: string;
18
+ codeChallengeMethod?: string;
15
19
  }
16
20
 
17
- export type CodeAuthenticationOptions = {
18
- code: string;
19
- redirectUri: string;
20
- codeVerifier?: string;
21
- }
22
-
23
- export type RefreshTokenAuthenticationOptions = {
24
- code: string;
25
- redirectUri: string;
21
+ export type AuthenticationOptions = {
22
+ codeVerifier?: string;
26
23
  }
27
24
 
28
- export type AuthenticationOptions = {
29
- refreshToken: string;
25
+ export type AuthenticationResponse = {
26
+ user: User;
27
+ idToken: string;
28
+ accessToken: string;
29
+ expiresIn: number;
30
30
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":""}