@storecraft/sdk 1.0.11 → 1.0.12

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/auth.js +63 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/sdk",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Official storecraft Universal Javascript SDK",
5
5
  "license": "MIT",
6
6
  "author": "Tomer Shalev (https://github.com/store-craft)",
package/src/auth.js CHANGED
@@ -1,7 +1,12 @@
1
1
  /**
2
2
  * @import {
3
3
  * ApiAuthChangePasswordType, ApiAuthResult, ApiAuthSigninType, ApiAuthSignupType,
4
- * ApiKeyResult, ApiQuery, AuthUserType, error
4
+ * ApiKeyResult, ApiQuery, AuthUserType, error,
5
+ OAuthProvider,
6
+ OAuthProviderCreateURIParams,
7
+ OAuthProviderCreateURIResponse,
8
+ OAuthProvidersList,
9
+ SignWithOAuthProviderParams
5
10
  * } from '@storecraft/core/api'
6
11
  * @import { SdkConfigAuth } from '../types.js';
7
12
  */
@@ -452,4 +457,61 @@ export default class Auth {
452
457
  return items;
453
458
  }
454
459
 
460
+ identity_providers_list = async () => {
461
+ /** @type {OAuthProvider[]} */
462
+ const items = await fetchApiWithAuth(
463
+ this.#sdk,
464
+ '/auth/identity-providers',
465
+ {
466
+ method: 'get'
467
+ }
468
+ );
469
+ return items;
470
+ }
471
+
472
+ /**
473
+ *
474
+ * @param {OAuthProviderCreateURIParams} params
475
+ * @returns {Promise<OAuthProviderCreateURIResponse>}
476
+ */
477
+ identity_provider_get_authorization_uri = async (params) => {
478
+ /** @type {OAuthProviderCreateURIResponse} */
479
+ const result = await fetchApiWithAuth(
480
+ this.#sdk,
481
+ '/auth/identity-providers/create_authorization_uri',
482
+ {
483
+ method: 'post',
484
+ body: JSON.stringify(params),
485
+ headers: {
486
+ 'Content-Type': 'application/json'
487
+ }
488
+ }
489
+ );
490
+ return result;
491
+ }
492
+
493
+ /**
494
+ * @description Signup / Signin with an OAuth Identity Provider
495
+ * @param {SignWithOAuthProviderParams} params
496
+ * @returns {Promise<ApiAuthResult>}
497
+ */
498
+ identity_provider_sign = async (params) => {
499
+
500
+ /** @type {ApiAuthResult} */
501
+ const result = await fetchApiWithAuth(
502
+ this.#sdk,
503
+ '/auth/identity-providers/sign',
504
+ {
505
+ method: 'post',
506
+ body: JSON.stringify(params),
507
+ headers: {
508
+ 'Content-Type': 'application/json'
509
+ }
510
+ }
511
+ );
512
+
513
+ this.#_update_and_notify_subscribers(result);
514
+
515
+ return result;
516
+ }
455
517
  }