arky-sdk 0.3.159 → 0.3.161
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 +25 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -271,10 +271,18 @@ var createAuthApi = (apiConfig) => {
|
|
|
271
271
|
}
|
|
272
272
|
const result = await apiConfig.httpClient.post("/v1/auth/session", {}, options);
|
|
273
273
|
if (result?.accessToken) {
|
|
274
|
-
apiConfig.setToken(result);
|
|
274
|
+
apiConfig.setToken({ ...result, isGuest: true });
|
|
275
275
|
}
|
|
276
276
|
return result;
|
|
277
277
|
},
|
|
278
|
+
/**
|
|
279
|
+
* Check if current user is a guest (anonymous)
|
|
280
|
+
*/
|
|
281
|
+
async isGuest() {
|
|
282
|
+
const tokens = await apiConfig.getToken();
|
|
283
|
+
if (!tokens?.accessToken) return true;
|
|
284
|
+
return tokens.isGuest === true;
|
|
285
|
+
},
|
|
278
286
|
// ==================== PLATFORM AUTH (Admin) ====================
|
|
279
287
|
/**
|
|
280
288
|
* Request platform auth code (Arky admin)
|
|
@@ -284,11 +292,15 @@ var createAuthApi = (apiConfig) => {
|
|
|
284
292
|
return apiConfig.httpClient.post("/v1/auth/code", params, options);
|
|
285
293
|
},
|
|
286
294
|
/**
|
|
287
|
-
* Verify platform auth code
|
|
295
|
+
* Verify platform auth code - automatically sets token on success
|
|
288
296
|
* POST /auth/verify
|
|
289
297
|
*/
|
|
290
298
|
async verify(params, options) {
|
|
291
|
-
|
|
299
|
+
const result = await apiConfig.httpClient.post("/v1/auth/verify", params, options);
|
|
300
|
+
if (result?.accessToken) {
|
|
301
|
+
apiConfig.setToken({ ...result, email: params.email, isGuest: false });
|
|
302
|
+
}
|
|
303
|
+
return result;
|
|
292
304
|
},
|
|
293
305
|
/**
|
|
294
306
|
* Refresh access token
|
|
@@ -306,11 +318,15 @@ var createAuthApi = (apiConfig) => {
|
|
|
306
318
|
return apiConfig.httpClient.post(`/v1/businesses/${businessId}/auth/code`, params, options);
|
|
307
319
|
},
|
|
308
320
|
/**
|
|
309
|
-
* Verify business auth code
|
|
321
|
+
* Verify business auth code - automatically sets token on success
|
|
310
322
|
* POST /businesses/{businessId}/auth/verify
|
|
311
323
|
*/
|
|
312
324
|
async businessVerify(businessId, params, options) {
|
|
313
|
-
|
|
325
|
+
const result = await apiConfig.httpClient.post(`/v1/businesses/${businessId}/auth/verify`, params, options);
|
|
326
|
+
if (result?.accessToken) {
|
|
327
|
+
apiConfig.setToken({ ...result, email: params.email, isGuest: false });
|
|
328
|
+
}
|
|
329
|
+
return result;
|
|
314
330
|
},
|
|
315
331
|
// ==================== DEPRECATED (for backwards compatibility) ====================
|
|
316
332
|
/**
|
|
@@ -1975,6 +1991,10 @@ async function createArkySDK(config) {
|
|
|
1975
1991
|
};
|
|
1976
1992
|
const accountApi = createAccountApi(apiConfig);
|
|
1977
1993
|
const authApi = createAuthApi(apiConfig);
|
|
1994
|
+
if (typeof window !== "undefined") {
|
|
1995
|
+
authApi.signInAnonymously().catch(() => {
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1978
1998
|
const sdk = {
|
|
1979
1999
|
auth: authApi,
|
|
1980
2000
|
account: accountApi,
|