@ocxp/client 0.2.6 → 0.2.7

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/dist/index.cjs CHANGED
@@ -2573,7 +2573,7 @@ var OCXPClient = class {
2573
2573
  body: { github_token: token }
2574
2574
  });
2575
2575
  if (response.error) {
2576
- throw new Error(`Failed to set GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2576
+ throw new Error(`Failed to set GitHub token: ${JSON.stringify(response.error)}`);
2577
2577
  }
2578
2578
  if (response.data === true) {
2579
2579
  return { success: true };
@@ -2586,13 +2586,15 @@ var OCXPClient = class {
2586
2586
  */
2587
2587
  async getGitHubTokenStatus() {
2588
2588
  const headers = await this.getHeaders();
2589
- const response = await this.client.request({
2590
- method: "GET",
2591
- url: "/auth/github-token",
2592
- headers
2593
- });
2589
+ const response = await this.client.request(
2590
+ {
2591
+ method: "GET",
2592
+ url: "/auth/github-token",
2593
+ headers
2594
+ }
2595
+ );
2594
2596
  if (response.error) {
2595
- throw new Error(`Failed to get GitHub token status: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2597
+ throw new Error(`Failed to get GitHub token status: ${JSON.stringify(response.error)}`);
2596
2598
  }
2597
2599
  const data = response.data;
2598
2600
  if (data && typeof data === "object" && "configured" in data) {
@@ -2612,13 +2614,87 @@ var OCXPClient = class {
2612
2614
  headers
2613
2615
  });
2614
2616
  if (response.error) {
2615
- throw new Error(`Failed to delete GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
2617
+ throw new Error(`Failed to delete GitHub token: ${JSON.stringify(response.error)}`);
2616
2618
  }
2617
2619
  if (response.data === true) {
2618
2620
  return { success: true };
2619
2621
  }
2620
2622
  return response.data || { success: true };
2621
2623
  }
2624
+ // ============== Project Credential Operations ==============
2625
+ /**
2626
+ * Get project credentials for frontend authentication
2627
+ * @param projectId - Project ID
2628
+ * @returns Project credentials
2629
+ */
2630
+ async getProjectCredentials(projectId) {
2631
+ const headers = await this.getHeaders();
2632
+ const response = await this.client.request({
2633
+ method: "GET",
2634
+ url: `/ocxp/project/${projectId}/credentials`,
2635
+ headers
2636
+ });
2637
+ if (response.error) {
2638
+ throw new Error(`Failed to get credentials: ${JSON.stringify(response.error)}`);
2639
+ }
2640
+ return response.data;
2641
+ }
2642
+ /**
2643
+ * Update project credentials for frontend authentication
2644
+ * @param projectId - Project ID
2645
+ * @param updates - Partial credential updates
2646
+ * @returns Updated project credentials
2647
+ */
2648
+ async updateProjectCredentials(projectId, updates) {
2649
+ const headers = await this.getHeaders();
2650
+ const response = await this.client.request({
2651
+ method: "PATCH",
2652
+ url: `/ocxp/project/${projectId}/credentials`,
2653
+ headers,
2654
+ body: updates
2655
+ });
2656
+ if (response.error) {
2657
+ throw new Error(`Failed to update credentials: ${JSON.stringify(response.error)}`);
2658
+ }
2659
+ return response.data;
2660
+ }
2661
+ /**
2662
+ * Test project credentials
2663
+ * @param projectId - Project ID
2664
+ * @returns Test result with success flag and optional message
2665
+ */
2666
+ async testProjectCredentials(projectId) {
2667
+ const headers = await this.getHeaders();
2668
+ const response = await this.client.request({
2669
+ method: "POST",
2670
+ url: `/ocxp/project/${projectId}/credentials/test`,
2671
+ headers
2672
+ });
2673
+ if (response.error) {
2674
+ throw new Error(`Failed to test credentials: ${JSON.stringify(response.error)}`);
2675
+ }
2676
+ const data = response.data;
2677
+ if (data && typeof data === "object" && "success" in data) {
2678
+ return data;
2679
+ }
2680
+ return { success: false };
2681
+ }
2682
+ /**
2683
+ * Delete project credentials
2684
+ * @param projectId - Project ID
2685
+ * @returns void
2686
+ */
2687
+ async deleteProjectCredentials(projectId) {
2688
+ const headers = await this.getHeaders();
2689
+ const response = await this.client.request({
2690
+ method: "DELETE",
2691
+ url: `/ocxp/project/${projectId}/credentials`,
2692
+ headers
2693
+ });
2694
+ if (response.error) {
2695
+ throw new Error(`Failed to delete credentials: ${JSON.stringify(response.error)}`);
2696
+ }
2697
+ }
2622
2698
  // ============== Namespaced Accessors ==============
2623
2699
  _mission;
2624
2700
  _project;