feeef 0.8.2 → 0.8.3

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/build/index.js CHANGED
@@ -791,6 +791,52 @@ var UserRepository = class extends ModelRepository {
791
791
  }
792
792
  };
793
793
 
794
+ // src/feeef/repositories/apps.ts
795
+ var AppRepository = class extends ModelRepository {
796
+ constructor(client) {
797
+ super("apps", client);
798
+ }
799
+ /**
800
+ * Regenerates the client secret for the app. Returns the app with
801
+ * clientSecret set once; store it securely.
802
+ *
803
+ * @param id - The app id.
804
+ * @returns The app including clientSecret.
805
+ */
806
+ async regenerateSecret(id) {
807
+ const res = await this.client.post(`/${this.resource}/${id}/regenerate-secret`);
808
+ return res.data;
809
+ }
810
+ /**
811
+ * Builds the OAuth authorize URL to which the user should be redirected.
812
+ *
813
+ * @param params - Parameters for the authorize URL.
814
+ * @param params.baseUrl - API base URL (e.g. https://api.feeef.org/api/v1).
815
+ * @param params.clientId - The app client id.
816
+ * @param params.redirectUri - Redirect URI registered for the app.
817
+ * @param params.responseType - Must be 'code' for authorization code flow.
818
+ * @param params.scope - Optional list of scopes (space-separated in URL).
819
+ * @param params.state - Optional state for CSRF protection.
820
+ * @param params.codeChallenge - Optional PKCE code challenge.
821
+ * @param params.codeChallengeMethod - Optional 'S256' or 'plain'.
822
+ * @returns The full authorize URL.
823
+ */
824
+ static buildAuthorizeUrl(params) {
825
+ const base = params.baseUrl.endsWith("/") ? params.baseUrl : `${params.baseUrl}/`;
826
+ const url = new URL("oauth/authorize", base);
827
+ url.searchParams.set("client_id", params.clientId);
828
+ url.searchParams.set("redirect_uri", params.redirectUri);
829
+ url.searchParams.set("response_type", params.responseType);
830
+ if (params.scope?.length) url.searchParams.set("scope", params.scope.join(" "));
831
+ if (params.state) url.searchParams.set("state", params.state);
832
+ if (params.codeChallenge) url.searchParams.set("code_challenge", params.codeChallenge);
833
+ if (params.codeChallengeMethod) {
834
+ url.searchParams.set("code_challenge_method", params.codeChallengeMethod);
835
+ }
836
+ return url.toString();
837
+ }
838
+ };
839
+
794
840
  // src/feeef/repositories/deposits.ts
795
841
  var DepositRepository = class extends ModelRepository {
796
842
  /**
@@ -3396,6 +3442,10 @@ var FeeeF = class {
3396
3442
  * The repository for managing users.
3397
3443
  */
3398
3444
  users;
3445
+ /**
3446
+ * The repository for managing developer-registered apps (OAuth clients).
3447
+ */
3448
+ apps;
3399
3449
  /**
3400
3450
  * The repository for managing orders.
3401
3451
  */
@@ -3482,6 +3532,7 @@ var FeeeF = class {
3482
3532
  this.imagePromptTemplates = new ImagePromptTemplatesRepository(this.client);
3483
3533
  this.imageGenerations = new ImageGenerationsRepository(this.client);
3484
3534
  this.users = new UserRepository(this.client);
3535
+ this.apps = new AppRepository(this.client);
3485
3536
  this.orders = new OrderRepository(this.client);
3486
3537
  this.deposits = new DepositRepository(this.client);
3487
3538
  this.transfers = new TransferRepository(this.client);
@@ -3920,6 +3971,7 @@ function validatePhoneNumber(phone) {
3920
3971
  export {
3921
3972
  ATTACHMENT_TYPES,
3922
3973
  ActionsService,
3974
+ AppRepository,
3923
3975
  CartService,
3924
3976
  CategoryRepository,
3925
3977
  CityRepository,