@opexa/portal-sdk 0.55.2 → 0.56.1

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
@@ -3146,6 +3146,70 @@ var CABINET_WITHDRAWAL_QUERY = gql`
3146
3146
  }
3147
3147
  }
3148
3148
  `;
3149
+ var MEMBER_VERIFICATION_REQUEST_QUERY = gql`
3150
+ query MemberVerificationRequest {
3151
+ memberVerificationRequest {
3152
+ id
3153
+ firstName
3154
+ lastName
3155
+ dateOfBirth
3156
+ idFrontImage {
3157
+ id
3158
+ url
3159
+ }
3160
+ selfieImage {
3161
+ id
3162
+ url
3163
+ }
3164
+ permanentAddress
3165
+ currentAddress
3166
+ sourceOfIncome
3167
+ natureOfWork
3168
+ nationality
3169
+ placeOfBirth
3170
+ status
3171
+ basicDetailsSubmitted
3172
+ basicDetailsVerified
3173
+ imageDetailsSubmitted
3174
+ pendingManualImageDetailsVerification
3175
+ imageDetailsVerified
3176
+ personalDetailsSubmitted
3177
+ remarks
3178
+ dateTimeCreated
3179
+ dateTimeLastUpdated
3180
+ dateTimeApproved
3181
+ dateTimeRejected
3182
+ }
3183
+ }
3184
+ `;
3185
+ var SUBMIT_MEMBER_VERIFICATION_REQUEST_BASIC_DETAILS_MUTATION = gql`
3186
+ mutation SubmitMemberVerificationRequestBasicDetails(
3187
+ $input: SubmitMemberVerificationRequestBasicDetailsInput!
3188
+ ) {
3189
+ submitMemberVerificationRequestBasicDetails(input: $input)
3190
+ }
3191
+ `;
3192
+ var SUBMIT_MEMBER_VERIFICATION_REQUEST_IMAGE_DETAILS_MUTATION = gql`
3193
+ mutation SubmitMemberVerificationRequestImageDetails(
3194
+ $input: SubmitMemberVerificationRequestImageDetailsInput!
3195
+ ) {
3196
+ submitMemberVerificationRequestImageDetails(input: $input)
3197
+ }
3198
+ `;
3199
+ var SUBMIT_MEMBER_VERIFICATION_REQUEST_PERSONAL_DETAILS_MUTATION = gql`
3200
+ mutation SubmitMemberVerificationRequestPersonalDetails(
3201
+ $input: SubmitMemberVerificationRequestPersonalDetailsInput!
3202
+ ) {
3203
+ submitMemberVerificationRequestPersonalDetails(input: $input)
3204
+ }
3205
+ `;
3206
+ var MEMBER_VERIFICATION_REQUEST_AUTOMATIC_APPROVAL_ENABLED_QUERY = gql`
3207
+ query MemberVerificationRequestAutomaticApprovalEnabled {
3208
+ platform {
3209
+ memberVerificationRequestAutomaticApprovalEnabled
3210
+ }
3211
+ }
3212
+ `;
3149
3213
 
3150
3214
  // src/services/utils.ts
3151
3215
  function createOperationError(code) {
@@ -3661,6 +3725,50 @@ var AccountService = class {
3661
3725
  }
3662
3726
  return { ok: true };
3663
3727
  }
3728
+ async memberVerificationRequest() {
3729
+ const res = await this.client.request(
3730
+ MEMBER_VERIFICATION_REQUEST_QUERY
3731
+ );
3732
+ if (!res.ok) return res;
3733
+ return {
3734
+ ok: true,
3735
+ data: res.data.memberVerificationRequest ?? null
3736
+ };
3737
+ }
3738
+ async submitMemberVerificationRequestBasicDetails(variables) {
3739
+ const res = await this.client.request(SUBMIT_MEMBER_VERIFICATION_REQUEST_BASIC_DETAILS_MUTATION, variables);
3740
+ if (!res.ok) return res;
3741
+ return {
3742
+ ok: true,
3743
+ data: res.data.submitMemberVerificationRequestBasicDetails
3744
+ };
3745
+ }
3746
+ async submitMemberVerificationRequestImageDetails(variables) {
3747
+ const res = await this.client.request(SUBMIT_MEMBER_VERIFICATION_REQUEST_IMAGE_DETAILS_MUTATION, variables);
3748
+ if (!res.ok) return res;
3749
+ return {
3750
+ ok: true,
3751
+ data: res.data.submitMemberVerificationRequestImageDetails
3752
+ };
3753
+ }
3754
+ async submitMemberVerificationRequestPersonalDetails(variables) {
3755
+ const res = await this.client.request(SUBMIT_MEMBER_VERIFICATION_REQUEST_PERSONAL_DETAILS_MUTATION, variables);
3756
+ if (!res.ok) return res;
3757
+ return {
3758
+ ok: true,
3759
+ data: res.data.submitMemberVerificationRequestPersonalDetails
3760
+ };
3761
+ }
3762
+ async memberVerificationRequestAutomaticApprovalEnabled() {
3763
+ const res = await this.client.request(
3764
+ MEMBER_VERIFICATION_REQUEST_AUTOMATIC_APPROVAL_ENABLED_QUERY
3765
+ );
3766
+ if (!res.ok) return res;
3767
+ return {
3768
+ ok: true,
3769
+ data: res.data.memberVerificationRequestAutomaticApprovalEnabled
3770
+ };
3771
+ }
3664
3772
  };
3665
3773
 
3666
3774
  // src/utils/status-code-to-operation-error.ts
@@ -5996,8 +6104,8 @@ function pollable(func, config) {
5996
6104
  };
5997
6105
  }
5998
6106
 
5999
- // src/sdk/session-manager.ts
6000
- var SessionManager = class {
6107
+ // src/sdk/session-manager-cookie.ts
6108
+ var SessionManagerCookie = class {
6001
6109
  logger;
6002
6110
  storageKey = "session";
6003
6111
  platformStorageKey = "session/platform";
@@ -6008,10 +6116,6 @@ var SessionManager = class {
6008
6116
  this.authService = config.authService;
6009
6117
  this.walletService = config.walletService;
6010
6118
  this.logger = config.logger;
6011
- if (config.sessionPrefix) {
6012
- this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
6013
- this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
6014
- }
6015
6119
  }
6016
6120
  get refreshing() {
6017
6121
  return this._refreshing;
@@ -6020,16 +6124,6 @@ var SessionManager = class {
6020
6124
  this._refreshing = value;
6021
6125
  }
6022
6126
  async create(input) {
6023
- if (this.isServer) {
6024
- this.logger.warn("'localStorage' is not available on the server.");
6025
- return {
6026
- ok: false,
6027
- error: {
6028
- name: "UnknownError",
6029
- message: "Server sign in is not supported."
6030
- }
6031
- };
6032
- }
6033
6127
  if (input.type === "MAYA") {
6034
6128
  localStorage.setItem(this.platformStorageKey, "MAYA");
6035
6129
  const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
@@ -6056,13 +6150,14 @@ var SessionManager = class {
6056
6150
  })();
6057
6151
  if (!r1.ok) return r1;
6058
6152
  const now2 = /* @__PURE__ */ new Date();
6059
- localStorage.setItem(
6153
+ cookies__default.default.set(
6060
6154
  this.storageKey,
6061
6155
  JSON.stringify({
6062
6156
  ...r1.data,
6063
6157
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6064
6158
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6065
- })
6159
+ }),
6160
+ { expires: subMinutes(addDays(now2, 30), 2).getTime() }
6066
6161
  );
6067
6162
  return {
6068
6163
  ok: true,
@@ -6073,13 +6168,16 @@ var SessionManager = class {
6073
6168
  const res2 = await this.authService.createSession(input);
6074
6169
  if (res2.ok) {
6075
6170
  const now2 = /* @__PURE__ */ new Date();
6076
- localStorage.setItem(
6171
+ cookies__default.default.set(
6077
6172
  this.storageKey,
6078
6173
  JSON.stringify({
6079
6174
  ...res2.data,
6080
6175
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6081
6176
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6082
- })
6177
+ }),
6178
+ {
6179
+ expires: subMinutes(addDays(now2, 30), 2).getTime()
6180
+ }
6083
6181
  );
6084
6182
  return {
6085
6183
  ok: true,
@@ -6091,18 +6189,18 @@ var SessionManager = class {
6091
6189
  if (input.type === "SOCIALS" || input.type === "TOKEN") {
6092
6190
  const res2 = await this.authService.createSession({
6093
6191
  type: "SOCIALS",
6094
- token: input.token,
6095
- channel: input.channel
6192
+ token: input.token
6096
6193
  });
6097
6194
  if (res2.ok) {
6098
6195
  const now2 = /* @__PURE__ */ new Date();
6099
- localStorage.setItem(
6196
+ cookies__default.default.set(
6100
6197
  this.storageKey,
6101
6198
  JSON.stringify({
6102
6199
  ...res2.data,
6103
6200
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6104
6201
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6105
- })
6202
+ }),
6203
+ { expires: subMinutes(addDays(now2, 30), 2).getTime() }
6106
6204
  );
6107
6205
  return {
6108
6206
  ok: true,
@@ -6116,13 +6214,14 @@ var SessionManager = class {
6116
6214
  const res2 = await this.authService.createSession(input);
6117
6215
  if (res2.ok) {
6118
6216
  const now2 = /* @__PURE__ */ new Date();
6119
- localStorage.setItem(
6217
+ cookies__default.default.set(
6120
6218
  this.storageKey,
6121
6219
  JSON.stringify({
6122
6220
  ...res2.data,
6123
6221
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6124
6222
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6125
- })
6223
+ }),
6224
+ { expires: subMinutes(addDays(now2, 30), 2).getTime() }
6126
6225
  );
6127
6226
  return {
6128
6227
  ok: true,
@@ -6142,13 +6241,14 @@ var SessionManager = class {
6142
6241
  };
6143
6242
  }
6144
6243
  const now = /* @__PURE__ */ new Date();
6145
- localStorage.setItem(
6244
+ cookies__default.default.set(
6146
6245
  this.storageKey,
6147
6246
  JSON.stringify({
6148
6247
  ...res.data,
6149
6248
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6150
6249
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6151
- })
6250
+ }),
6251
+ {}
6152
6252
  );
6153
6253
  return {
6154
6254
  ok: true,
@@ -6160,15 +6260,18 @@ var SessionManager = class {
6160
6260
  if (res.ok) {
6161
6261
  const now = /* @__PURE__ */ new Date();
6162
6262
  if (this.isServer) {
6163
- this.logger.warn("'localStorage' is not available on the server.");
6263
+ this.logger.warn("'client cookies' is not available on the server.");
6164
6264
  } else {
6165
- localStorage.setItem(
6265
+ cookies__default.default.set(
6166
6266
  this.storageKey,
6167
6267
  JSON.stringify({
6168
6268
  ...res.data,
6169
6269
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6170
6270
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6171
- })
6271
+ }),
6272
+ {
6273
+ expires: subMinutes(addDays(now, 30), 2).getTime()
6274
+ }
6172
6275
  );
6173
6276
  }
6174
6277
  return { ok: true };
@@ -6178,7 +6281,7 @@ var SessionManager = class {
6178
6281
  }
6179
6282
  async get() {
6180
6283
  if (this.isServer) {
6181
- this.logger.warn("'localStorage' is not available on the server.");
6284
+ this.logger.warn("'client cookies' is not available on the server.");
6182
6285
  return {
6183
6286
  ok: true,
6184
6287
  data: null
@@ -6188,7 +6291,7 @@ var SessionManager = class {
6188
6291
  await sleep(1e3);
6189
6292
  return await this.get();
6190
6293
  }
6191
- const val = localStorage.getItem(this.storageKey);
6294
+ const val = cookies__default.default.get(this.storageKey);
6192
6295
  if (!val) {
6193
6296
  return {
6194
6297
  ok: true,
@@ -6202,7 +6305,7 @@ var SessionManager = class {
6202
6305
  const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
6203
6306
  if (isAfter(now, refreshTokenExpiresAt)) {
6204
6307
  this.logger.warn("Session expired. Logging out..");
6205
- localStorage.removeItem(this.storageKey);
6308
+ cookies__default.default.remove(this.storageKey);
6206
6309
  return {
6207
6310
  ok: false,
6208
6311
  error: {
@@ -6219,7 +6322,7 @@ var SessionManager = class {
6219
6322
  if (!res.ok) {
6220
6323
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
6221
6324
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
6222
- localStorage.removeItem(this.storageKey);
6325
+ cookies__default.default.remove(this.storageKey);
6223
6326
  return {
6224
6327
  ok: false,
6225
6328
  error: res.error
@@ -6240,7 +6343,9 @@ var SessionManager = class {
6240
6343
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6241
6344
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6242
6345
  };
6243
- localStorage.setItem(this.storageKey, JSON.stringify(obj));
6346
+ cookies__default.default.set(this.storageKey, JSON.stringify(obj), {
6347
+ expires: subMinutes(addDays(now, 30), 2).getTime()
6348
+ });
6244
6349
  }
6245
6350
  return {
6246
6351
  ok: true,
@@ -6258,13 +6363,13 @@ var SessionManager = class {
6258
6363
  }
6259
6364
  async refresh() {
6260
6365
  if (this.isServer) {
6261
- this.logger.warn("'localStorage' is not available on the server.");
6366
+ this.logger.warn("'client cookies' is not available on the server.");
6262
6367
  return {
6263
6368
  ok: true,
6264
6369
  data: null
6265
6370
  };
6266
6371
  }
6267
- const val = localStorage.getItem(this.storageKey);
6372
+ const val = cookies__default.default.get(this.storageKey);
6268
6373
  if (!val) {
6269
6374
  return {
6270
6375
  ok: true,
@@ -6281,7 +6386,7 @@ var SessionManager = class {
6281
6386
  if (!res.ok) {
6282
6387
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
6283
6388
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
6284
- localStorage.removeItem(this.storageKey);
6389
+ cookies__default.default.remove(this.storageKey);
6285
6390
  return {
6286
6391
  ok: false,
6287
6392
  error: res.error
@@ -6302,7 +6407,9 @@ var SessionManager = class {
6302
6407
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6303
6408
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6304
6409
  };
6305
- localStorage.setItem(this.storageKey, JSON.stringify(obj));
6410
+ cookies__default.default.set(this.storageKey, JSON.stringify(obj), {
6411
+ expires: subMinutes(addDays(now, 30), 2).getTime()
6412
+ });
6306
6413
  return {
6307
6414
  ok: true,
6308
6415
  data: obj
@@ -6319,18 +6426,18 @@ var SessionManager = class {
6319
6426
  }
6320
6427
  async destroy() {
6321
6428
  if (this.isServer) {
6322
- this.logger.warn("'localStorage' is not available on the server.");
6429
+ this.logger.warn("'client cookies' is not available on the server.");
6323
6430
  return;
6324
6431
  }
6325
6432
  const res = await this.get();
6326
6433
  if (res.data?.accessToken) {
6327
6434
  await this.authService.destroySession(res.data.accessToken);
6328
6435
  }
6329
- localStorage.removeItem(this.storageKey);
6436
+ cookies__default.default.remove(this.storageKey);
6330
6437
  }
6331
6438
  async verify() {
6332
6439
  if (this.isServer) {
6333
- this.logger.warn("'localStorage' is not available on the server.");
6440
+ this.logger.warn("'client cookies' is not available on the server.");
6334
6441
  return true;
6335
6442
  }
6336
6443
  const s = await this.get();
@@ -6340,13 +6447,13 @@ var SessionManager = class {
6340
6447
  if (!s.data) return true;
6341
6448
  const v = await this.authService.verifySession(s.data.accessToken);
6342
6449
  if (!v) {
6343
- localStorage.removeItem(this.storageKey);
6450
+ cookies__default.default.remove(this.storageKey);
6344
6451
  }
6345
6452
  return v;
6346
6453
  }
6347
6454
  get onMaya() {
6348
6455
  if (this.isServer) {
6349
- this.logger.warn("'localStorage' is not available on the server.");
6456
+ this.logger.warn("'client cookies' is not available on the server.");
6350
6457
  return false;
6351
6458
  }
6352
6459
  return localStorage.getItem(this.platformStorageKey) === "MAYA";
@@ -6362,7 +6469,9 @@ var SessionManager = class {
6362
6469
  return typeof window === "undefined";
6363
6470
  }
6364
6471
  };
6365
- var SessionManagerCookie = class {
6472
+
6473
+ // src/sdk/session-manager.ts
6474
+ var SessionManager = class {
6366
6475
  logger;
6367
6476
  storageKey = "session";
6368
6477
  platformStorageKey = "session/platform";
@@ -6373,6 +6482,10 @@ var SessionManagerCookie = class {
6373
6482
  this.authService = config.authService;
6374
6483
  this.walletService = config.walletService;
6375
6484
  this.logger = config.logger;
6485
+ if (config.sessionPrefix) {
6486
+ this.storageKey = `${config.sessionPrefix}/${this.storageKey}`;
6487
+ this.platformStorageKey = `${config.sessionPrefix}/${this.platformStorageKey}`;
6488
+ }
6376
6489
  }
6377
6490
  get refreshing() {
6378
6491
  return this._refreshing;
@@ -6381,6 +6494,16 @@ var SessionManagerCookie = class {
6381
6494
  this._refreshing = value;
6382
6495
  }
6383
6496
  async create(input) {
6497
+ if (this.isServer) {
6498
+ this.logger.warn("'localStorage' is not available on the server.");
6499
+ return {
6500
+ ok: false,
6501
+ error: {
6502
+ name: "UnknownError",
6503
+ message: "Server sign in is not supported."
6504
+ }
6505
+ };
6506
+ }
6384
6507
  if (input.type === "MAYA") {
6385
6508
  localStorage.setItem(this.platformStorageKey, "MAYA");
6386
6509
  const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
@@ -6407,14 +6530,13 @@ var SessionManagerCookie = class {
6407
6530
  })();
6408
6531
  if (!r1.ok) return r1;
6409
6532
  const now2 = /* @__PURE__ */ new Date();
6410
- cookies__default.default.set(
6533
+ localStorage.setItem(
6411
6534
  this.storageKey,
6412
6535
  JSON.stringify({
6413
6536
  ...r1.data,
6414
6537
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6415
6538
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6416
- }),
6417
- { expires: subMinutes(addDays(now2, 30), 2).getTime() }
6539
+ })
6418
6540
  );
6419
6541
  return {
6420
6542
  ok: true,
@@ -6425,16 +6547,13 @@ var SessionManagerCookie = class {
6425
6547
  const res2 = await this.authService.createSession(input);
6426
6548
  if (res2.ok) {
6427
6549
  const now2 = /* @__PURE__ */ new Date();
6428
- cookies__default.default.set(
6550
+ localStorage.setItem(
6429
6551
  this.storageKey,
6430
6552
  JSON.stringify({
6431
6553
  ...res2.data,
6432
6554
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6433
6555
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6434
- }),
6435
- {
6436
- expires: subMinutes(addDays(now2, 30), 2).getTime()
6437
- }
6556
+ })
6438
6557
  );
6439
6558
  return {
6440
6559
  ok: true,
@@ -6446,18 +6565,18 @@ var SessionManagerCookie = class {
6446
6565
  if (input.type === "SOCIALS" || input.type === "TOKEN") {
6447
6566
  const res2 = await this.authService.createSession({
6448
6567
  type: "SOCIALS",
6449
- token: input.token
6568
+ token: input.token,
6569
+ channel: input.channel
6450
6570
  });
6451
6571
  if (res2.ok) {
6452
6572
  const now2 = /* @__PURE__ */ new Date();
6453
- cookies__default.default.set(
6573
+ localStorage.setItem(
6454
6574
  this.storageKey,
6455
6575
  JSON.stringify({
6456
6576
  ...res2.data,
6457
6577
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6458
6578
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6459
- }),
6460
- { expires: subMinutes(addDays(now2, 30), 2).getTime() }
6579
+ })
6461
6580
  );
6462
6581
  return {
6463
6582
  ok: true,
@@ -6471,14 +6590,13 @@ var SessionManagerCookie = class {
6471
6590
  const res2 = await this.authService.createSession(input);
6472
6591
  if (res2.ok) {
6473
6592
  const now2 = /* @__PURE__ */ new Date();
6474
- cookies__default.default.set(
6593
+ localStorage.setItem(
6475
6594
  this.storageKey,
6476
6595
  JSON.stringify({
6477
6596
  ...res2.data,
6478
6597
  accessTokenExpiresAt: addMinutes(now2, 8).getTime(),
6479
6598
  refreshTokenExpiresAt: subMinutes(addDays(now2, 30), 2).getTime()
6480
- }),
6481
- { expires: subMinutes(addDays(now2, 30), 2).getTime() }
6599
+ })
6482
6600
  );
6483
6601
  return {
6484
6602
  ok: true,
@@ -6498,14 +6616,13 @@ var SessionManagerCookie = class {
6498
6616
  };
6499
6617
  }
6500
6618
  const now = /* @__PURE__ */ new Date();
6501
- cookies__default.default.set(
6619
+ localStorage.setItem(
6502
6620
  this.storageKey,
6503
6621
  JSON.stringify({
6504
6622
  ...res.data,
6505
6623
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6506
6624
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6507
- }),
6508
- {}
6625
+ })
6509
6626
  );
6510
6627
  return {
6511
6628
  ok: true,
@@ -6517,18 +6634,15 @@ var SessionManagerCookie = class {
6517
6634
  if (res.ok) {
6518
6635
  const now = /* @__PURE__ */ new Date();
6519
6636
  if (this.isServer) {
6520
- this.logger.warn("'client cookies' is not available on the server.");
6637
+ this.logger.warn("'localStorage' is not available on the server.");
6521
6638
  } else {
6522
- cookies__default.default.set(
6639
+ localStorage.setItem(
6523
6640
  this.storageKey,
6524
6641
  JSON.stringify({
6525
6642
  ...res.data,
6526
6643
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6527
6644
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6528
- }),
6529
- {
6530
- expires: subMinutes(addDays(now, 30), 2).getTime()
6531
- }
6645
+ })
6532
6646
  );
6533
6647
  }
6534
6648
  return { ok: true };
@@ -6538,7 +6652,7 @@ var SessionManagerCookie = class {
6538
6652
  }
6539
6653
  async get() {
6540
6654
  if (this.isServer) {
6541
- this.logger.warn("'client cookies' is not available on the server.");
6655
+ this.logger.warn("'localStorage' is not available on the server.");
6542
6656
  return {
6543
6657
  ok: true,
6544
6658
  data: null
@@ -6548,7 +6662,7 @@ var SessionManagerCookie = class {
6548
6662
  await sleep(1e3);
6549
6663
  return await this.get();
6550
6664
  }
6551
- const val = cookies__default.default.get(this.storageKey);
6665
+ const val = localStorage.getItem(this.storageKey);
6552
6666
  if (!val) {
6553
6667
  return {
6554
6668
  ok: true,
@@ -6562,7 +6676,7 @@ var SessionManagerCookie = class {
6562
6676
  const refreshTokenExpiresAt = new Date(obj.refreshTokenExpiresAt);
6563
6677
  if (isAfter(now, refreshTokenExpiresAt)) {
6564
6678
  this.logger.warn("Session expired. Logging out..");
6565
- cookies__default.default.remove(this.storageKey);
6679
+ localStorage.removeItem(this.storageKey);
6566
6680
  return {
6567
6681
  ok: false,
6568
6682
  error: {
@@ -6579,7 +6693,7 @@ var SessionManagerCookie = class {
6579
6693
  if (!res.ok) {
6580
6694
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
6581
6695
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
6582
- cookies__default.default.remove(this.storageKey);
6696
+ localStorage.removeItem(this.storageKey);
6583
6697
  return {
6584
6698
  ok: false,
6585
6699
  error: res.error
@@ -6600,9 +6714,7 @@ var SessionManagerCookie = class {
6600
6714
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6601
6715
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6602
6716
  };
6603
- cookies__default.default.set(this.storageKey, JSON.stringify(obj), {
6604
- expires: subMinutes(addDays(now, 30), 2).getTime()
6605
- });
6717
+ localStorage.setItem(this.storageKey, JSON.stringify(obj));
6606
6718
  }
6607
6719
  return {
6608
6720
  ok: true,
@@ -6620,13 +6732,13 @@ var SessionManagerCookie = class {
6620
6732
  }
6621
6733
  async refresh() {
6622
6734
  if (this.isServer) {
6623
- this.logger.warn("'client cookies' is not available on the server.");
6735
+ this.logger.warn("'localStorage' is not available on the server.");
6624
6736
  return {
6625
6737
  ok: true,
6626
6738
  data: null
6627
6739
  };
6628
6740
  }
6629
- const val = cookies__default.default.get(this.storageKey);
6741
+ const val = localStorage.getItem(this.storageKey);
6630
6742
  if (!val) {
6631
6743
  return {
6632
6744
  ok: true,
@@ -6643,7 +6755,7 @@ var SessionManagerCookie = class {
6643
6755
  if (!res.ok) {
6644
6756
  this.logger.error(`Failed to refresh session: ${res.error.message}`);
6645
6757
  if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
6646
- cookies__default.default.remove(this.storageKey);
6758
+ localStorage.removeItem(this.storageKey);
6647
6759
  return {
6648
6760
  ok: false,
6649
6761
  error: res.error
@@ -6664,9 +6776,7 @@ var SessionManagerCookie = class {
6664
6776
  accessTokenExpiresAt: addMinutes(now, 8).getTime(),
6665
6777
  refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
6666
6778
  };
6667
- cookies__default.default.set(this.storageKey, JSON.stringify(obj), {
6668
- expires: subMinutes(addDays(now, 30), 2).getTime()
6669
- });
6779
+ localStorage.setItem(this.storageKey, JSON.stringify(obj));
6670
6780
  return {
6671
6781
  ok: true,
6672
6782
  data: obj
@@ -6683,18 +6793,18 @@ var SessionManagerCookie = class {
6683
6793
  }
6684
6794
  async destroy() {
6685
6795
  if (this.isServer) {
6686
- this.logger.warn("'client cookies' is not available on the server.");
6796
+ this.logger.warn("'localStorage' is not available on the server.");
6687
6797
  return;
6688
6798
  }
6689
6799
  const res = await this.get();
6690
6800
  if (res.data?.accessToken) {
6691
6801
  await this.authService.destroySession(res.data.accessToken);
6692
6802
  }
6693
- cookies__default.default.remove(this.storageKey);
6803
+ localStorage.removeItem(this.storageKey);
6694
6804
  }
6695
6805
  async verify() {
6696
6806
  if (this.isServer) {
6697
- this.logger.warn("'client cookies' is not available on the server.");
6807
+ this.logger.warn("'localStorage' is not available on the server.");
6698
6808
  return true;
6699
6809
  }
6700
6810
  const s = await this.get();
@@ -6704,13 +6814,13 @@ var SessionManagerCookie = class {
6704
6814
  if (!s.data) return true;
6705
6815
  const v = await this.authService.verifySession(s.data.accessToken);
6706
6816
  if (!v) {
6707
- cookies__default.default.remove(this.storageKey);
6817
+ localStorage.removeItem(this.storageKey);
6708
6818
  }
6709
6819
  return v;
6710
6820
  }
6711
6821
  get onMaya() {
6712
6822
  if (this.isServer) {
6713
- this.logger.warn("'client cookies' is not available on the server.");
6823
+ this.logger.warn("'localStorage' is not available on the server.");
6714
6824
  return false;
6715
6825
  }
6716
6826
  return localStorage.getItem(this.platformStorageKey) === "MAYA";
@@ -6824,7 +6934,8 @@ var Transformer = class {
6824
6934
  memberLevelSettings: this.memberLevelSettings.bind(this),
6825
6935
  achievementSettings: this.achievementSettings.bind(this),
6826
6936
  achievementPointsHistoryRecord: this.achievementPointsHistoryRecord.bind(this),
6827
- memberAchievements: this.memberAchievements.bind(this)
6937
+ memberAchievements: this.memberAchievements.bind(this),
6938
+ memberVerificationRequest: this.memberVerificationRequest.bind(this)
6828
6939
  };
6829
6940
  }
6830
6941
  site(data) {
@@ -8276,6 +8387,34 @@ var Transformer = class {
8276
8387
  };
8277
8388
  return compact(o);
8278
8389
  }
8390
+ memberVerificationRequest(data) {
8391
+ return {
8392
+ id: data.id,
8393
+ firstName: data.firstName ?? void 0,
8394
+ lastName: data.lastName ?? void 0,
8395
+ dateOfBirth: data.dateOfBirth ? new Date(data.dateOfBirth) : void 0,
8396
+ idFrontImage: data.idFrontImage ?? void 0,
8397
+ selfieImage: data.selfieImage ?? void 0,
8398
+ permanentAddress: data.permanentAddress ?? void 0,
8399
+ currentAddress: data.currentAddress ?? void 0,
8400
+ sourceOfIncome: data.sourceOfIncome ?? void 0,
8401
+ natureOfWork: data.natureOfWork ?? void 0,
8402
+ nationality: data.nationality ?? void 0,
8403
+ placeOfBirth: data.placeOfBirth ?? void 0,
8404
+ status: data.status,
8405
+ basicDetailsSubmitted: data.basicDetailsSubmitted,
8406
+ basicDetailsVerified: data.basicDetailsVerified,
8407
+ imageDetailsSubmitted: data.imageDetailsSubmitted,
8408
+ pendingManualImageDetailsVerification: data.pendingManualImageDetailsVerification,
8409
+ imageDetailsVerified: data.imageDetailsVerified,
8410
+ personalDetailsSubmitted: data.personalDetailsSubmitted,
8411
+ remarks: data.remarks ?? void 0,
8412
+ dateTimeCreated: new Date(data.dateTimeCreated),
8413
+ dateTimeLastUpdated: new Date(data.dateTimeLastUpdated),
8414
+ dateTimeApproved: data.dateTimeApproved ? new Date(data.dateTimeApproved) : void 0,
8415
+ dateTimeRejected: data.dateTimeRejected ? new Date(data.dateTimeRejected) : void 0
8416
+ };
8417
+ }
8279
8418
  };
8280
8419
 
8281
8420
  // src/sdk/sdk.ts
@@ -10460,16 +10599,53 @@ var Sdk = class {
10460
10599
  data: res.data ?? false
10461
10600
  };
10462
10601
  }
10602
+ /*
10603
+ *=============================================
10604
+ * MEMBER VERIFICATION REQUEST
10605
+ *=============================================
10606
+ */
10607
+ async memberVerificationRequest() {
10608
+ const res = await this.accountService.memberVerificationRequest();
10609
+ if (!res.ok) return res;
10610
+ return {
10611
+ ok: true,
10612
+ data: res.data ? this.transformer.transform.memberVerificationRequest(res.data) : null
10613
+ };
10614
+ }
10615
+ async submitMemberVerificationRequestBasicDetails(input) {
10616
+ return await this.accountService.submitMemberVerificationRequestBasicDetails(
10617
+ {
10618
+ input: {
10619
+ ...input,
10620
+ dateOfBirth: this.formatYmd(input.dateOfBirth)
10621
+ }
10622
+ }
10623
+ );
10624
+ }
10625
+ async submitMemberVerificationRequestImageDetails(input) {
10626
+ return await this.accountService.submitMemberVerificationRequestImageDetails(
10627
+ { input }
10628
+ );
10629
+ }
10630
+ async submitMemberVerificationRequestPersonalDetails(input) {
10631
+ return await this.accountService.submitMemberVerificationRequestPersonalDetails(
10632
+ { input }
10633
+ );
10634
+ }
10635
+ async memberVerificationRequestAutomaticApprovalEnabled() {
10636
+ return await this.accountService.memberVerificationRequestAutomaticApprovalEnabled();
10637
+ }
10463
10638
  /*
10464
10639
  *=============================================
10465
10640
  * UTILS
10466
10641
  *=============================================
10467
10642
  */
10468
10643
  formatYmd(date) {
10644
+ const date_ = date instanceof Date ? date : new Date(date);
10469
10645
  const ensure2Digits = (n) => n.toString().padStart(2, "0");
10470
- const y = date.getFullYear();
10471
- const m = ensure2Digits(date.getMonth() + 1);
10472
- const d = ensure2Digits(date.getDate());
10646
+ const y = date_.getFullYear();
10647
+ const m = ensure2Digits(date_.getMonth() + 1);
10648
+ const d = ensure2Digits(date_.getDate());
10473
10649
  return `${y}-${m}-${d}`;
10474
10650
  }
10475
10651
  };