@sylphx/sdk 0.10.2 → 0.10.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.
@@ -3440,6 +3440,7 @@ interface SignUpFormState {
3440
3440
  email: string;
3441
3441
  password: string;
3442
3442
  inviteCode: string;
3443
+ captchaToken: string;
3443
3444
  verificationCode: string;
3444
3445
  [key: string]: string;
3445
3446
  }
@@ -4150,7 +4151,11 @@ interface SdkRegisterResult {
4150
4151
  interface SdkAuthContextValue {
4151
4152
  login: (email: string, password: string) => Promise<SdkLoginResult>;
4152
4153
  verifyTwoFactor: (userId: string, code: string) => Promise<SdkVerify2FAResult>;
4153
- register: (name: string, email: string, password: string) => Promise<SdkRegisterResult>;
4154
+ register: (name: string, email: string, password: string, options?: {
4155
+ captchaToken?: string;
4156
+ invitationToken?: string;
4157
+ metadata?: Record<string, unknown>;
4158
+ }) => Promise<SdkRegisterResult>;
4154
4159
  forgotPassword: (email: string) => Promise<{
4155
4160
  success: boolean;
4156
4161
  message: string;
@@ -1435,8 +1435,14 @@ async function callApi(config2, path, options = {}) {
1435
1435
  }
1436
1436
 
1437
1437
  // src/orgs.ts
1438
+ import {
1439
+ organizationsEndpoints
1440
+ } from "@sylphx/contract";
1438
1441
  async function getOrganizations(config2) {
1439
- return callApi(config2, "/orgs");
1442
+ const endpoint = organizationsEndpoints.memberships;
1443
+ return callApi(config2, endpoint.path, {
1444
+ method: endpoint.method
1445
+ });
1440
1446
  }
1441
1447
  async function getOrganization(config2, orgIdOrSlug) {
1442
1448
  return callApi(config2, `/orgs/${orgIdOrSlug}`);
@@ -2744,6 +2750,9 @@ function useSylphx() {
2744
2750
  }
2745
2751
  };
2746
2752
  }
2753
+ function mutableOrganizations(organizations) {
2754
+ return [...organizations];
2755
+ }
2747
2756
  var ORG_STORAGE_KEY = "sylphx_active_org";
2748
2757
  var ORG_BROADCAST_CHANNEL = "sylphx_org_sync";
2749
2758
  function useOrganization() {
@@ -2860,9 +2869,10 @@ function useOrganization() {
2860
2869
  try {
2861
2870
  const result = await getOrganizations(config2);
2862
2871
  if (mounted) {
2863
- setOrganizations(result.organizations);
2872
+ const organizations2 = mutableOrganizations(result.organizations);
2873
+ setOrganizations(organizations2);
2864
2874
  const storedSlug = getStoredOrgSlug();
2865
- const orgToSelect = storedSlug ? result.organizations.find((o2) => o2.slug === storedSlug) : result.organizations[0];
2875
+ const orgToSelect = storedSlug ? organizations2.find((o2) => o2.slug === storedSlug) : organizations2[0];
2866
2876
  if (orgToSelect && !organization) {
2867
2877
  await selectOrganization(orgToSelect.slug);
2868
2878
  }
@@ -2990,7 +3000,7 @@ function useOrganization() {
2990
3000
  setIsLoading(true);
2991
3001
  try {
2992
3002
  const result = await getOrganizations(config2);
2993
- setOrganizations(result.organizations);
3003
+ setOrganizations(mutableOrganizations(result.organizations));
2994
3004
  if (organization) {
2995
3005
  await selectOrganization(organization.slug);
2996
3006
  }
@@ -7423,7 +7433,8 @@ function useSignUpForm(options = {}) {
7423
7433
  email: "",
7424
7434
  password: "",
7425
7435
  inviteCode: initialInviteCode,
7426
- verificationCode: ""
7436
+ verificationCode: "",
7437
+ captchaToken: ""
7427
7438
  });
7428
7439
  const [inviteInfo, setInviteInfo] = useState16(null);
7429
7440
  const [isVerifyingInvite, setIsVerifyingInvite] = useState16(!!initialInviteCode);
@@ -7488,6 +7499,7 @@ function useSignUpForm(options = {}) {
7488
7499
  email: "",
7489
7500
  password: "",
7490
7501
  inviteCode: initialInviteCode,
7502
+ captchaToken: "",
7491
7503
  verificationCode: ""
7492
7504
  });
7493
7505
  setError(null);
@@ -7518,7 +7530,10 @@ function useSignUpForm(options = {}) {
7518
7530
  setError("SDK not configured. Please wrap your app with SylphxProvider.");
7519
7531
  return;
7520
7532
  }
7521
- const registerResult = await authContext.register(form.name, form.email, form.password);
7533
+ const registerResult = await authContext.register(form.name, form.email, form.password, {
7534
+ invitationToken: form.inviteCode || void 0,
7535
+ captchaToken: form.captchaToken || void 0
7536
+ });
7522
7537
  result = {
7523
7538
  requiresVerification: registerResult.requiresVerification
7524
7539
  };
@@ -14072,8 +14087,15 @@ function SylphxProviderInner({
14072
14087
  }
14073
14088
  };
14074
14089
  },
14075
- register: async (name, email, password) => {
14076
- const result = await api.post("/auth/register", { email, password, name });
14090
+ register: async (name, email, password, options) => {
14091
+ const result = await api.post("/auth/register", {
14092
+ email,
14093
+ password,
14094
+ name,
14095
+ captchaToken: options?.captchaToken,
14096
+ invitationToken: options?.invitationToken,
14097
+ metadata: options?.metadata
14098
+ });
14077
14099
  return {
14078
14100
  requiresVerification: true,
14079
14101
  message: "Please check your email to verify your account",
@@ -14813,6 +14835,7 @@ var PATHS = {
14813
14835
  uploadPart: (id, n2) => `/storage/uploads/${encodeURIComponent(String(id))}/parts/${n2}`,
14814
14836
  files: "/storage/files",
14815
14837
  file: (id) => `/storage/files/${encodeURIComponent(String(id))}`,
14838
+ fileTakedown: (id) => `/storage/files/${encodeURIComponent(String(id))}:takedown`,
14816
14839
  fileRestore: (id) => `/storage/files/${encodeURIComponent(String(id))}:restore`,
14817
14840
  fileSignedUrl: (id) => `/storage/files/${encodeURIComponent(String(id))}:signedUrl`,
14818
14841
  fileCopy: (id) => `/storage/files/${encodeURIComponent(String(id))}:copy`,
@@ -15137,6 +15160,12 @@ async function filesGet(config2, fileId) {
15137
15160
  async function filesDelete(config2, fileId) {
15138
15161
  return callApi(config2, PATHS.file(fileId), { method: "DELETE" });
15139
15162
  }
15163
+ async function filesTakedown(config2, fileId, options) {
15164
+ return callApi(config2, PATHS.fileTakedown(fileId), {
15165
+ method: "POST",
15166
+ body: options
15167
+ });
15168
+ }
15140
15169
  async function filesRestore(config2, fileId) {
15141
15170
  return callApi(config2, PATHS.fileRestore(fileId), { method: "POST" });
15142
15171
  }
@@ -15181,6 +15210,7 @@ var storage = {
15181
15210
  list: filesList,
15182
15211
  get: filesGet,
15183
15212
  delete: filesDelete,
15213
+ takedown: filesTakedown,
15184
15214
  restore: filesRestore,
15185
15215
  signedUrl: filesSignedUrl,
15186
15216
  copy: filesCopy,